From 042b150267a683ec09f35946454d79baa6511ece Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Sat, 9 Jun 2012 15:38:12 +0200 Subject: [PATCH] drop crashrpt Signed-off-by: Sven Strickroth --- src/TortoiseGit.sln | 88 --- src/crashrpt/BaseDialog.cpp | 57 -- src/crashrpt/BaseDialog.h | 33 - src/crashrpt/CrashHandler.cpp | 523 ------------- src/crashrpt/CrashHandler.h | 409 ---------- src/crashrpt/CrashReport.h | 172 ---- src/crashrpt/CrashRpt.cpp | 296 ------- src/crashrpt/CrashRpt.h | 453 ----------- src/crashrpt/CrashRpt.rc | 359 --------- src/crashrpt/CrashRpt.vcproj | 1148 --------------------------- src/crashrpt/CrashRptDL.h | 339 -------- src/crashrpt/CrashRptStyleSheet.xsl | 154 ---- src/crashrpt/MailMsg.cpp | 509 ------------ src/crashrpt/MailMsg.h | 320 -------- src/crashrpt/MainDlg.cpp | 107 --- src/crashrpt/StackTrace.cpp | 311 -------- src/crashrpt/StackTrace.h | 11 - src/crashrpt/StdAfx.cpp | 18 - src/crashrpt/StdAfx.h | 25 - src/crashrpt/SymbolEngine.h | 442 ----------- src/crashrpt/Utility.cpp | 109 --- src/crashrpt/Utility.h | 95 --- src/crashrpt/WriteRegistry.cpp | 247 ------ src/crashrpt/WriteRegistry.h | 86 -- src/crashrpt/chglog.txt | 92 --- src/crashrpt/excprpt.cpp | 1037 ------------------------ src/crashrpt/excprpt.h | 110 --- src/crashrpt/maindlg.h | 33 - src/crashrpt/res/CrashRpt.ico | Bin 1078 -> 0 bytes src/crashrpt/res/crashrpt.exe.manifest | 24 - src/crashrpt/resource.h | 38 - src/crashrpt/zlib/adler32.c | 48 -- src/crashrpt/zlib/compress.c | 68 -- src/crashrpt/zlib/crc32.c | 162 ---- src/crashrpt/zlib/deflate.c | 1350 -------------------------------- src/crashrpt/zlib/deflate.h | 318 -------- src/crashrpt/zlib/gzio.c | 875 --------------------- src/crashrpt/zlib/infblock.c | 403 ---------- src/crashrpt/zlib/infblock.h | 39 - src/crashrpt/zlib/infcodes.c | 251 ------ src/crashrpt/zlib/infcodes.h | 27 - src/crashrpt/zlib/inffast.c | 183 ----- src/crashrpt/zlib/inffast.h | 17 - src/crashrpt/zlib/inffixed.h | 151 ---- src/crashrpt/zlib/inflate.c | 366 --------- src/crashrpt/zlib/inftrees.c | 454 ----------- src/crashrpt/zlib/inftrees.h | 58 -- src/crashrpt/zlib/infutil.c | 87 -- src/crashrpt/zlib/infutil.h | 98 --- src/crashrpt/zlib/maketree.c | 85 -- src/crashrpt/zlib/readme.txt | 37 - src/crashrpt/zlib/trees.c | 1214 ---------------------------- src/crashrpt/zlib/trees.h | 128 --- src/crashrpt/zlib/uncompr.c | 58 -- src/crashrpt/zlib/unzip.c | 1294 ------------------------------ src/crashrpt/zlib/unzip.h | 275 ------- src/crashrpt/zlib/zconf.h | 279 ------- src/crashrpt/zlib/zip.c | 719 ----------------- src/crashrpt/zlib/zip.h | 150 ---- src/crashrpt/zlib/zlib.h | 893 --------------------- src/crashrpt/zlib/zlibcpp.cpp | 131 ---- src/crashrpt/zlib/zlibcpp.h | 39 - src/crashrpt/zlib/zutil.c | 225 ------ src/crashrpt/zlib/zutil.h | 220 ------ 64 files changed, 18347 deletions(-) delete mode 100644 src/crashrpt/BaseDialog.cpp delete mode 100644 src/crashrpt/BaseDialog.h delete mode 100644 src/crashrpt/CrashHandler.cpp delete mode 100644 src/crashrpt/CrashHandler.h delete mode 100644 src/crashrpt/CrashReport.h delete mode 100644 src/crashrpt/CrashRpt.cpp delete mode 100644 src/crashrpt/CrashRpt.h delete mode 100644 src/crashrpt/CrashRpt.rc delete mode 100644 src/crashrpt/CrashRpt.vcproj delete mode 100644 src/crashrpt/CrashRptDL.h delete mode 100644 src/crashrpt/CrashRptStyleSheet.xsl delete mode 100644 src/crashrpt/MailMsg.cpp delete mode 100644 src/crashrpt/MailMsg.h delete mode 100644 src/crashrpt/MainDlg.cpp delete mode 100644 src/crashrpt/StackTrace.cpp delete mode 100644 src/crashrpt/StackTrace.h delete mode 100644 src/crashrpt/StdAfx.cpp delete mode 100644 src/crashrpt/StdAfx.h delete mode 100644 src/crashrpt/SymbolEngine.h delete mode 100644 src/crashrpt/Utility.cpp delete mode 100644 src/crashrpt/Utility.h delete mode 100644 src/crashrpt/WriteRegistry.cpp delete mode 100644 src/crashrpt/WriteRegistry.h delete mode 100644 src/crashrpt/chglog.txt delete mode 100644 src/crashrpt/excprpt.cpp delete mode 100644 src/crashrpt/excprpt.h delete mode 100644 src/crashrpt/maindlg.h delete mode 100644 src/crashrpt/res/CrashRpt.ico delete mode 100644 src/crashrpt/res/crashrpt.exe.manifest delete mode 100644 src/crashrpt/resource.h delete mode 100644 src/crashrpt/zlib/adler32.c delete mode 100644 src/crashrpt/zlib/compress.c delete mode 100644 src/crashrpt/zlib/crc32.c delete mode 100644 src/crashrpt/zlib/deflate.c delete mode 100644 src/crashrpt/zlib/deflate.h delete mode 100644 src/crashrpt/zlib/gzio.c delete mode 100644 src/crashrpt/zlib/infblock.c delete mode 100644 src/crashrpt/zlib/infblock.h delete mode 100644 src/crashrpt/zlib/infcodes.c delete mode 100644 src/crashrpt/zlib/infcodes.h delete mode 100644 src/crashrpt/zlib/inffast.c delete mode 100644 src/crashrpt/zlib/inffast.h delete mode 100644 src/crashrpt/zlib/inffixed.h delete mode 100644 src/crashrpt/zlib/inflate.c delete mode 100644 src/crashrpt/zlib/inftrees.c delete mode 100644 src/crashrpt/zlib/inftrees.h delete mode 100644 src/crashrpt/zlib/infutil.c delete mode 100644 src/crashrpt/zlib/infutil.h delete mode 100644 src/crashrpt/zlib/maketree.c delete mode 100644 src/crashrpt/zlib/readme.txt delete mode 100644 src/crashrpt/zlib/trees.c delete mode 100644 src/crashrpt/zlib/trees.h delete mode 100644 src/crashrpt/zlib/uncompr.c delete mode 100644 src/crashrpt/zlib/unzip.c delete mode 100644 src/crashrpt/zlib/unzip.h delete mode 100644 src/crashrpt/zlib/zconf.h delete mode 100644 src/crashrpt/zlib/zip.c delete mode 100644 src/crashrpt/zlib/zip.h delete mode 100644 src/crashrpt/zlib/zlib.h delete mode 100644 src/crashrpt/zlib/zlibcpp.cpp delete mode 100644 src/crashrpt/zlib/zlibcpp.h delete mode 100644 src/crashrpt/zlib/zutil.c delete mode 100644 src/crashrpt/zlib/zutil.h diff --git a/src/TortoiseGit.sln b/src/TortoiseGit.sln index 5d55faa60..f8bc8ce00 100644 --- a/src/TortoiseGit.sln +++ b/src/TortoiseGit.sln @@ -11,7 +11,6 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TortoiseProc", "TortoiseProc\TortoiseProc.vcproj", "{50797F06-39C5-4802-8E2B-7B7A4EF03214}" ProjectSection(ProjectDependencies) = postProject {A2C38606-3D96-4A2C-B5C5-22CEAC523B37} = {A2C38606-3D96-4A2C-B5C5-22CEAC523B37} - {13BC1836-2726-45C4-9249-5BA2BBBF8328} = {13BC1836-2726-45C4-9249-5BA2BBBF8328} {A5498556-CE09-4095-8335-08FC8370552D} = {A5498556-CE09-4095-8335-08FC8370552D} {2C879469-DB8F-4BF0-B016-AE864D2A7BBC} = {2C879469-DB8F-4BF0-B016-AE864D2A7BBC} {2B4F366C-93BA-491E-87AF-5EF7B37F75F7} = {2B4F366C-93BA-491E-87AF-5EF7B37F75F7} @@ -47,7 +46,6 @@ Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "WixSetup", "TortoiseGitSetu {84E07810-9AD4-4E0E-A7F7-FAD9A8CDFC7F} = {84E07810-9AD4-4E0E-A7F7-FAD9A8CDFC7F} {62507C2F-9290-4342-910F-BFC44DF99B01} = {62507C2F-9290-4342-910F-BFC44DF99B01} {E873DD32-5A31-4DE1-8341-A56A2A5489EA} = {E873DD32-5A31-4DE1-8341-A56A2A5489EA} - {13BC1836-2726-45C4-9249-5BA2BBBF8328} = {13BC1836-2726-45C4-9249-5BA2BBBF8328} {BC5A5F3B-E41A-4C56-B16F-263D2C6D6475} = {BC5A5F3B-E41A-4C56-B16F-263D2C6D6475} {A5498556-CE09-4095-8335-08FC8370552D} = {A5498556-CE09-4095-8335-08FC8370552D} {2C879469-DB8F-4BF0-B016-AE864D2A7BBC} = {2C879469-DB8F-4BF0-B016-AE864D2A7BBC} @@ -70,15 +68,12 @@ Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "WixSetup", "TortoiseGitSetu EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TGitCache", "TGitCache\TGitCache.vcproj", "{A00D2EDC-B4F5-4B41-94BA-13961DE5D296}" ProjectSection(ProjectDependencies) = postProject - {13BC1836-2726-45C4-9249-5BA2BBBF8328} = {13BC1836-2726-45C4-9249-5BA2BBBF8328} {2B4F366C-93BA-491E-87AF-5EF7B37F75F7} = {2B4F366C-93BA-491E-87AF-5EF7B37F75F7} {8E943F8F-ED43-42DB-A25B-C6356F01AAC7} = {8E943F8F-ED43-42DB-A25B-C6356F01AAC7} {5C6B6A95-2053-4593-9617-C4F176736D5A} = {5C6B6A95-2053-4593-9617-C4F176736D5A} {4F0A55DE-DAFD-4A0B-A03D-2C14CB77E08F} = {4F0A55DE-DAFD-4A0B-A03D-2C14CB77E08F} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CrashRpt", "crashrpt\CrashRpt.vcproj", "{13BC1836-2726-45C4-9249-5BA2BBBF8328}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TortoisePlink", "TortoisePlink\Windows\MSVC\Plink\TortoisePlink.vcproj", "{D3AFBFBE-5501-4077-B3B4-3D28BBCA8F20}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CustomActions", "TortoiseGitSetup\CustomActions\CustomActions.vcproj", "{454D5FCC-E25A-4B45-9CA2-01ABB0FA5181}" @@ -86,7 +81,6 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TortoiseGitBlame", "TortoiseGitBlame\TortoiseGitBlame.vcproj", "{62507C2F-9290-4342-910F-BFC44DF99B01}" ProjectSection(ProjectDependencies) = postProject {A2C38606-3D96-4A2C-B5C5-22CEAC523B37} = {A2C38606-3D96-4A2C-B5C5-22CEAC523B37} - {13BC1836-2726-45C4-9249-5BA2BBBF8328} = {13BC1836-2726-45C4-9249-5BA2BBBF8328} {A5498556-CE09-4095-8335-08FC8370552D} = {A5498556-CE09-4095-8335-08FC8370552D} {12E5B4AE-D7EF-4A57-A22D-6F9F9D8CE1FB} = {12E5B4AE-D7EF-4A57-A22D-6F9F9D8CE1FB} {4F0A55DE-DAFD-4A0B-A03D-2C14CB77E08F} = {4F0A55DE-DAFD-4A0B-A03D-2C14CB77E08F} @@ -1120,88 +1114,6 @@ Global {A00D2EDC-B4F5-4B41-94BA-13961DE5D296}.Release|x64.ActiveCfg = Release|x64 {A00D2EDC-B4F5-4B41-94BA-13961DE5D296}.Release|x64.Build.0 = Release|x64 {A00D2EDC-B4F5-4B41-94BA-13961DE5D296}.Release|x86.ActiveCfg = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.debug_static|Mixed Platforms.ActiveCfg = Debug|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.debug_static|Mixed Platforms.Build.0 = Debug|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.debug_static|Win32.ActiveCfg = Debug|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.debug_static|x64.ActiveCfg = Debug|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.debug_static|x64.Build.0 = Debug|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.debug_static|x86.ActiveCfg = Debug|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.Debug|Mixed Platforms.ActiveCfg = Debug|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.Debug|Mixed Platforms.Build.0 = Debug|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.Debug|Win32.ActiveCfg = Release|Win32 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.Debug|Win32.Build.0 = Release|Win32 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.Debug|x64.ActiveCfg = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.Debug|x64.Build.0 = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.Debug|x86.ActiveCfg = Debug|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.DLL ASM Debug|Mixed Platforms.ActiveCfg = Debug|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.DLL ASM Debug|Mixed Platforms.Build.0 = Debug|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.DLL ASM Debug|Win32.ActiveCfg = Debug|Win32 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.DLL ASM Debug|Win32.Build.0 = Debug|Win32 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.DLL ASM Debug|x64.ActiveCfg = Debug|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.DLL ASM Debug|x64.Build.0 = Debug|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.DLL ASM Debug|x86.ActiveCfg = Debug|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.DLL ASM Release|Mixed Platforms.ActiveCfg = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.DLL ASM Release|Mixed Platforms.Build.0 = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.DLL ASM Release|Win32.ActiveCfg = Release|Win32 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.DLL ASM Release|Win32.Build.0 = Release|Win32 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.DLL ASM Release|x64.ActiveCfg = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.DLL ASM Release|x64.Build.0 = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.DLL ASM Release|x86.ActiveCfg = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.DLL Debug|Mixed Platforms.ActiveCfg = Debug|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.DLL Debug|Mixed Platforms.Build.0 = Debug|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.DLL Debug|Win32.ActiveCfg = Debug|Win32 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.DLL Debug|Win32.Build.0 = Debug|Win32 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.DLL Debug|x64.ActiveCfg = Debug|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.DLL Debug|x64.Build.0 = Debug|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.DLL Debug|x86.ActiveCfg = Debug|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.DLL Release|Mixed Platforms.ActiveCfg = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.DLL Release|Mixed Platforms.Build.0 = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.DLL Release|Win32.ActiveCfg = Release|Win32 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.DLL Release|Win32.Build.0 = Release|Win32 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.DLL Release|x64.ActiveCfg = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.DLL Release|x64.Build.0 = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.DLL Release|x86.ActiveCfg = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.LIB ASM Debug|Mixed Platforms.ActiveCfg = Debug|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.LIB ASM Debug|Mixed Platforms.Build.0 = Debug|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.LIB ASM Debug|Win32.ActiveCfg = Debug|Win32 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.LIB ASM Debug|Win32.Build.0 = Debug|Win32 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.LIB ASM Debug|x64.ActiveCfg = Debug|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.LIB ASM Debug|x64.Build.0 = Debug|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.LIB ASM Debug|x86.ActiveCfg = Debug|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.LIB ASM Release|Mixed Platforms.ActiveCfg = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.LIB ASM Release|Mixed Platforms.Build.0 = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.LIB ASM Release|Win32.ActiveCfg = Release|Win32 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.LIB ASM Release|Win32.Build.0 = Release|Win32 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.LIB ASM Release|x64.ActiveCfg = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.LIB ASM Release|x64.Build.0 = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.LIB ASM Release|x86.ActiveCfg = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.LIB Debug|Mixed Platforms.ActiveCfg = Debug|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.LIB Debug|Mixed Platforms.Build.0 = Debug|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.LIB Debug|Win32.ActiveCfg = Debug|Win32 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.LIB Debug|Win32.Build.0 = Debug|Win32 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.LIB Debug|x64.ActiveCfg = Debug|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.LIB Debug|x64.Build.0 = Debug|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.LIB Debug|x86.ActiveCfg = Debug|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.LIB Release|Mixed Platforms.ActiveCfg = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.LIB Release|Mixed Platforms.Build.0 = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.LIB Release|Win32.ActiveCfg = Release|Win32 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.LIB Release|Win32.Build.0 = Release|Win32 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.LIB Release|x64.ActiveCfg = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.LIB Release|x64.Build.0 = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.LIB Release|x86.ActiveCfg = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.release_static|Mixed Platforms.ActiveCfg = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.release_static|Mixed Platforms.Build.0 = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.release_static|Win32.ActiveCfg = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.release_static|x64.ActiveCfg = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.release_static|x64.Build.0 = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.release_static|x86.ActiveCfg = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.Release|Mixed Platforms.ActiveCfg = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.Release|Mixed Platforms.Build.0 = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.Release|Win32.ActiveCfg = Release|Win32 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.Release|Win32.Build.0 = Release|Win32 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.Release|x64.ActiveCfg = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.Release|x64.Build.0 = Release|x64 - {13BC1836-2726-45C4-9249-5BA2BBBF8328}.Release|x86.ActiveCfg = Release|x64 {D3AFBFBE-5501-4077-B3B4-3D28BBCA8F20}.debug_static|Mixed Platforms.ActiveCfg = Debug|x64 {D3AFBFBE-5501-4077-B3B4-3D28BBCA8F20}.debug_static|Mixed Platforms.Build.0 = Debug|x64 {D3AFBFBE-5501-4077-B3B4-3D28BBCA8F20}.debug_static|Win32.ActiveCfg = Debug|x64 diff --git a/src/crashrpt/BaseDialog.cpp b/src/crashrpt/BaseDialog.cpp deleted file mode 100644 index b264c40bc..000000000 --- a/src/crashrpt/BaseDialog.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include "stdafx.h" -#include "BaseDialog.h" - - -INT_PTR CDialog::DoModal(HINSTANCE hInstance, int resID, HWND hWndParent) -{ - hResource = hInstance; - return DialogBoxParam(hInstance, MAKEINTRESOURCE(resID), hWndParent, &CDialog::stDlgFunc, (LPARAM)this); -} - -void CDialog::InitDialog(HWND hwndDlg, UINT iconID) -{ - HWND hwndOwner; - RECT rc, rcDlg, rcOwner; - - hwndOwner = ::GetParent(hwndDlg); - if (hwndOwner == NULL) - hwndOwner = ::GetDesktopWindow(); - - GetWindowRect(hwndOwner, &rcOwner); - GetWindowRect(hwndDlg, &rcDlg); - CopyRect(&rc, &rcOwner); - - OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top); - OffsetRect(&rc, -rc.left, -rc.top); - OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom); - - SetWindowPos(hwndDlg, HWND_TOP, rcOwner.left + (rc.right / 2), rcOwner.top + (rc.bottom / 2), 0, 0, SWP_NOSIZE); - HICON hIcon = (HICON)::LoadImage(hResource, MAKEINTRESOURCE(iconID), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE|LR_SHARED); - ::SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon); - ::SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)hIcon); -} - -INT_PTR CALLBACK CDialog::stDlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - CDialog* pWnd; - if (uMsg == WM_INITDIALOG) - { - // get the pointer to the window from lpCreateParams - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); - pWnd = (CDialog*)lParam; - pWnd->m_hwnd = hwndDlg; - } - // get the pointer to the window - pWnd = GetObjectFromWindow(hwndDlg); - - // if we have the pointer, go to the message handler of the window - // else, use DefWindowProc - if (pWnd) - { - LRESULT lRes = pWnd->DlgFunc(hwndDlg, uMsg, wParam, lParam); - SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, lRes); - return lRes; - } - else - return DefWindowProc(hwndDlg, uMsg, wParam, lParam); -} diff --git a/src/crashrpt/BaseDialog.h b/src/crashrpt/BaseDialog.h deleted file mode 100644 index 0da3ecfb9..000000000 --- a/src/crashrpt/BaseDialog.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once -#include - - -/** - * A base window class. - * Provides separate window message handlers for every window object based on - * this class. - */ -class CDialog -{ -public: - INT_PTR DoModal(HINSTANCE hInstance, int resID, HWND hWndParent); - - virtual LRESULT CALLBACK DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) = 0; - - operator HWND() {return m_hwnd;} -protected: - HINSTANCE hResource; - HWND m_hwnd; - - void InitDialog(HWND hwndDlg, UINT iconID); - - // the real message handler - static INT_PTR CALLBACK stDlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); - - // returns a pointer the dialog (stored as the WindowLong) - inline static CDialog * GetObjectFromWindow(HWND hWnd) - { - return (CDialog *)GetWindowLongPtr(hWnd, GWLP_USERDATA); - } -}; - diff --git a/src/crashrpt/CrashHandler.cpp b/src/crashrpt/CrashHandler.cpp deleted file mode 100644 index 35699432a..000000000 --- a/src/crashrpt/CrashHandler.cpp +++ /dev/null @@ -1,523 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Module: CrashHandler.cpp -// -// Desc: See CrashHandler.h -// -// Copyright (c) 2003 Michael Carruth -// -/////////////////////////////////////////////////////////////////////////////// - -#include "stdafx.h" -#include "CrashHandler.h" -#include "zlibcpp.h" -#include "excprpt.h" -#include "maindlg.h" -#include "mailmsg.h" -#include "WriteRegistry.h" -#include "resource.h" - -#include -#include -#include -#pragma comment(lib, "shlwapi") -#pragma comment(lib, "comctl32") - -#include - -BOOL g_bNoCrashHandler;// don't use the crash handler but let the system handle it - -// maps crash objects to processes -map _crashStateMap; - -// unhandled exception callback set with SetUnhandledExceptionFilter() -LONG WINAPI CustomUnhandledExceptionFilter(PEXCEPTION_POINTERS pExInfo) -{ - OutputDebugString("Exception\n"); - if (EXCEPTION_BREAKPOINT == pExInfo->ExceptionRecord->ExceptionCode) - { - // Breakpoint. Don't treat this as a normal crash. - return EXCEPTION_CONTINUE_SEARCH; - } - - if (g_bNoCrashHandler) - { - return EXCEPTION_CONTINUE_SEARCH; - } - - BOOL result = false; - if (_crashStateMap.find(GetCurrentProcessId()) != _crashStateMap.end()) - result = _crashStateMap[GetCurrentProcessId()]->GenerateErrorReport(pExInfo, NULL); - - // If we're in a debugger, return EXCEPTION_CONTINUE_SEARCH to cause the debugger to stop; - // or if GenerateErrorReport returned FALSE (i.e. drop into debugger). - return (!result || IsDebuggerPresent()) ? EXCEPTION_CONTINUE_SEARCH : EXCEPTION_EXECUTE_HANDLER; -} - -CCrashHandler * CCrashHandler::GetInstance() -{ - CCrashHandler *instance = NULL; - if (_crashStateMap.find(GetCurrentProcessId()) != _crashStateMap.end()) - instance = _crashStateMap[GetCurrentProcessId()]; - if (instance == NULL) { - // will register - instance = new CCrashHandler(); - } - return instance; -} - -CCrashHandler::CCrashHandler(): - m_oldFilter(NULL), - m_lpfnCallback(NULL), - m_pid(GetCurrentProcessId()), - m_ipc_event(NULL), - m_rpt(NULL), - m_installed(false), - m_hModule(NULL), - m_bUseUI(TRUE), - m_wantDebug(false) -{ - // wtl initialization stuff... - HRESULT hRes = ::CoInitialize(NULL); - if (hRes != S_OK) - m_pid = 0; - else - _crashStateMap[m_pid] = this; -} - -void CCrashHandler::Install(LPGETLOGFILE lpfn, LPCTSTR lpcszTo, LPCTSTR lpcszSubject, BOOL bUseUI) -{ - if (m_pid == 0) - return; -#ifdef _DEBUG - OutputDebugString("::Install\n"); -#endif - if (m_installed) { - Uninstall(); - } - // save user supplied callback - m_lpfnCallback = lpfn; - // save optional email info - m_sTo = lpcszTo; - m_sSubject = lpcszSubject; - m_bUseUI = bUseUI; - - // This is needed for CRT to not show dialog for invalid param - // failures and instead let the code handle it. - _CrtSetReportMode(_CRT_ASSERT, 0); - // add this filter in the exception callback chain - m_oldFilter = SetUnhandledExceptionFilter(CustomUnhandledExceptionFilter); -/*m_oldErrorMode=*/ SetErrorMode( SEM_FAILCRITICALERRORS ); - - m_installed = true; -} - -void CCrashHandler::Uninstall() -{ -#ifdef _DEBUG - OutputDebugString("Uninstall\n"); -#endif - // reset exception callback (to previous filter, which can be NULL) - SetUnhandledExceptionFilter(m_oldFilter); - m_installed = false; -} - -void CCrashHandler::EnableUI() -{ - m_bUseUI = TRUE; -} - -void CCrashHandler::DisableUI() -{ - m_bUseUI = FALSE; -} - -void CCrashHandler::DisableHandler() -{ - g_bNoCrashHandler = TRUE; -} - -void CCrashHandler::EnableHandler() -{ - g_bNoCrashHandler = FALSE; -} - -CCrashHandler::~CCrashHandler() -{ - - Uninstall(); - - _crashStateMap.erase(m_pid); - - ::CoUninitialize(); - -} - -void CCrashHandler::AddFile(LPCTSTR lpFile, LPCTSTR lpDesc) -{ - // make sure we don't already have the file - RemoveFile(lpFile); - // make sure the file exists - HANDLE hFile = ::CreateFile( - lpFile, - GENERIC_READ, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - 0); - if (hFile != INVALID_HANDLE_VALUE) - { - // add file to report - m_files.push_back(TStrStrPair(lpFile, lpDesc)); - ::CloseHandle(hFile); - } -} - -void CCrashHandler::RemoveFile(LPCTSTR lpFile) -{ - TStrStrVector::iterator iter; - for (iter = m_files.begin(); iter != m_files.end(); ++iter) { - if ((*iter).first == lpFile) { - iter = m_files.erase(iter); - break; - } - } -} - -void CCrashHandler::AddRegistryHive(LPCTSTR lpRegistryHive, LPCTSTR lpDesc) -{ - // make sure we don't already have the RegistryHive - RemoveRegistryHive(lpRegistryHive); - // Unfortunately, we have no easy way of verifying the existence of - // the registry hive. - // add RegistryHive to report - m_registryHives.push_back(TStrStrPair(lpRegistryHive, lpDesc)); -} - -void CCrashHandler::RemoveRegistryHive(LPCTSTR lpRegistryHive) -{ - TStrStrVector::iterator iter; - for (iter = m_registryHives.begin(); iter != m_registryHives.end(); ++iter) { - if ((*iter).first == lpRegistryHive) { - iter = m_registryHives.erase(iter); - } - } -} - -void CCrashHandler::AddEventLog(LPCTSTR lpEventLog, LPCTSTR lpDesc) -{ - // make sure we don't already have the EventLog - RemoveEventLog(lpEventLog); - // Unfortunately, we have no easy way of verifying the existence of - // the event log.. - // add EventLog to report - m_eventLogs.push_back(TStrStrPair(lpEventLog, lpDesc)); -} - -void CCrashHandler::RemoveEventLog(LPCTSTR lpEventLog) -{ - TStrStrVector::iterator iter; - for (iter = m_eventLogs.begin(); iter != m_eventLogs.end(); ++iter) { - if ((*iter).first == lpEventLog) { - iter = m_eventLogs.erase(iter); - } - } -} - -DWORD WINAPI CCrashHandler::DialogThreadExecute(LPVOID pParam) -{ - // New thread. This will display the dialog and handle the result. - CCrashHandler * self = reinterpret_cast(pParam); - CMainDlg mainDlg; - string sTempFileName = CUtility::getTempFileName(); - CZLib zlib; - - // delete existing copy, if any - DeleteFile(sTempFileName.c_str()); - - // zip the report - if (!zlib.Open(sTempFileName)) - return TRUE; - - // add report files to zip - TStrStrVector::iterator cur = self->m_files.begin(); - for (cur = self->m_files.begin(); cur != self->m_files.end(); cur++) - if (PathFileExists((*cur).first.c_str())) - zlib.AddFile((*cur).first); - - zlib.Close(); - - mainDlg.m_pUDFiles = &self->m_files; - mainDlg.m_sendButton = !self->m_sTo.empty(); - - INITCOMMONCONTROLSEX used = { - sizeof(INITCOMMONCONTROLSEX), - ICC_LISTVIEW_CLASSES | ICC_WIN95_CLASSES | ICC_BAR_CLASSES | ICC_USEREX_CLASSES - }; - InitCommonControlsEx(&used); - - INT_PTR status = mainDlg.DoModal(GetModuleHandle("CrashRpt.dll"), IDD_MAINDLG, GetDesktopWindow()); - if (IDOK == status || IDC_SAVE == status) - { - if (IDC_SAVE == status || self->m_sTo.empty() || - !self->MailReport(*self->m_rpt, sTempFileName.c_str(), mainDlg.m_sEmail.c_str(), mainDlg.m_sDescription.c_str())) - { - // write user data to file if to be supplied - if (!self->m_userDataFile.empty()) { - HANDLE hFile = ::CreateFile( - self->m_userDataFile.c_str(), - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - 0); - if (hFile != INVALID_HANDLE_VALUE) - { - static const char e_mail[] = "E-mail:"; - static const char newline[] = "\r\n"; - static const char description[] = "\r\n\r\nDescription:"; - DWORD writtenBytes; - ::WriteFile(hFile, e_mail, sizeof(e_mail) - 1, &writtenBytes, NULL); - ::WriteFile(hFile, mainDlg.m_sEmail.c_str(), mainDlg.m_sEmail.size(), &writtenBytes, NULL); - ::WriteFile(hFile, description, sizeof(description) - 1, &writtenBytes, NULL); - ::WriteFile(hFile, mainDlg.m_sDescription.c_str(), mainDlg.m_sDescription.size(), &writtenBytes, NULL); - ::WriteFile(hFile, newline, sizeof(newline) - 1, &writtenBytes, NULL); - ::CloseHandle(hFile); - // redo zip file to add user data - // delete existing copy, if any - DeleteFile(sTempFileName.c_str()); - - // zip the report - if (!zlib.Open(sTempFileName)) - return TRUE; - - // add report files to zip - TStrStrVector::iterator cur = self->m_files.begin(); - for (cur = self->m_files.begin(); cur != self->m_files.end(); cur++) - if (PathFileExists((*cur).first.c_str())) - zlib.AddFile((*cur).first); - - zlib.Close(); - } - } - self->SaveReport(*self->m_rpt, sTempFileName.c_str()); - } - } - - DeleteFile(sTempFileName.c_str()); - - self->m_wantDebug = IDC_DEBUG == status; - // signal main thread to resume - ::SetEvent(self->m_ipc_event); - // set flag for debugger break - - // exit thread - ::ExitThread(0); - // keep compiler happy. - return TRUE; -} - -BOOL CCrashHandler::GenerateErrorReport(PEXCEPTION_POINTERS pExInfo, BSTR message) -{ - CExceptionReport rpt(pExInfo, message); - unsigned int i; - // save state of file list prior to generating report - TStrStrVector save_m_files = m_files; - char temp[_MAX_PATH]; - - GetTempPath(sizeof temp, temp); - - - // let client add application specific files to report - if (m_lpfnCallback && !m_lpfnCallback(this)) - return TRUE; - - m_rpt = &rpt; - - // if no e-mail address, add file to contain user data - m_userDataFile = ""; - if (m_sTo.empty()) { - m_userDataFile = temp + string("\\") + CUtility::getAppName() + "_UserInfo.txt"; - HANDLE hFile = ::CreateFile( - m_userDataFile.c_str(), - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - 0); - if (hFile != INVALID_HANDLE_VALUE) - { - static const char description[] = "Your e-mail and description will go here."; - DWORD writtenBytes; - ::WriteFile(hFile, description, sizeof(description)-1, &writtenBytes, NULL); - ::CloseHandle(hFile); - m_files.push_back(TStrStrPair(m_userDataFile, LoadResourceString(IDS_USER_DATA))); - } else { - return m_wantDebug; - } - } - - - - // add crash files to report - string crashFile = rpt.getCrashFile(); - string crashLog = rpt.getCrashLog(); - m_files.push_back(TStrStrPair(crashFile, LoadResourceString(IDS_CRASH_DUMP))); - m_files.push_back(TStrStrPair(crashLog, LoadResourceString(IDS_CRASH_LOG))); - - // Export registry hives and add to report - std::vector extraFiles; - string file; - string number; - TStrStrVector::iterator iter; - int n = 0; - - for (iter = m_registryHives.begin(); iter != m_registryHives.end(); iter++) { - ++n; - TCHAR buf[MAX_PATH] = {0}; - _tprintf_s(buf, "%d", n); - number = buf; - file = temp + string("\\") + CUtility::getAppName() + "_registry" + number + ".reg"; - ::DeleteFile(file.c_str()); - - // we want to export in a readable format. Unfortunately, RegSaveKey saves in a binary - // form, so let's use our own function. - if (WriteRegistryTreeToFile((*iter).first.c_str(), file.c_str())) { - extraFiles.push_back(file); - m_files.push_back(TStrStrPair(file, (*iter).second)); - } else { - OutputDebugString("Could not write registry hive\n"); - } - } - // - // Add the specified event log(s). Note that this will not work on Win9x/WinME. - // - for (iter = m_eventLogs.begin(); iter != m_eventLogs.end(); iter++) { - HANDLE h; - h = OpenEventLog( NULL, // use local computer - (*iter).first.c_str()); // source name - if (h != NULL) { - - file = temp + string("\\") + CUtility::getAppName() + "_" + (*iter).first + ".evt"; - - DeleteFile(file.c_str()); - - if (BackupEventLog(h, file.c_str())) { - m_files.push_back(TStrStrPair(file, (*iter).second)); - extraFiles.push_back(file); - } else { - OutputDebugString("could not backup log\n"); - } - CloseEventLog(h); - } else { - OutputDebugString("could not open log\n"); - } - } - - - // add symbol files to report - for (i = 0; i < (UINT)rpt.getNumSymbolFiles(); i++) - m_files.push_back(TStrStrPair(rpt.getSymbolFile(i).c_str(), - string("Symbol File"))); - - //remove the crash handler, just in case the dialog crashes... - Uninstall(); - if (m_bUseUI) - { - // Start a new thread to display the dialog, and then wait - // until it completes - m_ipc_event = ::CreateEvent(NULL, FALSE, FALSE, "ACrashHandlerEvent"); - if (m_ipc_event == NULL) - return m_wantDebug; - DWORD threadId; - if (::CreateThread(NULL, 0, DialogThreadExecute, - reinterpret_cast(this), 0, &threadId) == NULL) - return m_wantDebug; - ::WaitForSingleObject(m_ipc_event, INFINITE); - CloseHandle(m_ipc_event); - } - else - { - string sTempFileName = CUtility::getTempFileName(); - CZLib zlib; - - sTempFileName += _T(".zip"); - // delete existing copy, if any - DeleteFile(sTempFileName.c_str()); - - // zip the report - if (!zlib.Open(sTempFileName)) - return TRUE; - - // add report files to zip - TStrStrVector::iterator cur = m_files.begin(); - for (cur = m_files.begin(); cur != m_files.end(); cur++) - if (PathFileExists((*cur).first.c_str())) - zlib.AddFile((*cur).first); - zlib.Close(); - fprintf(stderr, "a zipped crash report has been saved to\n"); - _ftprintf(stderr, sTempFileName.c_str()); - fprintf(stderr, "\n"); - if (!m_sTo.empty()) - { - fprintf(stderr, "please send the report to "); - _ftprintf(stderr, m_sTo.c_str()); - fprintf(stderr, "\n"); - } - } - // clean up - delete files we created - ::DeleteFile(crashFile.c_str()); - ::DeleteFile(crashLog.c_str()); - if (!m_userDataFile.empty()) { - ::DeleteFile(m_userDataFile.c_str()); - } - - std::vector::iterator file_iter; - for (file_iter = extraFiles.begin(); file_iter != extraFiles.end(); file_iter++) { - ::DeleteFile(file_iter->c_str()); - } - - // restore state of file list - m_files = save_m_files; - - m_rpt = NULL; - - return !m_wantDebug; -} - -BOOL CCrashHandler::SaveReport(CExceptionReport&, LPCTSTR lpcszFile) -{ - // let user more zipped report - return (CopyFile(lpcszFile, CUtility::getSaveFileName().c_str(), TRUE)); -} - -BOOL CCrashHandler::MailReport(CExceptionReport&, LPCTSTR lpcszFile, - LPCTSTR lpcszEmail, LPCTSTR lpcszDesc) -{ - CMailMsg msg; - msg - .SetTo(m_sTo) - .SetFrom(lpcszEmail) - .SetSubject(m_sSubject.empty()?_T("Incident Report"):m_sSubject) - .SetMessage(lpcszDesc) - .AddAttachment(lpcszFile, CUtility::getAppName() + _T(".zip")); - - return (msg.Send()); -} - -string CCrashHandler::LoadResourceString(UINT id) -{ - static int address; - char buffer[512]; - if (m_hModule == NULL) { - m_hModule = GetModuleHandle("CrashRpt.dll"); - } - buffer[0] = '\0'; - if (m_hModule) { - LoadString(m_hModule, id, buffer, sizeof buffer); - } - return buffer; -} diff --git a/src/crashrpt/CrashHandler.h b/src/crashrpt/CrashHandler.h deleted file mode 100644 index 1a06cc348..000000000 --- a/src/crashrpt/CrashHandler.h +++ /dev/null @@ -1,409 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Module: CrashHandler.h -// -// Desc: CCrashHandler is the main class used by crashrpt to manage all -// of the details associated with handling the exception, generating -// the report, gathering client input, and sending the report. -// -// Copyright (c) 2003 Michael Carruth -// -/////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "crashrpt.h" // defines LPGETLOGFILE callback -#include "excprpt.h" // bulk of crash report generation - -#ifndef TStrStrVector -#include - -typedef std::pair TStrStrPair; -typedef std::vector TStrStrVector; -#endif // !defined TStrStrVector - - -extern BOOL g_bNoCrashHandler;// don't use the crash handler but let the system handle it - -////////////////////////////// Class Definitions ///////////////////////////// - -// =========================================================================== -// CCrashHandler -// -// See the module comment at top of file. -// -class CCrashHandler -{ -public: - - //----------------------------------------------------------------------------- - // GetInstance (static) - // Returns the instance for the current process. Creates one if necessary. - // - // Parameters - // none - // - // Return Values - // none - // - // Remarks - // none - // - static CCrashHandler * GetInstance(); - - - //----------------------------------------------------------------------------- - // Install - // Installs the crash handler.. - // - // Parameters - // lpfn Client crash callback - // lpcszTo Email address to send crash report - // lpczSubject Subject line to be used with email - // - // Return Values - // none - // - // Remarks - // Passing NULL for lpTo will disable the email feature and cause the crash - // report to be saved to disk. - // - void Install( - LPGETLOGFILE lpfn = NULL, // Client crash callback - LPCTSTR lpcszTo = NULL, // EMail:To - LPCTSTR lpcszSubject = NULL, // EMail:Subject - BOOL bUseUI = TRUE - ); - - //----------------------------------------------------------------------------- - // Unnstall - // Removes the crash handler.. - // - // Parameters - // none - // - // Return Values - // none - // - // Remarks - // none - // - void Uninstall(); - - //----------------------------------------------------------------------------- - // EnableUI - // Enables the UI part - // - // Parameters - // none - // - // Return Values - // none - // - // Remarks - // none - // - void EnableUI(); - - //----------------------------------------------------------------------------- - // DisableUI - // Disables the UI part - // - // Parameters - // none - // - // Return Values - // none - // - // Remarks - // none - // - void DisableUI(); - - //----------------------------------------------------------------------------- - // DisableUI - // Disables the exception handler - // - // Parameters - // none - // - // Return Values - // none - // - // Remarks - // none - // - void DisableHandler(); - - //----------------------------------------------------------------------------- - // DisableUI - // Enables the custom exception handler - // - // Parameters - // none - // - // Return Values - // none - // - // Remarks - // none - // - void EnableHandler(); - - //----------------------------------------------------------------------------- - // ~CCrashHandler - // Uninitializes the crashrpt library. - // - // Parameters - // none - // - // Return Values - // none - // - // Remarks - // none - // - virtual - ~CCrashHandler(); - - //----------------------------------------------------------------------------- - // AddFile - // Adds a file to the crash report. - // - // Parameters - // lpFile Fully qualified file name - // lpDesc File description - // - // Return Values - // none - // - // Remarks - // Call this function to include application specific file(s) in the crash - // report. For example, application logs, initialization files, etc. - // - void - AddFile( - LPCTSTR lpFile, // File nae - LPCTSTR lpDesc // File description - ); - - //----------------------------------------------------------------------------- - // RemoveFile - // Removes a file from the crash report. - // - // Parameters - // lpFile Fully qualified file name - // - // Return Values - // none - // - // Remarks - // lpFile must exactly match that passed to AddFile. - // - void - RemoveFile( - LPCTSTR lpFile // File nae - ); - - //----------------------------------------------------------------------------- - // AddRegistryHive - // Adds a registry hive to the crash report. - // - // Parameters - // lpKey Fully registry eky - // lpDesc Description - // - // Return Values - // none - // - // Remarks - // Call this function to include application specific registry hive(s) in the crash - // report. - // - void - AddRegistryHive( - LPCTSTR lpKey, // Registry key - LPCTSTR lpDesc // description - ); - - //----------------------------------------------------------------------------- - // RemoveRegistryHive - // Removes a registry hive from the crash report. - // - // Parameters - // lpKey Full registry key - // - // Return Values - // none - // - // Remarks - // lpKey must exactly match that passed to AddRegistryHive. - // - void - RemoveRegistryHive( - LPCTSTR lpKey // Registry key - ); - - //----------------------------------------------------------------------------- - // AddEventLog - // Adds an event log to the crash report. - // - // Parameters - // lpKey Event log name ("Application", "System", "Security") - // lpDesc Description - // - // Return Values - // none - // - // Remarks - // Call this function to include application specific registry hive(s) in the crash - // report. - // - void - AddEventLog( - LPCTSTR lpKey, // Event log name - LPCTSTR lpDesc // description - ); - - //----------------------------------------------------------------------------- - // RemoveEventLog - // Removes an event log from the crash report. - // - // Parameters - // lpKey Event log name - // - // Return Values - // none - // - // Remarks - // lpKey must exactly match that passed to AddEventLog. - // - void - RemoveEventLog( - LPCTSTR lpKey // Registry key - ); - - //----------------------------------------------------------------------------- - // GenerateErrorReport - // Produces a crash report. - // - // Parameters - // pExInfo Pointer to an EXCEPTION_POINTERS structure - // - // Return Values - // BOOL TRUE if exception to be executed; FALSE - // if to search for another handler. This - // should be used to allow breaking into - // the debugger, where appropriate. - // - // Remarks - // Call this function to manually generate a crash report. - // - BOOL - GenerateErrorReport( - PEXCEPTION_POINTERS pExInfo, // Exception pointers (see MSDN) - BSTR message = NULL - ); - - -protected: - - //----------------------------------------------------------------------------- - // CCrashHandler - // Initializes the library and optionally set the client crash callback and - // sets up the email details. - // - // Parameters - // none - // - // Return Values - // none - // - // Remarks - // Passing NULL for lpTo will disable the email feature and cause the crash - // report to be saved to disk. - // - CCrashHandler( - ); - - //----------------------------------------------------------------------------- - // SaveReport - // Presents the user with a file save dialog and saves the crash report - // file to disk. This function is called if an Email:To was not provided - // in the constructor. - // - // Parameters - // rpt The report details - // lpcszFile The zipped crash report - // - // Return Values - // True is successful. - // - // Remarks - // none - // - BOOL - SaveReport( - CExceptionReport &rpt, - LPCTSTR lpcszFile - ); - - //----------------------------------------------------------------------------- - // MailReport - // Mails the zipped crash report to the address specified. - // - // Parameters - // rpt The report details - // lpcszFile The zipped crash report - // lpcszEmail The Email:To - // lpcszDesc - // - // Return Values - // TRUE is successful. - // - // Remarks - // MAPI is used to send the report. - // - BOOL - MailReport( - CExceptionReport &rpt, - LPCTSTR lpcszFile, - LPCTSTR lpcszEmail, - LPCTSTR lpcszSubject - ); - - //----------------------------------------------------------------------------- - // DialogThreadExecute - // Displays the dialog and handles the user's reply. Executed as a separate - // thread. - // - // Parameters - // pParam Standard CreateThreadParameter; set to pointer to CCrashHandler - // - // Return Values - // none - // - // Remarks - // Started from GenerateErrorReport via CreateThread. This ensures the caller - // is stopped (and will not confuse state by dispatching messages). - // - static DWORD WINAPI CCrashHandler::DialogThreadExecute(LPVOID pParam); - - string LoadResourceString(UINT id); - LPTOP_LEVEL_EXCEPTION_FILTER m_oldFilter; // previous exception filter - LPGETLOGFILE m_lpfnCallback; // client crash callback - int m_pid; // process id - TStrStrVector m_files; // custom files to add - TStrStrVector m_registryHives; // custom registry hives to save - TStrStrVector m_eventLogs; // custom event logs to save - string m_sTo; // Email:To - string m_sSubject; // Email:Subject - HANDLE m_ipc_event; // Event for dialog thread synchronization - CExceptionReport *m_rpt; // Exception report for dialog - bool m_installed; // True if already installed - HMODULE m_hModule; // Module handle for loading resource strings - string m_userDataFile; // file to save user input when m_sTo is empty - bool m_wantDebug; // user pushed Debug button - BOOL m_bUseUI; // use an UI or print to the error output -}; - diff --git a/src/crashrpt/CrashReport.h b/src/crashrpt/CrashReport.h deleted file mode 100644 index ed02d3749..000000000 --- a/src/crashrpt/CrashReport.h +++ /dev/null @@ -1,172 +0,0 @@ -#pragma once - -// Client crash callback -typedef BOOL (CALLBACK *LPGETLOGFILE) (LPVOID lpvState); -// Stack trace callback -typedef void (*TraceCallbackFunction)(DWORD_PTR address, const char *ImageName, - const char *FunctionName, DWORD functionDisp, - const char *Filename, DWORD LineNumber, DWORD lineDisp, - void *data); - -typedef LPVOID (*InstallEx)(LPGETLOGFILE pfn, LPCSTR lpcszTo, LPCSTR lpcszSubject, BOOL bUseUI); -typedef void (*UninstallEx)(LPVOID lpState); -typedef void (*EnableUI)(void); -typedef void (*DisableUI)(void); -typedef void (*EnableHandler)(void); -typedef void (*DisableHandler)(void); -typedef void (*AddFileEx)(LPVOID lpState, LPCSTR lpFile, LPCSTR lpDesc); -typedef void (*AddRegistryEx)(LPVOID lpState, LPCSTR lpRegistry, LPCSTR lpDesc); -typedef void (*AddEventLogEx)(LPVOID lpState, LPCSTR lpEventLog, LPCSTR lpDesc); - -/** - * \ingroup CrashRpt - * This class wraps the most important functions the CrashRpt-library - * offers. To learn more about the CrashRpt-library go to - * http://www.codeproject.com/debug/crash_report.asp \n - * To compile the library you need the WTL. You can get the WTL - * directly from Microsoft: - * http://www.microsoft.com/downloads/details.aspx?FamilyID=128e26ee-2112-4cf7-b28e-7727d9a1f288&DisplayLang=en \n - * \n - * Many changes were made to the library so if you read the - * article on CodeProject also read the change log in the source - * folder.\n - * The most important changes are: - * - stack trace is included in the report, with symbols/linenumbers if available - * - "save" button so the user can save the report instead of directly send it - * - can be used by multiple applications - * - zlib linked statically, so no need to ship the zlib.dll separately - * \n - * To use the library just include the header file "CrashReport.h" - * \code - * #include "CrashReport.h" - * \endcode - * Then you can either declare an instance of the class CCrashReport - * somewhere globally in your application like this: - * \code - * CCrashReport g_crasher("report@mycompany.com", "Crash report for MyApplication"); - * \endcode - * that way you can't add registry keys or additional files to the report, but - * it's the fastest and easiest way to use the library. - * Another way is to declare a global variable and initialize it in e.g. InitInstance() - * \code - * CCrashReport g_crasher; - * //then somewhere in InitInstance. - * g_crasher.AddFile("mylogfile.log", "this is a log file"); - * g_crasher.AddRegistry("HKCU\\Software\\MyCompany\\MyProgram"); - * \endcode - * - * - * \remark the dll is dynamically linked at runtime. So the main application - * will still work even if the dll is not shipped. - * - */ -class CCrashReport -{ -public: - /** - * Construct the CrashReport-Object. This loads the dll - * and initializes it. - * \param lpTo the mail address the crash report should be sent to - * \param lpSubject the mail subject - */ - CCrashReport(LPCSTR lpTo = NULL, LPCSTR lpSubject = NULL, BOOL bUseUI = TRUE) - { - InstallEx pfnInstallEx; - TCHAR szFileName[_MAX_PATH]; - GetModuleFileName(NULL, szFileName, _MAX_FNAME); - - // C:\Programme\TortoiseSVN\bin\TortoiseProc.exe -> C:\Programme\TortoiseSVN\bin\CrashRpt.dll - CString strFilename = szFileName; - strFilename = strFilename.Left(strFilename.ReverseFind(_T('\\')) + 1); - strFilename += _T("CrashRpt.dll"); - - m_hDll = LoadLibrary(strFilename); - if (m_hDll) - { - pfnInstallEx = (InstallEx)GetProcAddress(m_hDll, "InstallEx"); - if ( pfnInstallEx ) - { - m_lpvState = pfnInstallEx(NULL, lpTo, lpSubject, bUseUI); - } - } - } - ~CCrashReport() - { - UninstallEx pfnUninstallEx; - if ((m_hDll)&&(m_lpvState)) - { - pfnUninstallEx = (UninstallEx)GetProcAddress(m_hDll, "UninstallEx"); - pfnUninstallEx(m_lpvState); - } - FreeLibrary(m_hDll); - } - /** - * Adds a file which will be included in the crash report. Use this - * if your application generates log-files or the like. - * \param lpFile the full path to the file - * \param lpDesc a description of the file, used in the crash report dialog - */ - void AddFile(LPCSTR lpFile, LPCSTR lpDesc) - { - AddFileEx pfnAddFileEx; - if ((m_hDll)&&(m_lpvState)) - { - pfnAddFileEx = (AddFileEx)GetProcAddress(m_hDll, "AddFileEx"); - (pfnAddFileEx)(m_lpvState, lpFile, lpDesc); - } - } - /** - * Adds a whole registry tree to the crash report. - * \param lpFile the full registry path, e.g. "HKLM\\Software\\MyApplication" - * \param lpDesc a description of the generated registry file, used in the crash report dialog - */ - void AddRegistry(LPCSTR lpFile, LPCSTR lpDesc) - { - AddRegistryEx pfnAddRegistryEx; - if ((m_hDll)&&(m_lpvState)) - { - pfnAddRegistryEx = (AddRegistryEx)GetProcAddress(m_hDll, "AddRegistryHiveEx"); - (pfnAddRegistryEx)(m_lpvState, lpFile, lpDesc); - } - } - /** - * Adds a system Event Log to the crash report. - * \param lpFile - * \param lpDesc - */ - void AddEventLog(LPCSTR lpFile, LPCSTR lpDesc) - { - AddEventLogEx pfnAddEventLogEx; - if ((m_hDll)&&(m_lpvState)) - { - pfnAddEventLogEx = (AddEventLogEx)GetProcAddress(m_hDll, "AddEventLogEx"); - (pfnAddEventLogEx)(m_lpvState, lpFile, lpDesc); - } - } - - - void Enable(BOOL bEnable) - { - EnableHandler pfnEnableHandler; - DisableHandler pfnDisableHandler; - if ((m_hDll)&&(m_lpvState)) - { - if (bEnable) - { - pfnEnableHandler = (EnableHandler)GetProcAddress(m_hDll, "EnableHandlerEx"); - (pfnEnableHandler)(); - } - else - { - OutputDebugString(_T("Calling DisableHandlerEx\n")); - - pfnDisableHandler = (DisableHandler)GetProcAddress(m_hDll, "DisableHandlerEx"); - (pfnDisableHandler)(); - } - } - } - -private: - HMODULE m_hDll; - LPVOID m_lpvState; -}; \ No newline at end of file diff --git a/src/crashrpt/CrashRpt.cpp b/src/crashrpt/CrashRpt.cpp deleted file mode 100644 index 044c5170f..000000000 --- a/src/crashrpt/CrashRpt.cpp +++ /dev/null @@ -1,296 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Module: CrashRpt.cpp -// -// Desc: See CrashRpt.h -// -// Copyright (c) 2003 Michael Carruth -// -/////////////////////////////////////////////////////////////////////////////// - -#include "stdafx.h" -#include "CrashRpt.h" -#include "CrashHandler.h" - -#include "StackTrace.h" - -#ifdef _DEBUG -#define CRASH_ASSERT(pObj) \ - if (!pObj || sizeof(*pObj) != sizeof(CCrashHandler)) \ - DebugBreak() -#else -#define CRASH_ASSERT(pObj) -#endif // _DEBUG - -// New interfaces -CRASHRPTAPI LPVOID GetInstance() -{ - CCrashHandler *pImpl = CCrashHandler::GetInstance(); - CRASH_ASSERT(pImpl); - return pImpl; -} - -CRASHRPTAPI LPVOID InstallEx(LPGETLOGFILE pfn, LPCTSTR lpcszTo, LPCTSTR lpcszSubject, BOOL bUseUI) -{ -#ifdef _DEBUG - OutputDebugString("InstallEx\n"); -#endif - CCrashHandler *pImpl = CCrashHandler::GetInstance(); - CRASH_ASSERT(pImpl); - pImpl->Install(pfn, lpcszTo, lpcszSubject, bUseUI); - - return pImpl; -} - -CRASHRPTAPI void UninstallEx(LPVOID lpState) -{ - CCrashHandler *pImpl = (CCrashHandler*)lpState; - CRASH_ASSERT(pImpl); - - delete pImpl; -} - -CRASHRPTAPI void EnableUIEx(LPVOID lpState) -{ - CCrashHandler *pImpl = (CCrashHandler*)lpState; - CRASH_ASSERT(pImpl); - pImpl->EnableUI(); -} - -CRASHRPTAPI void DisableUIEx(LPVOID lpState) -{ - CCrashHandler *pImpl = (CCrashHandler*)lpState; - CRASH_ASSERT(pImpl); - pImpl->DisableUI(); -} - -CRASHRPTAPI void EnableHandlerEx(LPVOID lpState) -{ - CCrashHandler *pImpl = (CCrashHandler*)lpState; - CRASH_ASSERT(pImpl); - pImpl->EnableHandler(); -} - -CRASHRPTAPI void DisableHandlerEx(LPVOID lpState) -{ - CCrashHandler *pImpl = (CCrashHandler*)lpState; - CRASH_ASSERT(pImpl); - pImpl->DisableHandler(); -} - -CRASHRPTAPI void AddFileEx(LPVOID lpState, LPCTSTR lpFile, LPCTSTR lpDesc) -{ - CCrashHandler *pImpl = (CCrashHandler*)lpState; - CRASH_ASSERT(pImpl); - - pImpl->AddFile(lpFile, lpDesc); -} - -CRASHRPTAPI void RemoveFileEx(LPVOID lpState, LPCTSTR lpFile) -{ - CCrashHandler *pImpl = (CCrashHandler*)lpState; - CRASH_ASSERT(pImpl); - - pImpl->RemoveFile(lpFile); -} - -CRASHRPTAPI void AddRegistryHiveEx(LPVOID lpState, LPCTSTR lpHive, LPCTSTR lpDesc) -{ - CCrashHandler *pImpl = (CCrashHandler*)lpState; - CRASH_ASSERT(pImpl); - - pImpl->AddRegistryHive(lpHive, lpDesc); -} - -CRASHRPTAPI void RemoveRegistryHiveEx(LPVOID lpState, LPCTSTR lpFile) -{ - CCrashHandler *pImpl = (CCrashHandler*)lpState; - CRASH_ASSERT(pImpl); - - pImpl->RemoveRegistryHive(lpFile); -} - - -CRASHRPTAPI void AddEventLogEx(LPVOID lpState, LPCTSTR lpHive, LPCTSTR lpDesc) -{ - CCrashHandler *pImpl = (CCrashHandler*)lpState; - CRASH_ASSERT(pImpl); - - pImpl->AddEventLog(lpHive, lpDesc); -} - -CRASHRPTAPI void RemoveEventLogEx(LPVOID lpState, LPCTSTR lpFile) -{ - CCrashHandler *pImpl = (CCrashHandler*)lpState; - CRASH_ASSERT(pImpl); - - pImpl->RemoveEventLog(lpFile); -} - -CRASHRPTAPI void GenerateErrorReportEx(LPVOID lpState, PEXCEPTION_POINTERS pExInfo, BSTR message) -{ - CCrashHandler *pImpl = (CCrashHandler*)lpState; - CRASH_ASSERT(pImpl); - - if (!pImpl->GenerateErrorReport(pExInfo, message)) { - DebugBreak(); - } -} - -CRASHRPTAPI void StackTrace ( int numSkip, int depth, TraceCallbackFunction pFunction, CONTEXT *pContext, void *data) -{ - DoStackTrace(numSkip, depth > 0 ? depth : 9999, pFunction, pContext, data); -} - -// DLL Entry Points usable from Visual Basic -// explicit export is required to export undecorated names. -extern "C" LPVOID __stdcall InstallExVB(LPGETLOGFILE pfn, LPCTSTR lpcszTo, LPCTSTR lpcszSubject, BOOL bUseUI) -{ - return InstallEx(pfn, lpcszTo, lpcszSubject, bUseUI); -} - -extern "C" void __stdcall UninstallExVB(LPVOID lpState) -{ - UninstallEx(lpState); -} - -extern "C" void __stdcall EnableUIVB(void) -{ - EnableUI(); -} - -extern "C" void __stdcall DisableUIVB() -{ - DisableUI(); -} - -extern "C" void __stdcall AddFileExVB(LPVOID lpState, LPCTSTR lpFile, LPCTSTR lpDesc) -{ - AddFileEx(lpState, lpFile, lpDesc); -} - -extern "C" void __stdcall RemoveFileExVB(LPVOID lpState, LPCTSTR lpFile) -{ - RemoveFileEx(lpState, lpFile); -} - -extern "C" void __stdcall AddRegistryHiveExVB(LPVOID lpState, LPCTSTR lpRegistryHive, LPCTSTR lpDesc) -{ - AddRegistryHiveEx(lpState, lpRegistryHive, lpDesc); -} - -extern "C" void __stdcall RemoveRegistryHiveExVB(LPVOID lpState, LPCTSTR lpRegistryHive) -{ - RemoveRegistryHiveEx(lpState, lpRegistryHive); -} - -extern "C" void __stdcall GenerateErrorReportExVB(LPVOID lpState, PEXCEPTION_POINTERS pExInfo, BSTR message) -{ - GenerateErrorReportEx(lpState, pExInfo, message); -} - -extern "C" void __stdcall StackTraceVB(int numSkip, int depth, TraceCallbackFunction pFunction, CONTEXT *pContext, void *data) -{ - StackTrace(numSkip, depth, pFunction, pContext, data); -} - -// Compatibility interfaces -CRASHRPTAPI void Install(LPGETLOGFILE pfn, LPCTSTR lpcszTo, LPCTSTR lpcszSubject, BOOL bUseUI) -{ - (void) InstallEx(pfn, lpcszTo, lpcszSubject, bUseUI); -} - -CRASHRPTAPI void Uninstall() -{ - UninstallEx(CCrashHandler::GetInstance()); -} - -CRASHRPTAPI void EnableUI() -{ - EnableUIEx(CCrashHandler::GetInstance()); -} - -CRASHRPTAPI void DisableUI() -{ - DisableUIEx(CCrashHandler::GetInstance()); -} - -CRASHRPTAPI void AddFile(LPCTSTR lpFile, LPCTSTR lpDesc) -{ - AddFileEx(CCrashHandler::GetInstance(), lpFile, lpDesc); -} - -CRASHRPTAPI void RemoveFile(LPCTSTR lpFile) -{ - RemoveFileEx(CCrashHandler::GetInstance(), lpFile); -} - -CRASHRPTAPI void AddRegistryHive(LPCTSTR lpRegistryHive, LPCTSTR lpDesc) -{ - AddRegistryHiveEx(CCrashHandler::GetInstance(), lpRegistryHive, lpDesc); -} - -CRASHRPTAPI void RemoveRegistryHive(LPCTSTR lpRegistryHive) -{ - RemoveRegistryHiveEx(CCrashHandler::GetInstance(), lpRegistryHive); -} -CRASHRPTAPI void AddEventLog(LPCTSTR lpEventLog, LPCTSTR lpDesc) -{ - AddEventLogEx(CCrashHandler::GetInstance(), lpEventLog, lpDesc); -} - -CRASHRPTAPI void RemoveEventLog(LPCTSTR lpEventLog) -{ - RemoveEventLogEx(CCrashHandler::GetInstance(), lpEventLog); -} - -CRASHRPTAPI void GenerateErrorReport(BSTR message) -{ - GenerateErrorReportEx(CCrashHandler::GetInstance(), NULL, message); -} - -extern "C" void __stdcall InstallVB(LPGETLOGFILE pfn, LPCTSTR lpTo, LPCTSTR lpSubject, BOOL bUseUI) -{ - Install(pfn, lpTo, lpSubject, bUseUI); -} - -extern "C" void __stdcall UninstallVB() -{ - Uninstall(); -} - -extern "C" void __stdcall AddFileVB(LPCTSTR lpFile, LPCTSTR lpDesc) -{ - AddFile(lpFile, lpDesc); -} - -extern "C" void __stdcall RemoveFileVB(LPCTSTR lpFile) -{ - RemoveFile(lpFile); -} - -extern "C" void __stdcall AddRegistryHiveVB(LPCTSTR lpRegistryHive, LPCTSTR lpDesc) -{ - AddRegistryHive(lpRegistryHive, lpDesc); -} - -extern "C" void __stdcall RemoveRegistryHiveVB(LPCTSTR lpRegistryHive) -{ - RemoveRegistryHive(lpRegistryHive); -} - -extern "C" void __stdcall AddEventLogVB(LPCTSTR lpEventLog, LPCTSTR lpDesc) -{ - AddEventLog(lpEventLog, lpDesc); -} - -extern "C" void __stdcall RemoveEventLogVB(LPCTSTR lpEventLog) -{ - RemoveEventLog(lpEventLog); -} - -extern "C" void __stdcall GenerateErrorReportVB(BSTR message) -{ - GenerateErrorReport(message); -} - diff --git a/src/crashrpt/CrashRpt.h b/src/crashrpt/CrashRpt.h deleted file mode 100644 index 76f6e2774..000000000 --- a/src/crashrpt/CrashRpt.h +++ /dev/null @@ -1,453 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Module: CrashRpt.h -// -// Desc: Defines the interface for the CrashRpt.DLL. -// -// Copyright (c) 2003 Michael Carruth -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _CRASHRPT_H_ -#define _CRASHRPT_H_ - -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#include -#include // BSTR - -// CrashRpt.h -#ifdef CRASHRPTAPI - -// CRASHRPTAPI should be defined in all of the DLL's source files as -// #define CRASHRPTAPI extern "C" __declspec(dllexport) - -#else - -// This header file is included by an EXE - export -#define CRASHRPTAPI extern "C" __declspec(dllimport) - -#endif - -// Client crash callback -typedef BOOL (CALLBACK *LPGETLOGFILE) (LPVOID lpvState); -// Stack trace callback -typedef void (*TraceCallbackFunction)(DWORD_PTR address, const char *ImageName, - const char *FunctionName, DWORD_PTR functionDisp, - const char *Filename, DWORD LineNumber, DWORD lineDisp, - void *data); - - -//----------------------------------------------------------------------------- -// GetInstance -// Returns the instance (state information) for the current process. Will create -// one if required; does not install. -// -// Parameters -// none -// -// Return Values -// If the function succeeds, the return value is a pointer to the underlying -// crash object created. This state information is required as the first -// parameter to all other crash report functions. -// -// Remarks -// none -// -CRASHRPTAPI -LPVOID -GetInstance(); - -//----------------------------------------------------------------------------- -// Install, InstallEx -// Initializes the library and optionally set the client crash callback and -// sets up the email details. -// -// Parameters -// pfn Client crash callback -// lpTo Email address to send crash report -// lpSubject Subject line to be used with email -// -// Return Values -// InstallEx: -// If the function succeeds, the return value is a pointer to the underlying -// crash object created. This state information is required as the first -// parameter to all other crash report functions. -// Install: -// void -// -// Remarks -// Passing NULL for lpTo will disable the email feature and cause the crash -// report to be saved to disk. -// -CRASHRPTAPI -void -Install( - IN LPGETLOGFILE pfn OPTIONAL, // client crash callback - IN LPCSTR lpTo OPTIONAL, // Email:to - IN LPCSTR lpSubject OPTIONAL, // Email:subject - IN BOOL bUseUI OPTIONAL // UI or console - ); -CRASHRPTAPI -LPVOID -InstallEx( - IN LPGETLOGFILE pfn OPTIONAL, // client crash callback - IN LPCSTR lpTo OPTIONAL, // Email:to - IN LPCSTR lpSubject OPTIONAL, // Email:subject - IN BOOL bUseUI OPTIONAL // UI or console - ); - -//----------------------------------------------------------------------------- -// Uninstall, UninstallEx -// Uninstalls the unhandled exception filter set up in Install(). -// -// Parameters -// lpState State information returned from Install() -// -// Return Values -// void -// -// Remarks -// This call is optional. The crash report library will automatically -// deinitialize when the library is unloaded. Call this function to -// unhook the exception filter manually. -// -CRASHRPTAPI void Uninstall(); -CRASHRPTAPI -void -UninstallEx( - IN LPVOID lpState // State from Install() - ); - -CRASHRPTAPI void EnableUI(); -CRASHRPTAPI void DisableUI(); -//----------------------------------------------------------------------------- -// AddFile, AddFileEx -// Adds a file to the crash report. -// -// Parameters -// lpState State information returned from Install() -// lpFile Fully qualified file name -// lpDesc Description of file, used by details dialog -// -// Return Values -// void -// -// Remarks -// This function can be called anytime after Install() to add one or more -// files to the generated crash report. If lpFile and lpDesc exactly match -// a previously added pair, it is not added again. -// -CRASHRPTAPI -void -AddFile( - IN LPCSTR lpFile, // File name - IN LPCSTR lpDesc // File desc - ); -CRASHRPTAPI -void -AddFileEx( - IN LPVOID lpState, // State from Install() - IN LPCSTR lpFile, // File name - IN LPCSTR lpDesc // File desc - ); - -//----------------------------------------------------------------------------- -// RemoveFile -// Removes a file from the crash report. -// -// Parameters -// lpState State information returned from Install() -// lpFile Fully qualified file name -// -// Return Values -// void -// -// Remarks -// The filename must exactly match that provided to AddFile. -// -CRASHRPTAPI -void -RemoveFile( - IN LPCSTR lpFile // File name - ); -CRASHRPTAPI -void -RemoveFileEx( - IN LPVOID lpState, // State from Install() - IN LPCSTR lpFile // File name - ); - -//----------------------------------------------------------------------------- -// AddRegistryHive -// Adds a RegistryHive to the crash report. -// -// Parameters -// lpState State information returned from Install() -// lpRegistryHive Fully qualified RegistryHive name -// lpDesc Description of RegistryHive, used by details dialog -// -// Return Values -// void -// -// Remarks -// This function can be called anytime after Install() to add one or more -// RegistryHives to the generated crash report. If lpRegistryHive and lpDesc exactly match -// a previously added pair, it is not added again. -// -CRASHRPTAPI -void -AddRegistryHive( - IN LPCSTR lpRegistryHive, // RegistryHive name - IN LPCSTR lpDesc // RegistryHive desc - ); -CRASHRPTAPI -void -AddRegistryHiveEx( - IN LPVOID lpState, // State from Install() - IN LPCSTR lpRegistryHive, // RegistryHive name - IN LPCSTR lpDesc // RegistryHive desc - ); - -//----------------------------------------------------------------------------- -// RemoveRegistryHive -// Removes a RegistryHive from the crash report. -// -// Parameters -// lpState State information returned from Install() -// lpRegistryHive Fully qualified RegistryHive name -// -// Return Values -// void -// -// Remarks -// The RegistryHive name must exactly match that provided to AddRegistryHive. -// -CRASHRPTAPI -void -RemoveRegistryHive( - IN LPCSTR lpRegistryHive // RegistryHive name - ); -CRASHRPTAPI -void -RemoveRegistryHiveEx( - IN LPVOID lpState, // State from Install() - IN LPCSTR lpRegistryHive // RegistryHive name - ); - -//----------------------------------------------------------------------------- -// AddEventLog -// Adds an event log to the crash report. -// -// Parameters -// lpState State information returned from Install() -// lpEventLog Event log name ("Application", "Security", "System" or any other known to your system) -// lpDesc Description of event log, used by details dialog -// -// Return Values -// void -// -// Remarks -// This function can be called anytime after Install() to add one or more -// event logs to the generated crash report. If lpEventLog and lpDesc exactly match -// a previously added pair, it is not added again. -// -CRASHRPTAPI -void -AddEventLog( - IN LPCSTR lpEventLog, // Event Log name - IN LPCSTR lpDesc // Event Log desc - ); -CRASHRPTAPI -void -AddEventLogEx( - IN LPVOID lpState, // State from Install() - IN LPCSTR lpEventLog, // Event Log name - IN LPCSTR lpDesc // Event Log desc - ); - -//----------------------------------------------------------------------------- -// RemoveEventLog -// Removes a EventLog from the crash report. -// -// Parameters -// lpState State information returned from Install() -// lpEventLog Fully qualified EventLog name -// -// Return Values -// void -// -// Remarks -// The EventLog name must exactly match that provided to AddEventLog. -// -CRASHRPTAPI -void -RemoveEventLog( - IN LPCSTR lpEventLog // EventLog name - ); -CRASHRPTAPI -void -RemoveEventLogEx( - IN LPVOID lpState, // State from Install() - IN LPCSTR lpEventLog // EventLog name - ); - -//----------------------------------------------------------------------------- -// GenerateErrorReport, GenerateErrorReportEx -// Generates the crash report. -// -// Parameters -// lpState State information returned from Install() -// pExInfo Optional; pointer to an EXCEPTION_POINTERS structure -// message Optional; message to include in report -// -// Return Values -// void -// -// Remarks -// Call this function to manually generate a crash report. -// Note that only GenerateErrorReportEx can be supplied exception information. -// If you are using the basic interfaces and wish to supply exception information, -// use the call GenerateErrorReportEx, supplying GetInstance() for the state -// information. -// -CRASHRPTAPI -void -GenerateErrorReport( - IN BSTR message OPTIONAL - ); -CRASHRPTAPI -void -GenerateErrorReportEx( - IN LPVOID lpState, - IN PEXCEPTION_POINTERS pExInfo OPTIONAL, - IN BSTR message OPTIONAL - ); - -//----------------------------------------------------------------------------- -// StackTrace -// Creates a stack trace. -// -// Parameters -// numSkip Number of initial stack frames to skip -// depth Number of stack frames to process -// pFunction Optional; function to call for each frame -// pContext Optional; stack context to trace -// -// Return Values -// void -// -// Remarks -// Call this function to manually generate a stack trace. If -// pFunction is not supplied, stack trace frames are output using -// OutputDebugString. Note that this function does not require the -// 'lpState'; it can be called even if the crash handler is not -// installed. -// -CRASHRPTAPI -void -StackTrace( - IN int numSkip, - IN int depth OPTIONAL, - IN TraceCallbackFunction pFunction OPTIONAL, - IN CONTEXT * pContext OPTIONAL, - IN LPVOID data OPTIONAL - ); - - -//----------------------------------------------------------------------------- -// The following functions are identical to the above save that they are callable from Visual Basic -extern "C" -LPVOID -__stdcall -InstallExVB( - IN LPGETLOGFILE pfn OPTIONAL, // client crash callback - IN LPCSTR lpTo OPTIONAL, // Email:to - IN LPCSTR lpSubject OPTIONAL, // Email:subject - IN BOOL bUseUI OPTIONAL // UI or console - ); - - -extern "C" -void -__stdcall -UninstallExVB( - IN LPVOID lpState // State from InstallVB() - ); - - -extern "C" -void -__stdcall -EnableUIVB(); - -extern "C" -void -__stdcall -DisableUIVB(); - -extern "C" -void -__stdcall -AddFileExVB( - IN LPVOID lpState, // State from InstallVB() - IN LPCSTR lpFile, // File name - IN LPCSTR lpDesc // File desc - ); - -extern "C" -void -__stdcall -RemoveFileExVB( - IN LPVOID lpState, // State from InstallVB() - IN LPCSTR lpFile // File name - ); - -extern "C" -void -__stdcall -AddRegistryHiveExVB( - IN LPVOID lpState, // State from InstallVB() - IN LPCSTR lpRegistryHive, // RegistryHive name - IN LPCSTR lpDesc // RegistryHive desc - ); - -extern "C" -void -__stdcall -RemoveRegistryHiveExVB( - IN LPVOID lpState, // State from InstallVB() - IN LPCSTR lpRegistryHive // RegistryHive name - ); - -extern "C" -void -__stdcall -GenerateErrorReportExVB( - IN LPVOID lpState, - IN PEXCEPTION_POINTERS pExInfo OPTIONAL, - IN BSTR message OPTIONAL - ); - -extern "C" -void -__stdcall -StackTraceVB( - IN int numSkip, - IN int depth OPTIONAL, - IN TraceCallbackFunction pFunction OPTIONAL, - IN CONTEXT * pContext OPTIONAL, - IN LPVOID data OPTIONAL - ); - -extern "C" void __stdcall InstallVB(IN LPGETLOGFILE pfn OPTIONAL, IN LPCSTR lpTo OPTIONAL, IN LPCSTR lpSubject OPTIONAL, IN BOOL bUseUI OPTIONAL); -extern "C" void __stdcall UninstallVB(); -extern "C" void __stdcall AddFileVB(LPCSTR file, LPCSTR desc); -extern "C" void __stdcall RemoveFileVB(LPCSTR file); -extern "C" void __stdcall AddRegistryHiveVB(LPCSTR RegistryHive, LPCSTR desc); -extern "C" void __stdcall RemoveRegistryHiveVB(LPCSTR RegistryHive); -extern "C" void __stdcall GenerateErrorReportVB(BSTR message); - -#endif diff --git a/src/crashrpt/CrashRpt.rc b/src/crashrpt/CrashRpt.rc deleted file mode 100644 index 288d3f7a4..000000000 --- a/src/crashrpt/CrashRpt.rc +++ /dev/null @@ -1,359 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#define APSTUDIO_HIDDEN_SYMBOLS -#include "windows.h" -#undef APSTUDIO_HIDDEN_SYMBOLS -#ifndef APSTUDIO_INVOKED - -#endif -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Neutral resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU) -#ifdef _WIN32 -LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON "res\\CrashRpt.ico" -#endif // Neutral resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// German (Germany) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) -#ifdef _WIN32 -LANGUAGE LANG_GERMAN, SUBLANG_GERMAN -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_MAINDLG DIALOGEX 0, 0, 270, 219 -STYLE DS_SETFONT | WS_POPUP | WS_CAPTION | WS_SYSMENU -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - EDITTEXT IDC_EMAIL,20,94,230,14,ES_AUTOHSCROLL - EDITTEXT IDC_DESCRIPTION,20,127,230,58,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL - PUSHBUTTON "&Senden",IDOK,152,200,50,14,NOT WS_VISIBLE - PUSHBUTTON "&Beenden",IDCANCEL,205,200,50,14 - LTEXT "Das Programm hat einen schweren Fehler verursacht. Ihre nicht gespeicherten Daten sind wahrscheinlich verloren.",IDC_STATIC,20,4,230,20 - LTEXT "Wir haben einen Fehlerreport erstellt welchen Sie uns zuschicken können. Wir werden diesen Report vertraulich und anonym behandeln.",IDC_STATIC,20,28,230,20 - LTEXT "Um uns zu helfen diesen Fehler zu beheben und die Software zu verbessern geben Sie bitte Ihre Email-Adresse ein und beschreiben Sie kurz was Sie gerade taten als dieser Fehler auftrat.",IDC_STATIC,20,52,230,29 - LTEXT "Ihre EMail-Addresse (optional):",IDC_STATIC,20,82,230,8 - LTEXT "Beschreiben Sie was Sie taten als der Fehler auftrat (optional):",IDC_STATIC,20,116,230,8 - CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,0,194,272,1 - PUSHBUTTON "S&peichern",IDC_SAVE,99,200,50,14 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_MAINDLG, DIALOG - BEGIN - VERTGUIDE, 15 - VERTGUIDE, 20 - VERTGUIDE, 250 - VERTGUIDE, 255 - BOTTOMMARGIN, 213 - HORZGUIDE, 4 - HORZGUIDE, 195 - HORZGUIDE, 200 - END -END -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE -BEGIN - IDR_MAINFRAME "CrashRpt" -END - -STRINGTABLE -BEGIN - IDS_HEADER "{\\bnsi\\bnsicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fswiss\\fcharset0 Microsoft Sans Serif;}}\n{\\*\\generator Msftedit 5.41.15.1503;}\\viewkind4\\uc1\\pard\\b\\f0\\fs17 %s hat ein Problem festgestellt und wird beendet. Wir entschuldigen uns für Unannehmlichkeiten.\\b0}\n " - IDS_INVALID_EMAIL "Please enter a valid email address" - IDS_ZIP_FILTER "Zip Dateien (*.zip)" - IDS_HTTP_HEADER_CONTENT_TYPE - "Content-Type: Multipart/form-data; boundary=%s" - IDS_HTTP_HEADER_BOUNDARY "-----------------7d31389b0426" -END - -STRINGTABLE -BEGIN - IDS_ABOUTBOX "Über..." -END - -STRINGTABLE -BEGIN - IDS_FORM_DATA "module=%s&exception=%s&address=%s" -END - -STRINGTABLE -BEGIN - IDS_CONTENT_TYPE "Content-Type: Multipart/form-data; boundary=""crash-report-boundary""" -END - -STRINGTABLE -BEGIN - IDS_NAME "Name" - IDS_DESC "Beschreibung" - IDS_TYPE "Typ" - IDS_SIZE "Grösse" - IDS_CRASH_DUMP "Crash Dump" - IDS_CRASH_LOG "Crash Log" - IDS_SYMBOL_FILE "Symbol Datei" -END - -STRINGTABLE -BEGIN - IDS_USER_DATA "Ihre E-Mail und Beschreibung" -END - -#endif // German (Germany) resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_MAINDLG DIALOGEX 0, 0, 270, 217 -STYLE DS_SETFONT | WS_POPUP | WS_CAPTION | WS_SYSMENU -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - EDITTEXT IDC_EMAIL,20,95,230,14,ES_AUTOHSCROLL - EDITTEXT IDC_DESCRIPTION,20,129,230,57,ES_MULTILINE | ES_AUTOVSCROLL | ES_WANTRETURN | WS_VSCROLL - PUSHBUTTON "&Send",IDOK,152,198,50,14,NOT WS_VISIBLE - PUSHBUTTON "E&xit",IDCANCEL,205,198,50,14 - LTEXT "If you were in the middle of something, the information you were working on might be lost.",IDC_STATIC,20,6,230,20 - LTEXT "We have created an error report that you can send to us. We will treat this report as confidential and anonymous.",IDC_STATIC,20,30,230,20 - LTEXT "To help us diagnose the cause of this error and improve this software, please enter your email address, describe what you were doing when this error occurred, and send this report to us.",IDC_STATIC,20,54,230,29 - LTEXT "Your EMail Address (optional):",IDC_STATIC,20,84,230,8 - LTEXT "Describe what you were doing when the error occurred (optional):",IDC_STATIC,20,118,230,8 - CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,0,192,272,1 - PUSHBUTTON "Sa&ve",IDC_SAVE,99,198,50,14 -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_MAINDLG, DIALOG - BEGIN - VERTGUIDE, 15 - VERTGUIDE, 20 - VERTGUIDE, 250 - VERTGUIDE, 255 - BOTTOMMARGIN, 211 - HORZGUIDE, 6 - HORZGUIDE, 193 - HORZGUIDE, 198 - END -END -#endif // APSTUDIO_INVOKED - - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" - "#include ""windows.h""\r\n" - "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" - "#ifndef APSTUDIO_INVOKED\r\n" - "\r\n" - "#endif\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 3,1,2,3 - PRODUCTVERSION 3,1,2,3 - FILEFLAGSMASK 0x37L -#ifdef _DEBUG - FILEFLAGS 0x21L -#else - FILEFLAGS 0x20L -#endif - FILEOS 0x4L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "FileDescription", "Crash Report Module" - VALUE "FileVersion", "3.1.2.3" - VALUE "InternalName", "CrashRpt" - VALUE "LegalCopyright", "Copyright 2003-2007" - VALUE "OriginalFilename", "CrashRpt.exe" - VALUE "ProductName", "Crash Report Module" - VALUE "ProductVersion", "3.1.2.3" - VALUE "SpecialBuild", "0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE -BEGIN - IDR_MAINFRAME "CrashRpt" -END - -STRINGTABLE -BEGIN - IDS_HEADER "{\\bnsi\\bnsicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fswiss\\fcharset0 Microsoft Sans Serif;}}\n{\\*\\generator Msftedit 5.41.15.1503;}\\viewkind4\\uc1\\pard\\b\\f0\\fs17 %s has encountered a problem and needs to close. We are sorry for the inconvenience.\\b0}\n " - IDS_INVALID_EMAIL "Please enter a valid email address" - IDS_ZIP_FILTER "Zip Files (*.zip)" - IDS_HTTP_HEADER_CONTENT_TYPE - "Content-Type: Multipart/form-data; boundary=%s" - IDS_HTTP_HEADER_BOUNDARY "-----------------7d31389b0426" -END - -STRINGTABLE -BEGIN - IDS_ABOUTBOX "About..." -END - -STRINGTABLE -BEGIN - IDS_CONTENT_TYPE "Content-Type: Multipart/form-data; boundary=""crash-report-boundary""" -END - -STRINGTABLE -BEGIN - IDS_NAME "Name" - IDS_DESC "Description" - IDS_TYPE "Type" - IDS_SIZE "Size" - IDS_CRASH_DUMP "Crash Dump" - IDS_CRASH_LOG "Crash Log" - IDS_SYMBOL_FILE "Symbol File" -END - -STRINGTABLE -BEGIN - IDS_USER_DATA "Your e-mail and description" -END - -STRINGTABLE -BEGIN - IDS_FORM_DATA "module=%s&exception=%s&address=%s" -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// German (Switzerland) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DES) -#ifdef _WIN32 -LANGUAGE LANG_GERMAN, SUBLANG_GERMAN_SWISS -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -3 TEXTINCLUDE -BEGIN - "\r\0" -END - -#endif // APSTUDIO_INVOKED - -#endif // German (Switzerland) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/src/crashrpt/CrashRpt.vcproj b/src/crashrpt/CrashRpt.vcproj deleted file mode 100644 index 6650e9daa..000000000 --- a/src/crashrpt/CrashRpt.vcproj +++ /dev/null @@ -1,1148 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/crashrpt/CrashRptDL.h b/src/crashrpt/CrashRptDL.h deleted file mode 100644 index 7415fb1b7..000000000 --- a/src/crashrpt/CrashRptDL.h +++ /dev/null @@ -1,339 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Module: CrashRptDL.h -// -// Desc: Defines the interface for the CrashRpt.DLL, using a dynamically -// loaded instance of the library. Can be used when CrashRpt.dll may -// not be present on the system. -// -// Note that all functions except GetInstanceDL() and -// ReleaseInstanceDL() return an integer, which is non-zero ('true') -// when the real DLL function was located and called. This does not -// mean the actual DLL function succeeded, however. -// -// Please don't get confused by the macro usage; all functions do end -// in DL, even though the name supplied to CRASHRPT_DECLARE does not. -// -// Copyright (c) 2003 Michael Carruth -// Copyright (c) 2003 Grant McDorman -// 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. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _CRASHRPT_H_ -#define _CRASHRPT_H_ - -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#include -#include // BSTR - -// Client crash callback -typedef BOOL (CALLBACK *LPGETLOGFILE) (LPVOID lpvState); -// Stack trace callback -typedef void (*TraceCallbackFunction)(DWORD address, const char *ImageName, - const char *FunctionName, DWORD functionDisp, - const char *Filename, DWORD LineNumber, DWORD lineDisp, - void *data); - -// macro to create the inline forwarding function -#define CRASHRPT_DECLARE(function, declare1, declare2, arguments) \ - __inline int function##DL declare1 \ - { \ - typedef void (*function##_t) declare2; \ - function##_t p##function; \ - p##function = (function##_t) GetProcAddress(hModule, #function); \ - if (p##function != NULL) { \ - p##function arguments; \ - return 1; \ - } \ - return 0; \ - } - - - -//----------------------------------------------------------------------------- -// GetInstanceDL -// Returns the instance (module handle) for the CrashRpt DLL. -// -// Parameters -// none -// -// Return Values -// If the function succeeds, the return value is a module handle for the CrashRpt -// shared library (CrashRpt.dll). This handle is required for all the other functions. -// -// Remarks -// none -// -__inline -HMODULE -GetInstanceDL() -{ - return LoadLibrary("CrashRpt"); -} - -//----------------------------------------------------------------------------- -// InstallDL -// Initializes the library and optionally set the client crash callback and -// sets up the email details. -// -// Parameters -// hModule State information returned from GetInstanceDL() (must not be NULL) -// pfn Client crash callback -// lpTo Email address to send crash report -// lpSubject Subject line to be used with email -// -// Return Values -// non-zero if successful -// -// Remarks -// Passing NULL for lpTo will disable the email feature and cause the crash -// report to be saved to disk. -// -CRASHRPT_DECLARE(Install, (IN HMODULE hModule, IN LPGETLOGFILE pfn, IN LPCTSTR lpTo OPTIONAL, IN LPCTSTR lpSubject OPTIONAL), \ - (LPGETLOGFILE pfn, LPCTSTR lpTo, LPCTSTR lpSubject), \ - (pfn, lpTo, lpSubject)) - -//----------------------------------------------------------------------------- -// UninstallDL -// Uninstalls the unhandled exception filter set up in InstallDL(). -// -// Parameters -// hModule Module handle returned from GetInstanceDL() -// -// Return Values -// non-zero if successful -// -// Remarks -// This call is optional. The crash report library will automatically -// deinitialize when the library is unloaded. Call this function to -// unhook the exception filter manually. -// -CRASHRPT_DECLARE(Uninstall, (IN HMODULE hModule), \ - (), \ - ()) -//----------------------------------------------------------------------------- -// ReleaseInstanceDL -// Releases the library. -// -// Parameters -// hModule Module handle returned from GetInstanceDL() -// -// Return Values -// void -// -// Remarks -// This will call UninstallDL before releasing the library. -// -__inline -void -ReleaseInstanceDL(IN HMODULE hModule) -{ - UninstallDL(hModule); - FreeLibrary(hModule); -} - -//----------------------------------------------------------------------------- -// AddFileDL -// Adds a file to the crash report. -// -// Parameters -// hModule Module handle returned from GetInstanceDL() -// lpFile Fully qualified file name -// lpDesc Description of file, used by details dialog -// -// Return Values -// non-zero if successful -// -// Remarks -// This function can be called anytime after Install() to add one or more -// files to the generated crash report. If lpFile exactly matches -// a previously added file, it is not added again. -// -CRASHRPT_DECLARE(AddFile, (IN HMODULE hModule, IN LPCTSTR lpFile, IN LPCTSTR lpDesc), \ - (LPCTSTR lpFile, LPCTSTR lpDesc), \ - (lpFile, lpDesc)) - -//----------------------------------------------------------------------------- -// RemoveFileDL -// Removes a file from the crash report. -// -// Parameters -// hModule Module handle returned from GetInstanceDL() -// lpFile Fully qualified file name -// -// Return Values -// non-zero if successful -// -// Remarks -// The filename must exactly match that provided to AddFile. -// -CRASHRPT_DECLARE(RemoveFile, (IN HMODULE hModule, IN LPCTSTR lpFile), \ - (LPCTSTR lpFile), \ - (lpFile)) - -//----------------------------------------------------------------------------- -// AddRegistryHiveDL -// Adds a RegistryHive to the crash report. -// -// Parameters -// hModule Module handle returned from GetInstanceDL() -// lpRegistryHive Fully qualified RegistryHive name -// lpDesc Description of RegistryHive, used by details dialog -// -// Return Values -// non-zero if successful -// -// Remarks -// This function can be called anytime after Install() to add one or more -// RegistryHives to the generated crash report. If lpRegistryHive exactly matches -// a previously added file, it is not added again. -// -CRASHRPT_DECLARE(AddRegistryHive, (IN HMODULE hModule, IN LPCTSTR lpRegistryHive, IN LPCTSTR lpDesc), \ - (LPCTSTR lpRegistryHive, LPCTSTR lpDesc), \ - (lpRegistryHive, lpDesc)) - -//----------------------------------------------------------------------------- -// RemoveRegistryHiveDL -// Removes a RegistryHive from the crash report. -// -// Parameters -// hModule Module handle returned from GetInstanceDL() -// lpRegistryHive Fully qualified RegistryHive name -// -// Return Values -// non-zero if successful -// -// Remarks -// The RegistryHive name must exactly match that provided to AddRegistryHive. -// -CRASHRPT_DECLARE(RemoveRegistryHive, (IN HMODULE hModule, IN LPCTSTR lpRegistryHive), \ - (LPCTSTR lpRegistryHive), \ - (lpRegistryHive)) - -//----------------------------------------------------------------------------- -// AddEventLogDL -// Adds an event log to the crash report. -// -// Parameters -// hModule Module handle returned from GetInstanceDL() -// lpEventLog Event log name ("Application", "Security", "System" or any other known to your system) -// lpDesc Description of event log, used by details dialog -// -// Return Values -// non-zero if successful -// -// Remarks -// This function can be called anytime after Install() to add one or more -// event logs to the generated crash report. If lpEventLog exactly matches -// a previously added file, it is not added again. -// -CRASHRPT_DECLARE(AddEventLog, (IN HMODULE hModule, IN LPCTSTR lpEventLog, IN LPCTSTR lpDesc), \ - (LPCTSTR lpEventLog, LPCTSTR lpDesc), \ - (lpEventLog, lpDesc)) - -//----------------------------------------------------------------------------- -// RemoveEventLogDL -// Removes a EventLog from the crash report. -// -// Parameters -// hModule Module handle returned from GetInstanceDL() -// lpEventLog Fully qualified EventLog name -// -// Return Values -// non-zero if successful -// -// Remarks -// The EventLog name must exactly match that provided to AddEventLog. -// -CRASHRPT_DECLARE(RemoveEventLog, (IN HMODULE hModule, IN LPCTSTR lpEventLog), \ - (LPCTSTR lpEventLog), \ - (lpEventLog)) - -//----------------------------------------------------------------------------- -// GenerateErrorReportDL -// Generates the crash report. -// -// Parameters -// hModule Module handle returned from GetInstanceDL() -// pExInfo Optional; exception information -// message Optional; message to include in report -// -// Return Values -// non-zero if successful -// -// Remarks -// Call this function to manually generate a crash report. -// -__inline -int -GenerateErrorReportDL( - IN HMODULE hModule, - IN PEXCEPTION_POINTERS pExInfo OPTIONAL, - IN BSTR message OPTIONAL - ) -{ - // we can't use GenerateErrorReport(), because that is lacking the PEXCEPTION_POINTERS parameter - LPVOID instance; - typedef LPVOID (*GetInstance_t) (); - GetInstance_t pGetInstance; - pGetInstance = (GetInstance_t) GetProcAddress(hModule, "GetInstance"); - if (pGetInstance != NULL) { - typedef void (*GenerateErrorReportEx_t)(LPVOID lpState, PEXCEPTION_POINTERS pExInfo, BSTR message); - GenerateErrorReportEx_t pGenerateErrorReportEx; - - instance = pGetInstance(); - pGenerateErrorReportEx = (GenerateErrorReportEx_t) GetProcAddress(hModule, "GenerateErrorReportEx"); - if (pGenerateErrorReportEx != NULL) { - pGenerateErrorReportEx(instance, pExInfo, message); - return 1; - } - } - return 0; -} - - -//----------------------------------------------------------------------------- -// StackTraceDL -// Creates a stack trace. -// -// Parameters -// hModule Module handle returned from GetInstanceDL() -// numSkip Number of initial stack frames to skip -// depth Number of stack frames to process -// pFunction Optional; function to call for each frame -// pContext Optional; stack context to trace -// -// Return Values -// void -// -// Remarks -// Call this function to manually generate a stack trace. If -// pFunction is not supplied, stack trace frames are output using -// OutputDebugString. Can be called without installing (InstallDL) -// CrashRpt. -// -CRASHRPT_DECLARE(StackTrace, (IN HMODULE hModule, IN int numSkip, IN int depth, IN TraceCallbackFunction pFunction OPTIONAL, IN CONTEXT * pContext OPTIONAL, IN LPVOID data OPTIONAL), \ - (int numSkip, int depth, TraceCallbackFunction pFunction, CONTEXT * pContext, LPVOID data), \ - (numSkip, depth, pFunction, pContext, data)) - -#undef CRASHRPT_DECLARE - -#endif diff --git a/src/crashrpt/CrashRptStyleSheet.xsl b/src/crashrpt/CrashRptStyleSheet.xsl deleted file mode 100644 index 76af87216..000000000 --- a/src/crashrpt/CrashRptStyleSheet.xsl +++ /dev/null @@ -1,154 +0,0 @@ - - - - - - - - - -

Exception

- - - - - - - - - - - - - - - - - - - - - - - -
Exceptino Description Code Address ModuleFilename Function Line
- - - - - - - - - - - - - + - - - - - + - -
-
- - -

Application Description

-
 
-
- - -

Call Stack

- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Return Address Module File Function Line
- - - - - - - - - - - - - - - - - + - - - - - + - -
-
- - - -

Loaded Modules

- - - - - - - - - - - - - -
Full Path Product Version File Version Timestamp Base Addr Size
- - - - - - - - - - - - - -
-
- - - -
-
- diff --git a/src/crashrpt/MailMsg.cpp b/src/crashrpt/MailMsg.cpp deleted file mode 100644 index a0da4f5d7..000000000 --- a/src/crashrpt/MailMsg.cpp +++ /dev/null @@ -1,509 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Module: MailMsg.cpp -// -// Desc: See MailMsg.h -// -// Copyright (c) 2003 Michael Carruth -// -/////////////////////////////////////////////////////////////////////////////// - -#include "stdafx.h" -#include "MailMsg.h" - -CMailMsg::CMailMsg() -{ - m_lpCmcLogon = NULL; - m_lpCmcSend = NULL; - m_lpCmcLogoff = NULL; - m_lpMapiLogon = NULL; - m_lpMapiSendMail = NULL; - m_lpMapiLogoff = NULL; - m_lpMapiResolveName = NULL; - m_lpMapiFreeBuffer = NULL; - m_bReady = FALSE; -} - -CMailMsg::~CMailMsg() -{ - if (m_bReady) - Uninitialize(); -} - -CMailMsg& CMailMsg::SetFrom(string sAddress, string sName) -{ - if (m_bReady || Initialize()) - { - // only one sender allowed - if (m_from.size()) - m_from.empty(); - - m_from.push_back(TStrStrPair(sAddress,sName)); - } - - return *this; -} - -CMailMsg& CMailMsg::SetTo(string sAddress, string sName) -{ - if (m_bReady || Initialize()) - { - // only one recipient allowed - if (m_to.size()) - m_to.empty(); - - m_to.push_back(TStrStrPair(sAddress,sName)); - } - - return *this; -} - -CMailMsg& CMailMsg::SetCc(string sAddress, string sName) -{ - if (m_bReady || Initialize()) - { - m_cc.push_back(TStrStrPair(sAddress,sName)); - } - - return *this; -} - -CMailMsg& CMailMsg::SetBc(string sAddress, string sName) -{ - if (m_bReady || Initialize()) - { - m_bcc.push_back(TStrStrPair(sAddress, sName)); - } - - return *this; -} - -CMailMsg& CMailMsg::AddAttachment(string sAttachment, string sTitle) -{ - if (m_bReady || Initialize()) - { - m_attachments.push_back(TStrStrPair(sAttachment, sTitle)); - } - - return *this; -} - -BOOL CMailMsg::Send() -{ - // try mapi - int status = MAPISend(); - if (status != 0) - return status == 1; - // try cmc -// if (CMCSend()) -// return TRUE; - - return FALSE; -} - -/* -+------------------------------------------------------------------------------ -| -| Function: cResolveName() -| -| Parameters: [IN] lpszName = Name of e-mail recipient to resolve. -| [OUT] ppRecips = Pointer to a pointer to an lpMapiRecipDesc -| -| Purpose: Resolves an e-mail address and returns a pointer to a -| MapiRecipDesc structure filled with the recipient information -| contained in the address book. -| -| Note: ppRecips is allocated off the heap using MAPIAllocateBuffer. -| Any user of this method must be sure to release ppRecips when -| done with it using either MAPIFreeBuffer or cFreeBuffer. -+------------------------------------------------------------------------------- -*/ -int CMailMsg::cResolveName( LHANDLE m_lhSession, const char * lpszName, lpMapiRecipDesc *ppRecip ) -{ - HRESULT hRes = E_FAIL; - FLAGS flFlags = 0L; - ULONG ulReserved = 0L; - lpMapiRecipDesc pRecips = NULL; - - // Always check to make sure there is an active session - if ( m_lhSession ) - { - hRes = m_lpMapiResolveName ( - m_lhSession, // Session handle - 0L, // Parent window. - const_cast(lpszName), // Name of recipient. Passed in by argv. - flFlags, // Flags set to 0 for MAPIResolveName. - ulReserved, - &pRecips - ); - - if ( hRes == SUCCESS_SUCCESS ) - { - // Copy the recipient descriptor returned from MAPIResolveName to - // the out parameter for this function, - *ppRecip = pRecips; - } - } - return hRes; -} - - - -int CMailMsg::MAPISend() -{ - - TStrStrVector::iterator p; - int nIndex = 0; - size_t nRecipients = 0; - MapiRecipDesc* pRecipients = NULL; - MapiRecipDesc* pOriginator = NULL; - MapiRecipDesc* pFirstRecipient = NULL; - size_t nAttachments = 0; - MapiFileDesc* pAttachments = NULL; - ULONG status = 0; - MapiMessage message; - std::vector buffersToFree; - MapiRecipDesc* pRecip; - MapiRecipDesc grecip; - - if (m_bReady || Initialize()) - { - LHANDLE hMapiSession; - status = m_lpMapiLogon(NULL, NULL, NULL, MAPI_NEW_SESSION | MAPI_LOGON_UI, 0, &hMapiSession); - if (SUCCESS_SUCCESS != status) { - return FALSE; - } - - nRecipients = m_to.size() + m_cc.size() + m_bcc.size() + m_from.size(); - if (nRecipients) - { - pRecipients = new MapiRecipDesc[nRecipients]; - memset(pRecipients, 0, nRecipients * sizeof MapiRecipDesc); - } - - nAttachments = m_attachments.size(); - if (nAttachments) - pAttachments = new MapiFileDesc[nAttachments]; - - if (pRecipients) - { - pFirstRecipient = pRecipients; - if (m_from.size()) - { - // set from - if (cResolveName(hMapiSession, m_from.begin()->first.c_str(), &pOriginator) == SUCCESS_SUCCESS) { - buffersToFree.push_back(pOriginator); - } - } - if (m_to.size()) - { - if (cResolveName(hMapiSession, m_to.begin()->first.c_str(), &pRecip) == SUCCESS_SUCCESS) { - if (pFirstRecipient == NULL) - pFirstRecipient = &pRecipients[nIndex]; - pRecip->ulRecipClass = MAPI_TO; - memcpy(&pRecipients[nIndex], pRecip, sizeof pRecipients[nIndex]); - buffersToFree.push_back(pRecip); - nIndex++; - } - else - { - if (pFirstRecipient == NULL) - pFirstRecipient = &pRecipients[nIndex]; - grecip.ulRecipClass = MAPI_TO; - grecip.lpEntryID = 0; - grecip.lpszName = 0; - grecip.ulEIDSize = 0; - grecip.ulReserved = 0; - grecip.lpszAddress = (LPTSTR)(LPCTSTR)m_to.begin()->first.c_str(); - memcpy(&pRecipients[nIndex], &grecip, sizeof pRecipients[nIndex]); - nIndex++; - } - } - if (m_cc.size()) - { - // set cc's - for (p = m_cc.begin(); p != m_cc.end(); p++, nIndex++) - { - if ( cResolveName(hMapiSession, p->first.c_str(), &pRecip) == SUCCESS_SUCCESS) { - if (pFirstRecipient == NULL) - pFirstRecipient = &pRecipients[nIndex]; - pRecip->ulRecipClass = MAPI_CC; - memcpy(&pRecipients[nIndex], pRecip, sizeof pRecipients[nIndex]); - buffersToFree.push_back(pRecip); - nIndex++; - } - } - } - - if (m_bcc.size()) - { - // set bcc - for (p = m_bcc.begin(); p != m_bcc.end(); p++, nIndex++) - { - if ( cResolveName(hMapiSession, p->first.c_str(), &pRecip) == SUCCESS_SUCCESS) { - if (pFirstRecipient == NULL) - pFirstRecipient = &pRecipients[nIndex]; - pRecip->ulRecipClass = MAPI_BCC; - memcpy(&pRecipients[nIndex], pRecip, sizeof pRecipients[nIndex]); - buffersToFree.push_back(pRecip); - nIndex++; - } - } - } - } - if (pAttachments) - { - // add attachments - for (p = m_attachments.begin(), nIndex = 0; - p != m_attachments.end(); p++, nIndex++) - { - pAttachments[nIndex].ulReserved = 0; - pAttachments[nIndex].flFlags = 0; - pAttachments[nIndex].nPosition = 0; - pAttachments[nIndex].lpszPathName = (LPTSTR)p->first.c_str(); - pAttachments[nIndex].lpszFileName = (LPTSTR)p->second.c_str(); - pAttachments[nIndex].lpFileType = NULL; - } - } - memset(&message, 0, sizeof message); - message.ulReserved = 0; - if (!m_sSubject.empty()) - message.lpszSubject = (LPTSTR)m_sSubject.c_str(); - else - message.lpszSubject = "No Subject"; - if (!m_sMessage.empty()) - message.lpszNoteText = (LPTSTR)m_sMessage.c_str(); - else - message.lpszNoteText = "No Message Body"; - message.lpszMessageType = NULL; - message.lpszDateReceived = NULL; - message.lpszConversationID = NULL; - message.flFlags = 0; - message.lpOriginator = pOriginator; - message.nRecipCount = nIndex; - message.lpRecips = pFirstRecipient; - message.nFileCount = nAttachments; - message.lpFiles = pAttachments; - - status = m_lpMapiSendMail(hMapiSession, 0, &message, MAPI_DIALOG, 0); - - m_lpMapiLogoff(hMapiSession, NULL, 0, 0); - std::vector::iterator iter; - for (iter = buffersToFree.begin(); iter != buffersToFree.end(); iter++) { - m_lpMapiFreeBuffer(*iter); - } -if (SUCCESS_SUCCESS != status) { - string txt; - TCHAR buf[MAX_PATH]; - _tprintf_s(buf, "Message did not get sent due to error code %d.\r\n", status); - txt = buf; - switch (status) - { - case MAPI_E_AMBIGUOUS_RECIPIENT: - txt += "A recipient matched more than one of the recipient descriptor structures and MAPI_DIALOG was not set. No message was sent.\r\n" ; - break; - case MAPI_E_ATTACHMENT_NOT_FOUND: - txt += "The specified attachment was not found. No message was sent.\r\n" ; - break; - case MAPI_E_ATTACHMENT_OPEN_FAILURE: - txt += "The specified attachment could not be opened. No message was sent.\r\n" ; - break; - case MAPI_E_BAD_RECIPTYPE: - txt += "The type of a recipient was not MAPI_TO, MAPI_CC, or MAPI_BCC. No message was sent.\r\n" ; - break; - case MAPI_E_FAILURE: - txt += "One or more unspecified errors occurred. No message was sent.\r\n" ; - break; - case MAPI_E_INSUFFICIENT_MEMORY: - txt += "There was insufficient memory to proceed. No message was sent.\r\n" ; - break; - case MAPI_E_INVALID_RECIPS: - txt += "One or more recipients were invalid or did not resolve to any address.\r\n" ; - break; - case MAPI_E_LOGIN_FAILURE: - txt += "There was no default logon, and the user failed to log on successfully when the logon dialog box was displayed. No message was sent.\r\n" ; - break; - case MAPI_E_TEXT_TOO_LARGE: - txt += "The text in the message was too large. No message was sent.\r\n" ; - break; - case MAPI_E_TOO_MANY_FILES: - txt += "There were too many file attachments. No message was sent.\r\n" ; - break; - case MAPI_E_TOO_MANY_RECIPIENTS: - txt += "There were too many recipients. No message was sent.\r\n" ; - break; - case MAPI_E_UNKNOWN_RECIPIENT: - txt += "A recipient did not appear in the address list. No message was sent.\r\n" ; - break; - case MAPI_E_USER_ABORT: - txt += "The user canceled one of the dialog boxes. No message was sent.\r\n" ; - break; - default: - txt += "Unknown error code.\r\n" ; - break; - } - ::MessageBox(0, txt.c_str(), "Error", MB_OK); -} - - if (pRecipients) - delete [] pRecipients; - - if (nAttachments) - delete [] pAttachments; - } - - if (SUCCESS_SUCCESS == status) - return 1; - if (MAPI_E_USER_ABORT == status) - return -1; - // other failure - return 0; -} - -BOOL CMailMsg::CMCSend() -{ - TStrStrVector::iterator p; - int nIndex = 0; - CMC_recipient* pRecipients; - CMC_attachment* pAttachments; - CMC_session_id session; - CMC_return_code status = 0; - CMC_message message; - CMC_boolean bAvailable = FALSE; - CMC_time t_now = {0}; - - if (m_bReady || Initialize()) - { - pRecipients = new CMC_recipient[m_to.size() + m_cc.size() + m_bcc.size() + m_from.size()]; - pAttachments = new CMC_attachment[m_attachments.size()]; - - // set cc's - for (p = m_cc.begin(); p != m_cc.end(); p++, nIndex++) - { - pRecipients[nIndex].name = (LPTSTR)(LPCTSTR)p->second.c_str(); - pRecipients[nIndex].name_type = CMC_TYPE_INDIVIDUAL; - pRecipients[nIndex].address = (LPTSTR)(LPCTSTR)p->first.c_str(); - pRecipients[nIndex].role = CMC_ROLE_CC; - pRecipients[nIndex].recip_flags = 0; - pRecipients[nIndex].recip_extensions = NULL; - } - - // set bcc - for (p = m_bcc.begin(); p != m_bcc.end(); p++, nIndex++) - { - pRecipients[nIndex].name = (LPTSTR)(LPCTSTR)p->second.c_str(); - pRecipients[nIndex].name_type = CMC_TYPE_INDIVIDUAL; - pRecipients[nIndex].address = (LPTSTR)(LPCTSTR)p->first.c_str(); - pRecipients[nIndex].role = CMC_ROLE_BCC; - pRecipients[nIndex].recip_flags = 0; - pRecipients[nIndex].recip_extensions = NULL; - } - - // set to - pRecipients[nIndex].name = (LPTSTR)(LPCTSTR)m_to.begin()->second.c_str(); - pRecipients[nIndex].name_type = CMC_TYPE_INDIVIDUAL; - pRecipients[nIndex].address = (LPTSTR)(LPCTSTR)m_to.begin()->first.c_str(); - pRecipients[nIndex].role = CMC_ROLE_TO; - pRecipients[nIndex].recip_flags = 0; - pRecipients[nIndex].recip_extensions = NULL; - - // set from - pRecipients[nIndex+1].name = (LPTSTR)(LPCTSTR)m_from.begin()->second.c_str(); - pRecipients[nIndex+1].name_type = CMC_TYPE_INDIVIDUAL; - pRecipients[nIndex+1].address = (LPTSTR)(LPCTSTR)m_from.begin()->first.c_str(); - pRecipients[nIndex+1].role = CMC_ROLE_ORIGINATOR; - pRecipients[nIndex+1].recip_flags = CMC_RECIP_LAST_ELEMENT; - pRecipients[nIndex+1].recip_extensions = NULL; - - // add attachments - for (p = m_attachments.begin(), nIndex = 0; - p != m_attachments.end(); p++, nIndex++) - { - pAttachments[nIndex].attach_title = (LPTSTR)(LPCTSTR)p->second.c_str(); - pAttachments[nIndex].attach_type = NULL; - pAttachments[nIndex].attach_filename = (LPTSTR)(LPCTSTR)p->first.c_str(); - pAttachments[nIndex].attach_flags = 0; - pAttachments[nIndex].attach_extensions = NULL; - } - pAttachments[nIndex-1].attach_flags = CMC_ATT_LAST_ELEMENT; - - message.message_reference = NULL; - message.message_type = NULL; - if (m_sSubject.empty()) - message.subject = "No Subject"; - else - message.subject = (LPTSTR)(LPCTSTR)m_sSubject.c_str(); - message.time_sent = t_now; - if (m_sMessage.empty()) - message.text_note = "No Body"; - else - message.text_note = (LPTSTR)(LPCTSTR)m_sMessage.c_str(); - message.recipients = pRecipients; - message.attachments = pAttachments; - message.message_flags = 0; - message.message_extensions = NULL; - - status = m_lpCmcQueryConfiguration( - 0, - CMC_CONFIG_UI_AVAIL, - (void*)&bAvailable, - NULL - ); - - if (CMC_SUCCESS == status && bAvailable) - { - status = m_lpCmcLogon( - NULL, - NULL, - NULL, - NULL, - 0, - CMC_VERSION, - CMC_LOGON_UI_ALLOWED | - CMC_ERROR_UI_ALLOWED, - &session, - NULL - ); - - if (CMC_SUCCESS == status) - { - status = m_lpCmcSend(session, &message, 0, 0, NULL); - - m_lpCmcLogoff(session, NULL, CMC_LOGON_UI_ALLOWED, NULL); - } - } - - delete [] pRecipients; - delete [] pAttachments; - } - - return ((CMC_SUCCESS == status) && bAvailable); -} - -BOOL CMailMsg::Initialize() -{ - m_hMapi = ::LoadLibrary(_T("mapi32.dll")); - - if (!m_hMapi) - return FALSE; - - m_lpCmcQueryConfiguration = (LPCMCQUERY)::GetProcAddress(m_hMapi, _T("cmc_query_configuration")); - m_lpCmcLogon = (LPCMCLOGON)::GetProcAddress(m_hMapi, _T("cmc_logon")); - m_lpCmcSend = (LPCMCSEND)::GetProcAddress(m_hMapi, _T("cmc_send")); - m_lpCmcLogoff = (LPCMCLOGOFF)::GetProcAddress(m_hMapi, _T("cmc_logoff")); - m_lpMapiLogon = (LPMAPILOGON)::GetProcAddress(m_hMapi, _T("MAPILogon")); - m_lpMapiSendMail = (LPMAPISENDMAIL)::GetProcAddress(m_hMapi, _T("MAPISendMail")); - m_lpMapiLogoff = (LPMAPILOGOFF)::GetProcAddress(m_hMapi, _T("MAPILogoff")); - m_lpMapiResolveName = (LPMAPIRESOLVENAME) GetProcAddress(m_hMapi, _T("MAPIResolveName")); - m_lpMapiFreeBuffer = (LPMAPIFREEBUFFER) GetProcAddress(m_hMapi, _T("MAPIFreeBuffer")); - - m_bReady = (m_lpCmcLogon && m_lpCmcSend && m_lpCmcLogoff) || - (m_lpMapiLogon && m_lpMapiSendMail && m_lpMapiLogoff); - - return m_bReady; -} - -void CMailMsg::Uninitialize() -{ - ::FreeLibrary(m_hMapi); -} \ No newline at end of file diff --git a/src/crashrpt/MailMsg.h b/src/crashrpt/MailMsg.h deleted file mode 100644 index 6d412f96f..000000000 --- a/src/crashrpt/MailMsg.h +++ /dev/null @@ -1,320 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Module: MailMsg.h -// -// Desc: This class encapsulates the MAPI and CMC mail functions. -// -// Copyright (c) 2003 Michael Carruth -// -/////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include // CMC function defs -#include // MAPI function defs - -#ifndef TStrStrVector -// STL generates various warnings. -// 4100: unreferenced formal parameter -// 4663: C++ language change: to explicitly specialize class template... -// 4018: signed/unsigned mismatch -// 4245: conversion from to : signed/unsigned mismatch -#pragma warning(push, 3) -#pragma warning(disable: 4100) -#pragma warning(disable: 4663) -#pragma warning(disable: 4018) -#pragma warning(disable: 4245) -#include -#pragma warning(pop) - -typedef std::pair TStrStrPair; -typedef std::vector TStrStrVector; -#endif // !defined TStrStrVector - -// -// Define CMC entry points -// -typedef CMC_return_code (FAR PASCAL *LPCMCLOGON) \ - (CMC_string, CMC_string, CMC_string, CMC_object_identifier, \ - CMC_ui_id, CMC_uint16, CMC_flags, CMC_session_id FAR*, \ - CMC_extension FAR*); - -typedef CMC_return_code (FAR PASCAL *LPCMCSEND) \ - (CMC_session_id, CMC_message FAR*, CMC_flags, \ - CMC_ui_id, CMC_extension FAR*); - -typedef CMC_return_code (FAR PASCAL *LPCMCLOGOFF) \ - (CMC_session_id, CMC_ui_id, CMC_flags, CMC_extension FAR*); - -typedef CMC_return_code (FAR PASCAL *LPCMCQUERY) \ - (CMC_session_id, CMC_enum, CMC_buffer, CMC_extension FAR*); - - -////////////////////////////// Class Definitions ///////////////////////////// - -// =========================================================================== -// CMailMsg -// -// See the module comment at top of file. -// -class CMailMsg -{ -public: - CMailMsg(); - virtual ~CMailMsg(); - - //----------------------------------------------------------------------------- - // SetTo - // Sets the Email:To address - // - // Parameters - // sAddress Address - // sName Optional name - // - // Return Values - // CMailMsg reference - // - // Remarks - // Only one To address can be set. If called more than once - // the last address will be used. - // - CMailMsg& - SetTo( - string sAddress, - string sName = _T("") - ); - - //----------------------------------------------------------------------------- - // SetCc - // Sets the Email:Cc address - // - // Parameters - // sAddress Address - // sName Optional name - // - // Return Values - // CMailMsg reference - // - // Remarks - // Multiple Cc addresses can be set. - // - CMailMsg& - SetCc( - string sAddress, - string sName = _T("") - ); - - //----------------------------------------------------------------------------- - // SetBc - // Sets the Email:Bcc address - // - // Parameters - // sAddress Address - // sName Optional name - // - // Return Values - // CMailMsg reference - // - // Remarks - // Multiple Bcc addresses can be set. - // - CMailMsg& - SetBc( - string sAddress, - string sName = _T("") - ); - - //----------------------------------------------------------------------------- - // SetFrom - // Sets the Email:From address - // - // Parameters - // sAddress Address - // sName Optional name - // - // Return Values - // CMailMsg reference - // - // Remarks - // Only one From address can be set. If called more than once - // the last address will be used. - // - CMailMsg& - SetFrom( - string sAddress, - string sName = _T("") - ); - - //----------------------------------------------------------------------------- - // SetSubect - // Sets the Email:Subject - // - // Parameters - // sSubject Subject - // - // Return Values - // CMailMsg reference - // - // Remarks - // none - // - CMailMsg& - SetSubject( - string sSubject - ) {m_sSubject = sSubject; return *this;}; - - //----------------------------------------------------------------------------- - // SetMessage - // Sets the Email message body - // - // Parameters - // sMessage Message body - // - // Return Values - // CMailMsg reference - // - // Remarks - // none - // - CMailMsg& - SetMessage( - string sMessage - ) {m_sMessage = sMessage; return *this;}; - - //----------------------------------------------------------------------------- - // AddAttachment - // Attaches a file to the email - // - // Parameters - // sAttachment Fully qualified file name - // sTitle File display name - // - // Return Values - // CMailMsg reference - // - // Remarks - // none - // - CMailMsg& - AddAttachment( - string sAttachment, - string sTitle = _T("") - ); - - //----------------------------------------------------------------------------- - // Send - // Send the email. - // - // Parameters - // none - // - // Return Values - // TRUE if successful - // - // Remarks - // First simple MAPI is used if unsuccessful CMC is used. - // - BOOL Send(); - -protected: - - //----------------------------------------------------------------------------- - // CMCSend - // Send email using CMC functions. - // - // Parameters - // none - // - // Return Values - // TRUE if successful - // - // Remarks - // none - // - BOOL CMCSend(); - - //----------------------------------------------------------------------------- - // MAPISend - // Send email using MAPI functions. - // - // Parameters - // none - // - // Return Values - // -1: cancelled; 0: other failure; 1: success - // - // Remarks - // none - // - int MAPISend(); - - //----------------------------------------------------------------------------- - // Initialize - // Initialize MAPI32.dll - // - // Parameters - // none - // - // Return Values - // TRUE if successful - // - // Remarks - // none - // - BOOL Initialize(); - - //----------------------------------------------------------------------------- - // Uninitialize - // Uninitialize MAPI32.dll - // - // Parameters - // none - // - // Return Values - // void - // - // Remarks - // none - // - void Uninitialize(); - - /* - +------------------------------------------------------------------------------ - | - | Function: cResolveName() - | - | Parameters: [IN] lpszName = Name of e-mail recipient to resolve. - | [OUT] ppRecips = Pointer to a pointer to an lpMapiRecipDesc - | - | Purpose: Resolves an e-mail address and returns a pointer to a - | MapiRecipDesc structure filled with the recipient information - | contained in the address book. - | - | Note: ppRecips is allocated off the heap using MAPIAllocateBuffer. - | Any user of this method must be sure to release ppRecips when - | done with it using either MAPIFreeBuffer or cFreeBuffer. - +------------------------------------------------------------------------------- - */ - int cResolveName( LHANDLE m_lhSession, const char * lpszName, lpMapiRecipDesc *ppRecip ); - - TStrStrVector m_from; // From - TStrStrVector m_to; // To - TStrStrVector m_cc; // Cc - TStrStrVector m_bcc; // Bcc - TStrStrVector m_attachments; // Attachment - string m_sSubject; // EMail subject - string m_sMessage; // EMail message - - HMODULE m_hMapi; // Handle to MAPI32.DLL - LPCMCQUERY m_lpCmcQueryConfiguration; // Cmc func pointer - LPCMCLOGON m_lpCmcLogon; // Cmc func pointer - LPCMCSEND m_lpCmcSend; // Cmc func pointer - LPCMCLOGOFF m_lpCmcLogoff; // Cmc func pointer - LPMAPILOGON m_lpMapiLogon; // Mapi func pointer - LPMAPISENDMAIL m_lpMapiSendMail; // Mapi func pointer - LPMAPILOGOFF m_lpMapiLogoff; // Mapi func pointer - LPMAPIRESOLVENAME m_lpMapiResolveName; // Mapi func pointer - LPMAPIFREEBUFFER m_lpMapiFreeBuffer; // Mapi func pointer - - BOOL m_bReady; // MAPI is loaded -}; diff --git a/src/crashrpt/MainDlg.cpp b/src/crashrpt/MainDlg.cpp deleted file mode 100644 index cac27ffd4..000000000 --- a/src/crashrpt/MainDlg.cpp +++ /dev/null @@ -1,107 +0,0 @@ -#include "StdAfx.h" - -#include "MainDlg.h" -#include "resource.h" - -CMainDlg::CMainDlg(void) -{ -} - -CMainDlg::~CMainDlg(void) -{ -} - -LRESULT CMainDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - switch (uMsg) - { - case WM_INITDIALOG: - { - InitDialog(hwndDlg, IDR_MAINFRAME); - // - // Set title using app name - // - ::SetWindowText(*this, CUtility::getAppName().c_str()); - // Hide 'Send' button if required. Position 'Send' and 'Save'. - // - HWND okButton = ::GetDlgItem(*this, IDOK); - HWND saveButton = ::GetDlgItem(*this, IDC_SAVE); - if (m_sendButton) - { - // Line up Save, Send [OK] and Exit [Cancel] all in a row - HWND cancelButton = ::GetDlgItem(*this, IDCANCEL); - WINDOWPLACEMENT okPlace; - WINDOWPLACEMENT savePlace; - WINDOWPLACEMENT cancelPlace; - - ::GetWindowPlacement(okButton, &okPlace); - ::GetWindowPlacement(saveButton, &savePlace); - ::GetWindowPlacement(cancelButton, &cancelPlace); - - savePlace.rcNormalPosition.left = - okPlace.rcNormalPosition.left - - (savePlace.rcNormalPosition.right - savePlace.rcNormalPosition.left) + - (okPlace.rcNormalPosition.right - cancelPlace.rcNormalPosition.left); - ::SetWindowPlacement(saveButton, &savePlace); - - DWORD style = ::GetWindowLong(okButton, GWL_STYLE); - ::SetWindowLong(okButton, GWL_STYLE, style | WS_VISIBLE); - } - else - { - WINDOWPLACEMENT okPlace; - - // Put Save on top of the invisible Send [OK] - ::GetWindowPlacement(okButton, &okPlace); - - ::SetWindowPlacement(saveButton, &okPlace); - - DWORD style = ::GetWindowLong(okButton, GWL_STYLE); - ::SetWindowLong(okButton, GWL_STYLE, style & ~ WS_VISIBLE); - } - } - return TRUE; - case WM_COMMAND: - return DoCommand(LOWORD(wParam)); - default: - return FALSE; - } - return TRUE; -} - -LRESULT CMainDlg::DoCommand(int id) -{ - switch (id) - { - case IDOK: // send - { - HWND hWndEmail = ::GetDlgItem(*this, IDC_EMAIL); - HWND hWndDesc = ::GetDlgItem(*this, IDC_DESCRIPTION); - int nEmailLen = ::GetWindowTextLength(hWndEmail) + 1; - int nDescLen = ::GetWindowTextLength(hWndDesc) + 1; - - TCHAR * lpStr = new TCHAR[nEmailLen+1]; - ::GetWindowText(hWndEmail, lpStr, nEmailLen); - m_sEmail = lpStr; - delete [] lpStr; - - lpStr = new TCHAR[nDescLen+1]; - ::GetWindowText(hWndDesc, lpStr, nDescLen); - m_sDescription = lpStr; - delete [] lpStr; - } - EndDialog(*this, IDOK); - return 0; - break; - case IDC_SAVE: - EndDialog(*this, IDC_SAVE); - return 0; - break; - case IDCANCEL: - EndDialog(*this, IDCANCEL); - PostQuitMessage(IDCANCEL); - return 0; - break; - } - return 1; -} diff --git a/src/crashrpt/StackTrace.cpp b/src/crashrpt/StackTrace.cpp deleted file mode 100644 index 2ef387703..000000000 --- a/src/crashrpt/StackTrace.cpp +++ /dev/null @@ -1,311 +0,0 @@ -/*---------------------------------------------------------------------- - John Robbins - Microsoft Systems Journal Bugslayer Column - Feb 99 -----------------------------------------------------------------------*/ -#include - -#include "StackTrace.h" -#include "SymbolEngine.h" - -// 4710: inline function not inlined -#pragma warning(disable: 4710) -#pragma warning(disable: 4786) -#pragma warning(push, 3) -#include -#pragma warning(pop) - -/*////////////////////////////////////////////////////////////////////// - File Scope Globals -//////////////////////////////////////////////////////////////////////*/ - -// The symbol engine. Indexed by process-id so there is no collision between processes. -#pragma warning(push, 3) -typedef std::map TSymbolEngineMap; -static TSymbolEngineMap g_cSymMap; -#pragma warning(pop) - -static CSymbolEngine & GetSymbolEngine() -{ - DWORD CurrProcessId = GetCurrentProcessId(); - TSymbolEngineMap::iterator iter; - iter = g_cSymMap.lower_bound(CurrProcessId); - if (iter == g_cSymMap.end() || iter->first != CurrProcessId) { - CSymbolEngine cSym; - HANDLE hProcess = GetCurrentProcess ( ) ; - DWORD dwOpts = SymGetOptions ( ) ; - - // Turn on load lines. - SymSetOptions ( dwOpts | - SYMOPT_LOAD_LINES ) ; - iter = g_cSymMap.insert(iter, std::make_pair(CurrProcessId, CSymbolEngine())); - if ( FALSE == iter->second.SymInitialize ( hProcess , - NULL , - TRUE ) ) - { - OutputDebugString ( "DiagAssert : Unable to initialize the " - "symbol engine!!!\n" ) ; - -#ifdef _DEBUG - DebugBreak ( ) ; -#endif - } - } - return iter->second; -} - -static DWORD_PTR __stdcall GetModBase ( HANDLE hProcess , DWORD_PTR dwAddr ) -{ - // Check in the symbol engine first. - IMAGEHLP_MODULE stIHM ; - CSymbolEngine & cSym = GetSymbolEngine(); - // This is what the MFC stack trace routines forgot to do so their - // code will not get the info out of the symbol engine. - stIHM.SizeOfStruct = sizeof ( IMAGEHLP_MODULE ) ; - - if ( cSym.SymGetModuleInfo ( dwAddr , &stIHM ) ) - { - return ( stIHM.BaseOfImage ) ; - } - else - { - // Let's go fishing. - MEMORY_BASIC_INFORMATION stMBI ; - - if ( 0 != VirtualQueryEx ( hProcess , - (LPCVOID)dwAddr , - &stMBI , - sizeof ( stMBI ) ) ) - { - // Try and load it. - DWORD dwNameLen = 0 ; - TCHAR szFile[ MAX_PATH ] ; - szFile[0] = '\0'; - dwNameLen = GetModuleFileName ( (HINSTANCE) - stMBI.AllocationBase , - szFile , - MAX_PATH ); - HANDLE hFile = NULL ; - - if ( 0 != dwNameLen ) - { - hFile = CreateFile ( szFile , - GENERIC_READ , - FILE_SHARE_READ , - NULL , - OPEN_EXISTING , - 0 , - 0 ) ; - } -#ifdef NOTDEF_DEBUG - DWORD dwRet = -#endif - cSym.SymLoadModule ( hFile , - ( dwNameLen ? szFile : NULL ) , - NULL , - (DWORD)stMBI.AllocationBase , - 0 ); - ::CloseHandle(hFile); - -#ifdef NOTDEF_DEBUG - if ( 0 == dwRet ) - { - ATLTRACE ( "SymLoadModule failed : 0x%08X\n" , - GetLastError ( ) ) ; - } -#endif // _DEBUG - return ( (DWORD)stMBI.AllocationBase ) ; - } - } - return ( 0 ) ; -} - -static void PrintAddress (DWORD_PTR address, const char *ImageName, - const char *FunctionName, DWORD_PTR functionDisp, - const char *Filename, DWORD LineNumber, DWORD lineDisp, - void * /* data, unused */ ) -{ - static char buffer [ MAX_PATH*2 + 512 ]; - LPTSTR pCurrPos = buffer ; - // Always stick the address in first. - pCurrPos += _snprintf ( pCurrPos , sizeof buffer - (pCurrPos - buffer), addressFormat , address ) ; - - if (ImageName != NULL) { - LPCTSTR szName = strchr ( ImageName , ( '\\' ) ) ; - if ( NULL != szName ) { - szName++ ; - } else { - szName = const_cast(ImageName) ; - } - pCurrPos += _snprintf ( pCurrPos , sizeof buffer - (pCurrPos - buffer), ( "%s: " ) , szName ) ; - } else { - pCurrPos += _snprintf ( pCurrPos , sizeof buffer - (pCurrPos - buffer), ( ": " ) ); - } - if (FunctionName != NULL) { - if ( 0 == functionDisp ) { - pCurrPos += _snprintf ( pCurrPos , sizeof buffer - (pCurrPos - buffer), ( "%s" ) , FunctionName); - } else { - pCurrPos += _snprintf ( pCurrPos , sizeof buffer - (pCurrPos - buffer), - ( "%s + %d bytes" ) , - FunctionName , - functionDisp ) ; - } - if (Filename != NULL) { - // Put this on the next line and indented a bit. - pCurrPos += _snprintf( pCurrPos, sizeof buffer - (pCurrPos - buffer), "-\n"); - OutputDebugString(buffer); - pCurrPos = buffer; - pCurrPos += _snprintf ( pCurrPos , sizeof buffer - (pCurrPos - buffer), - ( "\t\t%s, Line %d" ) , - Filename , - LineNumber ) ; - if ( 0 != lineDisp ) - { - pCurrPos += _snprintf ( pCurrPos , sizeof buffer - (pCurrPos - buffer), - ( " + %d bytes" ) , - lineDisp ) ; - } - } - } else { - pCurrPos += _snprintf ( pCurrPos , sizeof buffer - (pCurrPos - buffer), ( "" ) ) ; - } - // Tack on a CRLF. - pCurrPos += _snprintf ( pCurrPos , sizeof buffer - (pCurrPos - buffer), ( "\n" ) ) ; - OutputDebugString ( buffer ); -} - - -void AddressToSymbol(DWORD_PTR dwAddr, TraceCallbackFunction pFunction, LPVOID data) -{ - char szTemp [ MAX_PATH + sizeof ( IMAGEHLP_SYMBOL ) ] ; - - PIMAGEHLP_SYMBOL pIHS = (PIMAGEHLP_SYMBOL)&szTemp ; - - IMAGEHLP_MODULE stIHM ; - IMAGEHLP_LINE stIHL ; - - bool haveModule = false; - bool haveFunction = false; - bool haveLine = false; - - CSymbolEngine & cSym = GetSymbolEngine(); - - SecureZeroMemory ( pIHS , MAX_PATH + sizeof ( IMAGEHLP_SYMBOL ) ) ; - SecureZeroMemory ( &stIHM , sizeof ( IMAGEHLP_MODULE ) ) ; - SecureZeroMemory ( &stIHL , sizeof ( IMAGEHLP_LINE ) ) ; - - pIHS->SizeOfStruct = sizeof ( IMAGEHLP_SYMBOL ) ; - pIHS->Address = dwAddr ; - pIHS->MaxNameLength = MAX_PATH ; - - stIHM.SizeOfStruct = sizeof ( IMAGEHLP_MODULE ) ; - - - // Get the module name. - haveModule = (0 != cSym.SymGetModuleInfo ( dwAddr , &stIHM )); - - // Get the function. - DWORD_PTR dwFuncDisp=0 ; - DWORD dwLineDisp=0; - if ( 0 != cSym.SymGetSymFromAddr ( dwAddr , &dwFuncDisp , pIHS ) ) - { - haveFunction = true; - - - // If I got a symbol, give the source and line a whirl. - - - stIHL.SizeOfStruct = sizeof ( IMAGEHLP_LINE ) ; - - haveLine = 0 != cSym.SymGetLineFromAddr ( dwAddr , - &dwLineDisp , - &stIHL ); - } - if (pFunction != NULL) { - - pFunction(dwAddr, haveModule ? stIHM.ImageName : NULL, - haveFunction ? pIHS->Name : NULL, dwFuncDisp, - haveLine ? stIHL.FileName : NULL, haveLine ? stIHL.LineNumber : 0, dwLineDisp, - data); - } -} - -void DoStackTrace ( int numSkip, int depth, TraceCallbackFunction pFunction, CONTEXT *pContext, LPVOID data ) -{ - HANDLE hProcess = GetCurrentProcess ( ) ; - - if (pFunction == NULL) { - pFunction = PrintAddress; - } - - // The symbol engine is initialized so do the stack walk. - - // The thread information - if not supplied. - CONTEXT stCtx ; - if (pContext == NULL) { - - stCtx.ContextFlags = CONTEXT_FULL ; - - if ( GetThreadContext ( GetCurrentThread ( ) , &stCtx ) ) - { - pContext = &stCtx; - } - } - if (pContext != NULL) { - STACKFRAME stFrame ; - DWORD dwMachine ; - - SecureZeroMemory ( &stFrame , sizeof ( STACKFRAME ) ) ; - - stFrame.AddrPC.Mode = AddrModeFlat ; - -#if defined (_M_IX86) - dwMachine = IMAGE_FILE_MACHINE_I386 ; - stFrame.AddrPC.Offset = pContext->Eip ; - stFrame.AddrStack.Offset = pContext->Esp ; - stFrame.AddrStack.Mode = AddrModeFlat ; - stFrame.AddrFrame.Offset = pContext->Ebp ; - stFrame.AddrFrame.Mode = AddrModeFlat ; - -#elif defined (_M_AMD64) - dwMachine = IMAGE_FILE_MACHINE_AMD64 ; - stFrame.AddrPC.Offset = pContext->Rip ; - stFrame.AddrStack.Offset = pContext->Rsp ; - stFrame.AddrStack.Mode = AddrModeFlat ; - stFrame.AddrFrame.Offset = pContext->Rbp ; - stFrame.AddrFrame.Mode = AddrModeFlat ; - -#elif defined (_M_ALPHA) - dwMachine = IMAGE_FILE_MACHINE_ALPHA ; - stFrame.AddrPC.Offset = (unsigned long)pContext->Fir ; -#else -#error ( "Unknown machine!" ) -#endif - - // Loop for the first stack elements. - for ( int i = 0 ; i < depth ; i++ ) - { - if ( FALSE == StackWalk ( dwMachine , - hProcess , - //hProcess , - GetCurrentThread(), - &stFrame , - pContext , - NULL , - SymFunctionTableAccess , - GetModBase , - NULL ) ) - { - break ; - } - if ( i >= numSkip ) - { - // Also check that the address is not zero. Sometimes - // StackWalk returns TRUE with a frame of zero. - if ( 0 != stFrame.AddrPC.Offset ) - { - AddressToSymbol ( stFrame.AddrPC.Offset, pFunction, data ) ; - } - } - } - - } -} diff --git a/src/crashrpt/StackTrace.h b/src/crashrpt/StackTrace.h deleted file mode 100644 index 3ea47ec06..000000000 --- a/src/crashrpt/StackTrace.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef STACKTRACE_H -#define STACKTRACE_H - -typedef void (*TraceCallbackFunction)(DWORD_PTR address, const char *ImageName, - const char *FunctionName, DWORD_PTR functionDisp, - const char *Filename, DWORD LineNumber, DWORD lineDisp, void *data); - -extern void DoStackTrace ( int numSkip, int depth=9999, TraceCallbackFunction pFunction=NULL, CONTEXT *pContext=NULL, void *data=NULL ); -extern void AddressToSymbol(DWORD_PTR dwAddr, TraceCallbackFunction pFunction, void *data); - -#endif diff --git a/src/crashrpt/StdAfx.cpp b/src/crashrpt/StdAfx.cpp deleted file mode 100644 index 3b3378d00..000000000 --- a/src/crashrpt/StdAfx.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// CrashRpt.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - - -////////////////////////////////////////////////////////////////////// -// how shall addresses be formatted? -////////////////////////////////////////////////////////////////////// - -const LPCTSTR addressFormat = sizeof (void*) <= 4 - ? _T("0x%08x") - : _T("0x%016x"); - -const LPCTSTR sizeFormat = _T("0x%08x"); -const LPCTSTR offsetFormat = _T("0x%x"); - diff --git a/src/crashrpt/StdAfx.h b/src/crashrpt/StdAfx.h deleted file mode 100644 index 992de4a44..000000000 --- a/src/crashrpt/StdAfx.h +++ /dev/null @@ -1,25 +0,0 @@ -#pragma once - -// Change these values to use different versions -#define WINVER 0x0400 -#define _WIN32_WINNT 0x0400 -#define _WIN32_IE 0x0400 -#include -#include -#include - -#include -#include -#include - -using namespace std; - -#define CRASHRPTAPI extern "C" __declspec(dllexport) -////////////////////////////////////////////////////////////////////// -// how shall addresses be formatted? -////////////////////////////////////////////////////////////////////// - -extern const LPCTSTR addressFormat; -extern const LPCTSTR offsetFormat; -extern const LPCTSTR sizeFormat; - diff --git a/src/crashrpt/SymbolEngine.h b/src/crashrpt/SymbolEngine.h deleted file mode 100644 index 155afcc83..000000000 --- a/src/crashrpt/SymbolEngine.h +++ /dev/null @@ -1,442 +0,0 @@ -/*---------------------------------------------------------------------- -"Debugging Applications" (Microsoft Press) -Copyright (c) 1997-2000 John Robbins -- All rights reserved. ------------------------------------------------------------------------- -This class is a paper-thin layer around the DBGHELP.DLL symbol engine. - -This class wraps only those functions that take the unique -HANDLE value. Other DBGHELP.DLL symbol engine functions are global in -scope, so I didn’t wrap them with this class. - ------------------------------------------------------------------------- -Compilation Defines: - -DO_NOT_WORK_AROUND_SRCLINE_BUG - If defined, the class will NOT work - around the SymGetLineFromAddr bug where - PDB file lookups fail after the first - lookup. -USE_BUGSLAYERUTIL - If defined, the class will have another - initialization method, BSUSymInitialize, which will - use BSUSymInitialize from BUGSLAYERUTIL.DLL to - initialize the symbol engine and allow the invade - process flag to work for all Win32 operating systems. - If you use this define, you must use - BUGSLAYERUTIL.H to include this file. -----------------------------------------------------------------------*/ - -#ifndef _SYMBOLENGINE_H -#define _SYMBOLENGINE_H - -// You could include either IMAGEHLP.DLL or DBGHELP.DLL. -#include "imagehlp.h" -#include - -// Include these in case the user forgets to link against them. -#pragma comment (lib,"dbghelp.lib") -#pragma comment (lib,"version.lib") - -// The great Bugslayer idea of creating wrapper classes on structures -// that have size fields came from fellow MSJ columnist, Paul DiLascia. -// Thanks, Paul! - -// I didn’t wrap IMAGEHLP_SYMBOL because that is a variable-size -// structure. - -// The IMAGEHLP_MODULE wrapper class -struct CImageHlp_Module : public IMAGEHLP_MODULE -{ - CImageHlp_Module ( ) - { - memset ( this , NULL , sizeof ( IMAGEHLP_MODULE ) ) ; - SizeOfStruct = sizeof ( IMAGEHLP_MODULE ) ; - } -} ; - -// The IMAGEHLP_LINE wrapper class -struct CImageHlp_Line : public IMAGEHLP_LINE -{ - CImageHlp_Line ( ) - { - memset ( this , NULL , sizeof ( IMAGEHLP_LINE ) ) ; - SizeOfStruct = sizeof ( IMAGEHLP_LINE ) ; - } -} ; - -// The symbol engine class -class CSymbolEngine -{ -/*---------------------------------------------------------------------- - Public Construction and Destruction -----------------------------------------------------------------------*/ -public : - // To use this class, call the SymInitialize member function to - // initialize the symbol engine and then use the other member - // functions in place of their corresponding DBGHELP.DLL functions. - CSymbolEngine ( void ) - { - } - - virtual ~CSymbolEngine ( void ) - { - } - -/*---------------------------------------------------------------------- - Public Helper Information Functions -----------------------------------------------------------------------*/ -public : - - // Returns the file version of DBGHELP.DLL being used. - // To convert the return values into a readable format: - // wsprintf ( szVer , - // ( "%d.%02d.%d.%d" ) , - // HIWORD ( dwMS ) , - // LOWORD ( dwMS ) , - // HIWORD ( dwLS ) , - // LOWORD ( dwLS ) ) ; - // szVer will contain a string like: 5.00.1878.1 - BOOL GetImageHlpVersion ( DWORD & dwMS , DWORD & dwLS ) - { - return( GetInMemoryFileVersion ( ( "DBGHELP.DLL" ) , - dwMS , - dwLS ) ) ; - } - - BOOL GetDbgHelpVersion ( DWORD & dwMS , DWORD & dwLS ) - { - return( GetInMemoryFileVersion ( ( "DBGHELP.DLL" ) , - dwMS , - dwLS ) ) ; - } - - // Returns the file version of the PDB reading DLLs - BOOL GetPDBReaderVersion ( DWORD & dwMS , DWORD & dwLS ) - { - // First try MSDBI.DLL. - if ( TRUE == GetInMemoryFileVersion ( ( "MSDBI.DLL" ) , - dwMS , - dwLS ) ) - { - return ( TRUE ) ; - } - else if ( TRUE == GetInMemoryFileVersion ( ( "MSPDB60.DLL" ), - dwMS , - dwLS )) - { - return ( TRUE ) ; - } - // Just fall down to MSPDB50.DLL. - return ( GetInMemoryFileVersion ( ( "MSPDB50.DLL" ) , - dwMS , - dwLS ) ) ; - } - - // The worker function used by the previous two functions - BOOL GetInMemoryFileVersion ( LPCTSTR szFile , - DWORD & dwMS , - DWORD & dwLS ) - { - HMODULE hInstIH = GetModuleHandle ( szFile ) ; - - // Get the full filename of the loaded version. - TCHAR szImageHlp[ MAX_PATH ] ; - GetModuleFileName ( hInstIH , szImageHlp , MAX_PATH ) ; - - dwMS = 0 ; - dwLS = 0 ; - - // Get the version information size. - DWORD dwVerInfoHandle ; - DWORD dwVerSize ; - - dwVerSize = GetFileVersionInfoSize ( szImageHlp , - &dwVerInfoHandle ) ; - if ( 0 == dwVerSize ) - { - return ( FALSE ) ; - } - - // Got the version size, now get the version information. - LPVOID lpData = (LPVOID)new TCHAR [ dwVerSize ] ; - if ( FALSE == GetFileVersionInfo ( szImageHlp , - dwVerInfoHandle , - dwVerSize , - lpData ) ) - { - delete [] lpData ; - return ( FALSE ) ; - } - - VS_FIXEDFILEINFO * lpVerInfo ; - UINT uiLen ; - BOOL bRet = VerQueryValue ( lpData , - ( "\\" ) , - (LPVOID*)&lpVerInfo , - &uiLen ) ; - if ( TRUE == bRet ) - { - dwMS = lpVerInfo->dwFileVersionMS ; - dwLS = lpVerInfo->dwFileVersionLS ; - } - - delete [] lpData ; - - return ( bRet ) ; - } - -/*---------------------------------------------------------------------- - Public Initialization and Cleanup -----------------------------------------------------------------------*/ -public : - - BOOL SymInitialize ( IN HANDLE hProcess , - IN LPSTR UserSearchPath , - IN BOOL fInvadeProcess ) - { - m_hProcess = hProcess ; - return ( ::SymInitialize ( hProcess , - UserSearchPath , - fInvadeProcess ) ) ; - } - -#ifdef USE_BUGSLAYERUTIL - BOOL BSUSymInitialize ( DWORD dwPID , - HANDLE hProcess , - PSTR UserSearchPath , - BOOL fInvadeProcess ) - { - m_hProcess = hProcess ; - return ( ::BSUSymInitialize ( dwPID , - hProcess , - UserSearchPath , - fInvadeProcess ) ) ; - } -#endif // USE_BUGSLAYERUTIL - BOOL SymCleanup ( void ) - { - return ( ::SymCleanup ( m_hProcess ) ) ; - } - -/*---------------------------------------------------------------------- - Public Module Manipulation -----------------------------------------------------------------------*/ -public : - - BOOL SymEnumerateModules ( IN PSYM_ENUMMODULES_CALLBACK - EnumModulesCallback, - IN PVOID UserContext ) - { - return ( ::SymEnumerateModules ( m_hProcess , - EnumModulesCallback , - UserContext ) ) ; - } - - BOOL SymLoadModule ( IN HANDLE hFile , - IN PSTR ImageName , - IN PSTR ModuleName , - IN DWORD_PTR BaseOfDll , - IN DWORD SizeOfDll ) - { - return ( ::SymLoadModule ( m_hProcess , - hFile , - ImageName , - ModuleName , - BaseOfDll , - SizeOfDll ) != NULL) ; - } - - BOOL EnumerateLoadedModules ( IN PENUMLOADED_MODULES_CALLBACK - EnumLoadedModulesCallback, - IN PVOID UserContext ) - { - return ( ::EnumerateLoadedModules ( m_hProcess , - EnumLoadedModulesCallback , - UserContext )); - } - - BOOL SymUnloadModule ( IN DWORD_PTR BaseOfDll ) - { - return ( ::SymUnloadModule ( m_hProcess , BaseOfDll ) ) ; - } - - BOOL SymGetModuleInfo ( IN DWORD_PTR dwAddr , - OUT PIMAGEHLP_MODULE ModuleInfo ) - { - return ( ::SymGetModuleInfo ( m_hProcess , - dwAddr , - ModuleInfo ) ) ; - } - - DWORD SymGetModuleBase ( IN DWORD_PTR dwAddr ) - { - return ( ::SymGetModuleBase ( m_hProcess , dwAddr ) != NULL ) ; - } - -/*---------------------------------------------------------------------- - Public Symbol Manipulation -----------------------------------------------------------------------*/ -public : - - BOOL SymEnumerateSymbols (IN DWORD_PTR BaseOfDll, - IN PSYM_ENUMSYMBOLS_CALLBACK - EnumSymbolsCallback, - IN PVOID UserContext ) - { - return ( ::SymEnumerateSymbols ( m_hProcess , - BaseOfDll , - EnumSymbolsCallback , - UserContext ) ) ; - } - - BOOL SymGetSymFromAddr ( IN DWORD_PTR dwAddr , - OUT PDWORD_PTR pdwDisplacement , - OUT PIMAGEHLP_SYMBOL Symbol ) - { - return ( ::SymGetSymFromAddr ( m_hProcess , - dwAddr , - pdwDisplacement , - Symbol ) ) ; - } - - BOOL SymGetSymFromName ( IN LPSTR Name , - OUT PIMAGEHLP_SYMBOL Symbol ) - { - return ( ::SymGetSymFromName ( m_hProcess , - Name , - Symbol ) ) ; - } - - BOOL SymGetSymNext ( IN OUT PIMAGEHLP_SYMBOL Symbol ) - { - return ( ::SymGetSymNext ( m_hProcess , Symbol ) ) ; - } - - BOOL SymGetSymPrev ( IN OUT PIMAGEHLP_SYMBOL Symbol ) - { - return ( ::SymGetSymPrev ( m_hProcess , Symbol ) ) ; - } - -/*---------------------------------------------------------------------- - Public Source Line Manipulation -----------------------------------------------------------------------*/ -public : - - BOOL SymGetLineFromAddr ( IN DWORD_PTR dwAddr , - OUT PDWORD pdwDisplacement , - OUT PIMAGEHLP_LINE Line ) - { - -#ifdef DO_NOT_WORK_AROUND_SRCLINE_BUG - // Just pass along the values returned by the main function. - return ( ::SymGetLineFromAddr ( m_hProcess , - dwAddr , - pdwDisplacement , - Line ) ) ; - -#else - // The problem is that the symbol engine finds only those source - // line addresses (after the first lookup) that fall exactly on - // a zero displacement. I’ll walk backward 100 bytes to - // find the line and return the proper displacement. - DWORD dwTempDis = 0 ; - while ( FALSE == ::SymGetLineFromAddr ( m_hProcess , - dwAddr - dwTempDis , - pdwDisplacement , - Line ) ) - { - dwTempDis += 1 ; - if ( 100 == dwTempDis ) - { - return ( FALSE ) ; - } - } - // I found it and the source line information is correct, so - // change the displacement if I had to search backward to find - // the source line. - if ( 0 != dwTempDis ) - { - *pdwDisplacement = dwTempDis ; - } - return ( TRUE ) ; -#endif // DO_NOT_WORK_AROUND_SRCLINE_BUG - } - - BOOL SymGetLineFromName ( IN LPSTR ModuleName , - IN LPSTR FileName , - IN DWORD dwLineNumber , - OUT PLONG plDisplacement , - IN OUT PIMAGEHLP_LINE Line ) - { - return ( ::SymGetLineFromName ( m_hProcess , - ModuleName , - FileName , - dwLineNumber , - plDisplacement , - Line ) ) ; - } - - BOOL SymGetLineNext ( IN OUT PIMAGEHLP_LINE Line ) - { - return ( ::SymGetLineNext ( m_hProcess , Line ) ) ; - } - - BOOL SymGetLinePrev ( IN OUT PIMAGEHLP_LINE Line ) - { - return ( ::SymGetLinePrev ( m_hProcess , Line ) ) ; - } - - BOOL SymMatchFileName ( IN LPSTR FileName , - IN LPSTR Match , - OUT LPSTR * FileNameStop , - OUT LPSTR * MatchStop ) - { - return ( ::SymMatchFileName ( FileName , - Match , - FileNameStop , - MatchStop ) ) ; - } - -/*---------------------------------------------------------------------- - Public Miscellaneous Members -----------------------------------------------------------------------*/ -public : - - LPVOID SymFunctionTableAccess ( DWORD_PTR AddrBase ) - { - return ( ::SymFunctionTableAccess ( m_hProcess , AddrBase ) ) ; - } - - BOOL SymGetSearchPath ( OUT LPSTR SearchPath , - IN DWORD SearchPathLength ) - { - return ( ::SymGetSearchPath ( m_hProcess , - SearchPath , - SearchPathLength ) ) ; - } - - BOOL SymSetSearchPath ( IN LPSTR SearchPath ) - { - return ( ::SymSetSearchPath ( m_hProcess , SearchPath ) ) ; - } - -/* BOOL SymRegisterCallback ( IN PSYMBOL_REGISTERED_CALLBACK - CallbackFunction, - IN DWORD_PTR UserContext ) - { - return ( ::SymRegisterCallback ( m_hProcess , - CallbackFunction , - UserContext ) ) ; - } -*/ - -/*---------------------------------------------------------------------- - Protected Data Members -----------------------------------------------------------------------*/ -protected : - // The unique value that will be used for this instance of the - // symbol engine. This value doesn’t have to be an actual - // process value, just a unique value. - HANDLE m_hProcess ; - -} ; - -#endif // _SYMBOLENGINE_H diff --git a/src/crashrpt/Utility.cpp b/src/crashrpt/Utility.cpp deleted file mode 100644 index 49b85635d..000000000 --- a/src/crashrpt/Utility.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Module: Utility.cpp -// -// Desc: See Utility.h -// -// Copyright (c) 2007 TortoiseSVN -// Copyright (c) 2003 Michael Carruth -// -/////////////////////////////////////////////////////////////////////////////// - -#include "stdafx.h" -#include "Utility.h" -#include "resource.h" - -namespace CUtility { - -BSTR CUtility::AllocSysString(string s) -{ -#if defined(_UNICODE) || defined(OLE2ANSI) - BSTR bstr = ::SysAllocStringLen(s.c_str(), s.size()); -#else - int nLen = MultiByteToWideChar(CP_ACP, 0, s.c_str(), - s.size(), NULL, NULL); - BSTR bstr = ::SysAllocStringLen(NULL, nLen); - if(bstr != NULL) - MultiByteToWideChar(CP_ACP, 0, s.c_str(), s.size(), bstr, nLen); -#endif - return bstr; -} - -FILETIME CUtility::getLastWriteFileTime(string sFile) -{ - FILETIME ftLocal = {0}; - HANDLE hFind; - WIN32_FIND_DATA ff32; - hFind = FindFirstFile(sFile.c_str(), &ff32); - if (INVALID_HANDLE_VALUE != hFind) - { - FileTimeToLocalFileTime(&(ff32.ftLastWriteTime), &ftLocal); - FindClose(hFind); - } - return ftLocal; -} - -FILETIME CUtility::getLastWriteFileTime(WCHAR * wszFile) -{ - FILETIME ftLocal = {0}; - HANDLE hFind; - WIN32_FIND_DATAW ff32; - hFind = FindFirstFileW(wszFile, &ff32); - if (INVALID_HANDLE_VALUE != hFind) - { - FileTimeToLocalFileTime(&(ff32.ftLastWriteTime), &ftLocal); - FindClose(hFind); - } - return ftLocal; -} - -string CUtility::getAppName() -{ - TCHAR szFileName[_MAX_PATH]; - GetModuleFileName(NULL, szFileName, _MAX_FNAME); - - string sAppName; // Extract from last '\' to '.' - - *_tcsrchr(szFileName, '.') = '\0'; - sAppName = (_tcsrchr(szFileName, '\\')+1); - - return sAppName; -} - - -string CUtility::getTempFileName() -{ - static int counter = 0; - TCHAR szTempDir[MAX_PATH - 14] = _T(""); - TCHAR szTempFile[MAX_PATH] = _T(""); - - if (GetTempPath(MAX_PATH - 14, szTempDir)) - GetTempFileName(szTempDir, getAppName().c_str(), ++counter, szTempFile); - - return szTempFile; -} - - -string CUtility::getSaveFileName() -{ - string sFilter = _T("Zip Files (*.zip)"); - - OPENFILENAME ofn = {0}; // common dialog box structure - TCHAR szFile[MAX_PATH] = {0}; // buffer for file name - // Initialize OPENFILENAME - ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hwndOwner = NULL; - ofn.lpstrFile = szFile; - ofn.nMaxFile = _countof(szFile); - ofn.Flags = OFN_OVERWRITEPROMPT; - - ofn.lpstrFilter = sFilter.c_str(); - ofn.nFilterIndex = 1; - // Display the Open dialog box. - bool bTargetSelected = !!GetSaveFileName(&ofn); - - DeleteFile(ofn.lpstrFile); // Just in-case it already exist - return ofn.lpstrFile; -} - -}; diff --git a/src/crashrpt/Utility.h b/src/crashrpt/Utility.h deleted file mode 100644 index e27f72150..000000000 --- a/src/crashrpt/Utility.h +++ /dev/null @@ -1,95 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Module: Utility.h -// -// Desc: Misc static helper methods -// -// Copyright (c) 2003 Michael Carruth -// -/////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "stdafx.h" - - -////////////////////////////// Class Definitions ///////////////////////////// - -// =========================================================================== -// CUtility -// -// See the module comment at top of file. -// -namespace CUtility -{ - - BSTR AllocSysString(string s); - - //----------------------------------------------------------------------------- - // getLastWriteFileTime - // Returns the time the file was last modified in a FILETIME structure. - // - // Parameters - // sFile Fully qualified file name - // - // Return Values - // FILETIME structure - // - // Remarks - // - FILETIME - getLastWriteFileTime( - string sFile - ); - FILETIME - getLastWriteFileTime( - WCHAR * wszFile - ); - //----------------------------------------------------------------------------- - // getAppName - // Returns the application module's file name - // - // Parameters - // none - // - // Return Values - // File name of the executable - // - // Remarks - // none - // - string - getAppName(); - - //----------------------------------------------------------------------------- - // getSaveFileName - // Presents the user with a save as dialog and returns the name selected. - // - // Parameters - // none - // - // Return Values - // Name of the file to save to, or "" if the user cancels. - // - // Remarks - // none - // - string - getSaveFileName(); - - //----------------------------------------------------------------------------- - // getTempFileName - // Returns a generated temporary file name - // - // Parameters - // none - // - // Return Values - // Temporary file name - // - // Remarks - // - string - getTempFileName(); -}; - diff --git a/src/crashrpt/WriteRegistry.cpp b/src/crashrpt/WriteRegistry.cpp deleted file mode 100644 index b719c11df..000000000 --- a/src/crashrpt/WriteRegistry.cpp +++ /dev/null @@ -1,247 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Module: WriteRegistry.cpp -// -// Desc: Functions to write a registry hive to a file. -// -// Copyright (c) 2003 Grant McDorman -// This file is licensed using a BSD-type license: -// 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. -// -/////////////////////////////////////////////////////////////////////////////// -#include - -#include // CreateFile, WriteFile, CloseHandle, DeleteFile, Reg* functions -#include // _snprintf - -#include "WriteRegistry.h" - -static bool WriteRegValue(HANDLE hFile, const char *key_path, const char *name, int name_len, DWORD type, const unsigned char *data, DWORD data_len); -static bool WriteValuesAndSubkeys(const char *key_path, HKEY parent_key, const char *subkey, HANDLE hFile); -static void WriteFileString(HANDLE hFile, const char *string); - -bool WriteRegistryTreeToFile(const char *key, const char *filename) -{ - const char *cp = strchr(key, '\\'); - if (cp == NULL) { - return false; - } - ptrdiff_t len = cp - key; - HKEY hKey = 0; - -#define IS_PATH(id, short_id) if (strncmp(key, #id, len) == 0 || strncmp(key, #short_id, len) == 0) hKey = id - IS_PATH(HKEY_CLASSES_ROOT, HKCR); - else IS_PATH(HKEY_CURRENT_USER, HKCU); - else IS_PATH(HKEY_LOCAL_MACHINE, HKLM); - else IS_PATH(HKEY_CURRENT_CONFIG, HKCC); - else IS_PATH(HKEY_USERS, HKU); - else IS_PATH(HKEY_PERFORMANCE_DATA, HKPD); - else IS_PATH(HKEY_DYN_DATA, HKDD); - else { - return false; - } - return WriteRegistryTreeToFile(hKey, cp + 1, filename); -} - -bool WriteRegistryTreeToFile(HKEY section, const char *subkey, const char *filename) -{ - bool status = false; - HANDLE hFile = ::CreateFile( - filename, - GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - 0); - if (INVALID_HANDLE_VALUE != hFile) { - char * key_path = "UNKNOWN"; -#define SET_PATH(id) if (id == section) key_path = #id - SET_PATH(HKEY_CLASSES_ROOT); - else SET_PATH(HKEY_CURRENT_USER); - else SET_PATH(HKEY_LOCAL_MACHINE); - else SET_PATH(HKEY_CURRENT_CONFIG); - else SET_PATH(HKEY_USERS); - else SET_PATH(HKEY_PERFORMANCE_DATA); - else SET_PATH(HKEY_DYN_DATA); - WriteFileString(hFile, "REGEDIT4\r\n"); -#undef SET_PATH - try { - status = WriteValuesAndSubkeys(key_path, section, subkey, hFile); - } catch (...) { - status = false; - } - CloseHandle(hFile); - if (!status) { - DeleteFile(filename); - } - } - return status; -} - -static bool WriteValuesAndSubkeys(const char *key_path, HKEY parent_key, const char *subkey, HANDLE hFile) -{ - HKEY key; - - if (RegOpenKeyEx(parent_key, subkey, 0, KEY_READ, &key) != ERROR_SUCCESS) { - OutputDebugString("RegOpenKeyEx failed, key:\n"); - OutputDebugString(subkey); - return false; - } - DWORD num_subkeys; - DWORD max_subkey_len; - DWORD num_values; - DWORD max_name_len; - DWORD max_value_len; - DWORD max_id_len; - - if (RegQueryInfoKey(key, - NULL, // class - NULL, // num_class - NULL, // reserved - &num_subkeys, &max_subkey_len, - NULL, // MaxClassLen - &num_values, &max_name_len, &max_value_len, NULL, NULL) != ERROR_SUCCESS) { - OutputDebugString("RegQueryInfoKey failed, key:\n"); - OutputDebugString(subkey); - return false; - } - - max_id_len = (max_name_len > max_subkey_len) ? max_name_len : max_subkey_len; - char *this_path = reinterpret_cast(alloca(strlen(key_path) + strlen(subkey) + 2)); - // strcpy/strcat safe because of above alloca - strcpy(this_path, key_path); - strcat(this_path, "\\"); - strcat(this_path, subkey); - - WriteFileString(hFile, "\r\n["); - WriteFileString(hFile, this_path); - WriteFileString(hFile, "]\r\n"); - - // enumerate values - char *name = reinterpret_cast(alloca(max_id_len*2 + 2)); - unsigned char *data = reinterpret_cast(alloca(max_value_len*2 + 2)); - DWORD index; - bool status = true; - - for (index = 0; index < num_values && status; index++) { - DWORD name_len = max_id_len + 1; - DWORD value_len = max_value_len + 1; - DWORD type; - if (RegEnumValue(key, index, name, &name_len, NULL, &type, data, &value_len) == ERROR_SUCCESS) { - status = WriteRegValue(hFile, this_path, name, name_len, type, data, value_len); - } - } - - // enumerate subkeys - for (index = 0; index < num_subkeys && status; index++) { - DWORD name_len = max_id_len + 1; - if (RegEnumKeyEx(key, index, name, &name_len, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) { - status = WriteValuesAndSubkeys(this_path, key, name, hFile); - } - } - - RegCloseKey(key); - - return status; -} - -static bool WriteRegValue(HANDLE hFile, const char * /*key_path*/, const char *name, int /* name_len */, DWORD type, const unsigned char *data, DWORD data_len) -{ - WriteFileString(hFile, "\""); - WriteFileString(hFile, name); - - char string_type[64]; - - switch(type) { - case REG_DWORD: // A 32-bit number. - strncpy(string_type, "\"=dword:", sizeof string_type); - break; - - case REG_SZ: // A null terminated string. - strncpy(string_type, "\"=\"", sizeof string_type); - break; - - case REG_BINARY: // Binary data in any form. - strncpy(string_type, "\"=hex:", sizeof string_type); - break; - - case REG_EXPAND_SZ: // A null-terminated string that contains unexpanded references to environment variables (for example, "%PATH%"). It will be a Unicode or ANSI string depending on whether you use the Unicode or ANSI functions. To expand the environment variable references, use the ExpandEnvironmentStrings function. - case REG_LINK: // A Unicode symbolic link. Used internally; applications should not use this type. - case REG_MULTI_SZ: // An array of null-terminated strings, terminated by two null characters. - case REG_NONE: // No defined value type. - case REG_DWORD_BIG_ENDIAN: // A 64-bit number in big-endian format. - case REG_RESOURCE_LIST: // A device-driver resource list. - default: - _snprintf(string_type, sizeof string_type, "\"=hex(%x):", type); - break; - } - - WriteFileString(hFile, string_type); - - if (type == REG_SZ || type == REG_EXPAND_SZ) { - // escape special characters; length includes trailing NUL - int i; - // don't crash'n'burn if data_len is 0 - for (i = 0; i < static_cast(data_len) - 1; i++) { - if (data[i] == '\\' || data[i] == '"') { - WriteFileString(hFile, "\\"); - } - if (isprint(data[i])) { - DWORD written; - if (!WriteFile(hFile, &data[i], 1, &written, NULL) || written != 1) { - return false; - } - } else { - _snprintf(string_type, sizeof string_type, "\\%02x", data[i]); - WriteFileString(hFile, string_type); - } - } - WriteFileString(hFile, "\""); - } else if (type == REG_DWORD) { - // write as hex, MSB first - int i; - for (i = static_cast(data_len) - 1; i >= 0; i--) { - _snprintf(string_type, sizeof string_type, "%02x", data[i]); - WriteFileString(hFile, string_type); - } - } else { - // write as comma-separated hex values - DWORD i; - for (i = 0; i < data_len; i++) { - _snprintf(string_type, sizeof string_type, "%s%02x", i > 0 ? "," : "", data[i]); - WriteFileString(hFile, string_type); - if (i > 0 && i % 16 == 0) { - WriteFileString(hFile, "\r\n"); - } - } - } - WriteFileString(hFile, "\r\n"); - - return true; -} - - - -static void WriteFileString(HANDLE hFile, const char *string) -{ - DWORD written; - if (!WriteFile(hFile, string, strlen(string), &written, NULL) || written != strlen(string)) { - OutputDebugString("WriteFile failed\n"); - throw false; - } -} diff --git a/src/crashrpt/WriteRegistry.h b/src/crashrpt/WriteRegistry.h deleted file mode 100644 index 7ed3203ad..000000000 --- a/src/crashrpt/WriteRegistry.h +++ /dev/null @@ -1,86 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Module: WriteRegistry.h -// -// Desc: Defines the interface for the WriteRegistry functions. -// -// Copyright (c) 2003 Grant McDorman -// This file is licensed using a BSD-type license: -// 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. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WRITEREGISTRY_H_ -#define _WRITEREGISTRY_H_ - -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - - -//----------------------------------------------------------------------------- -// WriteRegistryTreeToFile -// Writes a registry tree to a file. Registry tree is fully specified by -// the string. -// -// Parameters -// key registry key name; must start with on of: -// HKEY_CLASSES_ROOT or HKCR -// HKEY_CURRENT_USER or HKCU -// HKEY_LOCAL_MACHINE or HKLM -// HKEY_CURRENT_CONFIG or HKCC -// HKEY_USERS or HKU -// HKEY_PERFORMANCE_DATA or HKPD -// HKEY_DYN_DATA or HKDD -// filename file to write to -// -// Return Values -// Returns true if successful. -// -// Remarks -// Translates call into WriteRegistryTreeToFile(section, subkey, filename). -// -bool WriteRegistryTreeToFile(const char *key, const char *filename); - - -//----------------------------------------------------------------------------- -// WriteRegistryTreeToFile -// Writes a registry tree to a file. Registry tree is relative to given key, -// which must be one of the root keys. -// -// Parameters -// section registry section; must be one of -// HKEY_CLASSES_ROOT -// HKEY_CURRENT_USER -// HKEY_LOCAL_MACHINE -// HKEY_CURRENT_CONFIG -// HKEY_USERS -// HKEY_PERFORMANCE_DATA -// HKEY_DYN_DATA -// subkey subkey relative to section -// filename file to write to -// -// Return Values -// Returns true if successful. -// -// Remarks -// none -// -bool WriteRegistryTreeToFile(HKEY section, const char *subkey, const char *filename); - - -#endif diff --git a/src/crashrpt/chglog.txt b/src/crashrpt/chglog.txt deleted file mode 100644 index 418749ba6..000000000 --- a/src/crashrpt/chglog.txt +++ /dev/null @@ -1,92 +0,0 @@ -01/28/2007 Stefan Kueng - Major Changes: - * Remove dependency on WTL/ATL, use only Win32 API and the std lib. - -05/23/2003 Stefan Kueng - Major Changes: - * the zlib part now is linked statically, so no additional zlib.dll - needs to be shipped. - * added german language - Minor Changes: - * - Bugs Fixed: - * the symbol information wasn't shown sometimes (Stacktrace). - -04/08/2003 Grant McDorman - Version ID: 3.0.2.3 - Major Changes: - * A new header file, CrashRptDL.h, is available. It declares all the - functions with a 'DL' suffix, plus GetInstanceDL() and ReleaseInstanceDL(). - All of these versions are inline functions for run-time binding to - CrashRpt; by using these, your application can run without CrashRpt - available. See the header file for more details. - * A 'Debug' button is available. It is normally invisible, but will - become visible by setting - HKEY_CURRENT_USER\Software\Carruth\CrashRpt\EnableDebug - to a DWORD value of 1. Pressing this button will discard the - crash report and drop into the debugger. (On an explicit - GenerateErrorReport call, DebugBreak() is called). - * When running under a debugger, the handler will always drop into - the debugger after handling a crash (even if the crash is saved, mailed, - or the Exit button pressed). Note that this is NOT the case - for explicit calls to GenerateErrorReport. - * The dialog now includes a 'Save' button to allow the user to - explicitly save the crash report - * The 'Send' button is hidden if the handler is installed without - an e-mail address - * APIs introduced with previous release renamed with Ex suffix - * New API: GetInstance, returns CrashRpt instance for current - process - * APIs from January 12th release reintroduced; minor changes to - Install() call, however - * Initialize can be called multiple times; it will return - the same instance each time - * An API to get the instance for the current process was added - * APIs callable from Visual Basic added (suffix VB) - * API to add event logs to saved report (where the system supports event logs) - * API to add registry hives, in REGEDIT4 save format, to saved report - * API allowing removal of files added to report - * User-supplied e-mail and comments saved (as separate file) in - crash report if Initialize called without e-mail address - * Crash report XML includes stack walkback and, if possible, - file, function, and line number information for all addresses - * Dialog is in a separate thread, so crashing application freezes - * Application can include a message when calling GenerateErrorReport - * New API to generate stack trace (independant of crashes and crash - handling) - * User e-mail field now initialized with name of signed-on user - (no domain, unfortunately) - Minor Changes: - * Working files deleted after report mailed, saved, or cancelled - * XSL style sheet provided that will transform crash report XML to - HTML - * Minor internal design changes - * Package now includes Zlib 1.1.4 and dbghelp.dll 6.1.17.2. - Bugs Fixed: - * MAPI mailing fixed to work on Win2K with Outlook 98 and Exchange 2000 - * User cancelling MAPI e-mail will no longer cause CMC e-mailing to be - attempted - * Did not properly check for file existence when adding to report - * Did not display files properly in file list when a relative path - was used - * Did not uninstall if InstallExceptionHandler returned NULL - * Contents of file list grew each time GenerateErrorReport was called - * Under some circumstances, file types (and icons) were not properly - * displayed in the detail dialog -03/13/2003 - Major Changes: - * Replaced MFC with WTL - * Changed install() API - * Major refactoring - Minor Chages: - * Details dialog preview window now uses system - defined window color instead of white. - * Directory structure not saved in zip. - Bugs Fixed: - * Support for use by multiple apps - * Buffer overrun error when previewing files > 32k - * Main dialog now displays app icon - -01/12/2003 - New: - * Initial release diff --git a/src/crashrpt/excprpt.cpp b/src/crashrpt/excprpt.cpp deleted file mode 100644 index 5f17c1d9d..000000000 --- a/src/crashrpt/excprpt.cpp +++ /dev/null @@ -1,1037 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Module: excprpt.cpp -// -// Desc: See excprpt.h -// -// Copyright (c) 2003 Michael Carruth -// -/////////////////////////////////////////////////////////////////////////////// - - -#include "stdafx.h" -#include "excprpt.h" -#include "utility.h" - -#include "StackTrace.h" - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -//----------------------------------------------------------------------------- -// CExceptionReport::CExceptionReport -// -// -// -CExceptionReport::CExceptionReport(PEXCEPTION_POINTERS ExceptionInfo, BSTR message) -{ - m_excpInfo = ExceptionInfo; - m_message = message; - TCHAR szModName[_MAX_FNAME + 1]; - GetModuleFileName(NULL, szModName, _MAX_FNAME); - m_sModule = szModName; - m_sCommandLine = GetCommandLine(); - m_frameNumber = 0; -} - - -//----------------------------------------------------------------------------- -// CExceptionReport::getCrashFile -// -// Creates the dump file returning the file name -// -string CExceptionReport::getCrashFile() -{ - TCHAR buf[MAX_PATH] = {0}; - _stprintf_s(buf, MAX_PATH, _T("%s\\%s.dmp"), _tgetenv("TEMP"), CUtility::getAppName().c_str()); - - // Create the file - HANDLE hFile = CreateFile( - buf, - GENERIC_WRITE, - 0, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL); - - // - // Write the minidump to the file - // - if (hFile) - { - writeDumpFile(hFile, m_excpInfo, reinterpret_cast(this)); - } - - // Close file - CloseHandle(hFile); - - return string(buf); -} - - -void CExceptionReport::writeDumpFile(HANDLE hFile, PEXCEPTION_POINTERS excpInfo, void *data) -{ - if (excpInfo == NULL) { - // Generate exception to get proper context in dump - __try { - RaiseException(EXCEPTION_BREAKPOINT, 0, 0, NULL); - } __except(writeDumpFile(hFile, GetExceptionInformation(), data), EXCEPTION_CONTINUE_EXECUTION) { - } - } else { - MINIDUMP_EXCEPTION_INFORMATION eInfo; - eInfo.ThreadId = GetCurrentThreadId(); - eInfo.ExceptionPointers = excpInfo; - eInfo.ClientPointers = FALSE; - - MINIDUMP_CALLBACK_INFORMATION cbMiniDump; - cbMiniDump.CallbackRoutine = CExceptionReport::miniDumpCallback; - cbMiniDump.CallbackParam = data; - - MiniDumpWriteDump( - GetCurrentProcess(), - GetCurrentProcessId(), - hFile, - MiniDumpWithIndirectlyReferencedMemory, - excpInfo ? &eInfo : NULL, - NULL, - &cbMiniDump); - } -} - -//----------------------------------------------------------------------------- -// CExceptionReport::getCrashLog -// -// Creates the XML log file returning the name -// -string CExceptionReport::getCrashLog() -{ - string sFile; - MSXML2::IXMLDOMDocument *pDoc = NULL; - MSXML2::IXMLDOMNode *root = NULL; - MSXML2::IXMLDOMNode *node = NULL; - MSXML2::IXMLDOMNode *newNode = NULL; - BSTR rootName = ::SysAllocString(L"Exception"); - VARIANT v; - - CoInitialize(NULL); - - // Create an empty XML document - CHECKHR(CoCreateInstance( - MSXML2::CLSID_DOMDocument, - NULL, - CLSCTX_INPROC_SERVER, - MSXML2::IID_IXMLDOMDocument, - (void**)&pDoc)); - - // Create root node - root = CreateDOMNode(pDoc, MSXML2::NODE_ELEMENT, rootName); - - // - // Add exception record node - // - if (m_excpInfo) - { - node = CreateExceptionRecordNode(pDoc, m_excpInfo->ExceptionRecord); - CHECKHR(root->appendChild(node, &newNode)); - // The XML Document should now own the node. - SAFERELEASE(node); - SAFERELEASE(newNode); - } - - // - // Add optional message node - // - if (m_message != NULL) { - node = CreateMsgNode(pDoc, m_message); - CHECKHR(root->appendChild(node, &newNode)); - // The XML Document should now own the node. - SAFERELEASE(node); - SAFERELEASE(newNode); - } - - // - // Add processor node - // - node = CreateProcessorNode(pDoc); - CHECKHR(root->appendChild(node, &newNode)); - // The XML Document should now own the node. - SAFERELEASE(node); - SAFERELEASE(newNode); - - // - // Add OS node - // - node = CreateOSNode(pDoc); - CHECKHR(root->appendChild(node, &newNode)); - // The XML Document should now own the node. - SAFERELEASE(node); - SAFERELEASE(newNode); - - // - // Add modules node - // - node = CreateModulesNode(pDoc); - CHECKHR(root->appendChild(node, &newNode)); - // The XML Document should now own the node. - SAFERELEASE(node); - SAFERELEASE(newNode); - - // - // Add stack walkback node - // - node = CreateWalkbackNode(pDoc, m_excpInfo != NULL ? m_excpInfo->ContextRecord : NULL); - CHECKHR(root->appendChild(node, &newNode)); - // The XML Document should now own the node. - SAFERELEASE(node); - SAFERELEASE(newNode); - - - // Add the root to the doc - CHECKHR(pDoc->appendChild(root, NULL)); - - // - // Create dat file name and save - // - TCHAR buf[MAX_PATH] = {0}; - _tprintf_s(buf, _T("%s\\%s.xml"), getenv("TEMP"), CUtility::getAppName()); - V_VT(&v) = VT_BSTR; - V_BSTR(&v) = CUtility::AllocSysString(buf); - pDoc->save(v); - SysFreeString(V_BSTR(&v)); - -CleanUp: - SAFERELEASE(pDoc); - SAFERELEASE(root); - SAFERELEASE(node); - SAFERELEASE(newNode); - SysFreeString(rootName); - - CoUninitialize(); - - return sFile; -} - - -//----------------------------------------------------------------------------- -// CExceptionReport::getNumSymbolFiles -// -// Returns the number of symbols files found -// -int CExceptionReport::getNumSymbolFiles() -{ - return m_symFiles.size(); -} - - -//----------------------------------------------------------------------------- -// CExceptionReport::getSymbolFile -// -// Returns the symbol file name given an index -// -string CExceptionReport::getSymbolFile(int index) -{ - string ret; - - if (0 < index && index < (int)m_symFiles.size()) - ret = m_symFiles[index]; - - return ret; -} - -//----------------------------------------------------------------------------- -// CExceptionReport::CreateDOMNode -// -// Helper function -// -MSXML2::IXMLDOMNode* -CExceptionReport::CreateDOMNode(MSXML2::IXMLDOMDocument* pDoc, - int type, - BSTR bstrName) -{ - MSXML2::IXMLDOMNode * node; - VARIANT vtype; - - vtype.vt = VT_I4; - V_I4(&vtype) = (int)type; - - pDoc->createNode(vtype, bstrName, NULL, &node); - return node; -} - -//----------------------------------------------------------------------------- -// CreateExceptionSymbolAttributes -// -// Create attributes in the exception record with the symbolic info, if available -// -void CExceptionReport::CreateExceptionSymbolAttributes(DWORD_PTR /*address*/, const char * /*ImageName*/, - const char *FunctionName, DWORD_PTR functionDisp, - const char *Filename, DWORD LineNumber, DWORD lineDisp, - void *data) -{ - string sAddr; - BSTR funcName = ::SysAllocString(L"FunctionName"); - BSTR funcDispName = ::SysAllocString(L"FunctionDisplacement"); - BSTR fileName = ::SysAllocString(L"Filename"); - BSTR lineName = ::SysAllocString(L"LineNumber"); - BSTR lineDispName = ::SysAllocString(L"LineDisplacement"); - CExceptionReport *self = reinterpret_cast(data); - - VARIANT v; - - // don't need ImageName [module], as that is already done - if (FunctionName != NULL) { - V_VT(&v) = VT_BSTR; - V_BSTR(&v) = CUtility::AllocSysString(FunctionName); - self->m_exception_element->setAttribute(funcName, v); - // Recycle variant - SysFreeString(V_BSTR(&v)); - TCHAR buf[MAX_PATH] = {0}; - _tprintf_s(buf, offsetFormat, functionDisp); - V_VT(&v) = VT_BSTR; - V_BSTR(&v) = CUtility::AllocSysString(buf); - self->m_exception_element->setAttribute(funcDispName, v); - // Recycle variant - SysFreeString(V_BSTR(&v)); - } - - if (Filename != NULL) { - V_VT(&v) = VT_BSTR; - V_BSTR(&v) = CUtility::AllocSysString(Filename); - self->m_exception_element->setAttribute(fileName, v); - // Recycle variant - SysFreeString(V_BSTR(&v)); - - TCHAR buf[MAX_PATH] = {0}; - _tprintf_s(buf, _T("%d"), LineNumber); - V_VT(&v) = VT_BSTR; - V_BSTR(&v) = CUtility::AllocSysString(buf); - self->m_exception_element->setAttribute(lineName, v); - // Recycle variant - SysFreeString(V_BSTR(&v)); - - _tprintf_s(buf, offsetFormat, lineDisp); - V_VT(&v) = VT_BSTR; - V_BSTR(&v) = CUtility::AllocSysString(buf); - self->m_exception_element->setAttribute(lineDispName, v); - // Recycle variant - SysFreeString(V_BSTR(&v)); - } - ::SysFreeString(funcName); - ::SysFreeString(funcDispName); - ::SysFreeString(fileName); - ::SysFreeString(lineName); - ::SysFreeString(lineDispName); -} - -//----------------------------------------------------------------------------- -// CExceptionReport::CreateExceptionRecordNode -// -// -// -MSXML2::IXMLDOMNode* -CExceptionReport::CreateExceptionRecordNode(MSXML2::IXMLDOMDocument* pDoc, - EXCEPTION_RECORD* pExceptionRecord) -{ - MSXML2::IXMLDOMNode* pNode = NULL; - MSXML2::IXMLDOMElement* pElement = NULL; - BSTR nodeName = ::SysAllocString(L"ExceptionRecord"); - BSTR modName = ::SysAllocString(L"ModuleName"); - BSTR codeName = ::SysAllocString(L"ExceptionCode"); - BSTR descName = ::SysAllocString(L"ExceptionDescription"); - BSTR addrName = ::SysAllocString(L"ExceptionAddress"); - BSTR commandlineName = ::SysAllocString(L"CommandLine"); - - VARIANT v; - string sAddr; - - // Create exception record node - pNode = CreateDOMNode(pDoc, MSXML2::NODE_ELEMENT, nodeName); - - // Get element interface - CHECKHR(pNode->QueryInterface(MSXML2::IID_IXMLDOMElement, (void**)&pElement)); - - // - // Set module name attribute - // - V_VT(&v) = VT_BSTR; - V_BSTR(&v) = CUtility::AllocSysString(m_sModule); - pElement->setAttribute(modName, v); - // Recycle variant - SysFreeString(V_BSTR(&v)); - - // - // Set command line name attribute - // - V_VT(&v) = VT_BSTR; - V_BSTR(&v) = CUtility::AllocSysString(m_sCommandLine); - pElement->setAttribute(commandlineName, v); - // Recycle variant - SysFreeString(V_BSTR(&v)); - - // - // Set exception code - // - TCHAR buf[MAX_PATH] = {0}; - _tprintf_s(buf, _T("%#x"), pExceptionRecord->ExceptionCode); - m_sException = buf; - V_VT(&v) = VT_BSTR; - V_BSTR(&v) = CUtility::AllocSysString(buf); - pElement->setAttribute(codeName, v); - // Recycle variant - SysFreeString(V_BSTR(&v)); - - // - // Set exception description - // - V_VT(&v) = VT_BSTR; - switch (pExceptionRecord->ExceptionCode) - { - case EXCEPTION_ACCESS_VIOLATION: - V_BSTR(&v) = ::SysAllocString(L"EXCEPTION_ACCESS_VIOLATION"); - break; - case EXCEPTION_DATATYPE_MISALIGNMENT: - V_BSTR(&v) = ::SysAllocString(L"EXCEPTION_DATATYPE_MISALIGNMENT"); - break; - case EXCEPTION_BREAKPOINT: - V_BSTR(&v) = ::SysAllocString(L"EXCEPTION_BREAKPOINT"); - break; - case EXCEPTION_SINGLE_STEP: - V_BSTR(&v) = ::SysAllocString(L"EXCEPTION_SINGLE_STEP"); - break; - case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: - V_BSTR(&v) = ::SysAllocString(L"EXCEPTION_ARRAY_BOUNDS_EXCEEDED"); - break; - case EXCEPTION_FLT_DENORMAL_OPERAND: - V_BSTR(&v) = ::SysAllocString(L"EXCEPTION_FLT_DENORMAL_OPERAND"); - break; - case EXCEPTION_FLT_DIVIDE_BY_ZERO: - V_BSTR(&v) = ::SysAllocString(L"EXCEPTION_FLT_DIVIDE_BY_ZERO"); - break; - case EXCEPTION_FLT_INEXACT_RESULT: - V_BSTR(&v) = ::SysAllocString(L"EXCEPTION_FLT_INEXACT_RESULT"); - break; - case EXCEPTION_FLT_INVALID_OPERATION: - V_BSTR(&v) = ::SysAllocString(L"EXCEPTION_FLT_INVALID_OPERATION"); - break; - case EXCEPTION_FLT_OVERFLOW: - V_BSTR(&v) = ::SysAllocString(L"EXCEPTION_FLT_OVERFLOW"); - break; - case EXCEPTION_FLT_STACK_CHECK: - V_BSTR(&v) = ::SysAllocString(L"EXCEPTION_FLT_STACK_CHECK"); - break; - case EXCEPTION_FLT_UNDERFLOW: - V_BSTR(&v) = ::SysAllocString(L"EXCEPTION_FLT_UNDERFLOW"); - break; - case EXCEPTION_INT_DIVIDE_BY_ZERO: - V_BSTR(&v) = ::SysAllocString(L"EXCEPTION_INT_DIVIDE_BY_ZERO"); - break; - case EXCEPTION_INT_OVERFLOW: - V_BSTR(&v) = ::SysAllocString(L"EXCEPTION_INT_OVERFLOW"); - break; - case EXCEPTION_PRIV_INSTRUCTION: - V_BSTR(&v) = ::SysAllocString(L"EXCEPTION_PRIV_INSTRUCTION"); - break; - case EXCEPTION_IN_PAGE_ERROR: - V_BSTR(&v) = ::SysAllocString(L"EXCEPTION_IN_PAGE_ERROR"); - break; - case EXCEPTION_ILLEGAL_INSTRUCTION: - V_BSTR(&v) = ::SysAllocString(L"EXCEPTION_ILLEGAL_INSTRUCTION"); - break; - case EXCEPTION_NONCONTINUABLE_EXCEPTION: - V_BSTR(&v) = ::SysAllocString(L"EXCEPTION_NONCONTINUABLE_EXCEPTION"); - break; - case EXCEPTION_STACK_OVERFLOW: - V_BSTR(&v) = ::SysAllocString(L"EXCEPTION_STACK_OVERFLOW"); - break; - case EXCEPTION_INVALID_DISPOSITION: - V_BSTR(&v) = ::SysAllocString(L"EXCEPTION_INVALID_DISPOSITION"); - break; - case EXCEPTION_GUARD_PAGE: - V_BSTR(&v) = ::SysAllocString(L"EXCEPTION_GUARD_PAGE"); - break; - case EXCEPTION_INVALID_HANDLE: - V_BSTR(&v) = ::SysAllocString(L"EXCEPTION_INVALID_HANDLE"); - break; - default: - V_BSTR(&v) = L"EXCEPTION_UNKNOWN"; - break; - } - pElement->setAttribute(descName, v); - // Recycle variant - SysFreeString(V_BSTR(&v)); - - // - // Set exception address - // - _tprintf_s(buf, _T("%#x"), pExceptionRecord->ExceptionAddress); - m_sAddress = sAddr; - V_VT(&v) = VT_BSTR; - V_BSTR(&v) = CUtility::AllocSysString(buf); - pElement->setAttribute(addrName, v); - // Recycle variant - SysFreeString(V_BSTR(&v)); - - // Try to include symbolic information - m_exception_element = pElement; - AddressToSymbol(reinterpret_cast(pExceptionRecord->ExceptionAddress)-1, - CreateExceptionSymbolAttributes, - reinterpret_cast(this)); -CleanUp: - ::SysFreeString(nodeName); - ::SysFreeString(modName); - ::SysFreeString(codeName); - ::SysFreeString(addrName); - SAFERELEASE(pElement); - - return pNode; -} - -//----------------------------------------------------------------------------- -// CExceptionReport::CreateProcessorNode -// -// -// -MSXML2::IXMLDOMNode* -CExceptionReport::CreateProcessorNode(MSXML2::IXMLDOMDocument* pDoc) -{ - MSXML2::IXMLDOMNode* pNode = NULL; - MSXML2::IXMLDOMElement* pElement = NULL; - BSTR nodeName = ::SysAllocString(L"Processor"); - BSTR archName = ::SysAllocString(L"Architecture"); - BSTR levelName = ::SysAllocString(L"Level"); - BSTR numberName = ::SysAllocString(L"NumberOfProcessors"); - SYSTEM_INFO si; - VARIANT v; - - // Create exception record node - pNode = CreateDOMNode(pDoc, MSXML2::NODE_ELEMENT, nodeName); - - // Get element interface - CHECKHR(pNode->QueryInterface(MSXML2::IID_IXMLDOMElement, (void**)&pElement)); - - // - // Get processor info - // - GetSystemInfo(&si); - - // - // Set architecture - // - V_VT(&v) = VT_BSTR; - switch (si.wProcessorArchitecture) - { - case PROCESSOR_ARCHITECTURE_INTEL: - V_BSTR(&v) = ::SysAllocString(L"PROCESSOR_ARCHITECTURE_INTEL"); - break; - case PROCESSOR_ARCHITECTURE_MIPS: - V_BSTR(&v) = ::SysAllocString(L"PROCESSOR_ARCHITECTURE_MIPS"); - break; - case PROCESSOR_ARCHITECTURE_ALPHA: - V_BSTR(&v) = ::SysAllocString(L"PROCESSOR_ARCHITECTURE_ALPHA"); - break; - case PROCESSOR_ARCHITECTURE_PPC: - V_BSTR(&v) = ::SysAllocString(L"PROCESSOR_ARCHITECTURE_PPC"); - break; - case PROCESSOR_ARCHITECTURE_SHX: - V_BSTR(&v) = ::SysAllocString(L"PROCESSOR_ARCHITECTURE_SHX"); - break; - case PROCESSOR_ARCHITECTURE_ARM: - V_BSTR(&v) = ::SysAllocString(L"PROCESSOR_ARCHITECTURE_ARM"); - break; - case PROCESSOR_ARCHITECTURE_IA64: - V_BSTR(&v) = ::SysAllocString(L"PROCESSOR_ARCHITECTURE_IA64"); - break; - case PROCESSOR_ARCHITECTURE_ALPHA64: - V_BSTR(&v) = ::SysAllocString(L"PROCESSOR_ARCHITECTURE_ALPHA64"); - break; - case PROCESSOR_ARCHITECTURE_AMD64: - V_BSTR(&v) = ::SysAllocString(L"PROCESSOR_ARCHITECTURE_AMD64"); - break; - case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64: - V_BSTR(&v) = ::SysAllocString(L"PROCESSOR_ARCHITECTURE_IA32_ON_WIN64"); - break; - case PROCESSOR_ARCHITECTURE_UNKNOWN: - V_BSTR(&v) = ::SysAllocString(L"PROCESSOR_ARCHITECTURE_UNKNOWN"); - break; - default: - V_BSTR(&v) = ::SysAllocString(L"Unknown"); - } - pElement->setAttribute(archName, v); - // Recycle variant - SysFreeString(V_BSTR(&v)); - - // - // Set level - // - V_VT(&v) = VT_BSTR; - if (PROCESSOR_ARCHITECTURE_INTEL == si.wProcessorArchitecture) - { - switch (si.wProcessorLevel) - { - case 3: - V_BSTR(&v) = ::SysAllocString(L"Intel 30386"); - break; - case 4: - V_BSTR(&v) = ::SysAllocString(L"Intel 80486"); - break; - case 5: - V_BSTR(&v) = ::SysAllocString(L"Intel Pentium"); - break; - case 6: - V_BSTR(&v) = ::SysAllocString(L"Intel Pentium Pro or Pentium II"); - break; - default: - V_BSTR(&v) = ::SysAllocString(L"Unknown"); - } - } - pElement->setAttribute(levelName, v); - // Recycle variant - SysFreeString(V_BSTR(&v)); - - // - // Set num of processors - // - V_VT(&v) = VT_I4; - V_I4(&v) = si.dwNumberOfProcessors; - pElement->setAttribute(numberName, v); - -CleanUp: - ::SysFreeString(nodeName); - ::SysFreeString(archName); - ::SysFreeString(levelName); - ::SysFreeString(numberName); - SAFERELEASE(pElement); - - return pNode; -} - -//----------------------------------------------------------------------------- -// CExceptionReport::CreateOSNode -// -// -// -MSXML2::IXMLDOMNode* -CExceptionReport::CreateOSNode(MSXML2::IXMLDOMDocument* pDoc) -{ - MSXML2::IXMLDOMNode* pNode = NULL; - MSXML2::IXMLDOMElement* pElement = NULL; - BSTR nodeName = ::SysAllocString(L"OperatingSystem"); - BSTR majorName = ::SysAllocString(L"MajorVersion"); - BSTR minorName = ::SysAllocString(L"MinorVersion"); - BSTR buildName = ::SysAllocString(L"BuildNumber"); - BSTR csdName = ::SysAllocString(L"CSDVersion"); - OSVERSIONINFO oi; - VARIANT v; - - // Create exception record node - pNode = CreateDOMNode(pDoc, MSXML2::NODE_ELEMENT, nodeName); - - // Get element interface - CHECKHR(pNode->QueryInterface(MSXML2::IID_IXMLDOMElement, (void**)&pElement)); - - // - // Get OS info - // - oi.dwOSVersionInfoSize = sizeof(oi); - GetVersionEx(&oi); - - // - // Set major version - // - V_VT(&v) = VT_I4; - V_I4(&v) = oi.dwMajorVersion; - pElement->setAttribute(majorName, v); - - // - // Set minor version - // - V_VT(&v) = VT_I4; - V_I4(&v) = oi.dwMinorVersion; - pElement->setAttribute(minorName, v); - - // - // Set build version - // - V_VT(&v) = VT_I4; - V_I4(&v) = oi.dwBuildNumber; - pElement->setAttribute(buildName, v); - - // - // Set CSD version - // - V_VT(&v) = VT_BSTR; - V_BSTR(&v) = CUtility::AllocSysString(oi.szCSDVersion); - pElement->setAttribute(csdName, v); - ::SysFreeString(V_BSTR(&v)); - -CleanUp: - ::SysFreeString(nodeName); - ::SysFreeString(majorName); - ::SysFreeString(minorName); - ::SysFreeString(buildName); - ::SysFreeString(csdName); - SAFERELEASE(pElement); - - return pNode; -} - -//----------------------------------------------------------------------------- -// CExceptionReport::CreateModulesNode -// -// -// -MSXML2::IXMLDOMNode* -CExceptionReport::CreateModulesNode(MSXML2::IXMLDOMDocument* pDoc) -{ - MSXML2::IXMLDOMNode* pNode = NULL; - MSXML2::IXMLDOMNode* pNode2 = NULL; - MSXML2::IXMLDOMNode* pNewNode = NULL; - MSXML2::IXMLDOMElement* pElement = NULL; - MSXML2::IXMLDOMElement* pElement2= NULL; - BSTR nodeName = ::SysAllocString(L"Modules"); - BSTR nodeName2 = ::SysAllocString(L"Module"); - BSTR fullPath = ::SysAllocString(L"FullPath"); - BSTR baseAddrName = ::SysAllocString(L"BaseAddress"); - BSTR sizeName = ::SysAllocString(L"Size"); - BSTR timeStampName = ::SysAllocString(L"TimeStamp"); - BSTR fileVerName = ::SysAllocString(L"FileVersion"); - BSTR prodVerName = ::SysAllocString(L"ProductVersion"); - - string sAddr; - VARIANT v; - - - // Create modules node - pNode = CreateDOMNode(pDoc, MSXML2::NODE_ELEMENT, nodeName); - - // - // Add module information (freeing storage as we go) - // - MINIDUMP_MODULE_CALLBACK item; - std::vector::iterator iter; - for (iter = m_modules.begin(); iter != m_modules.end(); iter++) - { - item = *iter; - // Create module node - pNode2 = CreateDOMNode(pDoc, MSXML2::NODE_ELEMENT, nodeName2); - - // Get element interface - CHECKHR(pNode2->QueryInterface(MSXML2::IID_IXMLDOMElement, (void**)&pElement)); - - // - // Set full path - // - V_VT(&v) = VT_BSTR; - V_BSTR(&v) = SysAllocString(item.FullPath); - pElement->setAttribute(fullPath, v); - // Recycle variant - SysFreeString(V_BSTR(&v)); - - // - // Set base address - // - TCHAR buf[MAX_PATH] = {0}; - _tprintf_s(buf, addressFormat, item.BaseOfImage); - V_VT(&v) = VT_BSTR; - V_BSTR(&v) = CUtility::AllocSysString(buf); - pElement->setAttribute(baseAddrName, v); - // Recycle variant - SysFreeString(V_BSTR(&v)); - - // - // Set module size - // - _tprintf_s(buf, sizeFormat, item.SizeOfImage); - V_VT(&v) = VT_BSTR; - V_BSTR(&v) = CUtility::AllocSysString(buf); - pElement->setAttribute(sizeName, v); - // Recycle variant - SysFreeString(V_BSTR(&v)); - - // - // Set timestamp - // - FILETIME ft = CUtility::getLastWriteFileTime(item.FullPath); - SYSTEMTIME st = {0}; - - FileTimeToSystemTime(&ft, &st); - - _tprintf_s(buf, _T("%02u/%02u/%04u %02u:%02u:%02u"), - st.wMonth, - st.wDay, - st.wYear, - st.wHour, - st.wMinute, - st.wSecond); - - V_VT(&v) = VT_BSTR; - V_BSTR(&v) = CUtility::AllocSysString(buf); - pElement->setAttribute(timeStampName, v); - // Recycle variant - SysFreeString(V_BSTR(&v)); - - // - // Set file version - // - _tprintf_s(buf,"%d.%d.%d.%d", - HIWORD(item.VersionInfo.dwFileVersionMS), - LOWORD(item.VersionInfo.dwFileVersionMS), - HIWORD(item.VersionInfo.dwFileVersionLS), - LOWORD(item.VersionInfo.dwFileVersionLS)); - - V_VT(&v) = VT_BSTR; - V_BSTR(&v) = CUtility::AllocSysString(buf); - pElement->setAttribute(fileVerName, v); - // Recycle variant - SysFreeString(V_BSTR(&v)); - - // - // Set product version - // - _tprintf_s(buf, "%d.%d.%d.%d", - HIWORD(item.VersionInfo.dwProductVersionMS), - LOWORD(item.VersionInfo.dwProductVersionMS), - HIWORD(item.VersionInfo.dwProductVersionLS), - LOWORD(item.VersionInfo.dwProductVersionLS)); - - V_VT(&v) = VT_BSTR; - V_BSTR(&v) = CUtility::AllocSysString(buf); - pElement->setAttribute(prodVerName, v); - // Recycle variant - SysFreeString(V_BSTR(&v)); - - // - // Append module to modules - // - pNode->appendChild(pNode2, &pNewNode); - // The XML Document should now own the node. - SAFERELEASE(pNode2); - SAFERELEASE(pElement2); - SAFERELEASE(pNewNode); - - free(item.FullPath); - } - m_modules.clear(); - -CleanUp: - - ::SysFreeString(nodeName); - ::SysFreeString(nodeName2); - ::SysFreeString(fullPath); - ::SysFreeString(baseAddrName); - ::SysFreeString(sizeName); - ::SysFreeString(timeStampName); - ::SysFreeString(fileVerName); - ::SysFreeString(prodVerName); - SAFERELEASE(pNode2); - SAFERELEASE(pNewNode); - SAFERELEASE(pElement); - SAFERELEASE(pElement2); - - return pNode; -} - -//----------------------------------------------------------------------------- -// CreateMsgNode -// -// Builds the application-defined message node -// -MSXML2::IXMLDOMNode * -CExceptionReport::CreateMsgNode(MSXML2::IXMLDOMDocument* pDoc, BSTR message) -{ - MSXML2::IXMLDOMNode* pNode = NULL; - MSXML2::IXMLDOMElement* pElement = NULL; - BSTR nodeName = ::SysAllocString(L"ApplicationDescription"); - - // Create CrashDescription record node - pNode = CreateDOMNode(pDoc, MSXML2::NODE_ELEMENT, nodeName); - - // Get element interface - CHECKHR(pNode->QueryInterface(MSXML2::IID_IXMLDOMElement, (void**)&pElement)); - - pElement->put_text(message); - -CleanUp: - ::SysFreeString(nodeName); - SAFERELEASE(pElement); - - return pNode; -} - -//----------------------------------------------------------------------------- -// CreateWalkbackEntryNode -// -// Create a single node in the stack walback -// -void -CExceptionReport::CreateWalkbackEntryNode(DWORD_PTR address, const char *ImageName, - const char *FunctionName, DWORD_PTR functionDisp, - const char *Filename, DWORD LineNumber, DWORD lineDisp, - void *data) -{ - MSXML2::IXMLDOMNode* pNode = NULL; - MSXML2::IXMLDOMElement* pElement = NULL; - MSXML2::IXMLDOMNode* pNewNode = NULL; - string sAddr; - BSTR nodeName = ::SysAllocString(L"Frame"); - BSTR frameName = ::SysAllocString(L"FrameNumber"); - BSTR addrName = ::SysAllocString(L"ReturnAddress"); - BSTR moduleName = ::SysAllocString(L"ModuleName"); - BSTR funcName = ::SysAllocString(L"FunctionName"); - BSTR funcDispName = ::SysAllocString(L"FunctionDisplacement"); - BSTR fileName = ::SysAllocString(L"Filename"); - BSTR lineName = ::SysAllocString(L"LineNumber"); - BSTR lineDispName = ::SysAllocString(L"LineDisplacement"); - CExceptionReport *self = reinterpret_cast(data); - - // Create frame record node - pNode = self->CreateDOMNode(self->m_stack_doc, MSXML2::NODE_ELEMENT, nodeName); - - // Get element interface - CHECKHR(pNode->QueryInterface(MSXML2::IID_IXMLDOMElement, (void**)&pElement)); - - - VARIANT v; - - self->m_frameNumber++; - TCHAR buf[MAX_PATH] = {0}; - _tprintf_s(buf, _T("%d"), self->m_frameNumber); - - V_VT(&v) = VT_BSTR; - V_BSTR(&v) = CUtility::AllocSysString(buf); - pElement->setAttribute(frameName, v); - // Recycle variant - SysFreeString(V_BSTR(&v)); - - _tprintf_s(buf, offsetFormat, address); - V_VT(&v) = VT_BSTR; - V_BSTR(&v) = CUtility::AllocSysString(buf); - pElement->setAttribute(addrName, v); - // Recycle variant - SysFreeString(V_BSTR(&v)); - - if (ImageName != NULL) { - V_VT(&v) = VT_BSTR; - V_BSTR(&v) = CUtility::AllocSysString(ImageName); - pElement->setAttribute(moduleName, v); - // Recycle variant - SysFreeString(V_BSTR(&v)); - } - - if (FunctionName != NULL) { - V_VT(&v) = VT_BSTR; - V_BSTR(&v) = CUtility::AllocSysString(FunctionName); - pElement->setAttribute(funcName, v); - // Recycle variant - SysFreeString(V_BSTR(&v)); - _tprintf_s(buf, offsetFormat, functionDisp); - V_VT(&v) = VT_BSTR; - V_BSTR(&v) = CUtility::AllocSysString(buf); - pElement->setAttribute(funcDispName, v); - // Recycle variant - SysFreeString(V_BSTR(&v)); - } - - if (Filename != NULL) { - V_VT(&v) = VT_BSTR; - V_BSTR(&v) = CUtility::AllocSysString(Filename); - pElement->setAttribute(fileName, v); - // Recycle variant - SysFreeString(V_BSTR(&v)); - - _tprintf_s(buf, _T("%d"), LineNumber); - V_VT(&v) = VT_BSTR; - V_BSTR(&v) = CUtility::AllocSysString(buf); - pElement->setAttribute(lineName, v); - // Recycle variant - SysFreeString(V_BSTR(&v)); - - _tprintf_s(buf, offsetFormat, lineDisp); - V_VT(&v) = VT_BSTR; - V_BSTR(&v) = CUtility::AllocSysString(buf); - pElement->setAttribute(lineDispName, v); - // Recycle variant - SysFreeString(V_BSTR(&v)); - } - // add to walkback element - - self->m_stack_element->appendChild(pNode, &pNewNode); - SAFERELEASE(pNewNode); - // The XML Document should now own the node. -CleanUp: - SAFERELEASE(pNode); - SAFERELEASE(pElement); - ::SysFreeString(nodeName); - ::SysFreeString(frameName); - ::SysFreeString(addrName); - ::SysFreeString(moduleName); - ::SysFreeString(funcName); - ::SysFreeString(funcDispName); - ::SysFreeString(fileName); - ::SysFreeString(lineName); - ::SysFreeString(lineDispName); -} - -//----------------------------------------------------------------------------- -// CreateWalkbackNode -// -// Builds the stack walkback list -// -MSXML2::IXMLDOMNode * -CExceptionReport::CreateWalkbackNode(MSXML2::IXMLDOMDocument* pDoc, CONTEXT *pContext) -{ - MSXML2::IXMLDOMNode* pNode = NULL; - - MSXML2::IXMLDOMElement* pElement = NULL; - BSTR nodeName = ::SysAllocString(L"CallStack"); - - // Create CallStack record node - pNode = CreateDOMNode(pDoc, MSXML2::NODE_ELEMENT, nodeName); - - // Get element interface - CHECKHR(pNode->QueryInterface(MSXML2::IID_IXMLDOMElement, (void**)&pElement)); - - // create the trace - // set static variables for use by CreateWalkbackEntryNode - m_stack_element = pElement; - m_stack_doc = pDoc; - m_frameNumber = 0; - // If no context is supplied, skip 1 frames: - // 1 this function - // ?? - DoStackTrace(pContext == NULL ? 1 : 0, 9999, CreateWalkbackEntryNode, pContext, this); - -CleanUp: - ::SysFreeString(nodeName); - SAFERELEASE(pElement); - - return pNode; -} - -//----------------------------------------------------------------------------- -// CExceptionReport::miniDumpCallback -// -// Mini dump module callback. Hit once for each module processed by -// MiniDumpWriteDump. Builds a linked list of all module names which is -// eventually used to create the node in the XML log file. -// -BOOL CALLBACK -CExceptionReport::miniDumpCallback(PVOID data, - CONST PMINIDUMP_CALLBACK_INPUT CallbackInput, - PMINIDUMP_CALLBACK_OUTPUT) -{ - CExceptionReport *self = reinterpret_cast(data); - if (ModuleCallback == CallbackInput->CallbackType) - { - MINIDUMP_MODULE_CALLBACK item; - - item = CallbackInput->Module; - item.FullPath = _wcsdup(CallbackInput->Module.FullPath); - self->m_modules.push_back(item); - } - - return TRUE; -} \ No newline at end of file diff --git a/src/crashrpt/excprpt.h b/src/crashrpt/excprpt.h deleted file mode 100644 index a89b949a3..000000000 --- a/src/crashrpt/excprpt.h +++ /dev/null @@ -1,110 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Module: excprpt.h -// -// Desc: This class generates the dump and xml overview files. -// -// Copyright (c) 2003 Michael Carruth -// -/////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include -// STL generates various warnings. -// 4100: unreferenced formal parameter -// 4663: C++ language change: to explicitly specialize class template... -// 4018: signed/unsigned mismatch -// 4245: conversion from to : signed/unsigned mismatch -#pragma warning(push, 3) -#pragma warning(disable: 4100) -#pragma warning(disable: 4663) -#pragma warning(disable: 4018) -#pragma warning(disable: 4245) -#include -#pragma warning(pop) - -// Import MSXML interfaces -#import "msxml6.dll" named_guids raw_interfaces_only - -// -// COM helper macros -// -#define CHECKHR(x) {HRESULT hr = x; if (FAILED(hr)) goto CleanUp;} -#define SAFERELEASE(p) {if (p) {(p)->Release(); p = NULL;}} - - -////////////////////////////// Class Definitions ///////////////////////////// - -// =========================================================================== -// CExceptionReport -// -// See the module comment at top of file. -// -class CExceptionReport -{ -public: - CExceptionReport(PEXCEPTION_POINTERS ExceptionInfo, BSTR message); - - string getSymbolFile(int index); - int getNumSymbolFiles(); - string getCrashLog(); - string getCrashFile(); - string getModuleName() { return m_sModule; }; - string getExceptionCode() { return m_sException; }; - string getExceptionAddr() { return m_sAddress; }; - -private: - string m_sCommandLine; - string m_sModule; - string m_sException; - string m_sAddress; - - PEXCEPTION_POINTERS m_excpInfo; - BSTR m_message; - vector m_symFiles; - - // used by stack walkback - MSXML2::IXMLDOMElement* m_stack_element; - MSXML2::IXMLDOMDocument* m_stack_doc; - int m_frameNumber; - - // used by exception node creation, symbol translations - MSXML2::IXMLDOMElement* m_exception_element; - - // used by dump callback - std::vector m_modules; - - static void writeDumpFile(HANDLE file, PEXCEPTION_POINTERS m_excpInfo, void *data); - - MSXML2::IXMLDOMNode* CreateDOMNode(MSXML2::IXMLDOMDocument* pDoc, - int type, - BSTR bstrName); - - MSXML2::IXMLDOMNode* CreateExceptionRecordNode(MSXML2::IXMLDOMDocument* pDoc, - EXCEPTION_RECORD* pExceptionRecord); - static void CreateExceptionSymbolAttributes(DWORD_PTR address, const char *ImageName, - const char *FunctionName, DWORD_PTR functionDisp, - const char *Filename, DWORD LineNumber, DWORD lineDisp, - void *data); - - MSXML2::IXMLDOMNode* CreateProcessorNode(MSXML2::IXMLDOMDocument* pDoc); - - MSXML2::IXMLDOMNode* CreateOSNode(MSXML2::IXMLDOMDocument* pDoc); - - MSXML2::IXMLDOMNode* CreateModulesNode(MSXML2::IXMLDOMDocument* pDoc); - - MSXML2::IXMLDOMNode* CreateMsgNode(MSXML2::IXMLDOMDocument* pDoc, BSTR message); - - MSXML2::IXMLDOMNode* CreateWalkbackNode(MSXML2::IXMLDOMDocument* pDoc, CONTEXT *pContext); - - static void CreateWalkbackEntryNode(DWORD_PTR address, const char *ImageName, - const char *FunctionName, DWORD_PTR functionDisp, - const char *Filename, DWORD LineNumber, DWORD lineDisp, - void *data); - - static BOOL CALLBACK miniDumpCallback(PVOID CallbackParam, - CONST PMINIDUMP_CALLBACK_INPUT CallbackInput, - PMINIDUMP_CALLBACK_OUTPUT CallbackOutput); -}; - diff --git a/src/crashrpt/maindlg.h b/src/crashrpt/maindlg.h deleted file mode 100644 index 0d0afb76a..000000000 --- a/src/crashrpt/maindlg.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once - -#include "BaseDialog.h" -#include "Utility.h" -#include "CrashHandler.h" - - -////////////////////////////// Class Definitions ///////////////////////////// - -// =========================================================================== -// CMainDlg -// -// See the module comment at top of file. -// -class CMainDlg : public CDialog -{ -public: - CMainDlg(void); - ~CMainDlg(void); - -protected: - LRESULT CALLBACK DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); - LRESULT DoCommand(int id); - -public: - - string m_sEmail; // Email: From - string m_sDescription; // Email: Body - TStrStrVector *m_pUDFiles; // Files - BOOL m_sendButton; // Display 'Send' or 'Save' button -}; - -///////////////////////////////////////////////////////////////////////////// diff --git a/src/crashrpt/res/CrashRpt.ico b/src/crashrpt/res/CrashRpt.ico deleted file mode 100644 index 9cdfc8091409a0e3be16d0651258f9eb8281aa87..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcwPel00001 literal 1078 zcwWU)F>-@25L}!TM-zAgRVL5Kw^Bu=y3l%D_zP(n8lIDql1^TokU4n - - - - CrashRpt Application - - - - - - - diff --git a/src/crashrpt/resource.h b/src/crashrpt/resource.h deleted file mode 100644 index 474a9982f..000000000 --- a/src/crashrpt/resource.h +++ /dev/null @@ -1,38 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by CrashRpt.rc -// -#define IDC_SAVE 40 -#define IDC_DEBUG 50 -#define IDR_MAINFRAME 128 -#define IDD_MAINDLG 129 -#define IDC_DESCRIPTION 205 -#define IDS_NAME 1000 -#define IDS_DESC 1001 -#define IDS_TYPE 1002 -#define IDS_SIZE 1003 -#define IDC_EMAIL 1003 -#define IDS_CRASH_DUMP 1004 -#define IDS_CRASH_LOG 1005 -#define IDS_SYMBOL_FILE 1006 -#define IDS_USER_DATA 1008 -#define IDS_CONTENT_TYPE 57346 -#define IDS_HEADER 57610 -#define IDS_INVALID_EMAIL 57611 -#define IDS_ZIP_FILTER 57612 -#define IDS_HTTP_HEADER_CONTENT_TYPE 57613 -#define IDS_HTTP_HEADER_BOUNDARY 57614 -#define IDS_FORM_DATA 57638 -#define IDS_ABOUTBOX 57654 -#define IDC_STATIC -1 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 212 -#define _APS_NEXT_COMMAND_VALUE 32772 -#define _APS_NEXT_CONTROL_VALUE 1009 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/src/crashrpt/zlib/adler32.c b/src/crashrpt/zlib/adler32.c deleted file mode 100644 index b7b3f5cab..000000000 --- a/src/crashrpt/zlib/adler32.c +++ /dev/null @@ -1,48 +0,0 @@ -/* adler32.c -- compute the Adler-32 checksum of a data stream - * Copyright (C) 1995-2002 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id: adler32.c,v 1.1 2003/05/23 21:05:30 steveking Exp $ */ - -#include "zlib.h" - -#define BASE 65521L /* 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) {s1 += buf[i]; s2 += s1;} -#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); - -/* ========================================================================= */ -uLong ZEXPORT adler32(adler, buf, len) - uLong adler; - const Bytef *buf; - uInt len; -{ - unsigned long s1 = adler & 0xffff; - unsigned long s2 = (adler >> 16) & 0xffff; - int k; - - if (buf == Z_NULL) return 1L; - - while (len > 0) { - k = len < NMAX ? len : NMAX; - len -= k; - while (k >= 16) { - DO16(buf); - buf += 16; - k -= 16; - } - if (k != 0) do { - s1 += *buf++; - s2 += s1; - } while (--k); - s1 %= BASE; - s2 %= BASE; - } - return (s2 << 16) | s1; -} diff --git a/src/crashrpt/zlib/compress.c b/src/crashrpt/zlib/compress.c deleted file mode 100644 index 7a6b62cc8..000000000 --- a/src/crashrpt/zlib/compress.c +++ /dev/null @@ -1,68 +0,0 @@ -/* compress.c -- compress a memory buffer - * Copyright (C) 1995-2002 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id: compress.c,v 1.1 2003/05/23 21:05:30 steveking Exp $ */ - -#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); -} diff --git a/src/crashrpt/zlib/crc32.c b/src/crashrpt/zlib/crc32.c deleted file mode 100644 index 92d670bc7..000000000 --- a/src/crashrpt/zlib/crc32.c +++ /dev/null @@ -1,162 +0,0 @@ -/* crc32.c -- compute the CRC-32 of a data stream - * Copyright (C) 1995-2002 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id: crc32.c,v 1.1 2003/05/23 21:05:30 steveking Exp $ */ - -#include "zlib.h" - -#define local static - -#ifdef DYNAMIC_CRC_TABLE - -local int crc_table_empty = 1; -local uLongf crc_table[256]; -local void make_crc_table OF((void)); - -/* - Generate a table 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 table is simply the CRC of all possible eight bit values. This is all - the information needed to generate CRC's on data a byte at a time for all - combinations of CRC register values and incoming bytes. -*/ -local void make_crc_table() -{ - uLong c; - int n, k; - uLong poly; /* polynomial exclusive-or pattern */ - /* terms of polynomial defining this crc (except x^32): */ - static const Byte p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; - - /* make exclusive-or pattern from polynomial (0xedb88320L) */ - poly = 0L; - for (n = 0; n < sizeof(p)/sizeof(Byte); n++) - poly |= 1L << (31 - p[n]); - - for (n = 0; n < 256; n++) - { - c = (uLong)n; - for (k = 0; k < 8; k++) - c = c & 1 ? poly ^ (c >> 1) : c >> 1; - crc_table[n] = c; - } - crc_table_empty = 0; -} -#else -/* ======================================================================== - * Table of CRC-32's of all single-byte values (made by make_crc_table) - */ -local const uLongf crc_table[256] = { - 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, - 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L, - 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, - 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, - 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L, - 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, - 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, - 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL, - 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, - 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL, - 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, - 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, - 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L, - 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, - 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, - 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L, - 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, - 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L, - 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, - 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, - 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL, - 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, - 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L, - 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL, - 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, - 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L, - 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, - 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, - 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L, - 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL, - 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, - 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L, - 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L, - 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL, - 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, - 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, - 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL, - 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L, - 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, - 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L, - 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL, - 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L, - 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, - 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, - 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L, - 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L, - 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, - 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L, - 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L, - 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L, - 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, - 0x2d02ef8dL -}; -#endif - -/* ========================================================================= - * This function can be used by asm versions of crc32() - */ -const uLongf * ZEXPORT get_crc_table() -{ -#ifdef DYNAMIC_CRC_TABLE - if (crc_table_empty) make_crc_table(); -#endif - return (const uLongf *)crc_table; -} - -/* ========================================================================= */ -#define DO1(buf) crc = crc_table[((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8); -#define DO2(buf) DO1(buf); DO1(buf); -#define DO4(buf) DO2(buf); DO2(buf); -#define DO8(buf) DO4(buf); DO4(buf); - -/* ========================================================================= */ -uLong ZEXPORT crc32(crc, buf, len) - uLong crc; - const Bytef *buf; - uInt len; -{ - if (buf == Z_NULL) return 0L; -#ifdef DYNAMIC_CRC_TABLE - if (crc_table_empty) - make_crc_table(); -#endif - crc = crc ^ 0xffffffffL; - while (len >= 8) - { - DO8(buf); - len -= 8; - } - if (len) do { - DO1(buf); - } while (--len); - return crc ^ 0xffffffffL; -} diff --git a/src/crashrpt/zlib/deflate.c b/src/crashrpt/zlib/deflate.c deleted file mode 100644 index ff57852f7..000000000 --- a/src/crashrpt/zlib/deflate.c +++ /dev/null @@ -1,1350 +0,0 @@ -/* deflate.c -- compress data using the deflation algorithm - * Copyright (C) 1995-2002 Jean-loup Gailly. - * 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 ftp://ds.internic.net/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: deflate.c,v 1.1 2003/05/23 21:05:30 steveking Exp $ */ - -#include "deflate.h" - -const char deflate_copyright[] = - " deflate 1.1.4 Copyright 1995-2002 Jean-loup Gailly "; -/* - 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)); -local block_state deflate_slow 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 */ - -#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. - */ - -/* 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; - -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}, /* maximum 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}}; /* maximum compression */ - -/* 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 */ - -struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ - -/* =========================================================================== - * 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)]), \ - s->prev[(str) & s->w_mask] = match_head = 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 noheader = 0; - 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 == Z_NULL) { - strm->zalloc = zcalloc; - strm->opaque = (voidpf)0; - } - if (strm->zfree == Z_NULL) strm->zfree = zcfree; - - if (level == Z_DEFAULT_COMPRESSION) level = 6; -#ifdef FASTEST - level = 1; -#endif - - if (windowBits < 0) { /* undocumented feature: suppress zlib header */ - noheader = 1; - windowBits = -windowBits; - } - if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || - windowBits < 9 || windowBits > 15 || level < 0 || level > 9 || - strategy < 0 || strategy > Z_HUFFMAN_ONLY) { - return Z_STREAM_ERROR; - } - 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->noheader = noheader; - 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->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) { - 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->status != INIT_STATE) return Z_STREAM_ERROR; - - s = strm->state; - strm->adler = adler32(strm->adler, dictionary, dictLength); - - if (length < MIN_MATCH) return Z_OK; - if (length > MAX_DIST(s)) { - length = MAX_DIST(s); -#ifndef USE_DICT_HEAD - dictionary += dictLength - length; /* use the tail of the dictionary */ -#endif - } - 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 == Z_NULL || strm->zfree == Z_NULL) 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->noheader < 0) { - s->noheader = 0; /* was set to -1 by deflate(..., Z_FINISH); */ - } - s->status = s->noheader ? BUSY_STATE : INIT_STATE; - strm->adler = 1; - s->last_flush = Z_NO_FLUSH; - - _tr_init(s); - lm_init(s); - - 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; - - if (level == Z_DEFAULT_COMPRESSION) { - level = 6; - } - if (level < 0 || level > 9 || strategy < 0 || strategy > Z_HUFFMAN_ONLY) { - return Z_STREAM_ERROR; - } - func = configuration_table[s->level].func; - - if (func != configuration_table[level].func && strm->total_in != 0) { - /* Flush the last buffer: */ - err = deflate(strm, Z_PARTIAL_FLUSH); - } - 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; -} - -/* ========================================================================= - * 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_FINISH || 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 zlib header */ - if (s->status == INIT_STATE) { - - uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; - uInt level_flags = (s->level-1) >> 1; - - if (level_flags > 3) 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 = 1L; - } - - /* 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_BUFF_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 = (*(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 { /* 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 */ - } - } - 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->noheader) return Z_STREAM_END; - - /* Write the zlib trailer (adler32) */ - 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. - */ - s->noheader = -1; /* 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 != 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; - - *dest = *source; - - ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); - if (ds == Z_NULL) return Z_MEM_ERROR; - dest->state = (struct internal_state FAR *) ds; - *ds = *ss; - 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 -} - -/* =========================================================================== - * 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->noheader) { - strm->adler = adler32(strm->adler, strm->next_in, len); - } - 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; -#ifdef ASMV - match_init(); /* initialize the asm code */ -#endif -} - -/* =========================================================================== - * 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. - */ -#ifndef FASTEST -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: - */ -#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; -} - -#else /* FASTEST */ -/* --------------------------------------------------------------------------- - * Optimized version for level == 1 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 len <= s->lookahead ? len : s->lookahead; -} -#endif /* FASTEST */ -#endif /* ASMV */ - -#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 - -/* =========================================================================== - * 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 (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 - * and lookahead == 1 (input done one 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. - */ - } else 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); -} - -/* =========================================================================== - * 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, eof) { \ - _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), \ - (eof)); \ - s->block_start = s->strstart; \ - flush_pending(s->strm); \ - Tracev((stderr,"[FLUSH]")); \ -} - -/* Same but force premature exit if necessary. */ -#define FLUSH_BLOCK(s, eof) { \ - FLUSH_BLOCK_ONLY(s, eof); \ - if (s->strm->avail_out == 0) return (eof) ? 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 = NIL; /* 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: - */ - 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). - */ - if (s->strategy != Z_HUFFMAN_ONLY) { - 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 hash 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; -} - -/* =========================================================================== - * 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 = NIL; /* 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: - */ - 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). - */ - if (s->strategy != Z_HUFFMAN_ONLY) { - s->match_length = longest_match (s, hash_head); - } - /* longest_match() sets match_start */ - - if (s->match_length <= 5 && (s->strategy == Z_FILTERED || - (s->match_length == MIN_MATCH && - s->strstart - s->match_start > TOO_FAR))) { - - /* 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; -} diff --git a/src/crashrpt/zlib/deflate.h b/src/crashrpt/zlib/deflate.h deleted file mode 100644 index 26d2b884f..000000000 --- a/src/crashrpt/zlib/deflate.h +++ /dev/null @@ -1,318 +0,0 @@ -/* deflate.h -- internal compression state - * Copyright (C) 1995-2002 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: deflate.h,v 1.1 2003/05/23 21:05:30 steveking Exp $ */ - -#ifndef _DEFLATE_H -#define _DEFLATE_H - -#include "zutil.h" - -/* =========================================================================== - * 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 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 */ - int pending; /* nb of bytes in the pending buffer */ - int noheader; /* suppress zlib header and adler32 */ - Byte data_type; /* UNKNOWN, BINARY or ASCII */ - 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. - */ - -} 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. - */ - - /* in trees.c */ -void _tr_init OF((deflate_state *s)); -int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); -void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len, - int eof)); -void _tr_align OF((deflate_state *s)); -void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len, - int eof)); - -#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 _length_code[]; - extern uch _dist_code[]; -#else - extern const uch _length_code[]; - extern const uch _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 diff --git a/src/crashrpt/zlib/gzio.c b/src/crashrpt/zlib/gzio.c deleted file mode 100644 index 0e4108152..000000000 --- a/src/crashrpt/zlib/gzio.c +++ /dev/null @@ -1,875 +0,0 @@ -/* gzio.c -- IO on .gz files - * Copyright (C) 1995-2002 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - * - * Compile this file with -DNO_DEFLATE to avoid the compression code. - */ - -/* @(#) $Id: gzio.c,v 1.1 2003/05/23 21:05:30 steveking Exp $ */ - -#include - -#include "zutil.h" - -struct internal_state {int dummy;}; /* for buggy compilers */ - -#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 - -#define ALLOC(size) malloc(size) -#define TRYFREE(p) {if (p) free(p);} - -static int 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' */ - long startpos; /* start of compressed data in file (header skipped) */ -} 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 return 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->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 { - *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_DEFLATE - 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->startpos = 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 - * startpos anyway in write mode, so this initialization is not - * necessary. - */ - } else { - check_header(s); /* skip the .gz header */ - s->startpos = (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; - - /* Check the gzip magic header */ - for (len = 0; len < 2; len++) { - c = get_byte(s); - if (c != gz_magic[len]) { - if (len != 0) s->stream.avail_in++, s->stream.next_in--; - if (c != EOF) { - s->stream.avail_in++, s->stream.next_in--; - s->transparent = 1; - } - s->z_err = s->stream.avail_in != 0 ? Z_OK : Z_STREAM_END; - return; - } - } - 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_DEFLATE - 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; - - 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->stream.total_in += (uLong)len; - s->stream.total_out += (uLong)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->z_err = inflate(&(s->stream), Z_NO_FLUSH); - - 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->stream.total_out) in case of - * concatenated .gz files. Check for such files: - */ - check_header(s); - if (s->z_err == Z_OK) { - uLong total_in = s->stream.total_in; - uLong total_out = s->stream.total_out; - - inflateReset(&(s->stream)); - s->stream.total_in = total_in; - s->stream.total_out = total_out; - 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; -} - - -/* =========================================================================== - 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_DEFLATE -/* =========================================================================== - 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; - const voidp 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->z_err = deflate(&(s->stream), Z_NO_FLUSH); - 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; - - va_start(va, format); -#ifdef HAS_vsnprintf - (void)vsnprintf(buf, sizeof(buf), format, va); -#else - (void)vsprintf(buf, format, va); -#endif - va_end(va); - len = strlen(buf); /* some *sprintf don't return the nb of bytes written */ - if (len <= 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; - -#ifdef HAS_snprintf - 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); -#else - sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8, - a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); -#endif - len = strlen(buf); /* old sprintf doesn't return the nb of bytes written */ - if (len <= 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->z_err = deflate(&(s->stream), flush); - - /* 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_DEFLATE */ - -/* =========================================================================== - 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_DEFLATE - return -1L; -#else - if (whence == SEEK_SET) { - offset -= s->stream.total_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 */ - 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 (z_off_t)s->stream.total_in; -#endif - } - /* Rest of function is for reading only */ - - /* compute absolute position */ - if (whence == SEEK_CUR) { - offset += s->stream.total_out; - } - if (offset < 0) return -1L; - - if (s->transparent) { - /* map to fseek */ - s->stream.avail_in = 0; - s->stream.next_in = s->inbuf; - if (fseek(s->file, offset, SEEK_SET) < 0) return -1L; - - s->stream.total_in = s->stream.total_out = (uLong)offset; - return offset; - } - - /* For a negative seek, rewind and use positive seek */ - if ((uLong)offset >= s->stream.total_out) { - offset -= s->stream.total_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); - } - 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 (z_off_t)s->stream.total_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->stream.avail_in = 0; - s->stream.next_in = s->inbuf; - s->crc = crc32(0L, Z_NULL, 0); - - if (s->startpos == 0) { /* not a compressed file */ - rewind(s->file); - return 0; - } - - (void) inflateReset(&s->stream); - return fseek(s->file, s->startpos, 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; - - return (s == NULL || s->mode != 'r') ? 0 : s->z_eof; -} - -/* =========================================================================== - 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_DEFLATE - 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, s->stream.total_in); -#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); - strcpy(s->msg, s->path); - strcat(s->msg, ": "); - strcat(s->msg, m); - return (const char*)s->msg; -} diff --git a/src/crashrpt/zlib/infblock.c b/src/crashrpt/zlib/infblock.c deleted file mode 100644 index 943e8493c..000000000 --- a/src/crashrpt/zlib/infblock.c +++ /dev/null @@ -1,403 +0,0 @@ -/* infblock.c -- interpret and process block types to last block - * Copyright (C) 1995-2002 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "infblock.h" -#include "inftrees.h" -#include "infcodes.h" -#include "infutil.h" - -struct inflate_codes_state {int dummy;}; /* for buggy compilers */ - -/* simplify the use of the inflate_huft type with some defines */ -#define exop word.what.Exop -#define bits word.what.Bits - -/* Table for deflate from PKZIP's appnote.txt. */ -local const uInt border[] = { /* Order of the bit length code lengths */ - 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; - -/* - Notes beyond the 1.93a appnote.txt: - - 1. Distance pointers never point before the beginning of the output - stream. - 2. Distance pointers can point back across blocks, up to 32k away. - 3. There is an implied maximum of 7 bits for the bit length table and - 15 bits for the actual data. - 4. If only one code exists, then it is encoded using one bit. (Zero - would be more efficient, but perhaps a little confusing.) If two - codes exist, they are coded using one bit each (0 and 1). - 5. There is no way of sending zero distance codes--a dummy must be - sent if there are none. (History: a pre 2.0 version of PKZIP would - store blocks with no distance codes, but this was discovered to be - too harsh a criterion.) Valid only for 1.93a. 2.04c does allow - zero distance codes, which is sent as one code of zero bits in - length. - 6. There are up to 286 literal/length codes. Code 256 represents the - end-of-block. Note however that the static length tree defines - 288 codes just to fill out the Huffman codes. Codes 286 and 287 - cannot be used though, since there is no length base or extra bits - defined for them. Similarily, there are up to 30 distance codes. - However, static trees define 32 codes (all 5 bits) to fill out the - Huffman codes, but the last two had better not show up in the data. - 7. Unzip can check dynamic Huffman blocks for complete code sets. - The exception is that a single code would not be complete (see #4). - 8. The five bits following the block type is really the number of - literal codes sent minus 257. - 9. Length codes 8,16,16 are interpreted as 13 length codes of 8 bits - (1+6+6). Therefore, to output three times the length, you output - three codes (1+1+1), whereas to output four times the same length, - you only need two codes (1+3). Hmm. - 10. In the tree reconstruction algorithm, Code = Code + Increment - only if BitLength(i) is not zero. (Pretty obvious.) - 11. Correction: 4 Bits: # of Bit Length codes - 4 (4 - 19) - 12. Note: length code 284 can represent 227-258, but length code 285 - really is 258. The last length deserves its own, short code - since it gets used a lot in very redundant files. The length - 258 is special since 258 - 3 (the min match length) is 255. - 13. The literal/length and distance code bit lengths are read as a - single stream of lengths. It is possible (and advantageous) for - a repeat code (16, 17, or 18) to go across the boundary between - the two sets of lengths. - */ - - -void inflate_blocks_reset(s, z, c) -inflate_blocks_statef *s; -z_streamp z; -uLongf *c; -{ - if (c != Z_NULL) - *c = s->check; - if (s->mode == BTREE || s->mode == DTREE) - ZFREE(z, s->sub.trees.blens); - if (s->mode == CODES) - inflate_codes_free(s->sub.decode.codes, z); - s->mode = TYPE; - s->bitk = 0; - s->bitb = 0; - s->read = s->write = s->window; - if (s->checkfn != Z_NULL) - z->adler = s->check = (*s->checkfn)(0L, (const Bytef *)Z_NULL, 0); - Tracev((stderr, "inflate: blocks reset\n")); -} - - -inflate_blocks_statef *inflate_blocks_new(z, c, w) -z_streamp z; -check_func c; -uInt w; -{ - inflate_blocks_statef *s; - - if ((s = (inflate_blocks_statef *)ZALLOC - (z,1,sizeof(struct inflate_blocks_state))) == Z_NULL) - return s; - if ((s->hufts = - (inflate_huft *)ZALLOC(z, sizeof(inflate_huft), MANY)) == Z_NULL) - { - ZFREE(z, s); - return Z_NULL; - } - if ((s->window = (Bytef *)ZALLOC(z, 1, w)) == Z_NULL) - { - ZFREE(z, s->hufts); - ZFREE(z, s); - return Z_NULL; - } - s->end = s->window + w; - s->checkfn = c; - s->mode = TYPE; - Tracev((stderr, "inflate: blocks allocated\n")); - inflate_blocks_reset(s, z, Z_NULL); - return s; -} - - -int inflate_blocks(s, z, r) -inflate_blocks_statef *s; -z_streamp z; -int r; -{ - uInt t; /* temporary storage */ - uLong b; /* bit buffer */ - uInt k; /* bits in bit buffer */ - Bytef *p; /* input data pointer */ - uInt n; /* bytes available there */ - Bytef *q; /* output window write pointer */ - uInt m; /* bytes to end of window or read pointer */ - - /* copy input/output information to locals (UPDATE macro restores) */ - LOAD - - /* process input based on current state */ - while (1) switch (s->mode) - { - case TYPE: - NEEDBITS(3) - t = (uInt)b & 7; - s->last = t & 1; - switch (t >> 1) - { - case 0: /* stored */ - Tracev((stderr, "inflate: stored block%s\n", - s->last ? " (last)" : "")); - DUMPBITS(3) - t = k & 7; /* go to byte boundary */ - DUMPBITS(t) - s->mode = LENS; /* get length of stored block */ - break; - case 1: /* fixed */ - Tracev((stderr, "inflate: fixed codes block%s\n", - s->last ? " (last)" : "")); - { - uInt bl, bd; - inflate_huft *tl, *td; - - inflate_trees_fixed(&bl, &bd, &tl, &td, z); - s->sub.decode.codes = inflate_codes_new(bl, bd, tl, td, z); - if (s->sub.decode.codes == Z_NULL) - { - r = Z_MEM_ERROR; - LEAVE - } - } - DUMPBITS(3) - s->mode = CODES; - break; - case 2: /* dynamic */ - Tracev((stderr, "inflate: dynamic codes block%s\n", - s->last ? " (last)" : "")); - DUMPBITS(3) - s->mode = TABLE; - break; - case 3: /* illegal */ - DUMPBITS(3) - s->mode = BAD; - z->msg = (char*)"invalid block type"; - r = Z_DATA_ERROR; - LEAVE - } - break; - case LENS: - NEEDBITS(32) - if ((((~b) >> 16) & 0xffff) != (b & 0xffff)) - { - s->mode = BAD; - z->msg = (char*)"invalid stored block lengths"; - r = Z_DATA_ERROR; - LEAVE - } - s->sub.left = (uInt)b & 0xffff; - b = k = 0; /* dump bits */ - Tracev((stderr, "inflate: stored length %u\n", s->sub.left)); - s->mode = s->sub.left ? STORED : (s->last ? DRY : TYPE); - break; - case STORED: - if (n == 0) - LEAVE - NEEDOUT - t = s->sub.left; - if (t > n) t = n; - if (t > m) t = m; - zmemcpy(q, p, t); - p += t; n -= t; - q += t; m -= t; - if ((s->sub.left -= t) != 0) - break; - Tracev((stderr, "inflate: stored end, %lu total out\n", - z->total_out + (q >= s->read ? q - s->read : - (s->end - s->read) + (q - s->window)))); - s->mode = s->last ? DRY : TYPE; - break; - case TABLE: - NEEDBITS(14) - s->sub.trees.table = t = (uInt)b & 0x3fff; -#ifndef PKZIP_BUG_WORKAROUND - if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29) - { - s->mode = BAD; - z->msg = (char*)"too many length or distance symbols"; - r = Z_DATA_ERROR; - LEAVE - } -#endif - t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f); - if ((s->sub.trees.blens = (uIntf*)ZALLOC(z, t, sizeof(uInt))) == Z_NULL) - { - r = Z_MEM_ERROR; - LEAVE - } - DUMPBITS(14) - s->sub.trees.index = 0; - Tracev((stderr, "inflate: table sizes ok\n")); - s->mode = BTREE; - case BTREE: - while (s->sub.trees.index < 4 + (s->sub.trees.table >> 10)) - { - NEEDBITS(3) - s->sub.trees.blens[border[s->sub.trees.index++]] = (uInt)b & 7; - DUMPBITS(3) - } - while (s->sub.trees.index < 19) - s->sub.trees.blens[border[s->sub.trees.index++]] = 0; - s->sub.trees.bb = 7; - t = inflate_trees_bits(s->sub.trees.blens, &s->sub.trees.bb, - &s->sub.trees.tb, s->hufts, z); - if (t != Z_OK) - { - r = t; - if (r == Z_DATA_ERROR) - { - ZFREE(z, s->sub.trees.blens); - s->mode = BAD; - } - LEAVE - } - s->sub.trees.index = 0; - Tracev((stderr, "inflate: bits tree ok\n")); - s->mode = DTREE; - case DTREE: - while (t = s->sub.trees.table, - s->sub.trees.index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f)) - { - inflate_huft *h; - uInt i, j, c; - - t = s->sub.trees.bb; - NEEDBITS(t) - h = s->sub.trees.tb + ((uInt)b & inflate_mask[t]); - t = h->bits; - c = h->base; - if (c < 16) - { - DUMPBITS(t) - s->sub.trees.blens[s->sub.trees.index++] = c; - } - else /* c == 16..18 */ - { - i = c == 18 ? 7 : c - 14; - j = c == 18 ? 11 : 3; - NEEDBITS(t + i) - DUMPBITS(t) - j += (uInt)b & inflate_mask[i]; - DUMPBITS(i) - i = s->sub.trees.index; - t = s->sub.trees.table; - if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) || - (c == 16 && i < 1)) - { - ZFREE(z, s->sub.trees.blens); - s->mode = BAD; - z->msg = (char*)"invalid bit length repeat"; - r = Z_DATA_ERROR; - LEAVE - } - c = c == 16 ? s->sub.trees.blens[i - 1] : 0; - do { - s->sub.trees.blens[i++] = c; - } while (--j); - s->sub.trees.index = i; - } - } - s->sub.trees.tb = Z_NULL; - { - uInt bl, bd; - inflate_huft *tl, *td; - inflate_codes_statef *c; - - bl = 9; /* must be <= 9 for lookahead assumptions */ - bd = 6; /* must be <= 9 for lookahead assumptions */ - t = s->sub.trees.table; - t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f), - s->sub.trees.blens, &bl, &bd, &tl, &td, - s->hufts, z); - if (t != Z_OK) - { - if (t == (uInt)Z_DATA_ERROR) - { - ZFREE(z, s->sub.trees.blens); - s->mode = BAD; - } - r = t; - LEAVE - } - Tracev((stderr, "inflate: trees ok\n")); - if ((c = inflate_codes_new(bl, bd, tl, td, z)) == Z_NULL) - { - r = Z_MEM_ERROR; - LEAVE - } - s->sub.decode.codes = c; - } - ZFREE(z, s->sub.trees.blens); - s->mode = CODES; - case CODES: - UPDATE - if ((r = inflate_codes(s, z, r)) != Z_STREAM_END) - return inflate_flush(s, z, r); - r = Z_OK; - inflate_codes_free(s->sub.decode.codes, z); - LOAD - Tracev((stderr, "inflate: codes end, %lu total out\n", - z->total_out + (q >= s->read ? q - s->read : - (s->end - s->read) + (q - s->window)))); - if (!s->last) - { - s->mode = TYPE; - break; - } - s->mode = DRY; - case DRY: - FLUSH - if (s->read != s->write) - LEAVE - s->mode = DONE; - case DONE: - r = Z_STREAM_END; - LEAVE - case BAD: - r = Z_DATA_ERROR; - LEAVE - default: - r = Z_STREAM_ERROR; - LEAVE - } -} - - -int inflate_blocks_free(s, z) -inflate_blocks_statef *s; -z_streamp z; -{ - inflate_blocks_reset(s, z, Z_NULL); - ZFREE(z, s->window); - ZFREE(z, s->hufts); - ZFREE(z, s); - Tracev((stderr, "inflate: blocks freed\n")); - return Z_OK; -} - - -void inflate_set_dictionary(s, d, n) -inflate_blocks_statef *s; -const Bytef *d; -uInt n; -{ - zmemcpy(s->window, d, n); - s->read = s->write = s->window + n; -} - - -/* Returns true if inflate is currently at the end of a block generated - * by Z_SYNC_FLUSH or Z_FULL_FLUSH. - * IN assertion: s != Z_NULL - */ -int inflate_blocks_sync_point(s) -inflate_blocks_statef *s; -{ - return s->mode == LENS; -} diff --git a/src/crashrpt/zlib/infblock.h b/src/crashrpt/zlib/infblock.h deleted file mode 100644 index 4cf0fa969..000000000 --- a/src/crashrpt/zlib/infblock.h +++ /dev/null @@ -1,39 +0,0 @@ -/* infblock.h -- header to use infblock.c - * Copyright (C) 1995-2002 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. - */ - -struct inflate_blocks_state; -typedef struct inflate_blocks_state FAR inflate_blocks_statef; - -extern inflate_blocks_statef * inflate_blocks_new OF(( - z_streamp z, - check_func c, /* check function */ - uInt w)); /* window size */ - -extern int inflate_blocks OF(( - inflate_blocks_statef *, - z_streamp , - int)); /* initial return code */ - -extern void inflate_blocks_reset OF(( - inflate_blocks_statef *, - z_streamp , - uLongf *)); /* check value on output */ - -extern int inflate_blocks_free OF(( - inflate_blocks_statef *, - z_streamp)); - -extern void inflate_set_dictionary OF(( - inflate_blocks_statef *s, - const Bytef *d, /* dictionary */ - uInt n)); /* dictionary length */ - -extern int inflate_blocks_sync_point OF(( - inflate_blocks_statef *s)); diff --git a/src/crashrpt/zlib/infcodes.c b/src/crashrpt/zlib/infcodes.c deleted file mode 100644 index aa7b3a037..000000000 --- a/src/crashrpt/zlib/infcodes.c +++ /dev/null @@ -1,251 +0,0 @@ -/* infcodes.c -- process literals and length/distance pairs - * Copyright (C) 1995-2002 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "inftrees.h" -#include "infblock.h" -#include "infcodes.h" -#include "infutil.h" -#include "inffast.h" - -/* simplify the use of the inflate_huft type with some defines */ -#define exop word.what.Exop -#define bits word.what.Bits - -typedef enum { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */ - START, /* x: set up for LEN */ - LEN, /* i: get length/literal/eob next */ - LENEXT, /* i: getting length extra (have base) */ - DIST, /* i: get distance next */ - DISTEXT, /* i: getting distance extra */ - COPY, /* o: copying bytes in window, waiting for space */ - LIT, /* o: got literal, waiting for output space */ - WASH, /* o: got eob, possibly still output waiting */ - END, /* x: got eob and all data flushed */ - BADCODE} /* x: got error */ -inflate_codes_mode; - -/* inflate codes private state */ -struct inflate_codes_state { - - /* mode */ - inflate_codes_mode mode; /* current inflate_codes mode */ - - /* mode dependent information */ - uInt len; - union { - struct { - inflate_huft *tree; /* pointer into tree */ - uInt need; /* bits needed */ - } code; /* if LEN or DIST, where in tree */ - uInt lit; /* if LIT, literal */ - struct { - uInt get; /* bits to get for extra */ - uInt dist; /* distance back to copy from */ - } copy; /* if EXT or COPY, where and how much */ - } sub; /* submode */ - - /* mode independent information */ - Byte lbits; /* ltree bits decoded per branch */ - Byte dbits; /* dtree bits decoder per branch */ - inflate_huft *ltree; /* literal/length/eob tree */ - inflate_huft *dtree; /* distance tree */ - -}; - - -inflate_codes_statef *inflate_codes_new(bl, bd, tl, td, z) -uInt bl, bd; -inflate_huft *tl; -inflate_huft *td; /* need separate declaration for Borland C++ */ -z_streamp z; -{ - inflate_codes_statef *c; - - if ((c = (inflate_codes_statef *) - ZALLOC(z,1,sizeof(struct inflate_codes_state))) != Z_NULL) - { - c->mode = START; - c->lbits = (Byte)bl; - c->dbits = (Byte)bd; - c->ltree = tl; - c->dtree = td; - Tracev((stderr, "inflate: codes new\n")); - } - return c; -} - - -int inflate_codes(s, z, r) -inflate_blocks_statef *s; -z_streamp z; -int r; -{ - uInt j; /* temporary storage */ - inflate_huft *t; /* temporary pointer */ - uInt e; /* extra bits or operation */ - uLong b; /* bit buffer */ - uInt k; /* bits in bit buffer */ - Bytef *p; /* input data pointer */ - uInt n; /* bytes available there */ - Bytef *q; /* output window write pointer */ - uInt m; /* bytes to end of window or read pointer */ - Bytef *f; /* pointer to copy strings from */ - inflate_codes_statef *c = s->sub.decode.codes; /* codes state */ - - /* copy input/output information to locals (UPDATE macro restores) */ - LOAD - - /* process input and output based on current state */ - while (1) switch (c->mode) - { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */ - case START: /* x: set up for LEN */ -#ifndef SLOW - if (m >= 258 && n >= 10) - { - UPDATE - r = inflate_fast(c->lbits, c->dbits, c->ltree, c->dtree, s, z); - LOAD - if (r != Z_OK) - { - c->mode = r == Z_STREAM_END ? WASH : BADCODE; - break; - } - } -#endif /* !SLOW */ - c->sub.code.need = c->lbits; - c->sub.code.tree = c->ltree; - c->mode = LEN; - case LEN: /* i: get length/literal/eob next */ - j = c->sub.code.need; - NEEDBITS(j) - t = c->sub.code.tree + ((uInt)b & inflate_mask[j]); - DUMPBITS(t->bits) - e = (uInt)(t->exop); - if (e == 0) /* literal */ - { - c->sub.lit = t->base; - Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? - "inflate: literal '%c'\n" : - "inflate: literal 0x%02x\n", t->base)); - c->mode = LIT; - break; - } - if (e & 16) /* length */ - { - c->sub.copy.get = e & 15; - c->len = t->base; - c->mode = LENEXT; - break; - } - if ((e & 64) == 0) /* next table */ - { - c->sub.code.need = e; - c->sub.code.tree = t + t->base; - break; - } - if (e & 32) /* end of block */ - { - Tracevv((stderr, "inflate: end of block\n")); - c->mode = WASH; - break; - } - c->mode = BADCODE; /* invalid code */ - z->msg = (char*)"invalid literal/length code"; - r = Z_DATA_ERROR; - LEAVE - case LENEXT: /* i: getting length extra (have base) */ - j = c->sub.copy.get; - NEEDBITS(j) - c->len += (uInt)b & inflate_mask[j]; - DUMPBITS(j) - c->sub.code.need = c->dbits; - c->sub.code.tree = c->dtree; - Tracevv((stderr, "inflate: length %u\n", c->len)); - c->mode = DIST; - case DIST: /* i: get distance next */ - j = c->sub.code.need; - NEEDBITS(j) - t = c->sub.code.tree + ((uInt)b & inflate_mask[j]); - DUMPBITS(t->bits) - e = (uInt)(t->exop); - if (e & 16) /* distance */ - { - c->sub.copy.get = e & 15; - c->sub.copy.dist = t->base; - c->mode = DISTEXT; - break; - } - if ((e & 64) == 0) /* next table */ - { - c->sub.code.need = e; - c->sub.code.tree = t + t->base; - break; - } - c->mode = BADCODE; /* invalid code */ - z->msg = (char*)"invalid distance code"; - r = Z_DATA_ERROR; - LEAVE - case DISTEXT: /* i: getting distance extra */ - j = c->sub.copy.get; - NEEDBITS(j) - c->sub.copy.dist += (uInt)b & inflate_mask[j]; - DUMPBITS(j) - Tracevv((stderr, "inflate: distance %u\n", c->sub.copy.dist)); - c->mode = COPY; - case COPY: /* o: copying bytes in window, waiting for space */ - f = q - c->sub.copy.dist; - while (f < s->window) /* modulo window size-"while" instead */ - f += s->end - s->window; /* of "if" handles invalid distances */ - while (c->len) - { - NEEDOUT - OUTBYTE(*f++) - if (f == s->end) - f = s->window; - c->len--; - } - c->mode = START; - break; - case LIT: /* o: got literal, waiting for output space */ - NEEDOUT - OUTBYTE(c->sub.lit) - c->mode = START; - break; - case WASH: /* o: got eob, possibly more output */ - if (k > 7) /* return unused byte, if any */ - { - Assert(k < 16, "inflate_codes grabbed too many bytes") - k -= 8; - n++; - p--; /* can always return one */ - } - FLUSH - if (s->read != s->write) - LEAVE - c->mode = END; - case END: - r = Z_STREAM_END; - LEAVE - case BADCODE: /* x: got error */ - r = Z_DATA_ERROR; - LEAVE - default: - r = Z_STREAM_ERROR; - LEAVE - } -#ifdef NEED_DUMMY_RETURN - return Z_STREAM_ERROR; /* Some dumb compilers complain without this */ -#endif -} - - -void inflate_codes_free(c, z) -inflate_codes_statef *c; -z_streamp z; -{ - ZFREE(z, c); - Tracev((stderr, "inflate: codes free\n")); -} diff --git a/src/crashrpt/zlib/infcodes.h b/src/crashrpt/zlib/infcodes.h deleted file mode 100644 index 531d41927..000000000 --- a/src/crashrpt/zlib/infcodes.h +++ /dev/null @@ -1,27 +0,0 @@ -/* infcodes.h -- header to use infcodes.c - * Copyright (C) 1995-2002 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. - */ - -struct inflate_codes_state; -typedef struct inflate_codes_state FAR inflate_codes_statef; - -extern inflate_codes_statef *inflate_codes_new OF(( - uInt, uInt, - inflate_huft *, inflate_huft *, - z_streamp )); - -extern int inflate_codes OF(( - inflate_blocks_statef *, - z_streamp , - int)); - -extern void inflate_codes_free OF(( - inflate_codes_statef *, - z_streamp )); - diff --git a/src/crashrpt/zlib/inffast.c b/src/crashrpt/zlib/inffast.c deleted file mode 100644 index 655eaf0b8..000000000 --- a/src/crashrpt/zlib/inffast.c +++ /dev/null @@ -1,183 +0,0 @@ -/* inffast.c -- process literals and length/distance pairs fast - * Copyright (C) 1995-2002 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "inftrees.h" -#include "infblock.h" -#include "infcodes.h" -#include "infutil.h" -#include "inffast.h" - -struct inflate_codes_state {int dummy;}; /* for buggy compilers */ - -/* simplify the use of the inflate_huft type with some defines */ -#define exop word.what.Exop -#define bits word.what.Bits - -/* macros for bit input with no checking and for returning unused bytes */ -#define GRABBITS(j) {while(k<(j)){b|=((uLong)NEXTBYTE)<avail_in-n;c=(k>>3)>3:c;n+=c;p-=c;k-=c<<3;} - -/* Called with number of bytes left to write in window at least 258 - (the maximum string length) and number of input bytes available - at least ten. The ten bytes are six bytes for the longest length/ - distance pair plus four bytes for overloading the bit buffer. */ - -int inflate_fast(bl, bd, tl, td, s, z) -uInt bl, bd; -inflate_huft *tl; -inflate_huft *td; /* need separate declaration for Borland C++ */ -inflate_blocks_statef *s; -z_streamp z; -{ - inflate_huft *t; /* temporary pointer */ - uInt e; /* extra bits or operation */ - uLong b; /* bit buffer */ - uInt k; /* bits in bit buffer */ - Bytef *p; /* input data pointer */ - uInt n; /* bytes available there */ - Bytef *q; /* output window write pointer */ - uInt m; /* bytes to end of window or read pointer */ - uInt ml; /* mask for literal/length tree */ - uInt md; /* mask for distance tree */ - uInt c; /* bytes to copy */ - uInt d; /* distance back to copy from */ - Bytef *r; /* copy source pointer */ - - /* load input, output, bit values */ - LOAD - - /* initialize masks */ - ml = inflate_mask[bl]; - md = inflate_mask[bd]; - - /* do until not enough input or output space for fast loop */ - do { /* assume called with m >= 258 && n >= 10 */ - /* get literal/length code */ - GRABBITS(20) /* max bits for literal/length code */ - if ((e = (t = tl + ((uInt)b & ml))->exop) == 0) - { - DUMPBITS(t->bits) - Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? - "inflate: * literal '%c'\n" : - "inflate: * literal 0x%02x\n", t->base)); - *q++ = (Byte)t->base; - m--; - continue; - } - do { - DUMPBITS(t->bits) - if (e & 16) - { - /* get extra bits for length */ - e &= 15; - c = t->base + ((uInt)b & inflate_mask[e]); - DUMPBITS(e) - Tracevv((stderr, "inflate: * length %u\n", c)); - - /* decode distance base of block to copy */ - GRABBITS(15); /* max bits for distance code */ - e = (t = td + ((uInt)b & md))->exop; - do { - DUMPBITS(t->bits) - if (e & 16) - { - /* get extra bits to add to distance base */ - e &= 15; - GRABBITS(e) /* get extra bits (up to 13) */ - d = t->base + ((uInt)b & inflate_mask[e]); - DUMPBITS(e) - Tracevv((stderr, "inflate: * distance %u\n", d)); - - /* do the copy */ - m -= c; - r = q - d; - if (r < s->window) /* wrap if needed */ - { - do { - r += s->end - s->window; /* force pointer in window */ - } while (r < s->window); /* covers invalid distances */ - e = s->end - r; - if (c > e) - { - c -= e; /* wrapped copy */ - do { - *q++ = *r++; - } while (--e); - r = s->window; - do { - *q++ = *r++; - } while (--c); - } - else /* normal copy */ - { - *q++ = *r++; c--; - *q++ = *r++; c--; - do { - *q++ = *r++; - } while (--c); - } - } - else /* normal copy */ - { - *q++ = *r++; c--; - *q++ = *r++; c--; - do { - *q++ = *r++; - } while (--c); - } - break; - } - else if ((e & 64) == 0) - { - t += t->base; - e = (t += ((uInt)b & inflate_mask[e]))->exop; - } - else - { - z->msg = (char*)"invalid distance code"; - UNGRAB - UPDATE - return Z_DATA_ERROR; - } - } while (1); - break; - } - if ((e & 64) == 0) - { - t += t->base; - if ((e = (t += ((uInt)b & inflate_mask[e]))->exop) == 0) - { - DUMPBITS(t->bits) - Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? - "inflate: * literal '%c'\n" : - "inflate: * literal 0x%02x\n", t->base)); - *q++ = (Byte)t->base; - m--; - break; - } - } - else if (e & 32) - { - Tracevv((stderr, "inflate: * end of block\n")); - UNGRAB - UPDATE - return Z_STREAM_END; - } - else - { - z->msg = (char*)"invalid literal/length code"; - UNGRAB - UPDATE - return Z_DATA_ERROR; - } - } while (1); - } while (m >= 258 && n >= 10); - - /* not enough input or output--restore pointers and return */ - UNGRAB - UPDATE - return Z_OK; -} diff --git a/src/crashrpt/zlib/inffast.h b/src/crashrpt/zlib/inffast.h deleted file mode 100644 index ac643b329..000000000 --- a/src/crashrpt/zlib/inffast.h +++ /dev/null @@ -1,17 +0,0 @@ -/* inffast.h -- header to use inffast.c - * Copyright (C) 1995-2002 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. - */ - -extern int inflate_fast OF(( - uInt, - uInt, - inflate_huft *, - inflate_huft *, - inflate_blocks_statef *, - z_streamp )); diff --git a/src/crashrpt/zlib/inffixed.h b/src/crashrpt/zlib/inffixed.h deleted file mode 100644 index e997507c3..000000000 --- a/src/crashrpt/zlib/inffixed.h +++ /dev/null @@ -1,151 +0,0 @@ -/* inffixed.h -- table for decoding fixed codes - * Generated automatically by the maketree.c program - */ - -/* 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. - */ - -local uInt fixed_bl = 9; -local uInt fixed_bd = 5; -local inflate_huft fixed_tl[] = { - {{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115}, - {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},192}, - {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},160}, - {{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},224}, - {{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},144}, - {{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},208}, - {{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},176}, - {{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},240}, - {{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227}, - {{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},200}, - {{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},168}, - {{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},232}, - {{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},152}, - {{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},216}, - {{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},184}, - {{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},248}, - {{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163}, - {{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},196}, - {{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},164}, - {{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},228}, - {{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},148}, - {{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},212}, - {{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},180}, - {{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},244}, - {{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0}, - {{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},204}, - {{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},172}, - {{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},236}, - {{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},156}, - {{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},220}, - {{{82,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}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131}, - {{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},194}, - {{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},162}, - {{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},226}, - {{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},146}, - {{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},210}, - {{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},178}, - {{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},242}, - {{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258}, - {{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},202}, - {{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},170}, - {{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},234}, - {{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},154}, - {{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},218}, - {{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},186}, - {{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},250}, - {{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195}, - {{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},198}, - {{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},166}, - {{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},230}, - {{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},150}, - {{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},214}, - {{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},182}, - {{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},246}, - {{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0}, - {{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},206}, - {{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},174}, - {{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},238}, - {{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},158}, - {{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},222}, - {{{82,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}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115}, - {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},193}, - {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},161}, - {{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},225}, - {{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},145}, - {{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},209}, - {{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},177}, - {{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},241}, - {{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227}, - {{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},201}, - {{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},169}, - {{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},233}, - {{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},153}, - {{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},217}, - {{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},185}, - {{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},249}, - {{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163}, - {{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},197}, - {{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},165}, - {{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},229}, - {{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},149}, - {{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},213}, - {{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},181}, - {{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},245}, - {{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0}, - {{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},205}, - {{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},173}, - {{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},237}, - {{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},157}, - {{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},221}, - {{{82,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}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131}, - {{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},195}, - {{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},163}, - {{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},227}, - {{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},147}, - {{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},211}, - {{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},179}, - {{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},243}, - {{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258}, - {{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},203}, - {{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},171}, - {{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},235}, - {{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},155}, - {{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},219}, - {{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},187}, - {{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},251}, - {{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195}, - {{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},199}, - {{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},167}, - {{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},231}, - {{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},151}, - {{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},215}, - {{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},183}, - {{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},247}, - {{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0}, - {{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},207}, - {{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},175}, - {{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},239}, - {{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},159}, - {{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},223}, - {{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},191}, - {{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},255} - }; -local inflate_huft fixed_td[] = { - {{{80,5}},1}, {{{87,5}},257}, {{{83,5}},17}, {{{91,5}},4097}, - {{{81,5}},5}, {{{89,5}},1025}, {{{85,5}},65}, {{{93,5}},16385}, - {{{80,5}},3}, {{{88,5}},513}, {{{84,5}},33}, {{{92,5}},8193}, - {{{82,5}},9}, {{{90,5}},2049}, {{{86,5}},129}, {{{192,5}},24577}, - {{{80,5}},2}, {{{87,5}},385}, {{{83,5}},25}, {{{91,5}},6145}, - {{{81,5}},7}, {{{89,5}},1537}, {{{85,5}},97}, {{{93,5}},24577}, - {{{80,5}},4}, {{{88,5}},769}, {{{84,5}},49}, {{{92,5}},12289}, - {{{82,5}},13}, {{{90,5}},3073}, {{{86,5}},193}, {{{192,5}},24577} - }; diff --git a/src/crashrpt/zlib/inflate.c b/src/crashrpt/zlib/inflate.c deleted file mode 100644 index 5577e0203..000000000 --- a/src/crashrpt/zlib/inflate.c +++ /dev/null @@ -1,366 +0,0 @@ -/* inflate.c -- zlib interface to inflate modules - * Copyright (C) 1995-2002 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "infblock.h" - -struct inflate_blocks_state {int dummy;}; /* for buggy compilers */ - -typedef enum { - METHOD, /* waiting for method byte */ - FLAG, /* waiting for flag byte */ - DICT4, /* four dictionary check bytes to go */ - DICT3, /* three dictionary check bytes to go */ - DICT2, /* two dictionary check bytes to go */ - DICT1, /* one dictionary check byte to go */ - DICT0, /* waiting for inflateSetDictionary */ - BLOCKS, /* decompressing blocks */ - CHECK4, /* four check bytes to go */ - CHECK3, /* three check bytes to go */ - CHECK2, /* two check bytes to go */ - CHECK1, /* one check byte to go */ - DONE, /* finished check, done */ - BAD} /* got an error--stay here */ -inflate_mode; - -/* inflate private state */ -struct internal_state { - - /* mode */ - inflate_mode mode; /* current inflate mode */ - - /* mode dependent information */ - union { - uInt method; /* if FLAGS, method byte */ - struct { - uLong was; /* computed check value */ - uLong need; /* stream check value */ - } check; /* if CHECK, check values to compare */ - uInt marker; /* if BAD, inflateSync's marker bytes count */ - } sub; /* submode */ - - /* mode independent information */ - int nowrap; /* flag for no wrapper */ - uInt wbits; /* log2(window size) (8..15, defaults to 15) */ - inflate_blocks_statef - *blocks; /* current inflate_blocks state */ - -}; - - -int ZEXPORT inflateReset(z) -z_streamp z; -{ - if (z == Z_NULL || z->state == Z_NULL) - return Z_STREAM_ERROR; - z->total_in = z->total_out = 0; - z->msg = Z_NULL; - z->state->mode = z->state->nowrap ? BLOCKS : METHOD; - inflate_blocks_reset(z->state->blocks, z, Z_NULL); - Tracev((stderr, "inflate: reset\n")); - return Z_OK; -} - - -int ZEXPORT inflateEnd(z) -z_streamp z; -{ - if (z == Z_NULL || z->state == Z_NULL || z->zfree == Z_NULL) - return Z_STREAM_ERROR; - if (z->state->blocks != Z_NULL) - inflate_blocks_free(z->state->blocks, z); - ZFREE(z, z->state); - z->state = Z_NULL; - Tracev((stderr, "inflate: end\n")); - return Z_OK; -} - - -int ZEXPORT inflateInit2_(z, w, version, stream_size) -z_streamp z; -int w; -const char *version; -int stream_size; -{ - if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || - stream_size != sizeof(z_stream)) - return Z_VERSION_ERROR; - - /* initialize state */ - if (z == Z_NULL) - return Z_STREAM_ERROR; - z->msg = Z_NULL; - if (z->zalloc == Z_NULL) - { - z->zalloc = zcalloc; - z->opaque = (voidpf)0; - } - if (z->zfree == Z_NULL) z->zfree = zcfree; - if ((z->state = (struct internal_state FAR *) - ZALLOC(z,1,sizeof(struct internal_state))) == Z_NULL) - return Z_MEM_ERROR; - z->state->blocks = Z_NULL; - - /* handle undocumented nowrap option (no zlib header or check) */ - z->state->nowrap = 0; - if (w < 0) - { - w = - w; - z->state->nowrap = 1; - } - - /* set window size */ - if (w < 8 || w > 15) - { - inflateEnd(z); - return Z_STREAM_ERROR; - } - z->state->wbits = (uInt)w; - - /* create inflate_blocks state */ - if ((z->state->blocks = - inflate_blocks_new(z, z->state->nowrap ? Z_NULL : adler32, (uInt)1 << w)) - == Z_NULL) - { - inflateEnd(z); - return Z_MEM_ERROR; - } - Tracev((stderr, "inflate: allocated\n")); - - /* reset state */ - inflateReset(z); - return Z_OK; -} - - -int ZEXPORT inflateInit_(z, version, stream_size) -z_streamp z; -const char *version; -int stream_size; -{ - return inflateInit2_(z, DEF_WBITS, version, stream_size); -} - - -#define NEEDBYTE {if(z->avail_in==0)return r;r=f;} -#define NEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++) - -int ZEXPORT inflate(z, f) -z_streamp z; -int f; -{ - int r; - uInt b; - - if (z == Z_NULL || z->state == Z_NULL || z->next_in == Z_NULL) - return Z_STREAM_ERROR; - f = f == Z_FINISH ? Z_BUF_ERROR : Z_OK; - r = Z_BUF_ERROR; - while (1) switch (z->state->mode) - { - case METHOD: - NEEDBYTE - if (((z->state->sub.method = NEXTBYTE) & 0xf) != Z_DEFLATED) - { - z->state->mode = BAD; - z->msg = (char*)"unknown compression method"; - z->state->sub.marker = 5; /* can't try inflateSync */ - break; - } - if ((z->state->sub.method >> 4) + 8 > z->state->wbits) - { - z->state->mode = BAD; - z->msg = (char*)"invalid window size"; - z->state->sub.marker = 5; /* can't try inflateSync */ - break; - } - z->state->mode = FLAG; - case FLAG: - NEEDBYTE - b = NEXTBYTE; - if (((z->state->sub.method << 8) + b) % 31) - { - z->state->mode = BAD; - z->msg = (char*)"incorrect header check"; - z->state->sub.marker = 5; /* can't try inflateSync */ - break; - } - Tracev((stderr, "inflate: zlib header ok\n")); - if (!(b & PRESET_DICT)) - { - z->state->mode = BLOCKS; - break; - } - z->state->mode = DICT4; - case DICT4: - NEEDBYTE - z->state->sub.check.need = (uLong)NEXTBYTE << 24; - z->state->mode = DICT3; - case DICT3: - NEEDBYTE - z->state->sub.check.need += (uLong)NEXTBYTE << 16; - z->state->mode = DICT2; - case DICT2: - NEEDBYTE - z->state->sub.check.need += (uLong)NEXTBYTE << 8; - z->state->mode = DICT1; - case DICT1: - NEEDBYTE - z->state->sub.check.need += (uLong)NEXTBYTE; - z->adler = z->state->sub.check.need; - z->state->mode = DICT0; - return Z_NEED_DICT; - case DICT0: - z->state->mode = BAD; - z->msg = (char*)"need dictionary"; - z->state->sub.marker = 0; /* can try inflateSync */ - return Z_STREAM_ERROR; - case BLOCKS: - r = inflate_blocks(z->state->blocks, z, r); - if (r == Z_DATA_ERROR) - { - z->state->mode = BAD; - z->state->sub.marker = 0; /* can try inflateSync */ - break; - } - if (r == Z_OK) - r = f; - if (r != Z_STREAM_END) - return r; - r = f; - inflate_blocks_reset(z->state->blocks, z, &z->state->sub.check.was); - if (z->state->nowrap) - { - z->state->mode = DONE; - break; - } - z->state->mode = CHECK4; - case CHECK4: - NEEDBYTE - z->state->sub.check.need = (uLong)NEXTBYTE << 24; - z->state->mode = CHECK3; - case CHECK3: - NEEDBYTE - z->state->sub.check.need += (uLong)NEXTBYTE << 16; - z->state->mode = CHECK2; - case CHECK2: - NEEDBYTE - z->state->sub.check.need += (uLong)NEXTBYTE << 8; - z->state->mode = CHECK1; - case CHECK1: - NEEDBYTE - z->state->sub.check.need += (uLong)NEXTBYTE; - - if (z->state->sub.check.was != z->state->sub.check.need) - { - z->state->mode = BAD; - z->msg = (char*)"incorrect data check"; - z->state->sub.marker = 5; /* can't try inflateSync */ - break; - } - Tracev((stderr, "inflate: zlib check ok\n")); - z->state->mode = DONE; - case DONE: - return Z_STREAM_END; - case BAD: - return Z_DATA_ERROR; - default: - return Z_STREAM_ERROR; - } -#ifdef NEED_DUMMY_RETURN - return Z_STREAM_ERROR; /* Some dumb compilers complain without this */ -#endif -} - - -int ZEXPORT inflateSetDictionary(z, dictionary, dictLength) -z_streamp z; -const Bytef *dictionary; -uInt dictLength; -{ - uInt length = dictLength; - - if (z == Z_NULL || z->state == Z_NULL || z->state->mode != DICT0) - return Z_STREAM_ERROR; - - if (adler32(1L, dictionary, dictLength) != z->adler) return Z_DATA_ERROR; - z->adler = 1L; - - if (length >= ((uInt)1<state->wbits)) - { - length = (1<state->wbits)-1; - dictionary += dictLength - length; - } - inflate_set_dictionary(z->state->blocks, dictionary, length); - z->state->mode = BLOCKS; - return Z_OK; -} - - -int ZEXPORT inflateSync(z) -z_streamp z; -{ - uInt n; /* number of bytes to look at */ - Bytef *p; /* pointer to bytes */ - uInt m; /* number of marker bytes found in a row */ - uLong r, w; /* temporaries to save total_in and total_out */ - - /* set up */ - if (z == Z_NULL || z->state == Z_NULL) - return Z_STREAM_ERROR; - if (z->state->mode != BAD) - { - z->state->mode = BAD; - z->state->sub.marker = 0; - } - if ((n = z->avail_in) == 0) - return Z_BUF_ERROR; - p = z->next_in; - m = z->state->sub.marker; - - /* search */ - while (n && m < 4) - { - static const Byte mark[4] = {0, 0, 0xff, 0xff}; - if (*p == mark[m]) - m++; - else if (*p) - m = 0; - else - m = 4 - m; - p++, n--; - } - - /* restore */ - z->total_in += p - z->next_in; - z->next_in = p; - z->avail_in = n; - z->state->sub.marker = m; - - /* return no joy or set up to restart on a new block */ - if (m != 4) - return Z_DATA_ERROR; - r = z->total_in; w = z->total_out; - inflateReset(z); - z->total_in = r; z->total_out = w; - z->state->mode = BLOCKS; - 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(z) -z_streamp z; -{ - if (z == Z_NULL || z->state == Z_NULL || z->state->blocks == Z_NULL) - return Z_STREAM_ERROR; - return inflate_blocks_sync_point(z->state->blocks); -} diff --git a/src/crashrpt/zlib/inftrees.c b/src/crashrpt/zlib/inftrees.c deleted file mode 100644 index f89e801f3..000000000 --- a/src/crashrpt/zlib/inftrees.c +++ /dev/null @@ -1,454 +0,0 @@ -/* inftrees.c -- generate Huffman trees for efficient decoding - * Copyright (C) 1995-2002 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "inftrees.h" - -#if !defined(BUILDFIXED) && !defined(STDC) -# define BUILDFIXED /* non ANSI compilers may not accept inffixed.h */ -#endif - -const char inflate_copyright[] = - " inflate 1.1.4 Copyright 1995-2002 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. - */ -struct internal_state {int dummy;}; /* for buggy compilers */ - -/* simplify the use of the inflate_huft type with some defines */ -#define exop word.what.Exop -#define bits word.what.Bits - - -local int huft_build OF(( - uIntf *, /* code lengths in bits */ - uInt, /* number of codes */ - uInt, /* number of "simple" codes */ - const uIntf *, /* list of base values for non-simple codes */ - const uIntf *, /* list of extra bits for non-simple codes */ - inflate_huft * FAR*,/* result: starting table */ - uIntf *, /* maximum lookup bits (returns actual) */ - inflate_huft *, /* space for trees */ - uInt *, /* hufts used in space */ - uIntf * )); /* space for values */ - -/* Tables for deflate from PKZIP's appnote.txt. */ -local const uInt cplens[31] = { /* Copy lengths for literal codes 257..285 */ - 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}; - /* see note #13 above about 258 */ -local const uInt cplext[31] = { /* Extra bits for literal codes 257..285 */ - 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, 112, 112}; /* 112==invalid */ -local const uInt cpdist[30] = { /* Copy offsets for distance codes 0..29 */ - 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}; -local const uInt cpdext[30] = { /* Extra bits for distance codes */ - 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}; - -/* - Huffman code decoding is performed using a multi-level table lookup. - The fastest way to decode is to simply build a lookup table whose - size is determined by the longest code. However, the time it takes - to build this table can also be a factor if the data being decoded - is not very long. The most common codes are necessarily the - shortest codes, so those codes dominate the decoding time, and hence - the speed. The idea is you can have a shorter table that decodes the - shorter, more probable codes, and then point to subsidiary tables for - the longer codes. The time it costs to decode the longer codes is - then traded against the time it takes to make longer tables. - - This results of this trade are in the variables lbits and dbits - below. lbits is the number of bits the first level table for literal/ - length codes can decode in one step, and dbits is the same thing for - the distance codes. Subsequent tables are also less than or equal to - those sizes. These values may be adjusted either when all of the - codes are shorter than that, in which case the longest code length in - bits is used, or when the shortest code is *longer* than the requested - table size, in which case the length of the shortest code in bits is - used. - - There are two different values for the two tables, since they code a - different number of possibilities each. The literal/length table - codes 286 possible values, or in a flat code, a little over eight - bits. The distance table codes 30 possible values, or a little less - than five bits, flat. The optimum values for speed end up being - about one bit more than those, so lbits is 8+1 and dbits is 5+1. - The optimum values may differ though from machine to machine, and - possibly even between compilers. Your mileage may vary. - */ - - -/* If BMAX needs to be larger than 16, then h and x[] should be uLong. */ -#define BMAX 15 /* maximum bit length of any code */ - -local int huft_build(b, n, s, d, e, t, m, hp, hn, v) -uIntf *b; /* code lengths in bits (all assumed <= BMAX) */ -uInt n; /* number of codes (assumed <= 288) */ -uInt s; /* number of simple-valued codes (0..s-1) */ -const uIntf *d; /* list of base values for non-simple codes */ -const uIntf *e; /* list of extra bits for non-simple codes */ -inflate_huft * FAR *t; /* result: starting table */ -uIntf *m; /* maximum lookup bits, returns actual */ -inflate_huft *hp; /* space for trees */ -uInt *hn; /* hufts used in space */ -uIntf *v; /* working area: values in order of bit length */ -/* Given a list of code lengths and a maximum table size, make a set of - tables to decode that set of codes. Return Z_OK on success, Z_BUF_ERROR - if the given code set is incomplete (the tables are still built in this - case), or Z_DATA_ERROR if the input is invalid. */ -{ - - uInt a; /* counter for codes of length k */ - uInt c[BMAX+1]; /* bit length count table */ - uInt f; /* i repeats in table every f entries */ - int g; /* maximum code length */ - int h; /* table level */ - register uInt i; /* counter, current code */ - register uInt j; /* counter */ - register int k; /* number of bits in current code */ - int l; /* bits per table (returned in m) */ - uInt mask; /* (1 << w) - 1, to avoid cc -O bug on HP */ - register uIntf *p; /* pointer into c[], b[], or v[] */ - inflate_huft *q; /* points to current table */ - struct inflate_huft_s r; /* table entry for structure assignment */ - inflate_huft *u[BMAX]; /* table stack */ - register int w; /* bits before this table == (l * h) */ - uInt x[BMAX+1]; /* bit offsets, then code stack */ - uIntf *xp; /* pointer into x */ - int y; /* number of dummy codes added */ - uInt z; /* number of entries in current table */ - - - /* Generate counts for each bit length */ - p = c; -#define C0 *p++ = 0; -#define C2 C0 C0 C0 C0 -#define C4 C2 C2 C2 C2 - C4 /* clear c[]--assume BMAX+1 is 16 */ - p = b; i = n; - do { - c[*p++]++; /* assume all entries <= BMAX */ - } while (--i); - if (c[0] == n) /* null input--all zero length codes */ - { - *t = (inflate_huft *)Z_NULL; - *m = 0; - return Z_OK; - } - - - /* Find minimum and maximum length, bound *m by those */ - l = *m; - for (j = 1; j <= BMAX; j++) - if (c[j]) - break; - k = j; /* minimum code length */ - if ((uInt)l < j) - l = j; - for (i = BMAX; i; i--) - if (c[i]) - break; - g = i; /* maximum code length */ - if ((uInt)l > i) - l = i; - *m = l; - - - /* Adjust last length count to fill out codes, if needed */ - for (y = 1 << j; j < i; j++, y <<= 1) - if ((y -= c[j]) < 0) - return Z_DATA_ERROR; - if ((y -= c[i]) < 0) - return Z_DATA_ERROR; - c[i] += y; - - - /* Generate starting offsets into the value table for each length */ - x[1] = j = 0; - p = c + 1; xp = x + 2; - while (--i) { /* note that i == g from above */ - *xp++ = (j += *p++); - } - - - /* Make a table of values in order of bit lengths */ - p = b; i = 0; - do { - if ((j = *p++) != 0) - v[x[j]++] = i; - } while (++i < n); - n = x[g]; /* set n to length of v */ - - - /* Generate the Huffman codes and for each, make the table entries */ - x[0] = i = 0; /* first Huffman code is zero */ - p = v; /* grab values in bit order */ - h = -1; /* no tables yet--level -1 */ - w = -l; /* bits decoded == (l * h) */ - u[0] = (inflate_huft *)Z_NULL; /* just to keep compilers happy */ - q = (inflate_huft *)Z_NULL; /* ditto */ - z = 0; /* ditto */ - - /* go through the bit lengths (k already is bits in shortest code) */ - for (; k <= g; k++) - { - a = c[k]; - while (a--) - { - /* here i is the Huffman code of length k bits for value *p */ - /* make tables up to required level */ - while (k > w + l) - { - h++; - w += l; /* previous table always l bits */ - - /* compute minimum size table less than or equal to l bits */ - z = g - w; - z = z > (uInt)l ? l : z; /* table size upper limit */ - if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */ - { /* too few codes for k-w bit table */ - f -= a + 1; /* deduct codes from patterns left */ - xp = c + k; - if (j < z) - while (++j < z) /* try smaller tables up to z bits */ - { - if ((f <<= 1) <= *++xp) - break; /* enough codes to use up j bits */ - f -= *xp; /* else deduct codes from patterns */ - } - } - z = 1 << j; /* table entries for j-bit table */ - - /* allocate new table */ - if (*hn + z > MANY) /* (note: doesn't matter for fixed) */ - return Z_DATA_ERROR; /* overflow of MANY */ - u[h] = q = hp + *hn; - *hn += z; - - /* connect to last table, if there is one */ - if (h) - { - x[h] = i; /* save pattern for backing up */ - r.bits = (Byte)l; /* bits to dump before this table */ - r.exop = (Byte)j; /* bits in this table */ - j = i >> (w - l); - r.base = (uInt)(q - u[h-1] - j); /* offset to this table */ - u[h-1][j] = r; /* connect to last table */ - } - else - *t = q; /* first table is returned result */ - } - - /* set up table entry in r */ - r.bits = (Byte)(k - w); - if (p >= v + n) - r.exop = 128 + 64; /* out of values--invalid code */ - else if (*p < s) - { - r.exop = (Byte)(*p < 256 ? 0 : 32 + 64); /* 256 is end-of-block */ - r.base = *p++; /* simple code is just the value */ - } - else - { - r.exop = (Byte)(e[*p - s] + 16 + 64);/* non-simple--look up in lists */ - r.base = d[*p++ - s]; - } - - /* fill code-like entries with r */ - f = 1 << (k - w); - for (j = i >> w; j < z; j += f) - q[j] = r; - - /* backwards increment the k-bit code i */ - for (j = 1 << (k - 1); i & j; j >>= 1) - i ^= j; - i ^= j; - - /* backup over finished tables */ - mask = (1 << w) - 1; /* needed on HP, cc -O bug */ - while ((i & mask) != x[h]) - { - h--; /* don't need to update q */ - w -= l; - mask = (1 << w) - 1; - } - } - } - - - /* Return Z_BUF_ERROR if we were given an incomplete table */ - return y != 0 && g != 1 ? Z_BUF_ERROR : Z_OK; -} - - -int inflate_trees_bits(c, bb, tb, hp, z) -uIntf *c; /* 19 code lengths */ -uIntf *bb; /* bits tree desired/actual depth */ -inflate_huft * FAR *tb; /* bits tree result */ -inflate_huft *hp; /* space for trees */ -z_streamp z; /* for messages */ -{ - int r; - uInt hn = 0; /* hufts used in space */ - uIntf *v; /* work area for huft_build */ - - if ((v = (uIntf*)ZALLOC(z, 19, sizeof(uInt))) == Z_NULL) - return Z_MEM_ERROR; - r = huft_build(c, 19, 19, (uIntf*)Z_NULL, (uIntf*)Z_NULL, - tb, bb, hp, &hn, v); - if (r == Z_DATA_ERROR) - z->msg = (char*)"oversubscribed dynamic bit lengths tree"; - else if (r == Z_BUF_ERROR || *bb == 0) - { - z->msg = (char*)"incomplete dynamic bit lengths tree"; - r = Z_DATA_ERROR; - } - ZFREE(z, v); - return r; -} - - -int inflate_trees_dynamic(nl, nd, c, bl, bd, tl, td, hp, z) -uInt nl; /* number of literal/length codes */ -uInt nd; /* number of distance codes */ -uIntf *c; /* that many (total) code lengths */ -uIntf *bl; /* literal desired/actual bit depth */ -uIntf *bd; /* distance desired/actual bit depth */ -inflate_huft * FAR *tl; /* literal/length tree result */ -inflate_huft * FAR *td; /* distance tree result */ -inflate_huft *hp; /* space for trees */ -z_streamp z; /* for messages */ -{ - int r; - uInt hn = 0; /* hufts used in space */ - uIntf *v; /* work area for huft_build */ - - /* allocate work area */ - if ((v = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL) - return Z_MEM_ERROR; - - /* build literal/length tree */ - r = huft_build(c, nl, 257, cplens, cplext, tl, bl, hp, &hn, v); - if (r != Z_OK || *bl == 0) - { - if (r == Z_DATA_ERROR) - z->msg = (char*)"oversubscribed literal/length tree"; - else if (r != Z_MEM_ERROR) - { - z->msg = (char*)"incomplete literal/length tree"; - r = Z_DATA_ERROR; - } - ZFREE(z, v); - return r; - } - - /* build distance tree */ - r = huft_build(c + nl, nd, 0, cpdist, cpdext, td, bd, hp, &hn, v); - if (r != Z_OK || (*bd == 0 && nl > 257)) - { - if (r == Z_DATA_ERROR) - z->msg = (char*)"oversubscribed distance tree"; - else if (r == Z_BUF_ERROR) { -#ifdef PKZIP_BUG_WORKAROUND - r = Z_OK; - } -#else - z->msg = (char*)"incomplete distance tree"; - r = Z_DATA_ERROR; - } - else if (r != Z_MEM_ERROR) - { - z->msg = (char*)"empty distance tree with lengths"; - r = Z_DATA_ERROR; - } - ZFREE(z, v); - return r; -#endif - } - - /* done */ - ZFREE(z, v); - return Z_OK; -} - - -/* build fixed tables only once--keep them here */ -#ifdef BUILDFIXED -local int fixed_built = 0; -#define FIXEDH 544 /* number of hufts used by fixed tables */ -local inflate_huft fixed_mem[FIXEDH]; -local uInt fixed_bl; -local uInt fixed_bd; -local inflate_huft *fixed_tl; -local inflate_huft *fixed_td; -#else -#include "inffixed.h" -#endif - - -int inflate_trees_fixed(bl, bd, tl, td, z) -uIntf *bl; /* literal desired/actual bit depth */ -uIntf *bd; /* distance desired/actual bit depth */ -inflate_huft * FAR *tl; /* literal/length tree result */ -inflate_huft * FAR *td; /* distance tree result */ -z_streamp z; /* for memory allocation */ -{ -#ifdef BUILDFIXED - /* build fixed tables if not already */ - if (!fixed_built) - { - int k; /* temporary variable */ - uInt f = 0; /* number of hufts used in fixed_mem */ - uIntf *c; /* length list for huft_build */ - uIntf *v; /* work area for huft_build */ - - /* allocate memory */ - if ((c = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL) - return Z_MEM_ERROR; - if ((v = (uIntf*)ZALLOC(z, 288, sizeof(uInt))) == Z_NULL) - { - ZFREE(z, c); - return Z_MEM_ERROR; - } - - /* literal table */ - for (k = 0; k < 144; k++) - c[k] = 8; - for (; k < 256; k++) - c[k] = 9; - for (; k < 280; k++) - c[k] = 7; - for (; k < 288; k++) - c[k] = 8; - fixed_bl = 9; - huft_build(c, 288, 257, cplens, cplext, &fixed_tl, &fixed_bl, - fixed_mem, &f, v); - - /* distance table */ - for (k = 0; k < 30; k++) - c[k] = 5; - fixed_bd = 5; - huft_build(c, 30, 0, cpdist, cpdext, &fixed_td, &fixed_bd, - fixed_mem, &f, v); - - /* done */ - ZFREE(z, v); - ZFREE(z, c); - fixed_built = 1; - } -#endif - *bl = fixed_bl; - *bd = fixed_bd; - *tl = fixed_tl; - *td = fixed_td; - return Z_OK; -} diff --git a/src/crashrpt/zlib/inftrees.h b/src/crashrpt/zlib/inftrees.h deleted file mode 100644 index affbb3b21..000000000 --- a/src/crashrpt/zlib/inftrees.h +++ /dev/null @@ -1,58 +0,0 @@ -/* inftrees.h -- header to use inftrees.c - * Copyright (C) 1995-2002 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. - */ - -/* Huffman code lookup table entry--this entry is four bytes for machines - that have 16-bit pointers (e.g. PC's in the small or medium model). */ - -typedef struct inflate_huft_s FAR inflate_huft; - -struct inflate_huft_s { - union { - struct { - Byte Exop; /* number of extra bits or operation */ - Byte Bits; /* number of bits in this code or subcode */ - } what; - uInt pad; /* pad structure to a power of 2 (4 bytes for */ - } word; /* 16-bit, 8 bytes for 32-bit int's) */ - uInt base; /* literal, length base, distance base, - or table offset */ -}; - -/* Maximum size of dynamic tree. The maximum found in a long but non- - exhaustive search was 1004 huft structures (850 for length/literals - and 154 for distances, the latter actually the result of an - exhaustive search). The actual maximum is not known, but the - value below is more than safe. */ -#define MANY 1440 - -extern int inflate_trees_bits OF(( - uIntf *, /* 19 code lengths */ - uIntf *, /* bits tree desired/actual depth */ - inflate_huft * FAR *, /* bits tree result */ - inflate_huft *, /* space for trees */ - z_streamp)); /* for messages */ - -extern int inflate_trees_dynamic OF(( - uInt, /* number of literal/length codes */ - uInt, /* number of distance codes */ - uIntf *, /* that many (total) code lengths */ - uIntf *, /* literal desired/actual bit depth */ - uIntf *, /* distance desired/actual bit depth */ - inflate_huft * FAR *, /* literal/length tree result */ - inflate_huft * FAR *, /* distance tree result */ - inflate_huft *, /* space for trees */ - z_streamp)); /* for messages */ - -extern int inflate_trees_fixed OF(( - uIntf *, /* literal desired/actual bit depth */ - uIntf *, /* distance desired/actual bit depth */ - inflate_huft * FAR *, /* literal/length tree result */ - inflate_huft * FAR *, /* distance tree result */ - z_streamp)); /* for memory allocation */ diff --git a/src/crashrpt/zlib/infutil.c b/src/crashrpt/zlib/infutil.c deleted file mode 100644 index 976d5e521..000000000 --- a/src/crashrpt/zlib/infutil.c +++ /dev/null @@ -1,87 +0,0 @@ -/* inflate_util.c -- data and routines common to blocks and codes - * Copyright (C) 1995-2002 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -#include "zutil.h" -#include "infblock.h" -#include "inftrees.h" -#include "infcodes.h" -#include "infutil.h" - -struct inflate_codes_state {int dummy;}; /* for buggy compilers */ - -/* And'ing with mask[n] masks the lower n bits */ -uInt inflate_mask[17] = { - 0x0000, - 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, - 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff -}; - - -/* copy as much as possible from the sliding window to the output area */ -int inflate_flush(s, z, r) -inflate_blocks_statef *s; -z_streamp z; -int r; -{ - uInt n; - Bytef *p; - Bytef *q; - - /* local copies of source and destination pointers */ - p = z->next_out; - q = s->read; - - /* compute number of bytes to copy as far as end of window */ - n = (uInt)((q <= s->write ? s->write : s->end) - q); - if (n > z->avail_out) n = z->avail_out; - if (n && r == Z_BUF_ERROR) r = Z_OK; - - /* update counters */ - z->avail_out -= n; - z->total_out += n; - - /* update check information */ - if (s->checkfn != Z_NULL) - z->adler = s->check = (*s->checkfn)(s->check, q, n); - - /* copy as far as end of window */ - zmemcpy(p, q, n); - p += n; - q += n; - - /* see if more to copy at beginning of window */ - if (q == s->end) - { - /* wrap pointers */ - q = s->window; - if (s->write == s->end) - s->write = s->window; - - /* compute bytes to copy */ - n = (uInt)(s->write - q); - if (n > z->avail_out) n = z->avail_out; - if (n && r == Z_BUF_ERROR) r = Z_OK; - - /* update counters */ - z->avail_out -= n; - z->total_out += n; - - /* update check information */ - if (s->checkfn != Z_NULL) - z->adler = s->check = (*s->checkfn)(s->check, q, n); - - /* copy */ - zmemcpy(p, q, n); - p += n; - q += n; - } - - /* update pointers */ - z->next_out = p; - s->read = q; - - /* done */ - return r; -} diff --git a/src/crashrpt/zlib/infutil.h b/src/crashrpt/zlib/infutil.h deleted file mode 100644 index 0c0ace366..000000000 --- a/src/crashrpt/zlib/infutil.h +++ /dev/null @@ -1,98 +0,0 @@ -/* infutil.h -- types and macros common to blocks and codes - * Copyright (C) 1995-2002 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. - */ - -#ifndef _INFUTIL_H -#define _INFUTIL_H - -typedef enum { - TYPE, /* get type bits (3, including end bit) */ - LENS, /* get lengths for stored */ - STORED, /* processing stored block */ - TABLE, /* get table lengths */ - BTREE, /* get bit lengths tree for a dynamic block */ - DTREE, /* get length, distance trees for a dynamic block */ - CODES, /* processing fixed or dynamic block */ - DRY, /* output remaining window bytes */ - DONE, /* finished last block, done */ - BAD} /* got a data error--stuck here */ -inflate_block_mode; - -/* inflate blocks semi-private state */ -struct inflate_blocks_state { - - /* mode */ - inflate_block_mode mode; /* current inflate_block mode */ - - /* mode dependent information */ - union { - uInt left; /* if STORED, bytes left to copy */ - struct { - uInt table; /* table lengths (14 bits) */ - uInt index; /* index into blens (or border) */ - uIntf *blens; /* bit lengths of codes */ - uInt bb; /* bit length tree depth */ - inflate_huft *tb; /* bit length decoding tree */ - } trees; /* if DTREE, decoding info for trees */ - struct { - inflate_codes_statef - *codes; - } decode; /* if CODES, current state */ - } sub; /* submode */ - uInt last; /* true if this block is the last block */ - - /* mode independent information */ - uInt bitk; /* bits in bit buffer */ - uLong bitb; /* bit buffer */ - inflate_huft *hufts; /* single malloc for tree space */ - Bytef *window; /* sliding window */ - Bytef *end; /* one byte after sliding window */ - Bytef *read; /* window read pointer */ - Bytef *write; /* window write pointer */ - check_func checkfn; /* check function */ - uLong check; /* check on output */ - -}; - - -/* defines for inflate input/output */ -/* update pointers and return */ -#define UPDBITS {s->bitb=b;s->bitk=k;} -#define UPDIN {z->avail_in=n;z->total_in+=p-z->next_in;z->next_in=p;} -#define UPDOUT {s->write=q;} -#define UPDATE {UPDBITS UPDIN UPDOUT} -#define LEAVE {UPDATE return inflate_flush(s,z,r);} -/* get bytes and bits */ -#define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;} -#define NEEDBYTE {if(n)r=Z_OK;else LEAVE} -#define NEXTBYTE (n--,*p++) -#define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<>=(j);k-=(j);} -/* output bytes */ -#define WAVAIL (uInt)(qread?s->read-q-1:s->end-q) -#define LOADOUT {q=s->write;m=(uInt)WAVAIL;} -#define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=(uInt)WAVAIL;}} -#define FLUSH {UPDOUT r=inflate_flush(s,z,r); LOADOUT} -#define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;} -#define OUTBYTE(a) {*q++=(Byte)(a);m--;} -/* load local pointers */ -#define LOAD {LOADIN LOADOUT} - -/* masks for lower bits (size given to avoid silly warnings with Visual C++) */ -extern uInt inflate_mask[17]; - -/* copy as much as possible from the sliding window to the output area */ -extern int inflate_flush OF(( - inflate_blocks_statef *, - z_streamp , - int)); - -struct internal_state {int dummy;}; /* for buggy compilers */ - -#endif diff --git a/src/crashrpt/zlib/maketree.c b/src/crashrpt/zlib/maketree.c deleted file mode 100644 index c64de51e3..000000000 --- a/src/crashrpt/zlib/maketree.c +++ /dev/null @@ -1,85 +0,0 @@ -/* maketree.c -- make inffixed.h table for decoding fixed codes - * Copyright (C) 1995-2002 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. - */ - -/* This program is included in the distribution for completeness. - You do not need to compile or run this program since inffixed.h - is already included in the distribution. To use this program - you need to compile zlib with BUILDFIXED defined and then compile - and link this program with the zlib library. Then the output of - this program can be piped to inffixed.h. */ - -#include -#include -#include "zutil.h" -#include "inftrees.h" - -/* simplify the use of the inflate_huft type with some defines */ -#define exop word.what.Exop -#define bits word.what.Bits - -/* generate initialization table for an inflate_huft structure array */ -void maketree(uInt b, inflate_huft *t) -{ - int i, e; - - i = 0; - while (1) - { - e = t[i].exop; - if (e && (e & (16+64)) == 0) /* table pointer */ - { - fprintf(stderr, "maketree: cannot initialize sub-tables!\n"); - exit(1); - } - if (i % 4 == 0) - printf("\n "); - printf(" {{{%u,%u}},%u}", t[i].exop, t[i].bits, t[i].base); - if (++i == (1< -#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 void set_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 |= (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 |= 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 |= (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 |= (value) << s->bi_valid;\ - s->bi_valid += len;\ - }\ -} -#endif /* DEBUG */ - - -#define MAX(a,b) (a >= b ? a : b) -/* 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: */ - 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; - - /* 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 _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 _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 _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 (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) (MAX(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 _tr_stored_block(s, buf, stored_len, eof) - deflate_state *s; - charf *buf; /* input block */ - ulg stored_len; /* length of input block */ - int eof; /* true if this is the last block for a file */ -{ - send_bits(s, (STORED_BLOCK<<1)+eof, 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 _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 _tr_flush_block(s, buf, stored_len, eof) - deflate_state *s; - charf *buf; /* input block, or NULL if too old */ - ulg stored_len; /* length of input block */ - int eof; /* true 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 ascii or binary */ - if (s->data_type == Z_UNKNOWN) set_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 first the block length 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, eof); - -#ifdef FORCE_STATIC - } else if (static_lenb >= 0) { /* force static trees */ -#else - } else if (static_lenb == opt_lenb) { -#endif - send_bits(s, (STATIC_TREES<<1)+eof, 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)+eof, 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 (eof) { - 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*eof)); -} - -/* =========================================================================== - * Save the match info and tally the frequency counts. Return true if - * the current block must be flushed. - */ -int _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(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; -} - -/* =========================================================================== - * Set the data type to ASCII or BINARY, using a crude approximation: - * binary if more than 20% of the bytes are <= 6 or >= 128, ascii otherwise. - * IN assertion: the fields freq of dyn_ltree are set and the total of all - * frequencies does not exceed 64K (to fit in an int on 16 bit machines). - */ -local void set_data_type(s) - deflate_state *s; -{ - int n = 0; - unsigned ascii_freq = 0; - unsigned bin_freq = 0; - while (n < 7) bin_freq += s->dyn_ltree[n++].Freq; - while (n < 128) ascii_freq += s->dyn_ltree[n++].Freq; - while (n < LITERALS) bin_freq += s->dyn_ltree[n++].Freq; - s->data_type = (Byte)(bin_freq > (ascii_freq >> 2) ? Z_BINARY : Z_ASCII); -} - -/* =========================================================================== - * 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/src/crashrpt/zlib/trees.h b/src/crashrpt/zlib/trees.h deleted file mode 100644 index 1ca868b84..000000000 --- a/src/crashrpt/zlib/trees.h +++ /dev/null @@ -1,128 +0,0 @@ -/* 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 _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 _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/src/crashrpt/zlib/uncompr.c b/src/crashrpt/zlib/uncompr.c deleted file mode 100644 index 909ad2a20..000000000 --- a/src/crashrpt/zlib/uncompr.c +++ /dev/null @@ -1,58 +0,0 @@ -/* uncompr.c -- decompress a memory buffer - * Copyright (C) 1995-2002 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id: uncompr.c,v 1.1 2003/05/23 21:05:30 steveking Exp $ */ - -#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. - This function can be used to decompress a whole file at once if the - input file is mmap'ed. - - 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); - return err == Z_OK ? Z_BUF_ERROR : err; - } - *destLen = stream.total_out; - - err = inflateEnd(&stream); - return err; -} diff --git a/src/crashrpt/zlib/unzip.c b/src/crashrpt/zlib/unzip.c deleted file mode 100644 index 67c123f71..000000000 --- a/src/crashrpt/zlib/unzip.c +++ /dev/null @@ -1,1294 +0,0 @@ -/* unzip.c -- IO on .zip files using zlib - Version 0.15 beta, Mar 19th, 1998, - - Read unzip.h for more info -*/ - - -#include -#include -#include -#include "zlib.h" -#include "unzip.h" - -#ifdef STDC -# include -# include -# include -#endif -#ifdef NO_ERRNO_H - extern int errno; -#else -# include -#endif - - -#ifndef local -# define local static -#endif -/* compile with -Dlocal if your debugger can't find static symbols */ - - - -#if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) && \ - !defined(CASESENSITIVITYDEFAULT_NO) -#define CASESENSITIVITYDEFAULT_NO -#endif - - -#ifndef UNZ_BUFSIZE -#define UNZ_BUFSIZE (16384) -#endif - -#ifndef UNZ_MAXFILENAMEINZIP -#define UNZ_MAXFILENAMEINZIP (256) -#endif - -#ifndef ALLOC -# define ALLOC(size) (malloc(size)) -#endif -#ifndef TRYFREE -# define TRYFREE(p) {if (p) free(p);} -#endif - -#define SIZECENTRALDIRITEM (0x2e) -#define SIZEZIPLOCALHEADER (0x1e) - - -/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ - -#ifndef SEEK_CUR -#define SEEK_CUR 1 -#endif - -#ifndef SEEK_END -#define SEEK_END 2 -#endif - -#ifndef SEEK_SET -#define SEEK_SET 0 -#endif - -const char unz_copyright[] = - " unzip 0.15 Copyright 1998 Gilles Vollant "; - -/* unz_file_info_interntal contain internal info about a file in zipfile*/ -typedef struct unz_file_info_internal_s -{ - uLong offset_curfile;/* relative offset of local header 4 bytes */ -} unz_file_info_internal; - - -/* file_in_zip_read_info_s contain internal information about a file in zipfile, - when reading and decompress it */ -typedef struct -{ - char *read_buffer; /* internal buffer for compressed data */ - z_stream stream; /* zLib stream structure for inflate */ - - uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/ - uLong stream_initialised; /* flag set if stream structure is initialised*/ - - uLong offset_local_extrafield;/* offset of the local extra field */ - uInt size_local_extrafield;/* size of the local extra field */ - uLong pos_local_extrafield; /* position in the local extra field in read*/ - - uLong crc32; /* crc32 of all data uncompressed */ - uLong crc32_wait; /* crc32 we must obtain after decompress all */ - uLong rest_read_compressed; /* number of byte to be decompressed */ - uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/ - FILE* file; /* io structore of the zipfile */ - uLong compression_method; /* compression method (0==store) */ - uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ -} file_in_zip_read_info_s; - - -/* unz_s contain internal information about the zipfile -*/ -typedef struct -{ - FILE* file; /* io structore of the zipfile */ - unz_global_info gi; /* public global information */ - uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ - uLong num_file; /* number of the current file in the zipfile*/ - uLong pos_in_central_dir; /* pos of the current file in the central dir*/ - uLong current_file_ok; /* flag about the usability of the current file*/ - uLong central_pos; /* position of the beginning of the central dir*/ - - uLong size_central_dir; /* size of the central directory */ - uLong offset_central_dir; /* offset of start of central directory with - respect to the starting disk number */ - - unz_file_info cur_file_info; /* public info about the current file in zip*/ - unz_file_info_internal cur_file_info_internal; /* private info about it*/ - file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current - file if we are decompressing it */ -} unz_s; - - -/* =========================================================================== - 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 unzlocal_getByte(fin,pi) - FILE *fin; - int *pi; -{ - unsigned char c; - int err = fread(&c, 1, 1, fin); - if (err==1) - { - *pi = (int)c; - return UNZ_OK; - } - else - { - if (ferror(fin)) - return UNZ_ERRNO; - else - return UNZ_EOF; - } -} - - -/* =========================================================================== - Reads a long in LSB order from the given gz_stream. Sets -*/ -local int unzlocal_getShort (fin,pX) - FILE* fin; - uLong *pX; -{ - uLong x ; - int i; - int err; - - err = unzlocal_getByte(fin,&i); - x = (uLong)i; - - if (err==UNZ_OK) - err = unzlocal_getByte(fin,&i); - x += ((uLong)i)<<8; - - if (err==UNZ_OK) - *pX = x; - else - *pX = 0; - return err; -} - -local int unzlocal_getLong (fin,pX) - FILE* fin; - uLong *pX; -{ - uLong x ; - int i; - int err; - - err = unzlocal_getByte(fin,&i); - x = (uLong)i; - - if (err==UNZ_OK) - err = unzlocal_getByte(fin,&i); - x += ((uLong)i)<<8; - - if (err==UNZ_OK) - err = unzlocal_getByte(fin,&i); - x += ((uLong)i)<<16; - - if (err==UNZ_OK) - err = unzlocal_getByte(fin,&i); - x += ((uLong)i)<<24; - - if (err==UNZ_OK) - *pX = x; - else - *pX = 0; - return err; -} - - -/* My own strcmpi / strcasecmp */ -local int strcmpcasenosensitive_internal (fileName1,fileName2) - const char* fileName1; - const char* fileName2; -{ - for (;;) - { - char c1=*(fileName1++); - char c2=*(fileName2++); - if ((c1>='a') && (c1<='z')) - c1 -= 0x20; - if ((c2>='a') && (c2<='z')) - c2 -= 0x20; - if (c1=='\0') - return ((c2=='\0') ? 0 : -1); - if (c2=='\0') - return 1; - if (c1c2) - return 1; - } -} - - -#ifdef CASESENSITIVITYDEFAULT_NO -#define CASESENSITIVITYDEFAULTVALUE 2 -#else -#define CASESENSITIVITYDEFAULTVALUE 1 -#endif - -#ifndef STRCMPCASENOSENTIVEFUNCTION -#define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal -#endif - -/* - Compare two filename (fileName1,fileName2). - If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) - If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi - or strcasecmp) - If iCaseSenisivity = 0, case sensitivity is defaut of your operating system - (like 1 on Unix, 2 on Windows) - -*/ -extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivity) - const char* fileName1; - const char* fileName2; - int iCaseSensitivity; -{ - if (iCaseSensitivity==0) - iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE; - - if (iCaseSensitivity==1) - return strcmp(fileName1,fileName2); - - return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2); -} - -#define BUFREADCOMMENT (0x400) - -/* - Locate the Central directory of a zipfile (at the end, just before - the global comment) -*/ -local uLong unzlocal_SearchCentralDir(fin) - FILE *fin; -{ - unsigned char* buf; - uLong uSizeFile; - uLong uBackRead; - uLong uMaxBack=0xffff; /* maximum size of global comment */ - uLong uPosFound=0; - - if (fseek(fin,0,SEEK_END) != 0) - return 0; - - - uSizeFile = ftell( fin ); - - if (uMaxBack>uSizeFile) - uMaxBack = uSizeFile; - - buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); - if (buf==NULL) - return 0; - - uBackRead = 4; - while (uBackReaduMaxBack) - uBackRead = uMaxBack; - else - uBackRead+=BUFREADCOMMENT; - uReadPos = uSizeFile-uBackRead ; - - uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? - (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); - if (fseek(fin,uReadPos,SEEK_SET)!=0) - break; - - if (fread(buf,(uInt)uReadSize,1,fin)!=1) - break; - - for (i=(int)uReadSize-3; (i--)>0;) - if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && - ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) - { - uPosFound = uReadPos+i; - break; - } - - if (uPosFound!=0) - break; - } - TRYFREE(buf); - return uPosFound; -} - -/* - Open a Zip file. path contain the full pathname (by example, - on a Windows NT computer "c:\\test\\zlib109.zip" or on an Unix computer - "zlib/zlib109.zip". - If the zipfile cannot be opened (file don't exist or in not valid), the - return value is NULL. - Else, the return value is a unzFile Handle, usable with other function - of this unzip package. -*/ -extern unzFile ZEXPORT unzOpen (path) - const char *path; -{ - unz_s us; - unz_s *s; - uLong central_pos,uL; - FILE * fin ; - - uLong number_disk; /* number of the current dist, used for - spaning ZIP, unsupported, always 0*/ - uLong number_disk_with_CD; /* number the the disk with central dir, used - for spaning ZIP, unsupported, always 0*/ - uLong number_entry_CD; /* total number of entries in - the central dir - (same than number_entry on nospan) */ - - int err=UNZ_OK; - - if (unz_copyright[0]!=' ') - return NULL; - - fin=fopen(path,"rb"); - if (fin==NULL) - return NULL; - - central_pos = unzlocal_SearchCentralDir(fin); - if (central_pos==0) - err=UNZ_ERRNO; - - if (fseek(fin,central_pos,SEEK_SET)!=0) - err=UNZ_ERRNO; - - /* the signature, already checked */ - if (unzlocal_getLong(fin,&uL)!=UNZ_OK) - err=UNZ_ERRNO; - - /* number of this disk */ - if (unzlocal_getShort(fin,&number_disk)!=UNZ_OK) - err=UNZ_ERRNO; - - /* number of the disk with the start of the central directory */ - if (unzlocal_getShort(fin,&number_disk_with_CD)!=UNZ_OK) - err=UNZ_ERRNO; - - /* total number of entries in the central dir on this disk */ - if (unzlocal_getShort(fin,&us.gi.number_entry)!=UNZ_OK) - err=UNZ_ERRNO; - - /* total number of entries in the central dir */ - if (unzlocal_getShort(fin,&number_entry_CD)!=UNZ_OK) - err=UNZ_ERRNO; - - if ((number_entry_CD!=us.gi.number_entry) || - (number_disk_with_CD!=0) || - (number_disk!=0)) - err=UNZ_BADZIPFILE; - - /* size of the central directory */ - if (unzlocal_getLong(fin,&us.size_central_dir)!=UNZ_OK) - err=UNZ_ERRNO; - - /* offset of start of central directory with respect to the - starting disk number */ - if (unzlocal_getLong(fin,&us.offset_central_dir)!=UNZ_OK) - err=UNZ_ERRNO; - - /* zipfile comment length */ - if (unzlocal_getShort(fin,&us.gi.size_comment)!=UNZ_OK) - err=UNZ_ERRNO; - - if ((central_pospfile_in_zip_read!=NULL) - unzCloseCurrentFile(file); - - fclose(s->file); - TRYFREE(s); - return UNZ_OK; -} - - -/* - Write info about the ZipFile in the *pglobal_info structure. - No preparation of the structure is needed - return UNZ_OK if there is no problem. */ -extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info) - unzFile file; - unz_global_info *pglobal_info; -{ - unz_s* s; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - *pglobal_info=s->gi; - return UNZ_OK; -} - - -/* - Translate date/time from Dos format to tm_unz (readable more easilty) -*/ -local void unzlocal_DosDateToTmuDate (ulDosDate, ptm) - uLong ulDosDate; - tm_unz* ptm; -{ - uLong uDate; - uDate = (uLong)(ulDosDate>>16); - ptm->tm_mday = (uInt)(uDate&0x1f) ; - ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ; - ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ; - - ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800); - ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ; - ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ; -} - -/* - Get Info about the current file in the zipfile, with internal only info -*/ -local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file, - unz_file_info *pfile_info, - unz_file_info_internal - *pfile_info_internal, - char *szFileName, - uLong fileNameBufferSize, - void *extraField, - uLong extraFieldBufferSize, - char *szComment, - uLong commentBufferSize)); - -local int unzlocal_GetCurrentFileInfoInternal (file, - pfile_info, - pfile_info_internal, - szFileName, fileNameBufferSize, - extraField, extraFieldBufferSize, - szComment, commentBufferSize) - unzFile file; - unz_file_info *pfile_info; - unz_file_info_internal *pfile_info_internal; - char *szFileName; - uLong fileNameBufferSize; - void *extraField; - uLong extraFieldBufferSize; - char *szComment; - uLong commentBufferSize; -{ - unz_s* s; - unz_file_info file_info; - unz_file_info_internal file_info_internal; - int err=UNZ_OK; - uLong uMagic; - long lSeek=0; - - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - if (fseek(s->file,s->pos_in_central_dir+s->byte_before_the_zipfile,SEEK_SET)!=0) - err=UNZ_ERRNO; - - - /* we check the magic */ - if (err==UNZ_OK) - if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) - err=UNZ_ERRNO; - else if (uMagic!=0x02014b50) - err=UNZ_BADZIPFILE; - - if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(s->file,&file_info.version_needed) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(s->file,&file_info.flag) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(s->file,&file_info.compression_method) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getLong(s->file,&file_info.dosDate) != UNZ_OK) - err=UNZ_ERRNO; - - unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date); - - if (unzlocal_getLong(s->file,&file_info.crc) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getLong(s->file,&file_info.compressed_size) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getLong(s->file,&file_info.uncompressed_size) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(s->file,&file_info.size_filename) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(s->file,&file_info.size_file_extra) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(s->file,&file_info.size_file_comment) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(s->file,&file_info.disk_num_start) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(s->file,&file_info.internal_fa) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getLong(s->file,&file_info.external_fa) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getLong(s->file,&file_info_internal.offset_curfile) != UNZ_OK) - err=UNZ_ERRNO; - - lSeek+=file_info.size_filename; - if ((err==UNZ_OK) && (szFileName!=NULL)) - { - uLong uSizeRead ; - if (file_info.size_filename0) && (fileNameBufferSize>0)) - if (fread(szFileName,(uInt)uSizeRead,1,s->file)!=1) - err=UNZ_ERRNO; - lSeek -= uSizeRead; - } - - - if ((err==UNZ_OK) && (extraField!=NULL)) - { - uLong uSizeRead ; - if (file_info.size_file_extrafile,lSeek,SEEK_CUR)==0) - lSeek=0; - else - err=UNZ_ERRNO; - if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) - if (fread(extraField,(uInt)uSizeRead,1,s->file)!=1) - err=UNZ_ERRNO; - lSeek += file_info.size_file_extra - uSizeRead; - } - else - lSeek+=file_info.size_file_extra; - - - if ((err==UNZ_OK) && (szComment!=NULL)) - { - uLong uSizeRead ; - if (file_info.size_file_commentfile,lSeek,SEEK_CUR)==0) - lSeek=0; - else - err=UNZ_ERRNO; - if ((file_info.size_file_comment>0) && (commentBufferSize>0)) - if (fread(szComment,(uInt)uSizeRead,1,s->file)!=1) - err=UNZ_ERRNO; - lSeek+=file_info.size_file_comment - uSizeRead; - } - else - lSeek+=file_info.size_file_comment; - - if ((err==UNZ_OK) && (pfile_info!=NULL)) - *pfile_info=file_info; - - if ((err==UNZ_OK) && (pfile_info_internal!=NULL)) - *pfile_info_internal=file_info_internal; - - return err; -} - - - -/* - Write info about the ZipFile in the *pglobal_info structure. - No preparation of the structure is needed - return UNZ_OK if there is no problem. -*/ -extern int ZEXPORT unzGetCurrentFileInfo (file, - pfile_info, - szFileName, fileNameBufferSize, - extraField, extraFieldBufferSize, - szComment, commentBufferSize) - unzFile file; - unz_file_info *pfile_info; - char *szFileName; - uLong fileNameBufferSize; - void *extraField; - uLong extraFieldBufferSize; - char *szComment; - uLong commentBufferSize; -{ - return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL, - szFileName,fileNameBufferSize, - extraField,extraFieldBufferSize, - szComment,commentBufferSize); -} - -/* - Set the current file of the zipfile to the first file. - return UNZ_OK if there is no problem -*/ -extern int ZEXPORT unzGoToFirstFile (file) - unzFile file; -{ - int err=UNZ_OK; - unz_s* s; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - s->pos_in_central_dir=s->offset_central_dir; - s->num_file=0; - err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, - &s->cur_file_info_internal, - NULL,0,NULL,0,NULL,0); - s->current_file_ok = (err == UNZ_OK); - return err; -} - - -/* - Set the current file of the zipfile to the next file. - return UNZ_OK if there is no problem - return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. -*/ -extern int ZEXPORT unzGoToNextFile (file) - unzFile file; -{ - unz_s* s; - int err; - - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - if (!s->current_file_ok) - return UNZ_END_OF_LIST_OF_FILE; - if (s->num_file+1==s->gi.number_entry) - return UNZ_END_OF_LIST_OF_FILE; - - s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename + - s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ; - s->num_file++; - err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, - &s->cur_file_info_internal, - NULL,0,NULL,0,NULL,0); - s->current_file_ok = (err == UNZ_OK); - return err; -} - - -/* - Try locate the file szFileName in the zipfile. - For the iCaseSensitivity signification, see unzipStringFileNameCompare - - return value : - UNZ_OK if the file is found. It becomes the current file. - UNZ_END_OF_LIST_OF_FILE if the file is not found -*/ -extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity) - unzFile file; - const char *szFileName; - int iCaseSensitivity; -{ - unz_s* s; - int err; - - - uLong num_fileSaved; - uLong pos_in_central_dirSaved; - - - if (file==NULL) - return UNZ_PARAMERROR; - - if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP) - return UNZ_PARAMERROR; - - s=(unz_s*)file; - if (!s->current_file_ok) - return UNZ_END_OF_LIST_OF_FILE; - - num_fileSaved = s->num_file; - pos_in_central_dirSaved = s->pos_in_central_dir; - - err = unzGoToFirstFile(file); - - while (err == UNZ_OK) - { - char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; - unzGetCurrentFileInfo(file,NULL, - szCurrentFileName,sizeof(szCurrentFileName)-1, - NULL,0,NULL,0); - if (unzStringFileNameCompare(szCurrentFileName, - szFileName,iCaseSensitivity)==0) - return UNZ_OK; - err = unzGoToNextFile(file); - } - - s->num_file = num_fileSaved ; - s->pos_in_central_dir = pos_in_central_dirSaved ; - return err; -} - - -/* - Read the local header of the current zipfile - Check the coherency of the local header and info in the end of central - directory about this file - store in *piSizeVar the size of extra info in local header - (filename and size of extra field data) -*/ -local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar, - poffset_local_extrafield, - psize_local_extrafield) - unz_s* s; - uInt* piSizeVar; - uLong *poffset_local_extrafield; - uInt *psize_local_extrafield; -{ - uLong uMagic,uData,uFlags; - uLong size_filename; - uLong size_extra_field; - int err=UNZ_OK; - - *piSizeVar = 0; - *poffset_local_extrafield = 0; - *psize_local_extrafield = 0; - - if (fseek(s->file,s->cur_file_info_internal.offset_curfile + - s->byte_before_the_zipfile,SEEK_SET)!=0) - return UNZ_ERRNO; - - - if (err==UNZ_OK) - if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) - err=UNZ_ERRNO; - else if (uMagic!=0x04034b50) - err=UNZ_BADZIPFILE; - - if (unzlocal_getShort(s->file,&uData) != UNZ_OK) - err=UNZ_ERRNO; -/* - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion)) - err=UNZ_BADZIPFILE; -*/ - if (unzlocal_getShort(s->file,&uFlags) != UNZ_OK) - err=UNZ_ERRNO; - - if (unzlocal_getShort(s->file,&uData) != UNZ_OK) - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method)) - err=UNZ_BADZIPFILE; - - if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) && - (s->cur_file_info.compression_method!=Z_DEFLATED)) - err=UNZ_BADZIPFILE; - - if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* date/time */ - err=UNZ_ERRNO; - - if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* crc */ - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && - ((uFlags & 8)==0)) - err=UNZ_BADZIPFILE; - - if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size compr */ - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && - ((uFlags & 8)==0)) - err=UNZ_BADZIPFILE; - - if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size uncompr */ - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && - ((uFlags & 8)==0)) - err=UNZ_BADZIPFILE; - - - if (unzlocal_getShort(s->file,&size_filename) != UNZ_OK) - err=UNZ_ERRNO; - else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename)) - err=UNZ_BADZIPFILE; - - *piSizeVar += (uInt)size_filename; - - if (unzlocal_getShort(s->file,&size_extra_field) != UNZ_OK) - err=UNZ_ERRNO; - *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile + - SIZEZIPLOCALHEADER + size_filename; - *psize_local_extrafield = (uInt)size_extra_field; - - *piSizeVar += (uInt)size_extra_field; - - return err; -} - -/* - Open for reading data the current file in the zipfile. - If there is no error and the file is opened, the return value is UNZ_OK. -*/ -extern int ZEXPORT unzOpenCurrentFile (file) - unzFile file; -{ - int err=UNZ_OK; - int Store; - uInt iSizeVar; - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - uLong offset_local_extrafield; /* offset of the local extra field */ - uInt size_local_extrafield; /* size of the local extra field */ - - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - if (!s->current_file_ok) - return UNZ_PARAMERROR; - - if (s->pfile_in_zip_read != NULL) - unzCloseCurrentFile(file); - - if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar, - &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK) - return UNZ_BADZIPFILE; - - pfile_in_zip_read_info = (file_in_zip_read_info_s*) - ALLOC(sizeof(file_in_zip_read_info_s)); - if (pfile_in_zip_read_info==NULL) - return UNZ_INTERNALERROR; - - pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE); - pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield; - pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield; - pfile_in_zip_read_info->pos_local_extrafield=0; - - if (pfile_in_zip_read_info->read_buffer==NULL) - { - TRYFREE(pfile_in_zip_read_info); - return UNZ_INTERNALERROR; - } - - pfile_in_zip_read_info->stream_initialised=0; - - if ((s->cur_file_info.compression_method!=0) && - (s->cur_file_info.compression_method!=Z_DEFLATED)) - err=UNZ_BADZIPFILE; - Store = s->cur_file_info.compression_method==0; - - pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc; - pfile_in_zip_read_info->crc32=0; - pfile_in_zip_read_info->compression_method = - s->cur_file_info.compression_method; - pfile_in_zip_read_info->file=s->file; - pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile; - - pfile_in_zip_read_info->stream.total_out = 0; - - if (!Store) - { - pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; - pfile_in_zip_read_info->stream.zfree = (free_func)0; - pfile_in_zip_read_info->stream.opaque = (voidpf)0; - - err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); - if (err == Z_OK) - pfile_in_zip_read_info->stream_initialised=1; - /* 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. - * In unzip, i don't wait absolutely Z_STREAM_END because I known the - * size of both compressed and uncompressed data - */ - } - pfile_in_zip_read_info->rest_read_compressed = - s->cur_file_info.compressed_size ; - pfile_in_zip_read_info->rest_read_uncompressed = - s->cur_file_info.uncompressed_size ; - - - pfile_in_zip_read_info->pos_in_zipfile = - s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + - iSizeVar; - - pfile_in_zip_read_info->stream.avail_in = (uInt)0; - - - s->pfile_in_zip_read = pfile_in_zip_read_info; - return UNZ_OK; -} - - -/* - Read bytes from the current file. - buf contain buffer where data must be copied - len the size of buf. - - return the number of byte copied if somes bytes are copied - return 0 if the end of file was reached - return <0 with error code if there is an error - (UNZ_ERRNO for IO error, or zLib error for uncompress error) -*/ -extern int ZEXPORT unzReadCurrentFile (file, buf, len) - unzFile file; - voidp buf; - unsigned len; -{ - int err=UNZ_OK; - uInt iRead = 0; - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - pfile_in_zip_read_info=s->pfile_in_zip_read; - - if (pfile_in_zip_read_info==NULL) - return UNZ_PARAMERROR; - - - if ((pfile_in_zip_read_info->read_buffer == NULL)) - return UNZ_END_OF_LIST_OF_FILE; - if (len==0) - return 0; - - pfile_in_zip_read_info->stream.next_out = (Bytef*)buf; - - pfile_in_zip_read_info->stream.avail_out = (uInt)len; - - if (len>pfile_in_zip_read_info->rest_read_uncompressed) - pfile_in_zip_read_info->stream.avail_out = - (uInt)pfile_in_zip_read_info->rest_read_uncompressed; - - while (pfile_in_zip_read_info->stream.avail_out>0) - { - if ((pfile_in_zip_read_info->stream.avail_in==0) && - (pfile_in_zip_read_info->rest_read_compressed>0)) - { - uInt uReadThis = UNZ_BUFSIZE; - if (pfile_in_zip_read_info->rest_read_compressedrest_read_compressed; - if (uReadThis == 0) - return UNZ_EOF; - if (fseek(pfile_in_zip_read_info->file, - pfile_in_zip_read_info->pos_in_zipfile + - pfile_in_zip_read_info->byte_before_the_zipfile,SEEK_SET)!=0) - return UNZ_ERRNO; - if (fread(pfile_in_zip_read_info->read_buffer,uReadThis,1, - pfile_in_zip_read_info->file)!=1) - return UNZ_ERRNO; - pfile_in_zip_read_info->pos_in_zipfile += uReadThis; - - pfile_in_zip_read_info->rest_read_compressed-=uReadThis; - - pfile_in_zip_read_info->stream.next_in = - (Bytef*)pfile_in_zip_read_info->read_buffer; - pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis; - } - - if (pfile_in_zip_read_info->compression_method==0) - { - uInt uDoCopy,i ; - if (pfile_in_zip_read_info->stream.avail_out < - pfile_in_zip_read_info->stream.avail_in) - uDoCopy = pfile_in_zip_read_info->stream.avail_out ; - else - uDoCopy = pfile_in_zip_read_info->stream.avail_in ; - - for (i=0;istream.next_out+i) = - *(pfile_in_zip_read_info->stream.next_in+i); - - pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32, - pfile_in_zip_read_info->stream.next_out, - uDoCopy); - pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy; - pfile_in_zip_read_info->stream.avail_in -= uDoCopy; - pfile_in_zip_read_info->stream.avail_out -= uDoCopy; - pfile_in_zip_read_info->stream.next_out += uDoCopy; - pfile_in_zip_read_info->stream.next_in += uDoCopy; - pfile_in_zip_read_info->stream.total_out += uDoCopy; - iRead += uDoCopy; - } - else - { - uLong uTotalOutBefore,uTotalOutAfter; - const Bytef *bufBefore; - uLong uOutThis; - int flush=Z_SYNC_FLUSH; - - uTotalOutBefore = pfile_in_zip_read_info->stream.total_out; - bufBefore = pfile_in_zip_read_info->stream.next_out; - - /* - if ((pfile_in_zip_read_info->rest_read_uncompressed == - pfile_in_zip_read_info->stream.avail_out) && - (pfile_in_zip_read_info->rest_read_compressed == 0)) - flush = Z_FINISH; - */ - err=inflate(&pfile_in_zip_read_info->stream,flush); - - uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; - uOutThis = uTotalOutAfter-uTotalOutBefore; - - pfile_in_zip_read_info->crc32 = - crc32(pfile_in_zip_read_info->crc32,bufBefore, - (uInt)(uOutThis)); - - pfile_in_zip_read_info->rest_read_uncompressed -= - uOutThis; - - iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); - - if (err==Z_STREAM_END) - return (iRead==0) ? UNZ_EOF : iRead; - if (err!=Z_OK) - break; - } - } - - if (err==Z_OK) - return iRead; - return err; -} - - -/* - Give the current position in uncompressed data -*/ -extern z_off_t ZEXPORT unztell (file) - unzFile file; -{ - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - pfile_in_zip_read_info=s->pfile_in_zip_read; - - if (pfile_in_zip_read_info==NULL) - return UNZ_PARAMERROR; - - return (z_off_t)pfile_in_zip_read_info->stream.total_out; -} - - -/* - return 1 if the end of file was reached, 0 elsewhere -*/ -extern int ZEXPORT unzeof (file) - unzFile file; -{ - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - pfile_in_zip_read_info=s->pfile_in_zip_read; - - if (pfile_in_zip_read_info==NULL) - return UNZ_PARAMERROR; - - if (pfile_in_zip_read_info->rest_read_uncompressed == 0) - return 1; - else - return 0; -} - - - -/* - Read extra field from the current file (opened by unzOpenCurrentFile) - This is the local-header version of the extra field (sometimes, there is - more info in the local-header version than in the central-header) - - if buf==NULL, it return the size of the local extra field that can be read - - if buf!=NULL, len is the size of the buffer, the extra header is copied in - buf. - the return value is the number of bytes copied in buf, or (if <0) - the error code -*/ -extern int ZEXPORT unzGetLocalExtrafield (file,buf,len) - unzFile file; - voidp buf; - unsigned len; -{ - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - uInt read_now; - uLong size_to_read; - - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - pfile_in_zip_read_info=s->pfile_in_zip_read; - - if (pfile_in_zip_read_info==NULL) - return UNZ_PARAMERROR; - - size_to_read = (pfile_in_zip_read_info->size_local_extrafield - - pfile_in_zip_read_info->pos_local_extrafield); - - if (buf==NULL) - return (int)size_to_read; - - if (len>size_to_read) - read_now = (uInt)size_to_read; - else - read_now = (uInt)len ; - - if (read_now==0) - return 0; - - if (fseek(pfile_in_zip_read_info->file, - pfile_in_zip_read_info->offset_local_extrafield + - pfile_in_zip_read_info->pos_local_extrafield,SEEK_SET)!=0) - return UNZ_ERRNO; - - if (fread(buf,(uInt)size_to_read,1,pfile_in_zip_read_info->file)!=1) - return UNZ_ERRNO; - - return (int)read_now; -} - -/* - Close the file in zip opened with unzipOpenCurrentFile - Return UNZ_CRCERROR if all the file was read but the CRC is not good -*/ -extern int ZEXPORT unzCloseCurrentFile (file) - unzFile file; -{ - int err=UNZ_OK; - - unz_s* s; - file_in_zip_read_info_s* pfile_in_zip_read_info; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - pfile_in_zip_read_info=s->pfile_in_zip_read; - - if (pfile_in_zip_read_info==NULL) - return UNZ_PARAMERROR; - - - if (pfile_in_zip_read_info->rest_read_uncompressed == 0) - { - if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait) - err=UNZ_CRCERROR; - } - - - TRYFREE(pfile_in_zip_read_info->read_buffer); - pfile_in_zip_read_info->read_buffer = NULL; - if (pfile_in_zip_read_info->stream_initialised) - inflateEnd(&pfile_in_zip_read_info->stream); - - pfile_in_zip_read_info->stream_initialised = 0; - TRYFREE(pfile_in_zip_read_info); - - s->pfile_in_zip_read=NULL; - - return err; -} - - -/* - Get the global comment string of the ZipFile, in the szComment buffer. - uSizeBuf is the size of the szComment buffer. - return the number of byte copied or an error code <0 -*/ -extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf) - unzFile file; - char *szComment; - uLong uSizeBuf; -{ - int err=UNZ_OK; - unz_s* s; - uLong uReadThis ; - if (file==NULL) - return UNZ_PARAMERROR; - s=(unz_s*)file; - - uReadThis = uSizeBuf; - if (uReadThis>s->gi.size_comment) - uReadThis = s->gi.size_comment; - - if (fseek(s->file,s->central_pos+22,SEEK_SET)!=0) - return UNZ_ERRNO; - - if (uReadThis>0) - { - *szComment='\0'; - if (fread(szComment,(uInt)uReadThis,1,s->file)!=1) - return UNZ_ERRNO; - } - - if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment)) - *(szComment+s->gi.size_comment)='\0'; - return (int)uReadThis; -} diff --git a/src/crashrpt/zlib/unzip.h b/src/crashrpt/zlib/unzip.h deleted file mode 100644 index 5692cc8d0..000000000 --- a/src/crashrpt/zlib/unzip.h +++ /dev/null @@ -1,275 +0,0 @@ -/* unzip.h -- IO for uncompress .zip files using zlib - Version 0.15 beta, Mar 19th, 1998, - - Copyright (C) 1998 Gilles Vollant - - This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g - WinZip, InfoZip tools and compatible. - Encryption and multi volume ZipFile (span) are not supported. - Old compressions used by old PKZip 1.x are not supported - - THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE - CAN CHANGE IN FUTURE VERSION !! - I WAIT FEEDBACK at mail info@winimage.com - Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution - - Condition of use and distribution are the same than zlib : - - 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. - - -*/ -/* for more info about .ZIP format, see - ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip - PkWare has also a specification at : - ftp://ftp.pkware.com/probdesc.zip */ - -#ifndef _unz_H -#define _unz_H - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _ZLIB_H -#include "zlib.h" -#endif - -#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) -/* like the STRICT of WIN32, we define a pointer that cannot be converted - from (void*) without cast */ -typedef struct TagunzFile__ { int unused; } unzFile__; -typedef unzFile__ *unzFile; -#else -typedef voidp unzFile; -#endif - - -#define UNZ_OK (0) -#define UNZ_END_OF_LIST_OF_FILE (-100) -#define UNZ_ERRNO (Z_ERRNO) -#define UNZ_EOF (0) -#define UNZ_PARAMERROR (-102) -#define UNZ_BADZIPFILE (-103) -#define UNZ_INTERNALERROR (-104) -#define UNZ_CRCERROR (-105) - -/* tm_unz contain date/time info */ -typedef struct tm_unz_s -{ - uInt tm_sec; /* seconds after the minute - [0,59] */ - uInt tm_min; /* minutes after the hour - [0,59] */ - uInt tm_hour; /* hours since midnight - [0,23] */ - uInt tm_mday; /* day of the month - [1,31] */ - uInt tm_mon; /* months since January - [0,11] */ - uInt tm_year; /* years - [1980..2044] */ -} tm_unz; - -/* unz_global_info structure contain global data about the ZIPfile - These data comes from the end of central dir */ -typedef struct unz_global_info_s -{ - uLong number_entry; /* total number of entries in - the central dir on this disk */ - uLong size_comment; /* size of the global comment of the zipfile */ -} unz_global_info; - - -/* unz_file_info contain information about a file in the zipfile */ -typedef struct unz_file_info_s -{ - uLong version; /* version made by 2 bytes */ - uLong version_needed; /* version needed to extract 2 bytes */ - uLong flag; /* general purpose bit flag 2 bytes */ - uLong compression_method; /* compression method 2 bytes */ - uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ - uLong crc; /* crc-32 4 bytes */ - uLong compressed_size; /* compressed size 4 bytes */ - uLong uncompressed_size; /* uncompressed size 4 bytes */ - uLong size_filename; /* filename length 2 bytes */ - uLong size_file_extra; /* extra field length 2 bytes */ - uLong size_file_comment; /* file comment length 2 bytes */ - - uLong disk_num_start; /* disk number start 2 bytes */ - uLong internal_fa; /* internal file attributes 2 bytes */ - uLong external_fa; /* external file attributes 4 bytes */ - - tm_unz tmu_date; -} unz_file_info; - -extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, - const char* fileName2, - int iCaseSensitivity)); -/* - Compare two filename (fileName1,fileName2). - If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) - If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi - or strcasecmp) - If iCaseSenisivity = 0, case sensitivity is defaut of your operating system - (like 1 on Unix, 2 on Windows) -*/ - - -extern unzFile ZEXPORT unzOpen OF((const char *path)); -/* - Open a Zip file. path contain the full pathname (by example, - on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer - "zlib/zlib111.zip". - If the zipfile cannot be opened (file don't exist or in not valid), the - return value is NULL. - Else, the return value is a unzFile Handle, usable with other function - of this unzip package. -*/ - -extern int ZEXPORT unzClose OF((unzFile file)); -/* - Close a ZipFile opened with unzipOpen. - If there is files inside the .Zip opened with unzOpenCurrentFile (see later), - these files MUST be closed with unzipCloseCurrentFile before call unzipClose. - return UNZ_OK if there is no problem. */ - -extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, - unz_global_info *pglobal_info)); -/* - Write info about the ZipFile in the *pglobal_info structure. - No preparation of the structure is needed - return UNZ_OK if there is no problem. */ - - -extern int ZEXPORT unzGetGlobalComment OF((unzFile file, - char *szComment, - uLong uSizeBuf)); -/* - Get the global comment string of the ZipFile, in the szComment buffer. - uSizeBuf is the size of the szComment buffer. - return the number of byte copied or an error code <0 -*/ - - -/***************************************************************************/ -/* Unzip package allow you browse the directory of the zipfile */ - -extern int ZEXPORT unzGoToFirstFile OF((unzFile file)); -/* - Set the current file of the zipfile to the first file. - return UNZ_OK if there is no problem -*/ - -extern int ZEXPORT unzGoToNextFile OF((unzFile file)); -/* - Set the current file of the zipfile to the next file. - return UNZ_OK if there is no problem - return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. -*/ - -extern int ZEXPORT unzLocateFile OF((unzFile file, - const char *szFileName, - int iCaseSensitivity)); -/* - Try locate the file szFileName in the zipfile. - For the iCaseSensitivity signification, see unzStringFileNameCompare - - return value : - UNZ_OK if the file is found. It becomes the current file. - UNZ_END_OF_LIST_OF_FILE if the file is not found -*/ - - -extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, - unz_file_info *pfile_info, - char *szFileName, - uLong fileNameBufferSize, - void *extraField, - uLong extraFieldBufferSize, - char *szComment, - uLong commentBufferSize)); -/* - Get Info about the current file - if pfile_info!=NULL, the *pfile_info structure will contain somes info about - the current file - if szFileName!=NULL, the filemane string will be copied in szFileName - (fileNameBufferSize is the size of the buffer) - if extraField!=NULL, the extra field information will be copied in extraField - (extraFieldBufferSize is the size of the buffer). - This is the Central-header version of the extra field - if szComment!=NULL, the comment string of the file will be copied in szComment - (commentBufferSize is the size of the buffer) -*/ - -/***************************************************************************/ -/* for reading the content of the current zipfile, you can open it, read data - from it, and close it (you can close it before reading all the file) - */ - -extern int ZEXPORT unzOpenCurrentFile OF((unzFile file)); -/* - Open for reading data the current file in the zipfile. - If there is no error, the return value is UNZ_OK. -*/ - -extern int ZEXPORT unzCloseCurrentFile OF((unzFile file)); -/* - Close the file in zip opened with unzOpenCurrentFile - Return UNZ_CRCERROR if all the file was read but the CRC is not good -*/ - - -extern int ZEXPORT unzReadCurrentFile OF((unzFile file, - voidp buf, - unsigned len)); -/* - Read bytes from the current file (opened by unzOpenCurrentFile) - buf contain buffer where data must be copied - len the size of buf. - - return the number of byte copied if somes bytes are copied - return 0 if the end of file was reached - return <0 with error code if there is an error - (UNZ_ERRNO for IO error, or zLib error for uncompress error) -*/ - -extern z_off_t ZEXPORT unztell OF((unzFile file)); -/* - Give the current position in uncompressed data -*/ - -extern int ZEXPORT unzeof OF((unzFile file)); -/* - return 1 if the end of file was reached, 0 elsewhere -*/ - -extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, - voidp buf, - unsigned len)); -/* - Read extra field from the current file (opened by unzOpenCurrentFile) - This is the local-header version of the extra field (sometimes, there is - more info in the local-header version than in the central-header) - - if buf==NULL, it return the size of the local extra field - - if buf!=NULL, len is the size of the buffer, the extra header is copied in - buf. - the return value is the number of bytes copied in buf, or (if <0) - the error code -*/ - -#ifdef __cplusplus -} -#endif - -#endif /* _unz_H */ diff --git a/src/crashrpt/zlib/zconf.h b/src/crashrpt/zlib/zconf.h deleted file mode 100644 index 9e5e430f4..000000000 --- a/src/crashrpt/zlib/zconf.h +++ /dev/null @@ -1,279 +0,0 @@ -/* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2002 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id: zconf.h,v 1.1 2003/05/23 21:05:30 steveking Exp $ */ - -#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. - */ -#ifdef Z_PREFIX -# define deflateInit_ z_deflateInit_ -# define deflate z_deflate -# define deflateEnd z_deflateEnd -# define inflateInit_ z_inflateInit_ -# define inflate z_inflate -# define inflateEnd z_inflateEnd -# define deflateInit2_ z_deflateInit2_ -# define deflateSetDictionary z_deflateSetDictionary -# define deflateCopy z_deflateCopy -# define deflateReset z_deflateReset -# define deflateParams z_deflateParams -# define inflateInit2_ z_inflateInit2_ -# define inflateSetDictionary z_inflateSetDictionary -# define inflateSync z_inflateSync -# define inflateSyncPoint z_inflateSyncPoint -# define inflateReset z_inflateReset -# define compress z_compress -# define compress2 z_compress2 -# define uncompress z_uncompress -# define adler32 z_adler32 -# define crc32 z_crc32 -# define get_crc_table z_get_crc_table - -# define Byte z_Byte -# define uInt z_uInt -# define uLong z_uLong -# define Bytef z_Bytef -# define charf z_charf -# define intf z_intf -# define uIntf z_uIntf -# define uLongf z_uLongf -# define voidpf z_voidpf -# define voidp z_voidp -#endif - -#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) -# define WIN32 -#endif -#if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(i386) -# ifndef __32BIT__ -# define __32BIT__ -# endif -#endif -#if defined(__MSDOS__) && !defined(MSDOS) -# define MSDOS -#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). - */ -#if defined(MSDOS) && !defined(__32BIT__) -# define MAXSEG_64K -#endif -#ifdef MSDOS -# define UNALIGNED_OK -#endif - -#if (defined(MSDOS) || defined(_WINDOWS) || defined(WIN32)) && !defined(STDC) -# define STDC -#endif -#if defined(__STDC__) || defined(__cplusplus) || defined(__OS2__) -# ifndef STDC -# define STDC -# endif -#endif - -#ifndef STDC -# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ -# define const -# 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 - -/* Old Borland C incorrectly complains about missing returns: */ -#if defined(__BORLANDC__) && (__BORLANDC__ < 0x500) -# define NEED_DUMMY_RETURN -#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. - */ -#if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__) - /* MSC small or medium model */ -# define SMALL_MEDIUM -# ifdef _MSC_VER -# define FAR _far -# else -# define FAR far -# endif -#endif -#if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__)) -# ifndef __32BIT__ -# define SMALL_MEDIUM -# define FAR _far -# endif -#endif - -/* Compile with -DZLIB_DLL for Windows DLL support */ -#if defined(ZLIB_DLL) -# if defined(_WINDOWS) || defined(WINDOWS) -# ifdef FAR -# undef FAR -# endif -# include -# define ZEXPORT WINAPI -# ifdef WIN32 -# define ZEXPORTVA WINAPIV -# else -# define ZEXPORTVA FAR _cdecl _export -# endif -# endif -# if defined (__BORLANDC__) -# if (__BORLANDC__ >= 0x0500) && defined (WIN32) -# include -# define ZEXPORT __declspec(dllexport) WINAPI -# define ZEXPORTRVA __declspec(dllexport) WINAPIV -# else -# if defined (_Windows) && defined (__DLL__) -# define ZEXPORT _export -# define ZEXPORTVA _export -# endif -# endif -# endif -#endif - -#if defined (__BEOS__) -# if defined (ZLIB_DLL) -# define ZEXTERN extern __declspec(dllexport) -# else -# define ZEXTERN extern __declspec(dllimport) -# endif -#endif - -#ifndef ZEXPORT -# define ZEXPORT -#endif -#ifndef ZEXPORTVA -# define ZEXPORTVA -#endif -#ifndef ZEXTERN -# define ZEXTERN extern -#endif - -#ifndef FAR -# define FAR -#endif - -#if !defined(MACOS) && !defined(TARGET_OS_MAC) -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 FAR *voidpf; - typedef void *voidp; -#else - typedef Byte FAR *voidpf; - typedef Byte *voidp; -#endif - -#ifdef HAVE_UNISTD_H -# include /* for off_t */ -# include /* for SEEK_* and off_t */ -# define z_off_t off_t -#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 - -/* 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(inflateInit_,"ININ") -# pragma map(inflateInit2_,"ININ2") -# pragma map(inflateEnd,"INEND") -# pragma map(inflateSync,"INSY") -# pragma map(inflateSetDictionary,"INSEDI") -# pragma map(inflate_blocks,"INBL") -# pragma map(inflate_blocks_new,"INBLNE") -# pragma map(inflate_blocks_free,"INBLFR") -# pragma map(inflate_blocks_reset,"INBLRE") -# pragma map(inflate_codes_free,"INCOFR") -# pragma map(inflate_codes,"INCO") -# pragma map(inflate_fast,"INFA") -# pragma map(inflate_flush,"INFLU") -# pragma map(inflate_mask,"INMA") -# pragma map(inflate_set_dictionary,"INSEDI2") -# pragma map(inflate_copyright,"INCOPY") -# pragma map(inflate_trees_bits,"INTRBI") -# pragma map(inflate_trees_dynamic,"INTRDY") -# pragma map(inflate_trees_fixed,"INTRFI") -# pragma map(inflate_trees_free,"INTRFR") -#endif - -#endif /* _ZCONF_H */ diff --git a/src/crashrpt/zlib/zip.c b/src/crashrpt/zlib/zip.c deleted file mode 100644 index 135d0974f..000000000 --- a/src/crashrpt/zlib/zip.c +++ /dev/null @@ -1,719 +0,0 @@ -/* zip.c -- IO on .zip files using zlib - Version 0.15 beta, Mar 19th, 1998, - - Read zip.h for more info -*/ - - -#include -#include -#include -#include "zlib.h" -#include "zip.h" -#include "zutil.h" - -#ifdef STDC -# include -# include -# include -#endif -#ifdef NO_ERRNO_H - extern int errno; -#else -# include -#endif - - -#ifndef local -# define local static -#endif -/* compile with -Dlocal if your debugger can't find static symbols */ - -#ifndef VERSIONMADEBY -# define VERSIONMADEBY (0x0) /* platform depedent */ -#endif - -#ifndef Z_BUFSIZE -#define Z_BUFSIZE (16384) -#endif - -#ifndef Z_MAXFILENAMEINZIP -#define Z_MAXFILENAMEINZIP (256) -#endif - -#ifndef ALLOC -# define ALLOC(size) (malloc(size)) -#endif -#ifndef TRYFREE -# define TRYFREE(p) {if (p) free(p);} -#endif - -/* -#define SIZECENTRALDIRITEM (0x2e) -#define SIZEZIPLOCALHEADER (0x1e) -*/ - -/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ - -#ifndef SEEK_CUR -#define SEEK_CUR 1 -#endif - -#ifndef SEEK_END -#define SEEK_END 2 -#endif - -#ifndef SEEK_SET -#define SEEK_SET 0 -#endif - -const char zip_copyright[] = - " zip 0.15 Copyright 1998 Gilles Vollant "; - - -#define SIZEDATA_INDATABLOCK (4096-(4*4)) - -#define LOCALHEADERMAGIC (0x04034b50) -#define CENTRALHEADERMAGIC (0x02014b50) -#define ENDHEADERMAGIC (0x06054b50) - -#define FLAG_LOCALHEADER_OFFSET (0x06) -#define CRC_LOCALHEADER_OFFSET (0x0e) - -#define SIZECENTRALHEADER (0x2e) /* 46 */ - -typedef struct linkedlist_datablock_internal_s -{ - struct linkedlist_datablock_internal_s* next_datablock; - uLong avail_in_this_block; - uLong filled_in_this_block; - uLong unused; /* for future use and alignement */ - unsigned char data[SIZEDATA_INDATABLOCK]; -} linkedlist_datablock_internal; - -typedef struct linkedlist_data_s -{ - linkedlist_datablock_internal* first_block; - linkedlist_datablock_internal* last_block; -} linkedlist_data; - - -typedef struct -{ - z_stream stream; /* zLib stream structure for inflate */ - int stream_initialised; /* 1 is stream is initialised */ - uInt pos_in_buffered_data; /* last written byte in buffered_data */ - - uLong pos_local_header; /* offset of the local header of the file - currenty writing */ - char* central_header; /* central header data for the current file */ - uLong size_centralheader; /* size of the central header for cur file */ - uLong flag; /* flag of the file currently writing */ - - int method; /* compression method of file currenty wr.*/ - Byte buffered_data[Z_BUFSIZE];/* buffer contain compressed data to be writ*/ - uLong dosDate; - uLong crc32; -} curfile_info; - -typedef struct -{ - FILE * filezip; - linkedlist_data central_dir;/* datablock with central dir in construction*/ - int in_opened_file_inzip; /* 1 if a file in the zip is currently writ.*/ - curfile_info ci; /* info on the file curretly writing */ - - uLong begin_pos; /* position of the beginning of the zipfile */ - uLong number_entry; -} zip_internal; - -local linkedlist_datablock_internal* allocate_new_datablock() -{ - linkedlist_datablock_internal* ldi; - ldi = (linkedlist_datablock_internal*) - ALLOC(sizeof(linkedlist_datablock_internal)); - if (ldi!=NULL) - { - ldi->next_datablock = NULL ; - ldi->filled_in_this_block = 0 ; - ldi->avail_in_this_block = SIZEDATA_INDATABLOCK ; - } - return ldi; -} - -local void free_datablock(ldi) - linkedlist_datablock_internal* ldi; -{ - while (ldi!=NULL) - { - linkedlist_datablock_internal* ldinext = ldi->next_datablock; - TRYFREE(ldi); - ldi = ldinext; - } -} - -local void init_linkedlist(ll) - linkedlist_data* ll; -{ - ll->first_block = ll->last_block = NULL; -} - -local void free_linkedlist(ll) - linkedlist_data* ll; -{ - free_datablock(ll->first_block); - ll->first_block = ll->last_block = NULL; -} - - -local int add_data_in_datablock(ll,buf,len) - linkedlist_data* ll; - const void* buf; - uLong len; -{ - linkedlist_datablock_internal* ldi; - const unsigned char* from_copy; - - if (ll==NULL) - return ZIP_INTERNALERROR; - - if (ll->last_block == NULL) - { - ll->first_block = ll->last_block = allocate_new_datablock(); - if (ll->first_block == NULL) - return ZIP_INTERNALERROR; - } - - ldi = ll->last_block; - from_copy = (unsigned char*)buf; - - while (len>0) - { - uInt copy_this; - uInt i; - unsigned char* to_copy; - - if (ldi->avail_in_this_block==0) - { - ldi->next_datablock = allocate_new_datablock(); - if (ldi->next_datablock == NULL) - return ZIP_INTERNALERROR; - ldi = ldi->next_datablock ; - ll->last_block = ldi; - } - - if (ldi->avail_in_this_block < len) - copy_this = (uInt)ldi->avail_in_this_block; - else - copy_this = (uInt)len; - - to_copy = &(ldi->data[ldi->filled_in_this_block]); - - for (i=0;ifilled_in_this_block += copy_this; - ldi->avail_in_this_block -= copy_this; - from_copy += copy_this ; - len -= copy_this; - } - return ZIP_OK; -} - - -local int write_datablock(fout,ll) - FILE * fout; - linkedlist_data* ll; -{ - linkedlist_datablock_internal* ldi; - ldi = ll->first_block; - while (ldi!=NULL) - { - if (ldi->filled_in_this_block > 0) - if (fwrite(ldi->data,(uInt)ldi->filled_in_this_block,1,fout)!=1) - return ZIP_ERRNO; - ldi = ldi->next_datablock; - } - return ZIP_OK; -} - -/****************************************************************************/ - -/* =========================================================================== - Outputs a long in LSB order to the given file - nbByte == 1, 2 or 4 (byte, short or long) -*/ - -local int ziplocal_putValue OF((FILE *file, uLong x, int nbByte)); -local int ziplocal_putValue (file, x, nbByte) - FILE *file; - uLong x; - int nbByte; -{ - unsigned char buf[4]; - int n; - for (n = 0; n < nbByte; n++) { - buf[n] = (unsigned char)(x & 0xff); - x >>= 8; - } - if (fwrite(buf,nbByte,1,file)!=1) - return ZIP_ERRNO; - else - return ZIP_OK; -} - -local void ziplocal_putValue_inmemory OF((void* dest, uLong x, int nbByte)); -local void ziplocal_putValue_inmemory (dest, x, nbByte) - void* dest; - uLong x; - int nbByte; -{ - unsigned char* buf=(unsigned char*)dest; - int n; - for (n = 0; n < nbByte; n++) { - buf[n] = (unsigned char)(x & 0xff); - x >>= 8; - } -} -/****************************************************************************/ - - -local uLong ziplocal_TmzDateToDosDate(ptm,dosDate) - tm_zip* ptm; - uLong dosDate; -{ - uLong year = (uLong)ptm->tm_year; - if (year>1980) - year-=1980; - else if (year>80) - year-=80; - return - (uLong) (((ptm->tm_mday) + (32 * (ptm->tm_mon+1)) + (512 * year)) << 16) | - ((ptm->tm_sec/2) + (32* ptm->tm_min) + (2048 * (uLong)ptm->tm_hour)); -} - - -/****************************************************************************/ - -extern zipFile ZEXPORT zipOpen (pathname, append) - const char *pathname; - int append; -{ - zip_internal ziinit; - zip_internal* zi; - - ziinit.filezip = fopen(pathname,(append == 0) ? "wb" : "ab"); - if (ziinit.filezip == NULL) - return NULL; - ziinit.begin_pos = ftell(ziinit.filezip); - ziinit.in_opened_file_inzip = 0; - ziinit.ci.stream_initialised = 0; - ziinit.number_entry = 0; - init_linkedlist(&(ziinit.central_dir)); - - - zi = (zip_internal*)ALLOC(sizeof(zip_internal)); - if (zi==NULL) - { - fclose(ziinit.filezip); - return NULL; - } - - *zi = ziinit; - return (zipFile)zi; -} - -extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi, - extrafield_local, size_extrafield_local, - extrafield_global, size_extrafield_global, - comment, method, level) - zipFile file; - const char* filename; - const zip_fileinfo* zipfi; - const void* extrafield_local; - uInt size_extrafield_local; - const void* extrafield_global; - uInt size_extrafield_global; - const char* comment; - int method; - int level; -{ - zip_internal* zi; - uInt size_filename; - uInt size_comment; - uInt i; - int err = ZIP_OK; - - if (file == NULL) - return ZIP_PARAMERROR; - if ((method!=0) && (method!=Z_DEFLATED)) - return ZIP_PARAMERROR; - - zi = (zip_internal*)file; - - if (zi->in_opened_file_inzip == 1) - { - err = zipCloseFileInZip (file); - if (err != ZIP_OK) - return err; - } - - - if (filename==NULL) - filename="-"; - - if (comment==NULL) - size_comment = 0; - else - size_comment = strlen(comment); - - size_filename = strlen(filename); - - if (zipfi == NULL) - zi->ci.dosDate = 0; - else - { - if (zipfi->dosDate != 0) - zi->ci.dosDate = zipfi->dosDate; - else zi->ci.dosDate = ziplocal_TmzDateToDosDate(&zipfi->tmz_date,zipfi->dosDate); - } - - zi->ci.flag = 0; - if ((level==8) || (level==9)) - zi->ci.flag |= 2; - if ((level==2)) - zi->ci.flag |= 4; - if ((level==1)) - zi->ci.flag |= 6; - - zi->ci.crc32 = 0; - zi->ci.method = method; - zi->ci.stream_initialised = 0; - zi->ci.pos_in_buffered_data = 0; - zi->ci.pos_local_header = ftell(zi->filezip); - zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename + - size_extrafield_global + size_comment; - zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader); - - ziplocal_putValue_inmemory(zi->ci.central_header,(uLong)CENTRALHEADERMAGIC,4); - /* version info */ - ziplocal_putValue_inmemory(zi->ci.central_header+4,(uLong)VERSIONMADEBY,2); - ziplocal_putValue_inmemory(zi->ci.central_header+6,(uLong)20,2); - ziplocal_putValue_inmemory(zi->ci.central_header+8,(uLong)zi->ci.flag,2); - ziplocal_putValue_inmemory(zi->ci.central_header+10,(uLong)zi->ci.method,2); - ziplocal_putValue_inmemory(zi->ci.central_header+12,(uLong)zi->ci.dosDate,4); - ziplocal_putValue_inmemory(zi->ci.central_header+16,(uLong)0,4); /*crc*/ - ziplocal_putValue_inmemory(zi->ci.central_header+20,(uLong)0,4); /*compr size*/ - ziplocal_putValue_inmemory(zi->ci.central_header+24,(uLong)0,4); /*uncompr size*/ - ziplocal_putValue_inmemory(zi->ci.central_header+28,(uLong)size_filename,2); - ziplocal_putValue_inmemory(zi->ci.central_header+30,(uLong)size_extrafield_global,2); - ziplocal_putValue_inmemory(zi->ci.central_header+32,(uLong)size_comment,2); - ziplocal_putValue_inmemory(zi->ci.central_header+34,(uLong)0,2); /*disk nm start*/ - - if (zipfi==NULL) - ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)0,2); - else - ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)zipfi->internal_fa,2); - - if (zipfi==NULL) - ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)0,4); - else - ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)zipfi->external_fa,4); - - ziplocal_putValue_inmemory(zi->ci.central_header+42,(uLong)zi->ci.pos_local_header,4); - - for (i=0;ici.central_header+SIZECENTRALHEADER+i) = *(filename+i); - - for (i=0;ici.central_header+SIZECENTRALHEADER+size_filename+i) = - *(((const char*)extrafield_global)+i); - - for (i=0;ici.central_header+SIZECENTRALHEADER+size_filename+ - size_extrafield_global+i) = *(filename+i); - if (zi->ci.central_header == NULL) - return ZIP_INTERNALERROR; - - /* write the local header */ - err = ziplocal_putValue(zi->filezip,(uLong)LOCALHEADERMAGIC,4); - - if (err==ZIP_OK) - err = ziplocal_putValue(zi->filezip,(uLong)20,2);/* version needed to extract */ - if (err==ZIP_OK) - err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.flag,2); - - if (err==ZIP_OK) - err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.method,2); - - if (err==ZIP_OK) - err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.dosDate,4); - - if (err==ZIP_OK) - err = ziplocal_putValue(zi->filezip,(uLong)0,4); /* crc 32, unknown */ - if (err==ZIP_OK) - err = ziplocal_putValue(zi->filezip,(uLong)0,4); /* compressed size, unknown */ - if (err==ZIP_OK) - err = ziplocal_putValue(zi->filezip,(uLong)0,4); /* uncompressed size, unknown */ - - if (err==ZIP_OK) - err = ziplocal_putValue(zi->filezip,(uLong)size_filename,2); - - if (err==ZIP_OK) - err = ziplocal_putValue(zi->filezip,(uLong)size_extrafield_local,2); - - if ((err==ZIP_OK) && (size_filename>0)) - if (fwrite(filename,(uInt)size_filename,1,zi->filezip)!=1) - err = ZIP_ERRNO; - - if ((err==ZIP_OK) && (size_extrafield_local>0)) - if (fwrite(extrafield_local,(uInt)size_extrafield_local,1,zi->filezip) - !=1) - err = ZIP_ERRNO; - - zi->ci.stream.avail_in = (uInt)0; - zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; - zi->ci.stream.next_out = zi->ci.buffered_data; - zi->ci.stream.total_in = 0; - zi->ci.stream.total_out = 0; - - if ((err==ZIP_OK) && (zi->ci.method == Z_DEFLATED)) - { - zi->ci.stream.zalloc = (alloc_func)0; - zi->ci.stream.zfree = (free_func)0; - zi->ci.stream.opaque = (voidpf)0; - - err = deflateInit2(&zi->ci.stream, level, - Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, 0); - - if (err==Z_OK) - zi->ci.stream_initialised = 1; - } - - - if (err==Z_OK) - zi->in_opened_file_inzip = 1; - return err; -} - -extern int ZEXPORT zipWriteInFileInZip (file, buf, len) - zipFile file; - const voidp buf; - unsigned len; -{ - zip_internal* zi; - int err=ZIP_OK; - - if (file == NULL) - return ZIP_PARAMERROR; - zi = (zip_internal*)file; - - if (zi->in_opened_file_inzip == 0) - return ZIP_PARAMERROR; - - zi->ci.stream.next_in = buf; - zi->ci.stream.avail_in = len; - zi->ci.crc32 = crc32(zi->ci.crc32,buf,len); - - while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0)) - { - if (zi->ci.stream.avail_out == 0) - { - if (fwrite(zi->ci.buffered_data,(uInt)zi->ci.pos_in_buffered_data,1,zi->filezip) - !=1) - err = ZIP_ERRNO; - zi->ci.pos_in_buffered_data = 0; - zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; - zi->ci.stream.next_out = zi->ci.buffered_data; - } - - if (zi->ci.method == Z_DEFLATED) - { - uLong uTotalOutBefore = zi->ci.stream.total_out; - err=deflate(&zi->ci.stream, Z_NO_FLUSH); - zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; - - } - else - { - uInt copy_this,i; - if (zi->ci.stream.avail_in < zi->ci.stream.avail_out) - copy_this = zi->ci.stream.avail_in; - else - copy_this = zi->ci.stream.avail_out; - for (i=0;ici.stream.next_out)+i) = - *(((const char*)zi->ci.stream.next_in)+i); - { - zi->ci.stream.avail_in -= copy_this; - zi->ci.stream.avail_out-= copy_this; - zi->ci.stream.next_in+= copy_this; - zi->ci.stream.next_out+= copy_this; - zi->ci.stream.total_in+= copy_this; - zi->ci.stream.total_out+= copy_this; - zi->ci.pos_in_buffered_data += copy_this; - } - } - } - - return 0; -} - -extern int ZEXPORT zipCloseFileInZip (file) - zipFile file; -{ - zip_internal* zi; - int err=ZIP_OK; - - if (file == NULL) - return ZIP_PARAMERROR; - zi = (zip_internal*)file; - - if (zi->in_opened_file_inzip == 0) - return ZIP_PARAMERROR; - zi->ci.stream.avail_in = 0; - - if (zi->ci.method == Z_DEFLATED) - while (err==ZIP_OK) - { - uLong uTotalOutBefore; - if (zi->ci.stream.avail_out == 0) - { - if (fwrite(zi->ci.buffered_data,(uInt)zi->ci.pos_in_buffered_data,1,zi->filezip) - !=1) - err = ZIP_ERRNO; - zi->ci.pos_in_buffered_data = 0; - zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; - zi->ci.stream.next_out = zi->ci.buffered_data; - } - uTotalOutBefore = zi->ci.stream.total_out; - err=deflate(&zi->ci.stream, Z_FINISH); - zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; - } - - if (err==Z_STREAM_END) - err=ZIP_OK; /* this is normal */ - - if ((zi->ci.pos_in_buffered_data>0) && (err==ZIP_OK)) - if (fwrite(zi->ci.buffered_data,(uInt)zi->ci.pos_in_buffered_data,1,zi->filezip) - !=1) - err = ZIP_ERRNO; - - if ((zi->ci.method == Z_DEFLATED) && (err==ZIP_OK)) - { - err=deflateEnd(&zi->ci.stream); - zi->ci.stream_initialised = 0; - } - - ziplocal_putValue_inmemory(zi->ci.central_header+16,(uLong)zi->ci.crc32,4); /*crc*/ - ziplocal_putValue_inmemory(zi->ci.central_header+20, - (uLong)zi->ci.stream.total_out,4); /*compr size*/ - ziplocal_putValue_inmemory(zi->ci.central_header+24, - (uLong)zi->ci.stream.total_in,4); /*uncompr size*/ - - if (err==ZIP_OK) - err = add_data_in_datablock(&zi->central_dir,zi->ci.central_header, - (uLong)zi->ci.size_centralheader); - free(zi->ci.central_header); - - if (err==ZIP_OK) - { - long cur_pos_inzip = ftell(zi->filezip); - if (fseek(zi->filezip, - zi->ci.pos_local_header + 14,SEEK_SET)!=0) - err = ZIP_ERRNO; - - if (err==ZIP_OK) - err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.crc32,4); /* crc 32, unknown */ - - if (err==ZIP_OK) /* compressed size, unknown */ - err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.stream.total_out,4); - - if (err==ZIP_OK) /* uncompressed size, unknown */ - err = ziplocal_putValue(zi->filezip,(uLong)zi->ci.stream.total_in,4); - - if (fseek(zi->filezip, - cur_pos_inzip,SEEK_SET)!=0) - err = ZIP_ERRNO; - } - - zi->number_entry ++; - zi->in_opened_file_inzip = 0; - - return err; -} - -extern int ZEXPORT zipClose (file, global_comment) - zipFile file; - const char* global_comment; -{ - zip_internal* zi; - int err = 0; - uLong size_centraldir = 0; - uLong centraldir_pos_inzip ; - uInt size_global_comment; - if (file == NULL) - return ZIP_PARAMERROR; - zi = (zip_internal*)file; - - if (zi->in_opened_file_inzip == 1) - { - err = zipCloseFileInZip (file); - } - - if (global_comment==NULL) - size_global_comment = 0; - else - size_global_comment = strlen(global_comment); - - - centraldir_pos_inzip = ftell(zi->filezip); - if (err==ZIP_OK) - { - linkedlist_datablock_internal* ldi = zi->central_dir.first_block ; - while (ldi!=NULL) - { - if ((err==ZIP_OK) && (ldi->filled_in_this_block>0)) - if (fwrite(ldi->data,(uInt)ldi->filled_in_this_block, - 1,zi->filezip) !=1 ) - err = ZIP_ERRNO; - - size_centraldir += ldi->filled_in_this_block; - ldi = ldi->next_datablock; - } - } - free_datablock(zi->central_dir.first_block); - - if (err==ZIP_OK) /* Magic End */ - err = ziplocal_putValue(zi->filezip,(uLong)ENDHEADERMAGIC,4); - - if (err==ZIP_OK) /* number of this disk */ - err = ziplocal_putValue(zi->filezip,(uLong)0,2); - - if (err==ZIP_OK) /* number of the disk with the start of the central directory */ - err = ziplocal_putValue(zi->filezip,(uLong)0,2); - - if (err==ZIP_OK) /* total number of entries in the central dir on this disk */ - err = ziplocal_putValue(zi->filezip,(uLong)zi->number_entry,2); - - if (err==ZIP_OK) /* total number of entries in the central dir */ - err = ziplocal_putValue(zi->filezip,(uLong)zi->number_entry,2); - - if (err==ZIP_OK) /* size of the central directory */ - err = ziplocal_putValue(zi->filezip,(uLong)size_centraldir,4); - - if (err==ZIP_OK) /* offset of start of central directory with respect to the - starting disk number */ - err = ziplocal_putValue(zi->filezip,(uLong)centraldir_pos_inzip ,4); - - if (err==ZIP_OK) /* zipfile comment length */ - err = ziplocal_putValue(zi->filezip,(uLong)size_global_comment,2); - - if ((err==ZIP_OK) && (size_global_comment>0)) - if (fwrite(global_comment,(uInt)size_global_comment,1,zi->filezip) !=1 ) - err = ZIP_ERRNO; - fclose(zi->filezip); - TRYFREE(zi); - - return err; -} diff --git a/src/crashrpt/zlib/zip.h b/src/crashrpt/zlib/zip.h deleted file mode 100644 index 1eed46995..000000000 --- a/src/crashrpt/zlib/zip.h +++ /dev/null @@ -1,150 +0,0 @@ -/* zip.h -- IO for compress .zip files using zlib - Version 0.15 alpha, Mar 19th, 1998, - - Copyright (C) 1998 Gilles Vollant - - This unzip package allow creates .ZIP file, compatible with PKZip 2.04g - WinZip, InfoZip tools and compatible. - Encryption and multi volume ZipFile (span) are not supported. - Old compressions used by old PKZip 1.x are not supported - - For uncompress .zip file, look at unzip.h - - THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE - CAN CHANGE IN FUTURE VERSION !! - I WAIT FEEDBACK at mail info@winimage.com - Visit also http://www.winimage.com/zLibDll/zip.htm for evolution - - Condition of use and distribution are the same than zlib : - - 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. - - -*/ - -/* for more info about .ZIP format, see - ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip - PkWare has also a specification at : - ftp://ftp.pkware.com/probdesc.zip -*/ - -#ifndef _zip_H -#define _zip_H - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _ZLIB_H -#include "zlib.h" -#endif - -#if defined(STRICTZIP) || defined(STRICTZIPUNZIP) -/* like the STRICT of WIN32, we define a pointer that cannot be converted - from (void*) without cast */ -typedef struct TagzipFile__ { int unused; } zipFile__; -typedef zipFile__ *zipFile; -#else -typedef voidp zipFile; -#endif - -#define ZIP_OK (0) -#define ZIP_ERRNO (Z_ERRNO) -#define ZIP_PARAMERROR (-102) -#define ZIP_INTERNALERROR (-104) - -/* tm_zip contain date/time info */ -typedef struct tm_zip_s -{ - uInt tm_sec; /* seconds after the minute - [0,59] */ - uInt tm_min; /* minutes after the hour - [0,59] */ - uInt tm_hour; /* hours since midnight - [0,23] */ - uInt tm_mday; /* day of the month - [1,31] */ - uInt tm_mon; /* months since January - [0,11] */ - uInt tm_year; /* years - [1980..2044] */ -} tm_zip; - -typedef struct -{ - tm_zip tmz_date; /* date in understandable format */ - uLong dosDate; /* if dos_date == 0, tmu_date is used */ -/* uLong flag; */ /* general purpose bit flag 2 bytes */ - - uLong internal_fa; /* internal file attributes 2 bytes */ - uLong external_fa; /* external file attributes 4 bytes */ -} zip_fileinfo; - -extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append)); -/* - Create a zipfile. - pathname contain on Windows NT a filename like "c:\\zlib\\zlib111.zip" or on - an Unix computer "zlib/zlib111.zip". - if the file pathname exist and append=1, the zip will be created at the end - of the file. (useful if the file contain a self extractor code) - If the zipfile cannot be opened, the return value is NULL. - Else, the return value is a zipFile Handle, usable with other function - of this zip package. - - -*/ - -extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, - const char* filename, - const zip_fileinfo* zipfi, - const void* extrafield_local, - uInt size_extrafield_local, - const void* extrafield_global, - uInt size_extrafield_global, - const char* comment, - int method, - int level)); -/* - Open a file in the ZIP for writing. - filename : the filename in zip (if NULL, '-' without quote will be used - *zipfi contain supplemental information - if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local - contains the extrafield data the the local header - if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global - contains the extrafield data the the local header - if comment != NULL, comment contain the comment string - method contain the compression method (0 for store, Z_DEFLATED for deflate) - level contain the level of compression (can be Z_DEFAULT_COMPRESSION) -*/ - -extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, - const voidp buf, - unsigned len)); -/* - Write data in the zipfile -*/ - -extern int ZEXPORT zipCloseFileInZip OF((zipFile file)); -/* - Close the current file in the zipfile -*/ - -extern int ZEXPORT zipClose OF((zipFile file, - const char* global_comment)); -/* - Close the zipfile -*/ - -#ifdef __cplusplus -} -#endif - -#endif /* _zip_H */ diff --git a/src/crashrpt/zlib/zlib.h b/src/crashrpt/zlib/zlib.h deleted file mode 100644 index 5979f040c..000000000 --- a/src/crashrpt/zlib/zlib.h +++ /dev/null @@ -1,893 +0,0 @@ -/* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.1.4, March 11th, 2002 - - Copyright (C) 1995-2002 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 ftp://ds.internic.net/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.1.4" - -/* - 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 (for example if an input file is mmap'ed), 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 library also supports reading and writing files in gzip (.gz) format - with an interface similar to that of stdio. - - 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: ascii or binary */ - uLong adler; /* adler32 value of the uncompressed data */ - uLong reserved; /* reserved for future use */ -} z_stream; - -typedef z_stream FAR *z_streamp; - -/* - 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 /* will be removed, use Z_SYNC_FLUSH instead */ -#define Z_SYNC_FLUSH 2 -#define Z_FULL_FLUSH 3 -#define Z_FINISH 4 -/* Allowed flush values; see deflate() 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_DEFAULT_STRATEGY 0 -/* compression strategy; see deflateInit2() below for details */ - -#define Z_BINARY 0 -#define Z_ASCII 1 -#define Z_UNKNOWN 2 -/* Possible values of the data_type field */ - -#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, - 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. - - 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. - - 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 - the 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). - - 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 - 0.1% larger than avail_in plus 12 bytes. 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 data_type if it can make a good guess about - the input data type (Z_ASCII or Z_BINARY). 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 NULL), Z_BUF_ERROR if no progress is possible - (for example avail_in or avail_out was zero). -*/ - - -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. msg is set to null if there is no error - message. inflateInit does not perform any decompression apart from reading - the zlib header if present: this will be done by inflate(). (So next_in and - avail_in may be modified, but next_out and avail_out are unchanged.) -*/ - - -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 some - 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. - - If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much - output as possible to the output buffer. The flushing behavior of inflate is - not specified for values of the flush parameter other than Z_SYNC_FLUSH - and Z_FINISH, but the current implementation actually flushes as much output - as possible anyway. - - 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 routine - may be used for the single inflate() call. - - If a preset dictionary is needed at this point (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() 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 - adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent - (for example if next_in or next_out was 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. In the Z_DATA_ERROR - case, the application may then call inflateSync to look for a good - compression block. -*/ - - -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. - - 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), or Z_HUFFMAN_ONLY to force Huffman encoding only (no - string match). 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 and Z_HUFFMAN_ONLY. The strategy parameter only affects - the compression ratio but not the correctness of the compressed output even - if it is not set appropriately. - - deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid - method). 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 in - deflate or deflate2. Thus the strings most likely to be useful should be - put at the end of the dictionary, not at the front. - - 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.) - - deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a - parameter is invalid (such as NULL dictionary) 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 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 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 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. 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. - - inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative - memLevel). msg is set to null if there is no error message. inflateInit2 - does not perform any decompression apart from reading the zlib header if - present: this will be done by inflate(). (So next_in and avail_in may be - modified, but next_out and avail_out are unchanged.) -*/ - -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 this call returned Z_NEED_DICT. The dictionary chosen by the compressor - can be determined from the Adler32 value returned by this call of - inflate. The compressor and decompressor must use exactly the same - dictionary (see deflateSetDictionary). - - inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a - parameter is invalid (such as NULL dictionary) 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 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 NULL). -*/ - - - /* 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 easily 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 0.1% larger than - sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the - compressed buffer. - This function can be used to compress a whole file at once if the - input file is mmap'ed. - 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 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. -*/ - -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 compressed buffer. - This function can be used to decompress a whole file at once if the - input file is mmap'ed. - - 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. -*/ - - -typedef voidp gzFile; - -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". (See the description - of deflateInit2 for more information about the strategy parameter.) - - 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 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). */ - -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 (in 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 gzdopen(dup(fd), mode). - gzdopen returns NULL if there was insufficient memory to allocate - the (de)compression state. -*/ - -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. - gzread returns the number of uncompressed bytes actually read (0 for - end of file, -1 for error). */ - -ZEXTERN int ZEXPORT gzwrite OF((gzFile file, - const voidp buf, unsigned len)); -/* - Writes the given number of uncompressed bytes into the compressed file. - gzwrite returns the number of uncompressed bytes actually written - (0 in case of error). -*/ - -ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); -/* - 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). -*/ - -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. The string is then terminated with a null - character. - gzgets returns buf, or Z_NULL in case of error. -*/ - -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 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 returns Z_OK if - the flush parameter is Z_FINISH and all output could be flushed. - gzflush should be called only when strictly necessary because it can - degrade compression. -*/ - -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. - - gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) -*/ - -ZEXTERN int ZEXPORT gzeof OF((gzFile file)); -/* - Returns 1 when EOF has previously been detected reading the given - input stream, otherwise zero. -*/ - -ZEXTERN int ZEXPORT gzclose OF((gzFile file)); -/* - Flushes all pending output if necessary, closes the compressed file - and deallocates all the (de)compression state. The return value is the zlib - error number (see function gzerror below). -*/ - -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. -*/ - - /* 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 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 crc32 OF((uLong crc, const Bytef *buf, uInt len)); -/* - Update a running crc with the bytes buf[0..len-1] and return the updated - crc. If buf is NULL, this function returns the required initial value - 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(); -*/ - - - /* 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)); -#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)) - - -#if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL) - struct internal_state {int dummy;}; /* hack for buggy compilers */ -#endif - -ZEXTERN const char * ZEXPORT zError OF((int err)); -ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); -ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); - -#ifdef __cplusplus -} -#endif - -#endif /* _ZLIB_H */ diff --git a/src/crashrpt/zlib/zlibcpp.cpp b/src/crashrpt/zlib/zlibcpp.cpp deleted file mode 100644 index a1b533d98..000000000 --- a/src/crashrpt/zlib/zlibcpp.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Module: zlibcpp.cpp -// -// Desc: See zlibcpp.h -// -// Copyright (c) 2003 Michael Carruth -// -/////////////////////////////////////////////////////////////////////////////// - - -#include "stdafx.h" -#include "zlibcpp.h" -#include "utility.h" - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -//----------------------------------------------------------------------------- -// CZLib::CZLib -// -// -// -CZLib::CZLib() -{ - m_zf = 0; -} - - -//----------------------------------------------------------------------------- -// CZLib::~CZLib -// -// Close open zip file -// -CZLib::~CZLib() -{ - if (m_zf) - Close(); -} - - -//----------------------------------------------------------------------------- -// CZLib::Open -// -// Create or open zip file -// -BOOL CZLib::Open(string f_file, int f_nAppend) -{ - m_zf = zipOpen(f_file.c_str(), f_nAppend); - return (m_zf != NULL); -} - - -//----------------------------------------------------------------------------- -// CZLib::Close -// -// Close open zip file -// -void CZLib::Close() -{ - if (m_zf) - zipClose(m_zf, NULL); - - m_zf = 0; -} - - -//----------------------------------------------------------------------------- -// CZLib::AddFile -// -// Adds a file to the zip archive -// -BOOL CZLib::AddFile(string f_file) -{ - BOOL bReturn = FALSE; - - // Open file being added - HANDLE hFile = NULL; - hFile = CreateFile(f_file.c_str(), GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (hFile) - { - // Get file creation date - FILETIME ft = CUtility::getLastWriteFileTime(f_file); - zip_fileinfo zi = {0}; - - FileTimeToDosDateTime( - &ft, // last write FILETIME - ((LPWORD)&zi.dosDate)+1, // dos date - ((LPWORD)&zi.dosDate)+0); // dos time - - // Trim path off file name - string sFileName = f_file.substr(f_file.find_last_of(_T('\\')) + 1); - - // Start a new file in Zip - if (ZIP_OK == zipOpenNewFileInZip(m_zf, - sFileName.c_str(), - &zi, - NULL, - 0, - NULL, - 0, - NULL, - Z_DEFLATED, - Z_BEST_COMPRESSION)) - { - // Write file to Zip in 4 KB chunks - const DWORD BUFFSIZE = 4096; - TCHAR buffer[BUFFSIZE] = _T(""); - DWORD dwBytesRead = 0; - - while (ReadFile(hFile, &buffer, BUFFSIZE, &dwBytesRead, NULL) - && dwBytesRead) - { - if (ZIP_OK == zipWriteInFileInZip(m_zf, buffer, dwBytesRead) - && dwBytesRead < BUFFSIZE) - { - // Success - bReturn = TRUE; - } - } - - bReturn &= (ZIP_OK == zipCloseFileInZip(m_zf)); - } - - bReturn &= CloseHandle(hFile); - } - - return bReturn; -} \ No newline at end of file diff --git a/src/crashrpt/zlib/zlibcpp.h b/src/crashrpt/zlib/zlibcpp.h deleted file mode 100644 index 9d753c448..000000000 --- a/src/crashrpt/zlib/zlibcpp.h +++ /dev/null @@ -1,39 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// -// Module: zlibcpp.h -// -// Desc: Basic class wrapper for the zlib dll -// -// Copyright (c) 2003 Automatic Data Processing, Inc. All Rights Reserved. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _ZLIBCPP_H_ -#define _ZLIBCPP_H_ - -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef _WINDOWS -#define _WINDOWS -#endif // !_WINDOWS - -#ifndef _zip_H -#include "zip.h" -#endif // _zip_H - -class CZLib -{ -public: - CZLib(); - virtual ~CZLib(); - - BOOL Open(string f_file, int f_nAppend = 0); - BOOL AddFile(string f_file); - void Close(); -protected: - zipFile m_zf; -}; - -#endif // !_ZLIBCPP_H diff --git a/src/crashrpt/zlib/zutil.c b/src/crashrpt/zlib/zutil.c deleted file mode 100644 index 05b9f1b81..000000000 --- a/src/crashrpt/zlib/zutil.c +++ /dev/null @@ -1,225 +0,0 @@ -/* zutil.c -- target dependent utility functions for the compression library - * Copyright (C) 1995-2002 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id: zutil.c,v 1.1 2003/05/23 21:05:30 steveking Exp $ */ - -#include "zutil.h" - -struct internal_state {int dummy;}; /* for buggy compilers */ - -#ifndef STDC -extern void exit OF((int)); -#endif - -const char *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; -} - -#ifdef DEBUG - -# ifndef verbose -# define verbose 0 -# endif -int z_verbose = verbose; - -void 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); -} - - -#ifndef HAVE_MEMCPY - -void 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 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 zmemzero(dest, len) - Bytef* dest; - uInt len; -{ - if (len == 0) return; - do { - *dest++ = 0; /* ??? to be unrolled */ - } while (--len != 0); -} -#endif - -#ifdef __TURBOC__ -#if (defined( __BORLANDC__) || !defined(SMALL_MEDIUM)) && !defined(__32BIT__) -/* Small and medium model in Turbo C are for now limited to near allocation - * with reduced MAX_WBITS and MAX_MEM_LEVEL - */ -# 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 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 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 -#endif /* __TURBOC__ */ - - -#if defined(M_I86) && !defined(__32BIT__) -/* Microsoft C in 16-bit mode */ - -# define MY_ZCALLOC - -#if (!defined(_MSC_VER) || (_MSC_VER <= 600)) -# define _halloc halloc -# define _hfree hfree -#endif - -voidpf zcalloc (voidpf opaque, unsigned items, unsigned size) -{ - if (opaque) opaque = 0; /* to make compiler happy */ - return _halloc((long)items, size); -} - -void zcfree (voidpf opaque, voidpf ptr) -{ - if (opaque) opaque = 0; /* to make compiler happy */ - _hfree(ptr); -} - -#endif /* MSC */ - - -#ifndef MY_ZCALLOC /* Any system without a special alloc function */ - -#ifndef STDC -extern voidp calloc OF((uInt items, uInt size)); -extern void free OF((voidpf ptr)); -#endif - -voidpf zcalloc (opaque, items, size) - voidpf opaque; - unsigned items; - unsigned size; -{ - if (opaque) items += size - size; /* make compiler happy */ - return (voidpf)calloc(items, size); -} - -void zcfree (opaque, ptr) - voidpf opaque; - voidpf ptr; -{ - free(ptr); - if (opaque) return; /* make compiler happy */ -} - -#endif /* MY_ZCALLOC */ diff --git a/src/crashrpt/zlib/zutil.h b/src/crashrpt/zlib/zutil.h deleted file mode 100644 index 2326408ca..000000000 --- a/src/crashrpt/zlib/zutil.h +++ /dev/null @@ -1,220 +0,0 @@ -/* zutil.h -- internal interface and configuration of the compression library - * Copyright (C) 1995-2002 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: zutil.h,v 1.1 2003/05/23 21:05:30 steveking Exp $ */ - -#ifndef _Z_UTIL_H -#define _Z_UTIL_H - -#include "zlib.h" - -#ifdef STDC -# include -# include -# include -#endif -#ifdef NO_ERRNO_H - extern int errno; -#else -# 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 *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 */ - -#ifdef MSDOS -# 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 OS2 -# define OS_CODE 0x06 -#endif - -#ifdef WIN32 /* Window 95 & Windows NT */ -# define OS_CODE 0x0b -#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 - -#ifdef AMIGA -# define OS_CODE 0x01 -#endif - -#if defined(ATARI) || defined(atarist) -# define OS_CODE 0x05 -#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 __50SERIES /* Prime/PRIMOS */ -# define OS_CODE 0x0F -#endif - -#ifdef TOPS20 -# define OS_CODE 0x0a -#endif - -#if defined(_BEOS_) || defined(RISCOS) -# define fdopen(fd,mode) NULL /* No fdopen() */ -#endif - -#if (defined(_MSC_VER) && (_MSC_VER > 600)) -# define fdopen(fd,type) _fdopen(fd,type) -#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 */ - -#ifdef HAVE_STRERROR - extern char *strerror OF((int)); -# define zstrerror(errnum) strerror(errnum) -#else -# define zstrerror(errnum) "" -#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 - extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); - extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); - extern void zmemzero OF((Bytef* dest, uInt len)); -#endif - -/* Diagnostic functions */ -#ifdef DEBUG -# include - extern int z_verbose; - extern void 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 - - -typedef uLong (ZEXPORT *check_func) OF((uLong check, const Bytef *buf, - uInt len)); -voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); -void 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 /* _Z_UTIL_H */ -- 2.11.4.GIT