From f1892bd3a354c67719f718edea2feea0e767f918 Mon Sep 17 00:00:00 2001 From: Colin Finck Date: Wed, 8 Dec 2010 16:42:47 +0000 Subject: [PATCH] Remove the "irc", "press-media" and "tools" directories. They were moved to the "press-media" and "project-tools" repositories now. svn path=/trunk/; revision=49986 --- irc/ArchBlackmann/ArchBlackmann.cpp | 608 ---- irc/ArchBlackmann/ArchBlackmann.dsp | 216 -- irc/ArchBlackmann/ArchBlackmann.dsw | 29 - irc/ArchBlackmann/File.cpp | 265 -- irc/ArchBlackmann/File.h | 173 - irc/ArchBlackmann/IRCClient.cpp | 418 --- irc/ArchBlackmann/IRCClient.h | 148 - irc/ArchBlackmann/MD5.cpp | 418 --- irc/ArchBlackmann/MD5.h | 95 - irc/ArchBlackmann/QueueT.h | 315 -- irc/ArchBlackmann/Reli.h | 143 - irc/ArchBlackmann/ReliMT.cpp | 331 -- irc/ArchBlackmann/ReliMT.h | 229 -- irc/ArchBlackmann/SockUtils.cpp | 504 --- irc/ArchBlackmann/SockUtils.h | 132 - irc/ArchBlackmann/SplitJoin.cpp | 96 - irc/ArchBlackmann/SplitJoin.h | 32 - irc/ArchBlackmann/ThreadPool.cpp | 240 -- irc/ArchBlackmann/ThreadPool.h | 28 - irc/ArchBlackmann/auto_ptr.h | 87 - irc/ArchBlackmann/auto_vector.h | 141 - irc/ArchBlackmann/base64.cpp | 58 - irc/ArchBlackmann/base64.h | 12 - irc/ArchBlackmann/chomp.cpp | 15 - irc/ArchBlackmann/chomp.h | 13 - irc/ArchBlackmann/config.h | 7 - irc/ArchBlackmann/cram_md5.cpp | 23 - irc/ArchBlackmann/cram_md5.h | 15 - irc/ArchBlackmann/curse.txt | 1 - irc/ArchBlackmann/cursecop.txt | 10 - irc/ArchBlackmann/dev.txt | 15 - irc/ArchBlackmann/func.txt | 580 ---- irc/ArchBlackmann/grovel.txt | 10 - irc/ArchBlackmann/idle.txt | 1 - irc/ArchBlackmann/irql.txt | 9 - irc/ArchBlackmann/makefile | 38 - irc/ArchBlackmann/module.txt | 13 - irc/ArchBlackmann/nogrovel.txt | 5 - irc/ArchBlackmann/panic.cpp | 34 - irc/ArchBlackmann/panic.h | 18 - irc/ArchBlackmann/period.txt | 11 - irc/ArchBlackmann/readme.txt | 44 - irc/ArchBlackmann/ssprintf.cpp | 998 ------ irc/ArchBlackmann/ssprintf.h | 12 - irc/ArchBlackmann/status.txt | 654 ---- irc/ArchBlackmann/stru.txt | 7 - irc/ArchBlackmann/tech.txt | 73 - irc/ArchBlackmann/trim.cpp | 17 - irc/ArchBlackmann/trim.h | 13 - irc/ArchBlackmann/type.txt | 1000 ------ irc/ArchBlackmann/verify.h | 37 - irc/TechBot/CHMLibrary/AssemblyInfo.cs | 32 - .../CHMDecoding/BinaryReaderHelp.cs | 274 -- .../CHMLibrary/CHMDecoding/CHMBtree.cs | 325 -- irc/TechBot/CHMLibrary/CHMDecoding/CHMFile.cs | 2061 ------------ .../CHMLibrary/CHMDecoding/CHMIdxhdr.cs | 286 -- .../CHMLibrary/CHMDecoding/CHMStrings.cs | 256 -- .../CHMLibrary/CHMDecoding/CHMSystem.cs | 821 ----- .../CHMLibrary/CHMDecoding/CHMTocidx.cs | 288 -- .../CHMLibrary/CHMDecoding/CHMTopics.cs | 235 -- .../CHMLibrary/CHMDecoding/CHMUrlstr.cs | 308 -- .../CHMLibrary/CHMDecoding/CHMUrltable.cs | 245 -- .../CHMLibrary/CHMDecoding/DumpingInfo.cs | 395 --- .../CHMLibrary/CHMDecoding/FullTextEngine.cs | 1131 ------- .../CHMLibrary/CHMDecoding/HHCParser.cs | 593 ---- .../CHMLibrary/CHMDecoding/HHCParser2.cs | 220 -- .../CHMLibrary/CHMDecoding/HHKParser.cs | 550 ---- .../CHMLibrary/CHMDecoding/TopicEntry.cs | 245 -- .../CHMLibrary/CHMDecoding/UrlTableEntry.cs | 175 - .../CHMLibrary/CHMDecoding/enumerations.cs | 19 - irc/TechBot/CHMLibrary/CHMLibrary.cmbx | 16 - irc/TechBot/CHMLibrary/CHMLibrary.csproj | 85 - irc/TechBot/CHMLibrary/CHMLibrary.prjx | 58 - irc/TechBot/CHMLibrary/Category.cs | 201 -- irc/TechBot/CHMLibrary/ChmFileInfo.cs | 478 --- irc/TechBot/CHMLibrary/Default.build | 23 - irc/TechBot/CHMLibrary/HtmlHelpSystem.cs | 894 ------ irc/TechBot/CHMLibrary/HttpUtility.cs | 855 ----- irc/TechBot/CHMLibrary/Index.cs | 322 -- irc/TechBot/CHMLibrary/IndexItem.cs | 396 --- irc/TechBot/CHMLibrary/IndexTopic.cs | 216 -- irc/TechBot/CHMLibrary/InformationType.cs | 146 - irc/TechBot/CHMLibrary/Storage/CHMStream.cs | 2842 ----------------- irc/TechBot/CHMLibrary/TOCItem.cs | 494 --- irc/TechBot/CHMLibrary/TableOfContents.cs | 198 -- irc/TechBot/Compression/AssemblyInfo.cs | 32 - irc/TechBot/Compression/Checksums/Adler32.cs | 200 -- irc/TechBot/Compression/Checksums/CRC32.cs | 211 -- .../Compression/Checksums/IChecksum.cs | 93 - .../Compression/Checksums/StrangeCRC.cs | 159 - irc/TechBot/Compression/Compression.cmbx | 16 - irc/TechBot/Compression/Compression.csproj | 65 - irc/TechBot/Compression/Compression.prjx | 45 - irc/TechBot/Compression/Default.build | 20 - irc/TechBot/Compression/Deflater.cs | 542 ---- irc/TechBot/Compression/DeflaterConstants.cs | 85 - irc/TechBot/Compression/DeflaterEngine.cs | 653 ---- irc/TechBot/Compression/DeflaterHuffman.cs | 780 ----- irc/TechBot/Compression/DeflaterPending.cs | 52 - irc/TechBot/Compression/Inflater.cs | 782 ----- irc/TechBot/Compression/InflaterDynHeader.cs | 207 -- .../Compression/InflaterHuffmanTree.cs | 213 -- irc/TechBot/Compression/PendingBuffer.cs | 210 -- .../Streams/DeflaterOutputStream.cs | 379 --- .../Streams/InflaterInputStream.cs | 386 --- .../Compression/Streams/OutputWindow.cs | 176 - .../Compression/Streams/StreamManipulator.cs | 245 -- irc/TechBot/Compression/ZipException.cs | 62 - irc/TechBot/Resources/hresult.xml | 1088 ------- irc/TechBot/Resources/ntstatus.xml | 1111 ------- irc/TechBot/Resources/winerror.xml | 1839 ----------- irc/TechBot/Resources/wm.xml | 321 -- .../Base/BugCommand.cs | 42 - .../TechBot.Commands.Common/ErrorCommand.cs | 180 -- .../TechBot.Commands.Common/HResultCommand.cs | 66 - .../NtStatusCommand.cs | 66 - .../Properties/AssemblyInfo.cs | 35 - .../TechBot.Commands.Common/ReactOSBugUrl.cs | 21 - .../TechBot.Commands.Common/SambaBugUrl.cs | 21 - .../Settings.Designer.cs | 71 - .../TechBot.Commands.Common/Settings.cs | 28 - .../TechBot.Commands.Common/Settings.settings | 21 - .../TechBot.Commands.Common/SvnCommand.cs | 22 - .../TechBot.Commands.Common.csproj | 75 - .../TechBot.Commands.Common/WMCommand.cs | 94 - .../TechBot.Commands.Common/WineBugUrl.cs | 21 - .../WinerrorCommand.cs | 66 - .../TechBot.Commands.Common/app.config | 27 - .../TechBot.Commands.MSDN/ApiCommand.cs | 309 -- .../Properties/AssemblyInfo.cs | 35 - .../Settings.Designer.cs | 50 - .../TechBot.Commands.MSDN/Settings.settings | 12 - .../TechBot.Commands.MSDN.csproj | 69 - .../TechBot.Commands.MSDN.csproj.user | 5 - irc/TechBot/TechBot.Commands.MSDN/app.config | 18 - irc/TechBot/TechBot.Console/App.config | 27 - irc/TechBot/TechBot.Console/AssemblyInfo.cs | 32 - .../TechBot.Console/ConsoleTechBotService.cs | 37 - irc/TechBot/TechBot.Console/Default.build | 23 - irc/TechBot/TechBot.Console/Main.cs | 29 - .../TechBot.Console/Properties/.gitignore | 0 .../TechBot.Console/Settings.Designer.cs | 86 - irc/TechBot/TechBot.Console/Settings.settings | 21 - .../TechBot.Console/TechBot.Console.cmbx | 16 - .../TechBot.Console/TechBot.Console.csproj | 80 - .../TechBot.Console/TechBot.Console.prjx | 29 - .../TechBot.IRCLibrary/AssemblyInfo.cs | 32 - irc/TechBot/TechBot.IRCLibrary/Default.build | 20 - irc/TechBot/TechBot.IRCLibrary/IRC.cs | 30 - irc/TechBot/TechBot.IRCLibrary/IrcChannel.cs | 137 - irc/TechBot/TechBot.IRCLibrary/IrcClient.cs | 794 ----- .../TechBot.IRCLibrary/IrcException.cs | 50 - irc/TechBot/TechBot.IRCLibrary/IrcMessage.cs | 503 --- irc/TechBot/TechBot.IRCLibrary/IrcUser.cs | 132 - .../TechBot.IRCLibrary/Properties/.gitignore | 0 .../TechBot.IRCLibrary.cmbx | 16 - .../TechBot.IRCLibrary.csproj | 59 - .../TechBot.IRCLibrary.prjx | 31 - irc/TechBot/TechBot.IRCLibrary/app.config | 15 - .../Attributes/CommandAttribute.cs | 35 - .../CommandParameterAliasAttribute.cs | 34 - .../Attributes/CommandParameterAttribute.cs | 50 - .../Collections/CommandBuilderCollection.cs | 20 - .../TechBot.Library/Commands/Base/Command.cs | 90 - .../Commands/Base/XmlCommand.cs | 25 - .../Commands/Base/XmlLookupCommand.cs | 15 - .../TechBot.Library/Commands/HelpCommand.cs | 78 - .../TechBot.Library/Factory/CommandBuilder.cs | 52 - .../TechBot.Library/Factory/CommandFactory.cs | 60 - irc/TechBot/TechBot.Library/MessageContext.cs | 39 - irc/TechBot/TechBot.Library/NumberParser.cs | 62 - .../TechBot.Library/Properties/.gitignore | 0 .../Properties/AssemblyInfo.cs | 32 - irc/TechBot/TechBot.Library/ServiceOutput.cs | 9 - .../TechBot.Library/Settings.Designer.cs | 80 - irc/TechBot/TechBot.Library/Settings.cs | 28 - irc/TechBot/TechBot.Library/Settings.settings | 24 - .../TechBot.Library/TechBot.Library.csproj | 83 - .../TechBot.Library/TechBotIrcService.cs | 312 -- irc/TechBot/TechBot.Library/TechBotService.cs | 101 - irc/TechBot/TechBot.Library/app.config | 30 - irc/TechBot/TechBot.sln | 62 - irc/TechBot/TechBot/App.config | 44 - irc/TechBot/TechBot/AssemblyInfo.cs | 32 - irc/TechBot/TechBot/Default.build | 23 - irc/TechBot/TechBot/ProjectInstaller.cs | 28 - irc/TechBot/TechBot/Properties/.gitignore | 0 irc/TechBot/TechBot/ServiceThread.cs | 43 - irc/TechBot/TechBot/Settings.Designer.cs | 86 - irc/TechBot/TechBot/Settings.settings | 21 - irc/TechBot/TechBot/TechBot.csproj | 82 - irc/TechBot/TechBot/TechBot.prjx | 30 - irc/TechBot/TechBot/TechBotService.cs | 82 - 193 files changed, 39391 deletions(-) delete mode 100644 irc/ArchBlackmann/ArchBlackmann.cpp delete mode 100644 irc/ArchBlackmann/ArchBlackmann.dsp delete mode 100644 irc/ArchBlackmann/ArchBlackmann.dsw delete mode 100644 irc/ArchBlackmann/File.cpp delete mode 100644 irc/ArchBlackmann/File.h delete mode 100644 irc/ArchBlackmann/IRCClient.cpp delete mode 100644 irc/ArchBlackmann/IRCClient.h delete mode 100644 irc/ArchBlackmann/MD5.cpp delete mode 100644 irc/ArchBlackmann/MD5.h delete mode 100644 irc/ArchBlackmann/QueueT.h delete mode 100644 irc/ArchBlackmann/Reli.h delete mode 100644 irc/ArchBlackmann/ReliMT.cpp delete mode 100644 irc/ArchBlackmann/ReliMT.h delete mode 100644 irc/ArchBlackmann/SockUtils.cpp delete mode 100644 irc/ArchBlackmann/SockUtils.h delete mode 100644 irc/ArchBlackmann/SplitJoin.cpp delete mode 100644 irc/ArchBlackmann/SplitJoin.h delete mode 100644 irc/ArchBlackmann/ThreadPool.cpp delete mode 100644 irc/ArchBlackmann/ThreadPool.h delete mode 100644 irc/ArchBlackmann/auto_ptr.h delete mode 100644 irc/ArchBlackmann/auto_vector.h delete mode 100644 irc/ArchBlackmann/base64.cpp delete mode 100644 irc/ArchBlackmann/base64.h delete mode 100644 irc/ArchBlackmann/chomp.cpp delete mode 100644 irc/ArchBlackmann/chomp.h delete mode 100644 irc/ArchBlackmann/config.h delete mode 100644 irc/ArchBlackmann/cram_md5.cpp delete mode 100644 irc/ArchBlackmann/cram_md5.h delete mode 100644 irc/ArchBlackmann/curse.txt delete mode 100644 irc/ArchBlackmann/cursecop.txt delete mode 100644 irc/ArchBlackmann/dev.txt delete mode 100644 irc/ArchBlackmann/func.txt delete mode 100644 irc/ArchBlackmann/grovel.txt delete mode 100644 irc/ArchBlackmann/idle.txt delete mode 100644 irc/ArchBlackmann/irql.txt delete mode 100644 irc/ArchBlackmann/makefile delete mode 100644 irc/ArchBlackmann/module.txt delete mode 100644 irc/ArchBlackmann/nogrovel.txt delete mode 100644 irc/ArchBlackmann/panic.cpp delete mode 100644 irc/ArchBlackmann/panic.h delete mode 100644 irc/ArchBlackmann/period.txt delete mode 100644 irc/ArchBlackmann/readme.txt delete mode 100644 irc/ArchBlackmann/ssprintf.cpp delete mode 100644 irc/ArchBlackmann/ssprintf.h delete mode 100644 irc/ArchBlackmann/status.txt delete mode 100644 irc/ArchBlackmann/stru.txt delete mode 100644 irc/ArchBlackmann/tech.txt delete mode 100644 irc/ArchBlackmann/trim.cpp delete mode 100644 irc/ArchBlackmann/trim.h delete mode 100644 irc/ArchBlackmann/type.txt delete mode 100644 irc/ArchBlackmann/verify.h delete mode 100644 irc/TechBot/CHMLibrary/AssemblyInfo.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/BinaryReaderHelp.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/CHMBtree.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/CHMFile.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/CHMIdxhdr.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/CHMStrings.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/CHMSystem.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/CHMTocidx.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/CHMTopics.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/CHMUrlstr.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/CHMUrltable.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/DumpingInfo.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/FullTextEngine.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/HHCParser.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/HHCParser2.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/HHKParser.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/TopicEntry.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/UrlTableEntry.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMDecoding/enumerations.cs delete mode 100644 irc/TechBot/CHMLibrary/CHMLibrary.cmbx delete mode 100644 irc/TechBot/CHMLibrary/CHMLibrary.csproj delete mode 100644 irc/TechBot/CHMLibrary/CHMLibrary.prjx delete mode 100644 irc/TechBot/CHMLibrary/Category.cs delete mode 100644 irc/TechBot/CHMLibrary/ChmFileInfo.cs delete mode 100644 irc/TechBot/CHMLibrary/Default.build delete mode 100644 irc/TechBot/CHMLibrary/HtmlHelpSystem.cs delete mode 100644 irc/TechBot/CHMLibrary/HttpUtility.cs delete mode 100644 irc/TechBot/CHMLibrary/Index.cs delete mode 100644 irc/TechBot/CHMLibrary/IndexItem.cs delete mode 100644 irc/TechBot/CHMLibrary/IndexTopic.cs delete mode 100644 irc/TechBot/CHMLibrary/InformationType.cs delete mode 100644 irc/TechBot/CHMLibrary/Storage/CHMStream.cs delete mode 100644 irc/TechBot/CHMLibrary/TOCItem.cs delete mode 100644 irc/TechBot/CHMLibrary/TableOfContents.cs delete mode 100644 irc/TechBot/Compression/AssemblyInfo.cs delete mode 100644 irc/TechBot/Compression/Checksums/Adler32.cs delete mode 100644 irc/TechBot/Compression/Checksums/CRC32.cs delete mode 100644 irc/TechBot/Compression/Checksums/IChecksum.cs delete mode 100644 irc/TechBot/Compression/Checksums/StrangeCRC.cs delete mode 100644 irc/TechBot/Compression/Compression.cmbx delete mode 100644 irc/TechBot/Compression/Compression.csproj delete mode 100644 irc/TechBot/Compression/Compression.prjx delete mode 100644 irc/TechBot/Compression/Default.build delete mode 100644 irc/TechBot/Compression/Deflater.cs delete mode 100644 irc/TechBot/Compression/DeflaterConstants.cs delete mode 100644 irc/TechBot/Compression/DeflaterEngine.cs delete mode 100644 irc/TechBot/Compression/DeflaterHuffman.cs delete mode 100644 irc/TechBot/Compression/DeflaterPending.cs delete mode 100644 irc/TechBot/Compression/Inflater.cs delete mode 100644 irc/TechBot/Compression/InflaterDynHeader.cs delete mode 100644 irc/TechBot/Compression/InflaterHuffmanTree.cs delete mode 100644 irc/TechBot/Compression/PendingBuffer.cs delete mode 100644 irc/TechBot/Compression/Streams/DeflaterOutputStream.cs delete mode 100644 irc/TechBot/Compression/Streams/InflaterInputStream.cs delete mode 100644 irc/TechBot/Compression/Streams/OutputWindow.cs delete mode 100644 irc/TechBot/Compression/Streams/StreamManipulator.cs delete mode 100644 irc/TechBot/Compression/ZipException.cs delete mode 100644 irc/TechBot/Resources/hresult.xml delete mode 100644 irc/TechBot/Resources/ntstatus.xml delete mode 100644 irc/TechBot/Resources/winerror.xml delete mode 100644 irc/TechBot/Resources/wm.xml delete mode 100644 irc/TechBot/TechBot.Commands.Common/Base/BugCommand.cs delete mode 100644 irc/TechBot/TechBot.Commands.Common/ErrorCommand.cs delete mode 100644 irc/TechBot/TechBot.Commands.Common/HResultCommand.cs delete mode 100644 irc/TechBot/TechBot.Commands.Common/NtStatusCommand.cs delete mode 100644 irc/TechBot/TechBot.Commands.Common/Properties/AssemblyInfo.cs delete mode 100644 irc/TechBot/TechBot.Commands.Common/ReactOSBugUrl.cs delete mode 100644 irc/TechBot/TechBot.Commands.Common/SambaBugUrl.cs delete mode 100644 irc/TechBot/TechBot.Commands.Common/Settings.Designer.cs delete mode 100644 irc/TechBot/TechBot.Commands.Common/Settings.cs delete mode 100644 irc/TechBot/TechBot.Commands.Common/Settings.settings delete mode 100644 irc/TechBot/TechBot.Commands.Common/SvnCommand.cs delete mode 100644 irc/TechBot/TechBot.Commands.Common/TechBot.Commands.Common.csproj delete mode 100644 irc/TechBot/TechBot.Commands.Common/WMCommand.cs delete mode 100644 irc/TechBot/TechBot.Commands.Common/WineBugUrl.cs delete mode 100644 irc/TechBot/TechBot.Commands.Common/WinerrorCommand.cs delete mode 100644 irc/TechBot/TechBot.Commands.Common/app.config delete mode 100644 irc/TechBot/TechBot.Commands.MSDN/ApiCommand.cs delete mode 100644 irc/TechBot/TechBot.Commands.MSDN/Properties/AssemblyInfo.cs delete mode 100644 irc/TechBot/TechBot.Commands.MSDN/Settings.Designer.cs delete mode 100644 irc/TechBot/TechBot.Commands.MSDN/Settings.settings delete mode 100644 irc/TechBot/TechBot.Commands.MSDN/TechBot.Commands.MSDN.csproj delete mode 100644 irc/TechBot/TechBot.Commands.MSDN/TechBot.Commands.MSDN.csproj.user delete mode 100644 irc/TechBot/TechBot.Commands.MSDN/app.config delete mode 100644 irc/TechBot/TechBot.Console/App.config delete mode 100644 irc/TechBot/TechBot.Console/AssemblyInfo.cs delete mode 100644 irc/TechBot/TechBot.Console/ConsoleTechBotService.cs delete mode 100644 irc/TechBot/TechBot.Console/Default.build delete mode 100644 irc/TechBot/TechBot.Console/Main.cs delete mode 100644 irc/TechBot/TechBot.Console/Properties/.gitignore delete mode 100644 irc/TechBot/TechBot.Console/Settings.Designer.cs delete mode 100644 irc/TechBot/TechBot.Console/Settings.settings delete mode 100644 irc/TechBot/TechBot.Console/TechBot.Console.cmbx delete mode 100644 irc/TechBot/TechBot.Console/TechBot.Console.csproj delete mode 100644 irc/TechBot/TechBot.Console/TechBot.Console.prjx delete mode 100644 irc/TechBot/TechBot.IRCLibrary/AssemblyInfo.cs delete mode 100644 irc/TechBot/TechBot.IRCLibrary/Default.build delete mode 100644 irc/TechBot/TechBot.IRCLibrary/IRC.cs delete mode 100644 irc/TechBot/TechBot.IRCLibrary/IrcChannel.cs delete mode 100644 irc/TechBot/TechBot.IRCLibrary/IrcClient.cs delete mode 100644 irc/TechBot/TechBot.IRCLibrary/IrcException.cs delete mode 100644 irc/TechBot/TechBot.IRCLibrary/IrcMessage.cs delete mode 100644 irc/TechBot/TechBot.IRCLibrary/IrcUser.cs delete mode 100644 irc/TechBot/TechBot.IRCLibrary/Properties/.gitignore delete mode 100644 irc/TechBot/TechBot.IRCLibrary/TechBot.IRCLibrary.cmbx delete mode 100644 irc/TechBot/TechBot.IRCLibrary/TechBot.IRCLibrary.csproj delete mode 100644 irc/TechBot/TechBot.IRCLibrary/TechBot.IRCLibrary.prjx delete mode 100644 irc/TechBot/TechBot.IRCLibrary/app.config delete mode 100644 irc/TechBot/TechBot.Library/Attributes/CommandAttribute.cs delete mode 100644 irc/TechBot/TechBot.Library/Attributes/CommandParameterAliasAttribute.cs delete mode 100644 irc/TechBot/TechBot.Library/Attributes/CommandParameterAttribute.cs delete mode 100644 irc/TechBot/TechBot.Library/Collections/CommandBuilderCollection.cs delete mode 100644 irc/TechBot/TechBot.Library/Commands/Base/Command.cs delete mode 100644 irc/TechBot/TechBot.Library/Commands/Base/XmlCommand.cs delete mode 100644 irc/TechBot/TechBot.Library/Commands/Base/XmlLookupCommand.cs delete mode 100644 irc/TechBot/TechBot.Library/Commands/HelpCommand.cs delete mode 100644 irc/TechBot/TechBot.Library/Factory/CommandBuilder.cs delete mode 100644 irc/TechBot/TechBot.Library/Factory/CommandFactory.cs delete mode 100644 irc/TechBot/TechBot.Library/MessageContext.cs delete mode 100644 irc/TechBot/TechBot.Library/NumberParser.cs delete mode 100644 irc/TechBot/TechBot.Library/Properties/.gitignore delete mode 100644 irc/TechBot/TechBot.Library/Properties/AssemblyInfo.cs delete mode 100644 irc/TechBot/TechBot.Library/ServiceOutput.cs delete mode 100644 irc/TechBot/TechBot.Library/Settings.Designer.cs delete mode 100644 irc/TechBot/TechBot.Library/Settings.cs delete mode 100644 irc/TechBot/TechBot.Library/Settings.settings delete mode 100644 irc/TechBot/TechBot.Library/TechBot.Library.csproj delete mode 100644 irc/TechBot/TechBot.Library/TechBotIrcService.cs delete mode 100644 irc/TechBot/TechBot.Library/TechBotService.cs delete mode 100644 irc/TechBot/TechBot.Library/app.config delete mode 100644 irc/TechBot/TechBot.sln delete mode 100644 irc/TechBot/TechBot/App.config delete mode 100644 irc/TechBot/TechBot/AssemblyInfo.cs delete mode 100644 irc/TechBot/TechBot/Default.build delete mode 100644 irc/TechBot/TechBot/ProjectInstaller.cs delete mode 100644 irc/TechBot/TechBot/Properties/.gitignore delete mode 100644 irc/TechBot/TechBot/ServiceThread.cs delete mode 100644 irc/TechBot/TechBot/Settings.Designer.cs delete mode 100644 irc/TechBot/TechBot/Settings.settings delete mode 100644 irc/TechBot/TechBot/TechBot.csproj delete mode 100644 irc/TechBot/TechBot/TechBot.prjx delete mode 100644 irc/TechBot/TechBot/TechBotService.cs diff --git a/irc/ArchBlackmann/ArchBlackmann.cpp b/irc/ArchBlackmann/ArchBlackmann.cpp deleted file mode 100644 index 1d71f748847..00000000000 --- a/irc/ArchBlackmann/ArchBlackmann.cpp +++ /dev/null @@ -1,608 +0,0 @@ -// irc_test.cpp - -#ifdef _MSC_VER -#pragma warning ( disable : 4786 ) -#endif//_MSC_VER - -#include -#include - -#include "File.h" -#include "ssprintf.h" -#include "trim.h" - -#include "IRCClient.h" -#include "config.h" - -using std::string; -using std::vector; - -//vector tech, module, dev, stru, period, status, type, func, irql, curse, cursecop; - -class List -{ -public: - string name; - bool macro; - std::vector list; - string tag; - int last; - List() { last = -1; } - List ( const char* _name, bool _macro ) : name(_name), macro(_macro) - { - tag = ssprintf("%%%s%%",_name); - last = -1; - } -}; - -vector lists; -vector ops; - -void ImportList ( const char* listname, bool macro ) -{ - lists.push_back ( List ( listname, macro ) ); - List& list = lists.back(); - File f ( ssprintf("%s.txt",listname).c_str(), "r" ); - string line; - while ( f.next_line ( line, true ) ) - list.list.push_back ( line ); -} - -const char* ListRand ( List& list ) -{ - vector& l = list.list; - if ( !l.size() ) - { - static string nothing; - nothing = ssprintf ( "", list.name.c_str() ); - return nothing.c_str(); - } - else if ( l.size() == 1 ) - return l[0].c_str(); - int sel = list.last; - while ( sel == list.last ) - sel = rand()%l.size(); - list.last = sel; - return l[sel].c_str(); -} - -const char* ListRand ( int i ) -{ - return ListRand ( lists[i] ); -} - -int GetListIndex ( const char* listname ) -{ - for ( int i = 0; i < lists.size(); i++ ) - { - if ( !stricmp ( lists[i].name.c_str(), listname ) ) - return i; - } - return -1; -} - -List& GetList ( const char* listname ) -{ - return lists[GetListIndex(listname)]; -} - -const char* ListRand ( const char* list ) -{ - int i = GetListIndex ( list ); - if ( i < 0 ) - return NULL; - return ListRand(i); -} - -string TaggedReply ( const char* listname ) -{ - string t = ListRand(listname); - string out; - const char* p = t.c_str(); - while ( *p ) - { - if ( *p == '%' ) - { - bool found = false; - for ( int i = 0; i < lists.size() && !found; i++ ) - { - if ( lists[i].macro && !strnicmp ( p, lists[i].tag.c_str(), lists[i].tag.size() ) ) - { - out += ListRand(i); - p += lists[i].tag.size(); - found = true; - } - } - if ( !found ) - out += *p++; - } - const char* p2 = strchr ( p, '%' ); - if ( !p2 ) - p2 = p + strlen(p); - if ( p2 > p ) - { - out += string ( p, p2-p ); - p = p2; - } - } - return out; -} - -string gobble ( string& s, const char* delim ) -{ - const char* p = s.c_str(); - p += strspn ( p, delim ); - const char* p2 = strpbrk ( p, delim ); - if ( !p2 ) p2 = p + strlen(p); - string out ( p, p2-p ); - p2 += strspn ( p2, delim ); - s = string ( p2 ); - return out; -} - -bool isop ( const string& who ) -{ - for ( int i = 0; i < ops.size(); i++ ) - { - if ( ops[i] == who ) - return true; - } - return false; -} - - -// do custom stuff with the IRCClient from your subclass via the provided callbacks... -class MyIRCClient : public IRCClient -{ - File flog; - clock_t brake_silence; - - // wait another 30 mins to brake the silence - #define NOIDLE brake_silence = clock () + 30 * CLK_TCK * 60 - - void CheckIdle ( void ) - { - while (true) // _inRun - { - while (clock() < brake_silence) - Sleep(10000); - - string out = TaggedReply("idle"); - - if ( !strnicmp ( out.c_str(), "/me ", 4 ) ) - Action ( CHANNEL, &out[4] ); - else - PrivMsg ( CHANNEL, out ); - - NOIDLE; - } - } - - static void THREADAPI CallMe ( MyIRCClient* irc ) - { - irc->CheckIdle(); - } - -public: - - MyIRCClient() - { - NOIDLE; - ThreadPool::Instance().Launch ( (ThreadPoolFunc*)MyIRCClient::CallMe, this ); - flog.open ( "arch.log", "r+" ); - } - // see IRCClient.h for documentation on these callbacks... - bool OnConnected() - { - return true; - } - bool OnJoin ( const string& user, const string& channel ) - { - //printf ( "user '%s' joined channel '%s'\n", user.c_str(), channel.c_str() ); - return true; - } - bool OnPart ( const std::string& user, const std::string& channel ) - { - std::vector::iterator it = ops.begin(); - for ( ; it != ops.end(); it++ ) - { - if ( *it == user ) - { - printf ( "remove '%s' to ops list\n", user.c_str() ); - ops.erase ( it ); - } - } - return true; - } - bool OnNick ( const std::string& oldNick, const std::string& newNick ) - { - for ( int i = 0; i < ops.size(); i++ ) - { - if ( ops[i] == oldNick ) - { - printf ( "op '%s' changed nick to '%s'\n", oldNick.c_str(), newNick.c_str() ); - ops[i] = newNick; - return true; - } - } - return true; - } - bool OnEndChannelUsers ( const string& channel ) - { - return true; - } - bool OnPrivMsg ( const string& from, const string& text ) - { - //flog.flush(); - printf ( "<%s> %s\n", from.c_str(), text.c_str() ); - flog.printf ( "<%s> %s\n", from.c_str(), text.c_str() ); - - if ( !isop(from) ) - return PrivMsg ( from, "hey, your tongue doesn't belong there!" ); - - else if ( strnicmp ( text.c_str(), "!say ", 5 ) ) - return PrivMsg ( from, "Talk to me on normal Chanel" ); - - string say = trim(&text[5]); - - if ( !strnicmp ( say.c_str(), "/me ", 4 ) ) - return Action ( CHANNEL, trim(&say[4]) ); - else - return PrivMsg ( CHANNEL, trim(say) ); - } - bool OnChannelMsg ( const string& channel, const string& from, const string& text ) - { - fflush ( flog ); - printf ( "%s <%s> %s\n", channel.c_str(), from.c_str(), text.c_str() ); - flog.printf ( "%s <%s> %s\n", channel.c_str(), from.c_str(), text.c_str() ); - NOIDLE; // add 30 mins till idle - - bool found_name = false; - string text2 ( text ); - strlwr ( &text2[0] ); - - if ( !strnicmp ( text.c_str(), BOTNAME, strlen(BOTNAME) ) ) - found_name = true; - - string s ( text ); - - if ( found_name ) - gobble ( s, " \t" ); // remove bot name - - // command - if ( s[0] == '!' ) - { - bool from_op = isop(from); - string cmd = gobble ( s, " \t" ); - - // from all - if ( false && cmd == "!svn" && from == "TechBot" ) // || cmd == "!help" && !TechBotOnline - { - PrivMsg ( channel, "For my help try !what." ); - } - - // from normel user - else if ( !from_op ) - { - if ( cmd == "!grovel" ) - { - string out = ssprintf(TaggedReply("nogrovel").c_str(),from.c_str()); - if ( !strnicmp ( out.c_str(), "/me ", 4 ) ) - return Action ( channel, &out[4] ); - else - return PrivMsg ( channel, out ); - } - - else if ( cmd == "!what" ) - { - return PrivMsg ( channel, ssprintf("For you, %s, I only support the \"!grovel\" command.", from.c_str()).c_str() ); - } - - else if ( cmd == "!grovel" || cmd == "!kiss" || cmd == "!hug" - || cmd == "!give" || cmd == "!what" || cmd == "!add" || cmd == "!remove" ) - { - PrivMsg ( channel, ssprintf("%s: I only take commands from ops",from.c_str()) ); - } - } - - // from op - else if ( cmd == "!grovel" ) - { - string out = ssprintf(TaggedReply("grovel").c_str(),from.c_str()); - if ( !strnicmp ( out.c_str(), "/me ", 4 ) ) - return Action ( channel, &out[4] ); - else - return PrivMsg ( channel, out ); - } - else if ( cmd == "!kiss" ) - { - if ( s.size() ) - return Action ( channel, ssprintf("kisses %s",s.c_str()) ); - else - return PrivMsg ( channel, ssprintf("%s: huh?",from.c_str()) ); - } - else if ( cmd == "!hug" ) - { - if ( s.size() ) - return Action ( channel, ssprintf("hugs %s",s.c_str()) ); - else - return PrivMsg ( channel, ssprintf("%s: huh?",from.c_str()) ); - } - else if ( cmd == "!give" ) - { - string who = gobble(s," \t"); - if ( who.size() && s.size() ) - return Action ( channel, ssprintf("gives %s a %s",who.c_str(),s.c_str()) ); - else - return PrivMsg ( channel, ssprintf("%s: huh?",from.c_str()) ); - } - else if ( cmd == "!what" ) - { - PrivMsg ( channel, "For ops I support the following commands:" ); - PrivMsg ( channel, "!grovel" ); - PrivMsg ( channel, "!kiss" ); - PrivMsg ( channel, "!hug" ); - PrivMsg ( channel, "!give" ); - PrivMsg ( channel, "!say (the input is a private message)" ); - PrivMsg ( channel, "!add" ); - PrivMsg ( channel, "!remove" ); - PrivMsg ( channel, " - for more info see wiki" ); - } - else if ( cmd == "!add" ) - { - string listname = gobble ( s, " \t" ); - int i = GetListIndex ( listname.c_str() ); - if ( i == -1 ) - return PrivMsg ( channel, ssprintf("%s: I don't have a list named '%s'",from.c_str(),listname.c_str()) ); - List& list = lists[i]; - if ( s[0] == '\"' || s[0] == '\'' ) - { - char delim = s[0]; - const char* p = &s[1]; - const char* p2 = strchr ( p, delim ); - if ( !p2 ) - return PrivMsg ( channel, ssprintf("%s: Couldn't add, unmatched quotes",from.c_str()) ); - s = string ( p, p2-p ); - } - for ( i = 0; i < list.list.size(); i++ ) - { - if ( list.list[i] == s ) - return PrivMsg ( channel, ssprintf("%s: entry already exists in list '%s'",from.c_str(),listname.c_str()) ); - } - if ( !stricmp ( listname.c_str(), "curse" ) ) - strlwr ( &s[0] ); - list.list.push_back ( s ); - { - File f ( ssprintf("%s.txt",list.name.c_str()), "w" ); - for ( i = 0; i < list.list.size(); i++ ) - f.printf ( "%s\n", list.list[i].c_str() ); - } - return PrivMsg ( channel, ssprintf("%s: entry added to list '%s'",from.c_str(),listname.c_str()) ); - } - else if ( cmd == "!remove" ) - { - string listname = gobble ( s, " \t" ); - int i = GetListIndex ( listname.c_str() ); - if ( i == -1 ) - return PrivMsg ( channel, ssprintf("%s: I don't have a list named '%s'",from.c_str(),listname.c_str()) ); - List& list = lists[i]; - if ( s[0] == '\"' || s[0] == '\'' ) - { - char delim = s[0]; - const char* p = &s[1]; - const char* p2 = strchr ( p, delim ); - if ( !p2 ) - return PrivMsg ( channel, ssprintf("%s: Couldn't add, unmatched quotes",from.c_str()) ); - s = string ( p, p2-p ); - } - std::vector::iterator it = list.list.begin(); - for ( ; it != list.list.end(); it++ ) - { - if ( *it == s ) - { - list.list.erase ( it ); - { - File f ( ssprintf("%s.txt",list.name.c_str()), "w" ); - it = list.list.begin(); - for ( ; it < list.list.end(); it++ ) - f.printf ( "%s\n", it->c_str() ); - } - return PrivMsg ( channel, ssprintf("%s: entry removed from list '%s'",from.c_str(),listname.c_str()) ); - } - } - return PrivMsg ( channel, ssprintf("%s: entry doesn't exist in list '%s'",from.c_str(),listname.c_str()) ); - } - else - { - if (found_name) - return PrivMsg ( channel, ssprintf("%s: huh?",from.c_str()) ); - } - - } // if (command) - - bool found_curse = false; - static vector& curse = GetList("curse").list; - text2 = " " + text2 + " "; - - for ( int i = 0; i < curse.size() && !found_curse; i++ ) - { - if ( strstr ( text2.c_str(), curse[i].c_str() ) ) - found_curse = true; - } - if ( found_curse ) - { - static List& cursecop = GetList("cursecop"); - return PrivMsg ( channel, ssprintf("%s: %s", from.c_str(), ListRand(cursecop)) ); - } - - string botname (BOTNAME); - strlwr ( &botname[0] ); - //botname = " " + botname + " "; - - if ( strstr(text2.c_str(), botname.c_str()) || strstr(text2.c_str(), " arch ") || found_name ) - { - string out = ssprintf("%s: %s", from.c_str(), TaggedReply("tech").c_str()); - flog.printf ( "TECH-REPLY: %s\n", out.c_str() ); - if ( !strnicmp ( out.c_str(), "/me ", 4 ) ) - return Action ( channel, &out[4] ); - else - return PrivMsg ( channel, out ); - } - return true; - - } // On Chanel Message - - bool OnChannelMode ( const string& channel, const string& mode ) - { - //printf ( "OnChannelMode(%s,%s)\n", channel.c_str(), mode.c_str() ); - return true; - } - bool OnUserModeInChannel ( const string& src, const string& channel, const string& mode, const string& target ) - { - printf ( "OnUserModeInChannel(%s,%s,%s,%s)\n", src.c_str(), channel.c_str(), mode.c_str(), target.c_str() ); - const char* p = mode.c_str(); - if ( !p ) - return true; - while ( *p ) - { - switch ( *p++ ) - { - case '+': - while ( *p != 0 && *p != ' ' ) - { - if ( *p == 'o' ) - { - printf ( "adding '%s' to ops list\n", target.c_str() ); - ops.push_back ( target ); - } - break; - } - break; - case '-': - while ( *p != 0 && *p != ' ' ) - { - if ( *p == 'o' ) - { - std::vector::iterator it = ops.begin(); - for ( ; it != ops.end(); it++ ) - { - if ( *it == target ) - { - printf ( "remove '%s' to ops list\n", target.c_str() ); - ops.erase ( it ); - } - } - break; - } - } - } - } - return true; - } - bool OnMode ( const string& user, const string& mode ) - { - //printf ( "OnMode(%s,%s)\n", user.c_str(), mode.c_str() ); - return true; - } - bool OnChannelUsers ( const string& channel, const vector& users ) - { - //printf ( "[%s has %i users]: ", channel.c_str(), users.size() ); - for ( int i = 0; i < users.size(); i++ ) - { - if ( users[i][0] == '@' ) - ops.push_back ( &users[i][1] ); - /*if ( i ) - printf ( ", " ); - printf ( "%s", users[i].c_str() );*/ - } - //printf ( "\n" ); - return true; - } - bool OnKick ( void ) - { - Join(CHANNEL); - return true; - } - bool OnBanned ( const std::string& channel ) - { - Sleep(10000); - return Join(CHANNEL); - } -}; - -int main ( int argc, char** argv ) -{ - srand ( time(NULL) ); - - ImportList ( "dev", true ); - ImportList ( "func", true ); - ImportList ( "dev", true ); - ImportList ( "func", true ); - ImportList ( "irql", true ); - ImportList ( "module", true ); - ImportList ( "period", true ); - ImportList ( "status", true ); - ImportList ( "stru", true ); - ImportList ( "type", true ); - - ImportList ( "tech", false ); - ImportList ( "curse", false ); - ImportList ( "cursecop", false ); - ImportList ( "grovel", false ); - ImportList ( "nogrovel", false ); - ImportList ( "idle", false ); - -#ifdef _DEBUG - printf ( "initializing IRCClient debugging\n" ); - IRCClient::SetDebug ( true ); -#endif//_DEBUG - - while (true) - { - printf ( "calling suStartup()\n" ); - suStartup(); - printf ( "creating IRCClient object\n" ); - MyIRCClient irc; - printf ( "connecting to freenode\n" ); - - if ( !irc.Connect ( SERVER ) ) // irc.freenode.net - { - printf ( "couldn't connect to server\n" ); - Sleep(10000); - continue; - } - printf ( "sending user command\n" ); - if ( !irc.User ( BOTNAME, "reactos.com", SERVER, "ArchBlackmann" ) ) - { - printf ( "USER command failed, retying ...\n" ); - Sleep(10000); - continue; - } - printf ( "sending nick\n" ); - if ( !irc.Nick ( BOTNAME ) ) - { - printf ( "NICK command failed, retying ...\n" ); - Sleep(10000); - continue; - } - printf ( "setting mode\n" ); - if ( !irc.Mode ( MODE ) ) - { - printf ( "MODE command failed, retying ...\n" ); - Sleep(10000); - continue; - } - printf ( "joining channel\n" ); - if ( !irc.Join ( CHANNEL ) ) - { - printf ( "JOIN command failed, retying ...\n" ); - Sleep(10000); - continue; - } - - printf ( "entering irc client processor\n" ); - irc.Run ( false ); // do the processing in this thread... - } - - return 0; -} diff --git a/irc/ArchBlackmann/ArchBlackmann.dsp b/irc/ArchBlackmann/ArchBlackmann.dsp deleted file mode 100644 index 03768e37c32..00000000000 --- a/irc/ArchBlackmann/ArchBlackmann.dsp +++ /dev/null @@ -1,216 +0,0 @@ -# Microsoft Developer Studio Project File - Name="ArchBlackmann" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=ArchBlackmann - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "ArchBlackmann.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "ArchBlackmann.mak" CFG="ArchBlackmann - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "ArchBlackmann - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "ArchBlackmann - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "ArchBlackmann - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 - -!ELSEIF "$(CFG)" == "ArchBlackmann - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "ArchBlackmann - Win32 Release" -# Name "ArchBlackmann - Win32 Debug" -# Begin Source File - -SOURCE=.\ArchBlackmann.cpp -# End Source File -# Begin Source File - -SOURCE=.\auto_ptr.h -# End Source File -# Begin Source File - -SOURCE=.\auto_vector.h -# End Source File -# Begin Source File - -SOURCE=.\base64.cpp -# End Source File -# Begin Source File - -SOURCE=.\base64.h -# End Source File -# Begin Source File - -SOURCE=.\chomp.cpp -# End Source File -# Begin Source File - -SOURCE=.\chomp.h -# End Source File -# Begin Source File - -SOURCE=.\config.h -# End Source File -# Begin Source File - -SOURCE=.\cram_md5.cpp -# End Source File -# Begin Source File - -SOURCE=.\cram_md5.h -# End Source File -# Begin Source File - -SOURCE=.\File.cpp -# End Source File -# Begin Source File - -SOURCE=.\File.h -# End Source File -# Begin Source File - -SOURCE=.\IRCClient.cpp -# End Source File -# Begin Source File - -SOURCE=.\IRCClient.h -# End Source File -# Begin Source File - -SOURCE=.\MD5.cpp -# End Source File -# Begin Source File - -SOURCE=.\MD5.h -# End Source File -# Begin Source File - -SOURCE=.\panic.cpp -# End Source File -# Begin Source File - -SOURCE=.\panic.h -# End Source File -# Begin Source File - -SOURCE=.\QueueT.h -# End Source File -# Begin Source File - -SOURCE=.\Reli.h -# End Source File -# Begin Source File - -SOURCE=.\ReliMT.cpp -# End Source File -# Begin Source File - -SOURCE=.\ReliMT.h -# End Source File -# Begin Source File - -SOURCE=.\SockUtils.cpp -# End Source File -# Begin Source File - -SOURCE=.\SockUtils.h -# End Source File -# Begin Source File - -SOURCE=.\SplitJoin.cpp -# End Source File -# Begin Source File - -SOURCE=.\SplitJoin.h -# End Source File -# Begin Source File - -SOURCE=.\ssprintf.cpp -# End Source File -# Begin Source File - -SOURCE=.\ssprintf.h -# End Source File -# Begin Source File - -SOURCE=.\ThreadPool.cpp -# End Source File -# Begin Source File - -SOURCE=.\ThreadPool.h -# End Source File -# Begin Source File - -SOURCE=.\trim.cpp -# End Source File -# Begin Source File - -SOURCE=.\trim.h -# End Source File -# Begin Source File - -SOURCE=.\verify.h -# End Source File -# End Target -# End Project diff --git a/irc/ArchBlackmann/ArchBlackmann.dsw b/irc/ArchBlackmann/ArchBlackmann.dsw deleted file mode 100644 index d8c4784be0e..00000000000 --- a/irc/ArchBlackmann/ArchBlackmann.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "ArchBlackmann"=.\ArchBlackmann.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/irc/ArchBlackmann/File.cpp b/irc/ArchBlackmann/File.cpp deleted file mode 100644 index a9fc94ed158..00000000000 --- a/irc/ArchBlackmann/File.cpp +++ /dev/null @@ -1,265 +0,0 @@ -// File.cpp -// (C) 2002-2004 Royce Mitchell III -// Dually licensed under BSD & LGPL - -#ifdef _MSC_VER -#pragma warning ( disable : 4786 ) -#endif//_MSC_VER - -#include -#include -#include "File.h" - -#ifndef nelem -#define nelem(x) ( sizeof(x) / sizeof(x[0]) ) -#endif//nelem - -typedef File::filesize_t filesize_t; -typedef File::fileoff_t fileoff_t; - - -fileoff_t File::seek ( fileoff_t offset ) -{ -#ifdef WIN32 - if ( _f->_flag & _IOWRT ) // is there pending output? - fflush ( _f ); - - // reset "buffered input" variables - _f->_cnt = 0; - _f->_ptr = _f->_base; - - // make sure we're going forward - if ( _f->_flag & _IORW ) - _f->_flag &= ~(_IOREAD|_IOWRT); - - return _lseeki64 ( _fileno(_f), offset, SEEK_SET ); -#else//UNIX - return lseek64 ( fileno(_f), offset, SEEK_SET ); -#endif -} - -std::string File::getline ( bool strip_crlf /*= false*/ ) -{ - std::string s = ""; - char buf[256]; - for ( ;; ) - { - *buf = 0; - fgets ( buf, nelem(buf)-1, _f ); - if ( !*buf ) - break; - s += buf; - if ( strchr ( "\r\n", buf[strlen(buf)-1] ) ) - break; - } - if ( strip_crlf && s.size() ) - { - char* p = strpbrk ( &s[0], "\r\n" ); - if ( p ) - { - *p = '\0'; - s.resize ( p-&s[0] ); - } - } - return s; -} - -std::wstring File::wgetline ( bool strip_crlf /*= false*/ ) -{ - std::wstring s = L""; - wchar_t buf[256]; - for ( ;; ) - { - *buf = 0; - fgetws ( buf, nelem(buf)-1, _f ); - if ( !*buf ) - break; - s += buf; - if ( wcschr ( L"\r\n", buf[wcslen(buf)-1] ) ) - break; - } - if ( strip_crlf && s.size() ) - { - wchar_t* p = wcspbrk ( &s[0], L"\r\n" ); - if ( p ) - { - *p = L'\0'; - s.resize ( (p-&s[0])/sizeof(wchar_t) ); - } - } - return s; -} - -// this function searches for the next end-of-line and puts all data it -// finds until then in the 'line' parameter. -// -// call continuously until the function returns false ( no more data ) -bool File::next_line ( std::string& line, bool strip_crlf ) -{ - line = getline(strip_crlf); - // indicate that we're done *if*: - // 1) there's no more data, *and* - // 2) we're at the end of the file - return line.size()>0 || !eof(); -} - -bool File::next_line ( std::wstring& line, bool strip_crlf ) -{ - line = wgetline ( strip_crlf ); - return line.size()>0 || !eof(); -} - -/* -example usage: - -bool mycallback ( const std::string& line, int line_number, long lparam ) -{ - std::cout << line << std::endl; - return true; // continue enumeration -} - -File f ( "file.txt", "rb" ); // open file for binary read-only ( i.e. "rb" ) -f.enum_lines ( mycallback, 0, true ); -*/ - -/*bool File::enum_lines ( bool (*callback)(const std::string& line, int line_number, long lparam), long lparam, bool strip_crlf ) -{ - int line_number = 0; - for ( ;; ) - { - std::string s = getline(strip_crlf); - line_number++; - if ( !s.size() ) - { - if ( eof() ) - return true; - else - continue; - } - if ( !(*callback) ( s, line_number, lparam ) ) - return false; - } -}*/ - -filesize_t File::length() const -{ -#ifdef WIN32 - return _filelengthi64 ( _fileno(_f) ); -#elif defined(UNIX) - struct stat64 file_stat; - verify(fstat64(fileno(_f), &file_stat) == 0); - return file_stat.st_size; -#endif -} - -void File::close() -{ - if ( _f ) - { - fclose(_f); - _f = 0; - } -} - -void File::printf ( const char* fmt, ... ) -{ - va_list arg; - int done; - - va_start(arg, fmt); - assert(_f); - done = vfprintf ( _f, fmt, arg ); - va_end(arg); -} - -/*static*/ bool File::LoadIntoString ( std::string& s, const std::string& filename ) -{ - File in ( filename, "rb" ); - if ( !in.isopened() ) - return false; - filesize_t flen = in.length(); - size_t len = size_t(flen); - if ( len != flen ) - return false; // file too big... - s.resize ( len + 1 ); - if ( !in.read ( &s[0], len ) ) - return false; - s[len] = '\0'; - s.resize ( len ); - return true; -} - -/*static*/ bool File::LoadIntoString ( std::string& s, const std::wstring& filename ) -{ - File in ( filename, L"rb" ); - if ( !in.isopened() ) - return false; - filesize_t flen = in.length(); - size_t len = size_t(flen); - if ( len != flen ) - return false; // file too big... - s.resize ( len + 1 ); - if ( !in.read ( &s[0], len ) ) - return false; - s[len] = '\0'; - s.resize ( len ); - return true; -} - -/*static*/ bool File::SaveFromString ( const std::string& filename, const std::string& s, bool binary ) -{ - File out ( filename, binary ? "wb" : "w" ); - if ( !out.isopened() ) - return false; - out.write ( s.c_str(), s.size() ); - return true; -} - -/*static*/ bool File::SaveFromString ( const std::wstring& filename, const std::string& s, bool binary ) -{ - File out ( filename, binary ? L"wb" : L"w" ); - if ( !out.isopened() ) - return false; - out.write ( s.c_str(), s.size() ); - return true; -} - -/*static*/ bool File::SaveFromBuffer ( const std::string& filename, const char* buf, size_t buflen, bool binary ) -{ - File out ( filename, binary ? "wb" : "w" ); - if ( !out.isopened() ) - return false; - out.write ( buf, buflen ); - return true; -} - -/*static*/ bool File::SaveFromBuffer ( const std::wstring& filename, const char* buf, size_t buflen, bool binary ) -{ - File out ( filename, binary ? L"wb" : L"w" ); - if ( !out.isopened() ) - return false; - out.write ( buf, buflen ); - return true; -} - -/*static*/ std::string File::TempFileName ( const std::string& prefix ) -{ -#ifdef WIN32 - std::string s ( _tempnam ( ".", prefix.c_str() ) ); - return s; -#else - // FIXME - return string(""); -#endif -} - -/*static*/ std::wstring File::TempFileName ( const std::wstring& prefix ) -{ -#ifdef WIN32 - std::wstring s ( _wtempnam ( L".", prefix.c_str() ) ); - return s; -#else - // FIXME - return std::wstring(L""); -#endif -} diff --git a/irc/ArchBlackmann/File.h b/irc/ArchBlackmann/File.h deleted file mode 100644 index a5baea62515..00000000000 --- a/irc/ArchBlackmann/File.h +++ /dev/null @@ -1,173 +0,0 @@ -// File.h -// (C) 2002-2004 Royce Mitchell III -// Dually licensed under BSD & LGPL - -#ifndef FILE_H -#define FILE_H - -#ifdef WIN32 -# include // fgetc -# include -#elif defined(UNIX) -# include -# include -#endif -#include -#include - -class File -{ -public: -#ifdef WIN32 - typedef __int64 fileoff_t; - typedef unsigned __int64 filesize_t; -#else//_MSC_VER - typedef __off64_t fileoff_t; - typedef __size64_t filesize_t; -#endif//_MSC_VER - - File() : _f(0) - { - } - - File ( const std::string& filename, const char* mode ) : _f(0) - { - open ( filename, mode ); - } - - File ( const std::wstring& filename, const wchar_t* mode ) : _f(0) - { - open ( filename, mode ); - } - - File ( const char* filename, const char* mode ) : _f(0) - { - open ( filename, mode ); - } - - File ( const wchar_t* filename, const wchar_t* mode ) : _f(0) - { - open ( filename, mode ); - } - - ~File() - { - close(); - } - - bool open ( const std::string& filename, const char* mode ) - { - assert ( !_f ); - return ( _f = fopen ( filename.c_str(), mode ) ) != 0; - } - - bool open ( const std::wstring& filename, const wchar_t* mode ) - { - assert ( !_f ); - return ( _f = _wfopen ( filename.c_str(), mode ) ) != 0; - } - - bool open ( const char* filename, const char* mode ) - { - assert ( !_f ); - return ( _f = fopen ( filename, mode ) ) != 0; - } - - bool open ( const wchar_t* filename, const wchar_t* mode ) - { - assert ( !_f ); - return ( _f = _wfopen ( filename, mode ) ) != 0; - } - - fileoff_t seek ( fileoff_t offset ); - - int get() - { - return fgetc ( _f ); - } - - bool put ( int c ) - { - return fputc ( c, _f ) != EOF; - } - - std::string getline ( bool strip_crlf = false ); - std::wstring wgetline ( bool strip_crlf = false ); - - // this function searches for the next end-of-line and puts all data it - // finds until then in the 'line' parameter. - // - // call continuously until the function returns false ( no more data ) - bool next_line ( std::string& line, bool strip_crlf ); - bool next_line ( std::wstring& line, bool strip_crlf ); - - bool read ( void* data, unsigned len ) - { - return len == fread ( data, 1, len, _f ); - } - - bool write ( const void* data, unsigned len ) - { - return len == fwrite ( data, 1, len, _f ); - } - - bool write ( const std::string& data ) - { - return data.length() == fwrite ( data.c_str(), 1, data.length(), _f ); - } - - bool write ( const std::wstring& data ) - { - return data.length() == fwrite ( data.c_str(), sizeof(data[0]), data.length(), _f ); - } - - filesize_t length() const; - - void close(); - - bool isopened() const - { - return _f != 0; - } - - bool is_open() const - { - return _f != 0; - } - - bool eof() const - { - return feof(_f) ? true : false; - } - - FILE* operator * () - { - return _f; - } - - operator FILE*() - { - return _f; - } - - void printf ( const char* fmt, ... ); - void printf ( const wchar_t* fmt, ... ); - - static bool LoadIntoString ( std::string& s, const std::string& filename ); - static bool LoadIntoString ( std::string& s, const std::wstring& filename ); - static bool SaveFromString ( const std::string& filename, const std::string& s, bool binary ); - static bool SaveFromString ( const std::wstring& filename, const std::string& s, bool binary ); - static bool SaveFromBuffer ( const std::string& filename, const char* buf, size_t buflen, bool binary ); - static bool SaveFromBuffer ( const std::wstring& filename, const char* buf, size_t buflen, bool binary ); - - static std::string TempFileName ( const std::string& prefix ); - static std::wstring TempFileName ( const std::wstring& prefix ); - -private: - File(const File&) {} - const File& operator = ( const File& ) { return *this; } - - FILE * _f; -}; - -#endif//FILE_H diff --git a/irc/ArchBlackmann/IRCClient.cpp b/irc/ArchBlackmann/IRCClient.cpp deleted file mode 100644 index 5910358365a..00000000000 --- a/irc/ArchBlackmann/IRCClient.cpp +++ /dev/null @@ -1,418 +0,0 @@ -// IRCClient.cpp -// This file is (C) 2004 Royce Mitchell III -// and released under the BSD & LGPL licenses - -#ifdef _MSC_VER -#pragma warning ( disable : 4786 ) -#endif//_MSC_VER - -#include -#include - -#include "IRCClient.h" -#include "MD5.h" -#include "cram_md5.h" -#include "trim.h" -#include "chomp.h" -#include "SplitJoin.h" -#include "base64.h" -#include "config.h" - -using std::string; -using std::stringstream; -using std::vector; - -bool IRCClient::_debug = true; - -// see rfc1459 for IRC-Protocoll Reference - -IRCClient::IRCClient() - : _timeout(10*60*1000), _inRun(false) -{ -} - -bool IRCClient::Connect ( const string& server, short port ) -{ - string buf; - Close(); - Attach ( suTcpSocket() ); - if ( !suConnect ( *this, server.c_str(), port ) ) - return false; - return true; -} - -bool -IRCClient::User ( const string& user, const string& mode, - const string& network, const string& realname ) -{ - string buf; - buf = "USER " + user + " \"" + mode + "\" \"" + network + "\" :" + realname + "\n"; - return Send ( buf ); -} - -bool -IRCClient::Nick ( const string& nick ) -{ - _nick = nick; - Send ( "NICK " + _nick + "\n" ); - PrivMsg ("NickServ", "IDENTIFY " + (string)PASS); - return true; -} - -bool -IRCClient::Mode ( const string& mode ) -{ - return Send ( "MODE " + _nick + " " + mode + "\n" ); -} - -bool -IRCClient::Names ( const string& channel ) -{ - return Send ( "NAMES " + channel + "\n" ); -} - -bool -IRCClient::Mode ( const string& channel, const string& mode, const string& target ) -{ - return Send ( "MODE " + channel + " " + mode + " " + target + "\n" ); -} - -bool -IRCClient::Join ( const string& channel ) -{ - return Send("JOIN " + channel + "\n"); -} - -bool -IRCClient::PrivMsg ( const string& to, const string& text ) -{ - return Send ( "PRIVMSG " + to + " :" + text + '\n' ); -} - -bool -IRCClient::Action ( const string& to, const string& text ) -{ - return Send ( "PRIVMSG " + to + " :" + (char)1 + "ACTION " + text + (char)1 + '\n' ); -} - -bool -IRCClient::Part ( const string& channel, const string& text ) -{ - return Send ( "PART " + channel + " :" + text + "\n" ); -} - -bool -IRCClient::Quit ( const string& text ) -{ - return Send( "QUIT :" + text + "\n"); -} - -bool IRCClient::_Recv ( string& buf ) -{ - bool b = (recvUntil ( buf, '\n', _timeout ) > 0); - if ( b && _debug ) - { - printf ( ">> %s", buf.c_str() ); - if ( buf[buf.length()-1] != '\n' ) - printf ( "\n" ); - } - return b; -} - -bool IRCClient::Send ( const string& buf ) -{ - if ( _debug ) - { - printf ( "<< %s", buf.c_str() ); - if ( buf[buf.length()-1] != '\n' ) - printf ( "\n" ); - } - return ( buf.length() == (size_t)send ( *this, buf.c_str(), buf.length(), 0 ) ); -} - -bool IRCClient::OnPing( const string& text ) -{ - return Send( "PONG " + text + "\n" ); -} - - -int THREADAPI IRCClient::Callback ( IRCClient* irc ) -{ - return irc->Run ( false ); -} - -int IRCClient::Run ( bool launch_thread ) -{ - if ( (SOCKET)*this == INVALID_SOCKET ) - return 0; - if ( _inRun ) return 1; - if ( launch_thread ) - { - ThreadPool::Instance().Launch ( (ThreadPoolFunc*)IRCClient::Callback, this ); - return 1; - } - _inRun = true; - if ( _debug ) printf ( "IRCClient::Run() - waiting for responses\n" ); - string buf; - while ( _Recv(buf) ) - { - if ( !strnicmp ( buf.c_str(), "NOTICE ", 7 ) ) - { - //printf ( "recv'd NOTICE msg...\n" ); - // TODO... - //OnAuth ( - } - else if ( !strnicmp ( buf.c_str(), "PING ", 5 ) ) - { - const char* p = &buf[5]; // point to first char after "PING " - while ( *p == ':' ) // then read past the colons - p++; - const char* p2 = strpbrk ( p, "\r\n" ); // find the end of line - string text ( p, p2-p ); // and set the text - OnPing( text ); - } - else if ( buf[0] == ':' ) - { - const char* p = &buf[1]; // skip first colon... - const char* p2 = strpbrk ( p, " !" ); - if ( !p2 ) - { - printf ( "!!!:OnRecv failure 0: ", buf.c_str() ); - continue; - } - string src ( p, p2-p ); - if ( !src.length() ) - { - printf ( "!!!:OnRecv failure 0.5: %s", buf.c_str() ); - continue; - } - p = p2 + 1; - if ( *p2 == '!' ) - { - p2 = strchr ( p, ' ' ); - if ( !p2 ) - { - printf ( "!!!:OnRecv failure 1: %s", buf.c_str() ); - continue; - } - //string srchost ( p, p2-p ); - p = p2 + 1; - } - p2 = strchr ( p, ' ' ); - if ( !p2 ) - { - printf ( "!!!:OnRecv failure 2: %s", buf.c_str() ); - continue; - } - string cmd ( p, p2-p ); - p = p2 + 1; - p2 = strpbrk ( p, " :" ); - if ( !p2 ) - { - printf ( "!!!:OnRecv failure 3: %s", buf.c_str() ); - continue; - } - string tgt ( p, p2-p ); - p = p2 + 1; - p += strspn ( p, " " ); - if ( *p == '=' ) - { - p++; - p += strspn ( p, " " ); - } - if ( *p == ':' ) - p++; - p2 = strpbrk ( p, "\r\n" ); - if ( !p2 ) - { - printf ( "!!!:OnRecv failure 4: %s", buf.c_str() ); - continue; - } - string text ( p, p2-p ); - strlwr ( &cmd[0] ); - if ( cmd == "privmsg" ) - { - if ( !tgt.length() ) - { - printf ( "!!!:OnRecv failure 5 (PRIVMSG w/o target): %s", buf.c_str() ); - continue; - } - if ( *p == 1 ) - { - p++; - p2 = strchr ( p, ' ' ); - if ( !p2 ) p2 = p + strlen(p); - cmd = string ( p, p2-p ); - strlwr ( &cmd[0] ); - p = p2 + 1; - p2 = strchr ( p, 1 ); - if ( !p2 ) - { - printf ( "!!!:OnRecv failure 6 (no terminating \x01 for initial \x01 found: %s", buf.c_str() ); - continue; - } - text = string ( p, p2-p ); - if ( cmd == "action" ) - { - if ( tgt[0] == '#' ) - OnChannelAction ( tgt, src, text ); - else - OnPrivAction ( src, text ); - } - else - { - printf ( "!!!:OnRecv failure 7 (unrecognized \x01 command '%s': %s", cmd.c_str(), buf.c_str() ); - continue; - } - } - else - { - if ( tgt[0] == '#' ) - OnChannelMsg ( tgt, src, text ); - else - OnPrivMsg ( src, text ); - } - } - else if ( cmd == "mode" ) - { - // two diff. kinds of mode notifications... - //printf ( "[MODE] src='%s' cmd='%s' tgt='%s' text='%s'", src.c_str(), cmd.c_str(), tgt.c_str(), text.c_str() ); - //OnMode ( - // self mode change: - // [MODE] src=Nick cmd=mode tgt=Nick text=+i - // channel mode change: - // [MODE] src=Nick cmd=mode tgt=#Channel text=+o Nick - if ( tgt[0] == '#' ) - { - p = text.c_str(); - p2 = strchr ( p, ' ' ); - if ( p2 && *p2 ) - { - string mode ( p, p2-p ); - p = p2 + 1; - p += strspn ( p, " " ); - OnUserModeInChannel ( src, tgt, mode, trim(p) ); - } - else - OnChannelMode ( tgt, text ); - } - else - OnMode ( tgt, text ); - } - else if ( cmd == "join" ) - { - mychannel = text; - OnJoin ( src, text ); - } - else if ( cmd == "part" ) - { - OnPart ( src, text ); - } - else if ( cmd == "nick" ) - { - OnNick ( src, text ); - } - else if ( cmd == "kick" ) - { - OnKick (); - } - else if ( isdigit(cmd[0]) ) - { - int i = atoi(cmd.c_str()); - switch ( i ) - { - - case 1: // "Welcome!" - i.e. it's okay to issue commands now... - OnConnected(); - break; - - case 353: // user list for channel.... - { - p = text.c_str(); - p2 = strpbrk ( p, " :" ); - if ( !p2 ) continue; - string channel ( p, p2-p ); - p = strchr ( p2, ':' ); - if ( !p ) continue; - p++; - vector users; - while ( *p ) - { - p2 = strchr ( p, ' ' ); - if ( !p2 ) - p2 = p + strlen(p); - users.push_back ( string ( p, p2-p ) ); - p = p2+1; - p += strspn ( p, " " ); - } - OnChannelUsers ( channel, users ); - } - break; - - case 366: // END of user list for channel - { - p = text.c_str(); - p2 = strpbrk ( p, " :" ); - if ( !p2 ) continue; - string channel ( p, p2-p ); - OnEndChannelUsers ( channel ); - } - break; - - case 474: // You are banned - { - p = text.c_str(); - p2 = strpbrk ( p, " :" ); - if ( !p2 ) continue; - string channel ( p, p2-p ); - OnBanned ( channel ); - } - break; - - case 433: // Nick in Use - { - string nick = _nick; - Nick (nick + "_"); - - PrivMsg ("NickServ", "GHOST " + nick + " " + PASS); - - // HACK HACK HACK - Mode ( "+i" ); - Join ( CHANNEL ); // this is because IRC client does not review if his commands were sucessfull - - Sleep ( 1000 ); - Nick ( nick ); - } - break; - - case 2: //MOTD - case 376: //MOTD - case 372: - break; - - default: - if ( _debug ) printf ( "unknown command %i: %s", i, buf.c_str() ); - break; - } - } - else - { - if ( strstr ( buf.c_str(), "ACTION" ) ) - { - printf ( "ACTION: " ); - for ( int i = 0; i < buf.size(); i++ ) - printf ( "%c(%xh)", buf[i], (unsigned)(unsigned char)buf[i] ); - } - else if ( _debug ) printf ( "unrecognized ':' response: %s", buf.c_str() ); - } - } - else - { - if ( _debug ) printf ( "unrecognized irc msg: %s", buf.c_str() ); - } - //OnRecv ( buf ); - } - if ( _debug ) printf ( "IRCClient::Run() - exiting\n" ); - _inRun = false; - return 0; -} diff --git a/irc/ArchBlackmann/IRCClient.h b/irc/ArchBlackmann/IRCClient.h deleted file mode 100644 index 57fa2105e50..00000000000 --- a/irc/ArchBlackmann/IRCClient.h +++ /dev/null @@ -1,148 +0,0 @@ -// IRCClient.h -// This file is (C) 2004 Royce Mitchell III -// and released under the BSD & LGPL licenses - -#ifndef IRCCLIENT_H -#define IRCCLIENT_H - -#include -#include -#include "SockUtils.h" -#include "ThreadPool.h" - -class IRCClient : public suBufferedRecvSocket -{ - -public: - IRCClient(); - - std::string mychannel; - static bool GetDebug() { return _debug; } - static bool SetDebug ( bool debug ) { bool old = _debug; _debug = debug; return old; } - - // connect to server ( record greeting for apop if it exists ) - bool Connect ( const std::string& server, short port = 6667 ); - - bool Running() { return _inRun; } - - ////////////////////////// IRC Client Protocol commands /////////////////////// - - // first thing you must call... mode can be "" - // network can be same as name of server used in Connect() above - bool User ( const std::string& user, const std::string& mode, - const std::string& network, const std::string& realname ); - - // change nick... - bool Nick ( const std::string& nick ); - - // change mode for self... - bool Mode ( const std::string& mode ); - - // set someone's mode in channel ( like oping someone ) - bool Mode ( const std::string& channel, const std::string& mode, const std::string& target ); - - // request a list of names of clients in a channel - bool Names ( const std::string& channel ); - - // join a channel... - bool Join ( const std::string& channel ); - - // send message to someone or some channel - bool PrivMsg ( const std::string& to, const std::string& text ); - - // send /me to someone or some channel - bool Action ( const std::string& to, const std::string& text ); - - // leave a channel - bool Part ( const std::string& channel, const std::string& text ); - - // log off - bool Quit ( const std::string& text ); - - ////////////////////// callback functions //////////////////////////// - - // OnConnected: you just successfully logged into irc server - virtual bool OnConnected() = 0; - - virtual bool OnNick ( const std::string& oldNick, const std::string& newNick ) { return true; } - - // OnJoin: someone just successfully joined a channel you are in ( also sent when you successfully join a channel ) - virtual bool OnJoin ( const std::string& user, const std::string& channel ) { return true; } - - // OnPart: someone just left a channel you are in - virtual bool OnPart ( const std::string& user, const std::string& channel ) { return true; } - - // OnPrivMsg: you just received a private message from a user - virtual bool OnPrivMsg ( const std::string& from, const std::string& text ) { return true; } - - virtual bool OnPrivAction ( const std::string& from, const std::string& text ) { return true; } - - // OnChannelMsg: you just received a chat line in a channel - virtual bool OnChannelMsg ( const std::string& channel, const std::string& from, - const std::string& text ) { return true; } - - // OnChannelAction: you just received a "/me" line in a channel - virtual bool OnChannelAction ( const std::string& channel, const std::string& from, - const std::string& text ) { return true; } - - // OnChannelMode: notification of a change of a channel's mode - virtual bool OnChannelMode ( const std::string& channel, const std::string& mode ) - { return true; } - - // OnUserModeInChannel: notification of a mode change of a user with respect to a channel. - // f.ex.: this will be called when someone is oped in a channel. - virtual bool OnUserModeInChannel ( const std::string& src, const std::string& channel, - const std::string& mode, const std::string& target ) { return true; } - - // OnMode: you will receive this when you change your own mode, at least... - virtual bool OnMode ( const std::string& user, const std::string& mode ) { return true; } - - // notification of what users are in a channel ( you may get multiple of these... ) - virtual bool OnChannelUsers ( const std::string& channel, const std::vector& users ) - { return true; } - - // OnKick: if the client has been kicked - virtual bool OnKick ( void ) { return true; } - - // OnKick: if the client has been kicked - virtual bool OnBanned ( const std::string& channel ) { return true; } - - // notification that you have received the entire list of users for a channel - virtual bool OnEndChannelUsers ( const std::string& channel ) { return true; } - - // OnPing - default implementation replies to PING with a valid PONG. required on some systems to - // log in. Most systems require a response in order to stay connected, used to verify a client hasn't - // dropped. - virtual bool OnPing ( const std::string& text ); - - ////////////////////// other functions //////////////////////////// - - // this is for sending data to irc server. it's public in case you need to send some - // command not supported by this base class... - bool Send ( const std::string& buf ); - - // if launch_thread is true, this function will spawn a thread that will process - // incoming packets until the socket dies. - // otherwise ( launch_thread is false ) this function will do that processing - // in *this* thread, and not return until the socket dies. - int Run ( bool launch_thread ); - - ////////////////////// private stuff //////////////////////////// -private: - bool _Recv ( std::string& buf ); - - static int THREADAPI Callback ( IRCClient* irc ); - - static bool _debug; - std::string _nick; - int _timeout; - std::string _apop_challenge; - - volatile bool _inRun; - - // disable copy semantics - IRCClient ( const IRCClient& ); - IRCClient& operator = ( const IRCClient& ); -}; - -#endif//IRCCLIENT_H diff --git a/irc/ArchBlackmann/MD5.cpp b/irc/ArchBlackmann/MD5.cpp deleted file mode 100644 index 43200cfa1a1..00000000000 --- a/irc/ArchBlackmann/MD5.cpp +++ /dev/null @@ -1,418 +0,0 @@ -// MD5.CPP - RSA Data Security, Inc., MD5 message-digest algorithm - -/* -Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All -rights reserved. - -License to copy and use this software is granted provided that it -is identified as the "RSA Data Security, Inc. MD5 Message-Digest -Algorithm" in all material mentioning or referencing this software -or this function. - -License is also granted to make and use derivative works provided -that such works are identified as "derived from the RSA Data -Security, Inc. MD5 Message-Digest Algorithm" in all material -mentioning or referencing the derived work. - -RSA Data Security, Inc. makes no representations concerning either -the merchantability of this software or the suitability of this -software for any particular purpose. It is provided "as is" -without express or implied warranty of any kind. - -These notices must be retained in any copies of any part of this -documentation and/or software. -*/ - -//#include -#include -#include -#include -#include "MD5.h" - -using std::string; -using std::vector; - -// Constants for MD5Transform routine. -#define S11 7 -#define S12 12 -#define S13 17 -#define S14 22 -#define S21 5 -#define S22 9 -#define S23 14 -#define S24 20 -#define S31 4 -#define S32 11 -#define S33 16 -#define S34 23 -#define S41 6 -#define S42 10 -#define S43 15 -#define S44 21 - -static void MD5Transform ( UINT4 [4], const uchar [64] ); -static void Encode ( unsigned char *, UINT4 *, unsigned int ); -static void Decode ( UINT4 *, const uchar *, unsigned int ); - -static unsigned char PADDING[64] = -{ - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -// F, G, H and I are basic MD5 functions. -#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) -#define G(x, y, z) (((x) & (z)) | ((y) & (~z))) -#define H(x, y, z) ((x) ^ (y) ^ (z)) -#define I(x, y, z) ((y) ^ ((x) | (~z))) - -// ROTATE_LEFT rotates x left n bits. -#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) - -// FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. -// Rotation is separate from addition to prevent recomputation. -#define FF(a, b, c, d, x, s, ac) { \ - (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define GG(a, b, c, d, x, s, ac) { \ - (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define HH(a, b, c, d, x, s, ac) { \ - (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } -#define II(a, b, c, d, x, s, ac) { \ - (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \ - (a) = ROTATE_LEFT ((a), (s)); \ - (a) += (b); \ - } - -// MD5 initialization. Begins an MD5 operation, writing a new context. -void MD5Init ( - MD5_CTX *context ) // context -{ - context->count[0] = context->count[1] = 0; - // Load magic initialization constants. - context->state[0] = 0x67452301; - context->state[1] = 0xefcdab89; - context->state[2] = 0x98badcfe; - context->state[3] = 0x10325476; -} - -// MD5 block update operation. Continues an MD5 message-digest -// operation, processing another message block, and updating the -// context. -void MD5Update ( - MD5_CTX *context, // context - const char *input_, // input block - unsigned int inputLen ) // length of input block -{ - unsigned int i, index, partLen; - const uchar* input = (const uchar*)input_; - - // Compute number of bytes mod 64 - index = (unsigned int)((context->count[0] >> 3) & 0x3F); - - // Update number of bits - if ((context->count[0] += ((UINT4)inputLen << 3)) - < ((UINT4)inputLen << 3)) - context->count[1]++; - context->count[1] += ((UINT4)inputLen >> 29); - - partLen = 64 - index; - - // Transform as many times as possible. - if (inputLen >= partLen) - { - memcpy - ((POINTER)&context->buffer[index], (POINTER)input, partLen); - MD5Transform (context->state, context->buffer); - - for (i = partLen; i + 63 < inputLen; i += 64) - MD5Transform (context->state, &input[i]); - - index = 0; - } - else - i = 0; - - // Buffer remaining input - memcpy - ((POINTER)&context->buffer[index], (POINTER)&input[i], - inputLen-i); -} - -// MD5 finalization. Ends an MD5 message-digest operation, writing the -// the message digest and zeroizing the context. -void MD5Final ( - unsigned char digest[16], // message digest - MD5_CTX *context ) // context -{ - uchar bits[8]; - unsigned int index, padLen; - - // Save number of bits - Encode (bits, context->count, 8); - - // Pad out to 56 mod 64. - index = (unsigned int)((context->count[0] >> 3) & 0x3f); - padLen = (index < 56) ? (56 - index) : (120 - index); - MD5Update (context, (const char*)PADDING, padLen); - - // Append length (before padding) - MD5Update (context, (const char*)bits, 8); - - // Store state in digest - Encode (digest, context->state, 16); - - // Zeroize sensitive information. - memset ((POINTER)context, 0, sizeof (*context)); -} - -// MD5 basic transformation. Transforms state based on block. -static void MD5Transform ( - UINT4 state[4], - const uchar block[64] ) -{ - UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; - - Decode (x, block, 64); - - // Round 1 - FF (a, b, c, d, x[ 0], S11, 0xd76aa478); // 1 - FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); // 2 - FF (c, d, a, b, x[ 2], S13, 0x242070db); // 3 - FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); // 4 - FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); // 5 - FF (d, a, b, c, x[ 5], S12, 0x4787c62a); // 6 - FF (c, d, a, b, x[ 6], S13, 0xa8304613); // 7 - FF (b, c, d, a, x[ 7], S14, 0xfd469501); // 8 - FF (a, b, c, d, x[ 8], S11, 0x698098d8); // 9 - FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); // 10 - FF (c, d, a, b, x[10], S13, 0xffff5bb1); // 11 - FF (b, c, d, a, x[11], S14, 0x895cd7be); // 12 - FF (a, b, c, d, x[12], S11, 0x6b901122); // 13 - FF (d, a, b, c, x[13], S12, 0xfd987193); // 14 - FF (c, d, a, b, x[14], S13, 0xa679438e); // 15 - FF (b, c, d, a, x[15], S14, 0x49b40821); // 16 - - // Round 2 - GG (a, b, c, d, x[ 1], S21, 0xf61e2562); // 17 - GG (d, a, b, c, x[ 6], S22, 0xc040b340); // 18 - GG (c, d, a, b, x[11], S23, 0x265e5a51); // 19 - GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); // 20 - GG (a, b, c, d, x[ 5], S21, 0xd62f105d); // 21 - GG (d, a, b, c, x[10], S22, 0x2441453); // 22 - GG (c, d, a, b, x[15], S23, 0xd8a1e681); // 23 - GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); // 24 - GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); // 25 - GG (d, a, b, c, x[14], S22, 0xc33707d6); // 26 - GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); // 27 - GG (b, c, d, a, x[ 8], S24, 0x455a14ed); // 28 - GG (a, b, c, d, x[13], S21, 0xa9e3e905); // 29 - GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); // 30 - GG (c, d, a, b, x[ 7], S23, 0x676f02d9); // 31 - GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); // 32 - - // Round 3 - HH (a, b, c, d, x[ 5], S31, 0xfffa3942); // 33 - HH (d, a, b, c, x[ 8], S32, 0x8771f681); // 34 - HH (c, d, a, b, x[11], S33, 0x6d9d6122); // 35 - HH (b, c, d, a, x[14], S34, 0xfde5380c); // 36 - HH (a, b, c, d, x[ 1], S31, 0xa4beea44); // 37 - HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); // 38 - HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); // 39 - HH (b, c, d, a, x[10], S34, 0xbebfbc70); // 40 - HH (a, b, c, d, x[13], S31, 0x289b7ec6); // 41 - HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); // 42 - HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); // 43 - HH (b, c, d, a, x[ 6], S34, 0x4881d05); // 44 - HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); // 45 - HH (d, a, b, c, x[12], S32, 0xe6db99e5); // 46 - HH (c, d, a, b, x[15], S33, 0x1fa27cf8); // 47 - HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); // 48 - - // Round 4 - II (a, b, c, d, x[ 0], S41, 0xf4292244); // 49 - II (d, a, b, c, x[ 7], S42, 0x432aff97); // 50 - II (c, d, a, b, x[14], S43, 0xab9423a7); // 51 - II (b, c, d, a, x[ 5], S44, 0xfc93a039); // 52 - II (a, b, c, d, x[12], S41, 0x655b59c3); // 53 - II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); // 54 - II (c, d, a, b, x[10], S43, 0xffeff47d); // 55 - II (b, c, d, a, x[ 1], S44, 0x85845dd1); // 56 - II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); // 57 - II (d, a, b, c, x[15], S42, 0xfe2ce6e0); // 58 - II (c, d, a, b, x[ 6], S43, 0xa3014314); // 59 - II (b, c, d, a, x[13], S44, 0x4e0811a1); // 60 - II (a, b, c, d, x[ 4], S41, 0xf7537e82); // 61 - II (d, a, b, c, x[11], S42, 0xbd3af235); // 62 - II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); // 63 - II (b, c, d, a, x[ 9], S44, 0xeb86d391); // 64 - - state[0] += a; - state[1] += b; - state[2] += c; - state[3] += d; - - // Zeroize sensitive information. - memset ((POINTER)x, 0, sizeof (x)); -} - -// Encodes input (UINT4) into output (unsigned char). Assumes len is -// a multiple of 4. -static void Encode ( - unsigned char *output, - UINT4 *input, - unsigned int len ) -{ - unsigned int i, j; - - for (i = 0, j = 0; j < len; i++, j += 4) { - output[j] = (unsigned char)(input[i] & 0xff); - output[j+1] = (unsigned char)((input[i] >> 8) & 0xff); - output[j+2] = (unsigned char)((input[i] >> 16) & 0xff); - output[j+3] = (unsigned char)((input[i] >> 24) & 0xff); - } -} - -// Decodes input (unsigned char) into output (UINT4). Assumes len is -// a multiple of 4. -static void Decode ( - UINT4 *output, - const uchar *input, - unsigned int len ) -{ - unsigned int i, j; - - for (i = 0, j = 0; j < len; i++, j += 4) - output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) | - (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24); -} - -void digest2ascii ( char *ascii, const unsigned char *digest ) -{ - int i; - static char* table = "0123456789abcdef"; - for ( i = 0; i < 16; i++ ) - { - *ascii++ = table[(*digest)>>4]; - *ascii++ = table[(*digest++)%16]; - } - *ascii++ = 0; -} - -void ascii2digest ( unsigned char *digest, const char *ascii ) -{ - int i; -#define CONV(c) (unsigned char)( (toupper(c)>='A') ? (toupper(c)+10-'A') : ((c)-'0') ) -#define MAKECHAR(a,b) ((CONV(a)%16)<<4)|(CONV(b)%16) - for ( i = 0; i < 16; i++ ) - { - *digest++ = MAKECHAR(ascii[0],ascii[1]); - ascii += 2; - } -} - -#ifdef __cplusplus -MD5::MD5() -{ - Init(); -} - -void MD5::Init() -{ - MD5Init(&_ctx); -} - -void MD5::Update ( const string& s ) -{ - MD5Update ( &_ctx, s.c_str(), s.size() ); -} - -string MD5::Final ( char* digest ) -{ - vector v; - v.resize(16); - MD5Final ( &v[0], &_ctx ); - if ( digest ) - memmove ( digest, &v[0], 16 ); - string s; - static char* tohex = "0123456789abcdef"; - for ( int i = 0; i < 16; i++ ) - { - uchar c = v[i]; - s += tohex[ (c>>4) & 0xF ]; - s += tohex[ c & 0xF ]; - } - return s; -} - -string MD5Hex ( const string& s ) -{ - MD5 md5; - md5.Update ( s ); - return md5.Final(); -} - -string MD5Bin ( const string& s ) -{ - MD5 md5; - md5.Update ( s ); - char digest[16]; - md5.Final ( digest ); - return string ( digest, 16 ); -} - -string HMAC_MD5 ( const string& key, const string& text, char* out_bin ) -{ - MD5 md5; - char k_ipad[65]; // inner padding - key XORd with ipad - char k_opad[65]; // outer padding - key XORd with opad - string tmp; - char digest[16]; - int i; - // if key is longer than 64 bytes reset it to key=MD5(key) - if ( key.length() > 64 ) - { - md5.Init(); - md5.Update ( key ); - md5.Final ( digest ); - tmp = string ( digest, 16 ); - } - else - tmp = key; - - // start out by storing key in pads - memset ( k_ipad, 0, sizeof(k_ipad) ); - memset ( k_opad, 0, sizeof(k_opad) ); - memcpy ( k_ipad, tmp.c_str(), tmp.length() ); - memcpy ( k_opad, tmp.c_str(), tmp.length() ); - - // XOR key with ipad and opad values - for ( i=0; i<64; i++ ) - { - k_ipad[i] ^= 0x36; - k_opad[i] ^= 0x5c; - } - - // "inner" MD5 - md5.Init(); - md5.Update(k_ipad); - md5.Update(text); - md5.Final ( digest ); - - // "outer" MD5 - md5.Init(); - md5.Update(k_opad); - md5.Update(string(digest,16)); - return md5.Final(out_bin); -} -#endif//__cplusplus diff --git a/irc/ArchBlackmann/MD5.h b/irc/ArchBlackmann/MD5.h deleted file mode 100644 index f4bd3c19d9a..00000000000 --- a/irc/ArchBlackmann/MD5.h +++ /dev/null @@ -1,95 +0,0 @@ -// MD5.H - header file for MD5.CPP - -/* -Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All -rights reserved. - -License to copy and use this software is granted provided that it -is identified as the "RSA Data Security, Inc. MD5 Message-Digest -Algorithm" in all material mentioning or referencing this software -or this function. - -License is also granted to make and use derivative works provided -that such works are identified as "derived from the RSA Data -Security, Inc. MD5 Message-Digest Algorithm" in all material -mentioning or referencing the derived work. - -RSA Data Security, Inc. makes no representations concerning either -the merchantability of this software or the suitability of this -software for any particular purpose. It is provided "as is" -without express or implied warranty of any kind. - -These notices must be retained in any copies of any part of this -documentation and/or software. -*/ - -#ifndef __MD5_H -#define __MD5_H - -#ifdef __cplusplus -#include -#endif//__cplusplus - -#ifndef uchar -#define uchar unsigned char -#endif//uchar - -#ifndef ushort -#define ushort unsigned short -#endif//ushort - -#ifndef ulong -#define ulong unsigned long -#endif//ulong - -#ifdef __cplusplus -extern "C" { -#endif//__cplusplus - -typedef uchar *POINTER; // POINTER defines a generic pointer type -typedef ushort UINT2; // UINT2 defines a two byte word -typedef ulong UINT4; // UINT4 defines a four byte word - -// MD5 context. -typedef struct -{ - UINT4 state[4]; // state (ABCD) - UINT4 count[2]; // number of bits, modulo 2^64 (lsb first) - unsigned char buffer[64]; // input buffer -} MD5_CTX; - -void MD5Init ( MD5_CTX * ); -void MD5Update ( MD5_CTX *, const char *, unsigned int ); -void MD5Final ( uchar [16], MD5_CTX * ); - -void digest2ascii ( char *ascii, const uchar *digest ); -void ascii2digest ( uchar *digest, const char *ascii ); - -#ifdef __cplusplus - -} // extern "C" - -class MD5 -{ -public: - MD5(); - void Init(); - void Update ( const std::string& s ); - std::string Final ( char* digest = 0 ); - -private: - MD5_CTX _ctx; -}; - -std::string MD5Hex ( const std::string& s ); - -std::string MD5Bin ( const std::string& s ); - -std::string HMAC_MD5 ( - const std::string& key, - const std::string& text, - char* out_bin = NULL ); - -#endif//__cplusplus - -#endif//__MD5_H diff --git a/irc/ArchBlackmann/QueueT.h b/irc/ArchBlackmann/QueueT.h deleted file mode 100644 index 3d15bcbf741..00000000000 --- a/irc/ArchBlackmann/QueueT.h +++ /dev/null @@ -1,315 +0,0 @@ -/* -** Author: Samuel R. Blackburn -** Internet: wfc@pobox.com -** -** You can use it any way you like as long as you don't try to sell it. -** -** Any attempt to sell WFC in source code form must have the permission -** of the original author. You can produce commercial executables with -** WFC but you can't sell WFC. -** -** Copyright, 2000, Samuel R. Blackburn -** -** NOTE: I modified the info block below so it hopefully wouldn't conflict -** with the original file. Royce Mitchell III -*/ - -#ifndef QUEUET_CLASS_HEADER -#define QUEUET_CLASS_HEADER - -#include "ReliMT.h" - -#ifdef WIN32 -#include // off_t -#define HEAPCREATE(size) m_Heap = ::HeapCreate ( HEAP_NO_SERIALIZE, size, 0 ) -#define HEAPALLOC(size) ::HeapAlloc ( m_Heap, HEAP_NO_SERIALIZE, size ) -#define HEAPREALLOC(p,size) ::HeapReAlloc( m_Heap, HEAP_NO_SERIALIZE, p, size ) -#define HEAPFREE(p) ::HeapFree ( m_Heap, HEAP_NO_SERIALIZE, p ) -#define HEAPDESTROY() ::HeapDestroy ( m_Heap ); m_Heap = 0; -#else -#define HEAPCREATE(size) -#define HEAPALLOC(size) malloc(size) -#define HEAPREALLOC(p,size) realloc(p,size); -#define HEAPFREE(p) free(p) -#define HEAPDESTROY() -#endif - -template -class CQueueT : public Uncopyable -{ -protected: - - // What we want to protect - - Mutex m_AddMutex; - Mutex m_GetMutex; - - T* m_Items; - - off_t m_AddIndex; - off_t m_GetIndex; - size_t m_Size; - -#ifdef WIN32 - HANDLE m_Heap; -#endif//WIN32 - inline void m_GrowBy ( size_t number_of_new_items ); - -public: - - inline CQueueT ( size_t initial_size = 1024 ); - inline ~CQueueT(); - - inline bool Add( const T& new_item ); - inline void Empty() { m_AddIndex = 0; m_GetIndex = 0; }; - inline bool Get( T& item ); - inline size_t GetLength() const; - inline size_t GetMaximumLength() const { return( m_Size ); }; - inline bool AddArray ( const T* new_items, int item_count ); - inline int GetArray ( T* items, const int maxget, const T& tEnd ); - inline bool Contains ( const T& t ); -}; - -template -inline CQueueT::CQueueT ( size_t initial_size ) -{ - m_AddIndex = 0; - m_GetIndex = 0; - m_Items = NULL; - - if ( initial_size == 0 ) - initial_size = 1; - - /* - ** 1999-11-05 - ** We create our own heap because all of the pointers used are allocated - ** and freed be us. We don't have to worry about a non-serialized thread - ** accessing something we allocated. Because of this, we can perform our - ** memory allocations in a heap dedicated to queueing. This means when we - ** have to allocate more memory, we don't have to wait for all other threads - ** to pause while we allocate from the shared heap (like the C Runtime heap) - */ - - HEAPCREATE( ( ( ( 2 * initial_size * sizeof(T) ) < 65536 ) ? 65536 : (2 * initial_size * sizeof(T) ) ) ); - - m_Items = (T*)HEAPALLOC ( initial_size * sizeof(T) ); - - m_Size = ( m_Items == NULL ) ? 0 : initial_size; -} - -template -inline CQueueT::~CQueueT() -{ - m_AddIndex = 0; - m_GetIndex = 0; - m_Size = 0; - - if ( m_Items != NULL ) - { - HEAPFREE(m_Items); - m_Items = NULL; - } - - HEAPDESTROY(); -} - -template -inline bool CQueueT::Add ( const T& item ) -{ - // Block other threads from entering Add(); - Mutex::Lock addlock ( m_AddMutex ); - - // Add the item - - m_Items[ m_AddIndex ] = item; - - // 1999-12-08 - // Many many thanks go to Lou Franco (lfranco@spheresoft.com) - // for finding an bug here. It rare but recreatable situations, - // m_AddIndex could be in an invalid state. - - // Make sure m_AddIndex is never invalid - - off_t new_add_index = ( ( m_AddIndex + 1 ) >= (off_t)m_Size ) ? 0 : m_AddIndex + 1; - - if ( new_add_index == m_GetIndex ) - { - // The queue is full. We need to grow. - // Stop anyone from getting from the queue - Mutex::Lock getlock ( m_GetMutex ); - - m_AddIndex = new_add_index; - - // One last double-check. - - if ( m_AddIndex == m_GetIndex ) - { - m_GrowBy ( m_Size ); - } - - } - else - { - m_AddIndex = new_add_index; - } - - return true; -} - -template -inline bool CQueueT::Get( T& item ) -{ - // Prevent other threads from entering Get() - Mutex::Lock getlock ( m_GetMutex ); - - if ( m_GetIndex == m_AddIndex ) - { - // Let's check to see if our queue has grown too big - // If it has, then shrink it - - if ( m_Size > 1024 ) - { - // Yup, we're too big for our britches - Mutex::TryLock addlock ( m_AddMutex ); - if ( addlock ) - { - // Now, no one can add to the queue - - if ( m_GetIndex == m_AddIndex ) // is queue empty? - { - // See if we can just shrink it... - T* return_value = (T*)HEAPREALLOC(m_Items,1024 * sizeof(T)); - - if ( return_value != NULL ) - { - m_Items = (T*) return_value; - } - else - { - // Looks like we'll have to do it the hard way - HEAPFREE ( m_Items ); - m_Items = (T*) HEAPALLOC ( 1024 * sizeof(T) ); - } - - m_Size = ( m_Items == NULL ) ? 0 : 1024; - m_AddIndex = 0; - m_GetIndex = 0; - } - else - { - // m_GetIndex != m_AddIndex, this means that someone added - // to the queue between the time we checked m_Size for being - // too big and the time we entered the add critical section. - // If this happened then we are too busy to shrink - } - } - } - return false; - } - - item = m_Items[ m_GetIndex ]; - - // Make sure m_GetIndex is never invalid - - m_GetIndex = ( ( m_GetIndex + 1 ) >= (off_t)m_Size ) ? 0 : m_GetIndex + 1; - - return true; -} - -template -inline int CQueueT::GetArray ( T* items, const int maxget, const T& tEnd ) -{ - // TODO - oooh baby does this need to be optimized - // Prevent other threads from entering Get() - Mutex::Lock getlock ( m_GetMutex ); //::EnterCriticalSection( &m_GetCriticalSection ); - - int iResult = 0; - for ( int i = 0; i < maxget; i++ ) - { - if ( !Get(items[i]) ) - break; - iResult++; - if ( items[i] == tEnd ) - break; - } - // Let other threads call Get() now - //::LeaveCriticalSection( &m_GetCriticalSection ); - return iResult; -} - -template -inline size_t CQueueT::GetLength() const -{ - // This is a very expensive process! - // No one can call Add() or Get() while we're computing this - - size_t number_of_items_in_the_queue = 0; - - Mutex::Lock addlock ( m_AddMutex ); - Mutex::Lock getlock ( m_GetMutex ); - - number_of_items_in_the_queue = ( m_AddIndex >= m_GetIndex ) ? - ( m_AddIndex - m_GetIndex ) : - ( ( m_AddIndex + m_Size ) - m_GetIndex ); - - return number_of_items_in_the_queue; -} - -template -inline void CQueueT::m_GrowBy ( size_t number_of_new_items ) -{ - // Prevent other threads from calling Get(). - // We don't need to enter the AddCriticalSection because - // m_GrowBy() is only called from Add(); - - T* new_array = NULL; - T* pointer_to_free = NULL; - - size_t new_size = m_Size + number_of_new_items; - - { // Prevent other threads from getting - Mutex::Lock getlock ( m_GetMutex ); - - // 2000-05-16 - // Thanks go to Royce Mitchell III (royce3@aim-controls.com) for finding - // a HUGE bug here. I was using HeapReAlloc as a short cut but my logic - // was flawed. In certain circumstances, queue items were being dropped. - - new_array = (T*)HEAPALLOC ( new_size * sizeof(T) ); - - // Now copy all of the old items from the old queue to the new one. - - // Get the entries from the get-index to the end of the array - memcpy ( new_array, &m_Items[m_GetIndex], ( m_Size - m_GetIndex ) * sizeof(T) ); - - // Get the entries from the beginning of the array to the add-index - memcpy ( &new_array[m_Size-m_GetIndex], m_Items, m_AddIndex * sizeof(T) ); - - m_AddIndex = (off_t)m_Size; - m_GetIndex = 0; - m_Size = new_size; - pointer_to_free = m_Items; - m_Items = new_array; - } // Mutex::Lock - HEAPFREE ( pointer_to_free ); -} - -template -inline bool CQueueT::Contains ( const T& t ) -{ - Mutex::Lock addlock ( m_AddMutex ); - Mutex::Lock getlock ( m_GetMutex ); - - for ( int i = m_GetIndex; i != m_AddIndex; i++ ) - { - if ( i == m_Size ) - i = 0; - if ( m_Items[i] == t ) - return true; - } - return m_Items[m_AddIndex] == t; -} - -typedef CQueueT CCharQueue; - -#endif // QUEUE_CLASS_HEADER diff --git a/irc/ArchBlackmann/Reli.h b/irc/ArchBlackmann/Reli.h deleted file mode 100644 index ebc35d3a4a8..00000000000 --- a/irc/ArchBlackmann/Reli.h +++ /dev/null @@ -1,143 +0,0 @@ -// Reli.h -// lots of code here is (c) Bartosz Milewski, 1996, www.relisoft.com -// The rest is (C) 2002-2004 Royce Mitchell III -// and released under the LGPL & BSD licenses - -#ifndef __RELI_H -#define __RELI_H - -//////////////////////////////////////////////////////////////////////////////// -// Assert - -#undef Assert -#ifdef NDEBUG - #define Assert(exp) ((void)0) -#else - void _wassert (char* szExpr, char* szFile, int line); - #define Assert(exp) (void)( (exp) || (_wassert(#exp, __FILE__, __LINE__), 0) ) -#endif /* NDEBUG */ - -//////////////////////////////////////////////////////////////////////////////// -// Swap - -template -void Swap(T a,T b) -{ - T t = a; - a = b; - b = t; -} - -//////////////////////////////////////////////////////////////////////////////// -// Uncopyable - base class disabling copy ctors -class Uncopyable -{ -public: - Uncopyable(){} // need a default ctor -private: - Uncopyable ( const Uncopyable& ); - const Uncopyable& operator = ( const Uncopyable& ); -}; - -//////////////////////////////////////////////////////////////////////////////// -// SPtr - Smart Pointer's must be passed by reference or const reference - -template -class SPtr : public Uncopyable -{ -public: - virtual ~SPtr () { Destroy(); } - T * operator->() { return _p; } - T const * operator->() const { return _p; } - operator T&() { Assert(_p); return *_p; } - operator const T&() const { Assert(_p); return *_p; } - void Acquire ( SPtr& t ) { Destroy(); Swap(_p,t._p); } - void Destroy() { if ( _p ) { delete _p; _p = 0; } } -protected: - SPtr (): _p (0) {} - explicit SPtr (T* p): _p (p) {} - T * _p; -private: - operator T* () { return _p; } -}; - -#define DECLARE_SPTR(cls,init,init2) \ -class S##cls : public SPtr \ -{ \ -public: \ - S##cls ( cls* p ) : SPtr(p) {} \ - explicit S##cls init : SPtr (new cls init2) {} \ -}; -/* Example Usage of DECLARE_SPTR: -class MyClass -{ -public: // can be protected - MyClass ( int i ) - { - ... - } - ... -}; DECLARE_SPTR(MyClass,(int i),(i)) -SMyClass ptr(i); -*/ -#define DECLARE_SPTRV(cls) typedef SPtr S##cls; -/* Example Usage of DECLARE_SPTRV: -class MyAbstractClass -{ -public: // can be protected - MyAbstractClass ( int i ) - { - ... - } - void MyPureVirtFunc() = 0; - ... -}; DECLARE_SPTRV(MyAbstractClass) -SMyAbstractClass ptr ( new MySubClass(i) ); -*/ - -#define DECLARE_PTR(cls,init,init2) \ - class Ptr : public SPtr \ - { \ - Ptr(cls* p) : SPtr ( p ) \ - { \ - } \ - Ptr init : SPtr ( new cls init2 ) {} \ - }; -/* Example Usage of DECLARE_PTR: -class MyClass -{ - DECLARE_PTR(MyClass,(int i),(i)) -public: // can be protected - MyClass ( int i ) - { - ... - } - void MyPureVirtFunc() = 0; - ... -}; -MyClass::Ptr ptr ( i ); -*/ - -#define DECLARE_PTRV(cls) \ - class Ptr : public SPtr \ - { \ - Ptr(cls* p) : SPtr ( p ) \ - { \ - } \ - }; -/* Example Usage of DECLARE_PTRV: -class MyAbstractClass -{ - DECLARE_PTRV(MyAbstractClass) -public: // can be protected - MyAbstractClass ( int i ) - { - ... - } - void MyPureVirtFunc() = 0; - ... -}; -MyAbstractClass::Ptr ptr ( new MySubClass(i) ); -*/ - -#endif//__RELI_H diff --git a/irc/ArchBlackmann/ReliMT.cpp b/irc/ArchBlackmann/ReliMT.cpp deleted file mode 100644 index 2c50dc40f1c..00000000000 --- a/irc/ArchBlackmann/ReliMT.cpp +++ /dev/null @@ -1,331 +0,0 @@ -// ReliMT.cpp -// lots of code here is (c) Bartosz Milewski, 1996, www.relisoft.com -// The rest is (C) 2002-2004 Royce Mitchell III -// and released under the LGPL & BSD licenses - -#include -#include -#ifdef WIN32 -# define WIN32_LEAN_AND_MEAN -# include -# define snprintf _snprintf -#elif defined(UNIX) -# include -# include -#else -# error unrecognized target -#endif//WIN32|UNIX -#include "verify.h" -#include "ReliMT.h" - -//////////////////////////////////////////////////////////////////////////////// -// Assert - -void _wassert ( char* szExpr, char* szFile, int line ) -{ - fprintf ( stderr, "Assertion Failure: \"%s\" in file %s, line %d", szExpr, szFile, line ); - exit (-1); -} - - -//////////////////////////////////////////////////////////////////////////////// -// Thread - -Thread::Thread ( long (THREADAPI * pFun) (void* arg), void* pArg ) -{ -#ifdef WIN32 - verify ( _handle = CreateThread ( - 0, // Security attributes - 0, // Stack size - (DWORD (WINAPI*)(void*))pFun, - pArg, - 0, // don't create suspended. - &_tid )); -#elif defined(UNIX) - // set up the thread attribute: right now, we do nothing with it. - pthread_attr_t attr; - pthread_attr_init(&attr); - - // this will make the threads created by this process really concurrent - verify ( !pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM) ); - - // create the new OS thread object - verify ( !pthread_create ( &_threadId, &attr, (void* (*) (void*))pFun, pArg ) ); - - verify ( !pthread_attr_destroy(&attr) ); -#else -# error unrecognized target -#endif//WIN32|UNIX -} - -Thread::~Thread() -{ -#ifdef WIN32 - verify ( CloseHandle ( _handle ) ); -#elif defined(UNIX) - verify ( !pthread_cancel ( _threadId ) ); -#else -# error unrecognized target -#endif//WIN32|UNIX -} - -/*void Thread::Resume() -{ -#ifdef WIN32 - ResumeThread (_handle); -#elif defined(UNIX) -# error how to resume thread in unix? -#else -# error unrecognized target -#endif//WIN32|UNIX -}*/ - -void Thread::WaitForDeath() -{ -#ifdef WIN32 - DWORD dw = WaitForSingleObject ( _handle, 2000 ); - ASSERT ( dw != WAIT_FAILED ); -#elif defined(UNIX) - verify ( !pthread_join ( _threadId, (void**)NULL ) ); -#else -# error unrecognized target -#endif//WIN32|UNIX -} - - -//////////////////////////////////////////////////////////////////////////////// -// ActiveObject - -// The constructor of the derived class -// should call -// _thread.Resume(); -// at the end of construction - -ActiveObject::ActiveObject() : _isDying (0), _thread (0) -{ -} - -ActiveObject::~ActiveObject() -{ - ASSERT ( !_thread ); // call Kill() from subclass's dtor - // Kill() - // You can't call a virtual function from a dtor, EVEN INDIRECTLY - // so, you must call Kill() in the subclass's dtor -} - -// FlushThread must reset all the events on which the thread might be waiting. -void ActiveObject::Kill() -{ - if ( _thread ) - { - _isDying++; - FlushThread(); - // Let's make sure it's gone - _thread->WaitForDeath(); - delete _thread; - _thread = 0; - } -} - -void ActiveObject::Start() -{ - ASSERT ( !_thread ); - _thread = new Thread ( ThreadEntry, this ); -} - -long THREADAPI ActiveObject::ThreadEntry ( void* pArg ) -{ - ActiveObject * pActive = (ActiveObject*)pArg; - pActive->InitThread(); - pActive->Run(); - pActive->Kill(); - return 0; -} - - -/////////////////////////////////////////////////////////////////////////////// -// Mutex - -Mutex::Mutex() -{ -#ifdef WIN32 - verify ( _h = CreateMutex ( NULL, FALSE, NULL ) ); -#elif defined(UNIX) - pthread_mutexattr_t attrib; - verify ( !pthread_mutexattr_init( &attrib ) ); - // allow recursive locks - verify ( !pthread_mutexattr_settype( &attrib, PTHREAD_MUTEX_RECURSIVE ) ); - verify ( !pthread_mutex_init ( &_mutex, &attrib ) ); -#else -# error unrecognized target -#endif -} - -Mutex::~Mutex() -{ -#ifdef WIN32 - verify ( CloseHandle ( _h ) ); -#elif defined(UNIX) - verify ( !pthread_mutex_destroy(&_mutex) ); -#else -# error unrecognized target -#endif -} - -void Mutex::Acquire() -{ -#ifdef WIN32 - DWORD dw = WaitForSingleObject ( _h, INFINITE ); - ASSERT ( dw == WAIT_OBJECT_0 || dw == WAIT_ABANDONED ); -#elif defined(UNIX) - verify ( !pthread_mutex_lock(&_mutex) ); -#else -# error unrecognized target -#endif -} - -bool Mutex::TryAcquire() -{ -#ifdef WIN32 - DWORD dw = WaitForSingleObject ( _h, 1 ); - ASSERT ( dw == WAIT_OBJECT_0 || dw == WAIT_TIMEOUT || dw == WAIT_ABANDONED ); - return (dw != WAIT_TIMEOUT); -#elif defined(UNIX) - int err = pthread_mutex_trylock(&_mutex); - ASSERT ( err == EBUSY || err == 0 ); - return (err == 0); -#else -# error unrecognized target -#endif -} - -void Mutex::Release() -{ -#ifdef WIN32 - verify ( ReleaseMutex ( _h ) ); -#elif defined(UNIX) - verify ( !pthread_mutex_unlock(&_mutex) ); - // we could allow EPERM return value too, but we are forcing user into RIIA -#else -# error unrecognized target -#endif -} - -Mutex::Lock::Lock ( Mutex& m ) : _m(m) -{ - _m.Acquire(); -} - -Mutex::Lock::~Lock() -{ - _m.Release(); -} - -Mutex::TryLock::TryLock ( Mutex& m ) : _m(m) -{ - _bLocked = _m.TryAcquire(); -} - -Mutex::TryLock::~TryLock() -{ - if ( _bLocked ) - _m.Release(); -} - -/////////////////////////////////////////////////////////////////////////////// -// Event - -Event::Event() -{ -#ifdef WIN32 - // start in non-signaled state (red light) - // auto reset after every Wait - verify ( _handle = CreateEvent ( 0, FALSE, FALSE, 0 ) ); -#elif defined(UNIX) - //verify ( !pthread_cond_init ( &_cond, NULL /* default attributes */) ); - sem_init(); - //verify(sem_init()); -#else -# error unrecognized target -#endif -} - -Event::~Event() -{ -#ifdef WIN32 - verify ( CloseHandle ( _handle ) ); -#elif defined(UNIX) - //verify ( !pthread_cond_destroy ( &_cond ) ); - sem_destroy(); -#else -# error unrecognized target -#endif -} - -void Event::Release() // put into signaled state -{ -#ifdef WIN32 - verify ( SetEvent ( _handle ) ); -#elif defined(UNIX) - //verify ( !pthread_cond_signal ( &_cond ) ); - verify(!sem_V()); -#else -# error unrecognized target -#endif -} - -void Event::Wait() -{ -#ifdef WIN32 - // Wait until event is in signaled (green) state - DWORD dw = WaitForSingleObject ( _handle, INFINITE ); - ASSERT ( dw == WAIT_OBJECT_0 || dw == WAIT_ABANDONED ); -#elif defined(UNIX) - // According to docs: The pthread_cond_wait() and pthread_cond_timedwait() - // functions are used to block on a condition variable. They are called - // with mutex locked by the calling thread or undefined behaviour will - // result. - //Mutex::Lock lock ( _mutex ); - //verify ( !pthread_cond_wait ( &_cond, _mutex ) ); - verify(!sem_P()); -#else -# error unrecognized target -#endif -} - -#ifdef UNIX -void Event::sem_init() -{ - sem_id = semget(IPC_PRIVATE, 1, 0666 | IPC_CREAT); - ASSERT(sem_id != -1); -} - -int Event::sem_P() -{ - struct sembuf sb; - sb.sem_num = 0; - sb.sem_op = -1; - sb.sem_flg = 0; - return semop(sem_id, &sb, 1); -} - -int Event::sem_V() -{ - struct sembuf sb; - sb.sem_num = 0; - sb.sem_op = 1; - sb.sem_flg = 0; - return semop(sem_id, &sb, 1); -} - -void Event::sem_destroy() -{ -#ifdef MACOSX - semun mactmp; - mactmp.val = 0; - semctl(sem_id, 0, IPC_RMID, mactmp); -#else - semctl(sem_id, 0, IPC_RMID, 0); -#endif -} -#endif - diff --git a/irc/ArchBlackmann/ReliMT.h b/irc/ArchBlackmann/ReliMT.h deleted file mode 100644 index 17fb12169a6..00000000000 --- a/irc/ArchBlackmann/ReliMT.h +++ /dev/null @@ -1,229 +0,0 @@ -// ReliMT.h -// lots of code here is (c) Bartosz Milewski, 1996, www.relisoft.com -// The rest is (C) 2003-2004 Royce Mitchell III -// and released under the LGPL & BSD licenses - - -#ifndef __RELIMT_H -#define __RELIMT_H - -#include "Reli.h" - -#ifdef WIN32 -# ifndef _WINDOWS_ -# define WIN32_LEAN_AND_MEAN -# include -# endif -# define THREADAPI WINAPI -#elif defined(UNIX) -# include -# include -# include "string.h" -# include //Semaphore -# include //Semaphore -# include //Semaphore -# define THREADAPI -#else -# error unrecognized target -#endif - - -//////////////////////////////////////////////////////////////////////////////// -// Thread - -class Thread : public Uncopyable -{ -public: - Thread ( long (THREADAPI * pFun) (void* arg), void* pArg ); - ~Thread(); - //void Resume(); - void WaitForDeath(); - - // platform-specific stuff: -private: -#ifdef WIN32 - HANDLE _handle; - DWORD _tid; // thread id -#elif defined(UNIX) - pthread_t _threadId; // id of the thread -#else -# error unrecognized target -#endif - //DECLARE_PTR(Thread,(long (THREADAPI * pFun) (void* arg), void* pArg),(pFun,pArg)); -}; //DECLARE_SPTR(Thread,(long (THREADAPI * pFun) (void* arg), void* pArg),(pFun,pArg)); - -//////////////////////////////////////////////////////////////////////////////// -// ActiveObject - -class ActiveObject : public Uncopyable -{ -public: - ActiveObject(); - virtual ~ActiveObject(); - void Kill(); - void Start(); - -protected: - virtual void InitThread() = 0; - virtual void Run() = 0; - virtual void FlushThread() = 0; - - int _isDying; - - static long THREADAPI ThreadEntry ( void *pArg ); - Thread *_thread; - - //DECLARE_PTRV(ActiveObject); -}; //DECLARE_SPTRV(ActiveObject); - -// Last thing in the constructor of a class derived from -// ActiveObject you must call -// Start(); -// Inside the loop the Run method you must keep checking _isDying -// if (_isDying) -// return; -// FlushThread must reset all the events on which the thread might be waiting. -// Example: -#if 0 -// MyAsyncOutputter - class that outputs strings to a file asynchronously -class MyAsyncOutputter : public ActiveObject -{ -public: - MyAsyncOutputter ( const string& filename ) : _filename(filename), _currentBuf(0) - { - Start(); // start thread - } - void InitThread() - { - _f.open ( _filename, "wb" ); - } - void Output ( const string& s ) - { - { - // acquire lock long enough to add the string to the active buffer - Mutex::Lock lock ( _mutex ); - _buf[_currentBuf].push_back ( s ); - } - _event.Release(); // don't need the lock fire the event - } - void Run() - { - while ( !_isDying ) - { - // wait for signal from Output() or FlushThread() - _event.Wait(); - { - // acquire lock long enough to switch active buffers - Mutex::Lock lock ( _mutex ); - _currentBuf = 1-_currentBuf; - ASSERT ( !_buf[_currentBuf].size() ); - } - // get a reference to the old buffer - vector& buf = _buf[1-_currentBuf]; - // write each string out to file and then empty the buffer - for ( int i = 0; i < buf.size(); i++ ) - _f.write ( buf[i].c_str(), buf[i].size() ); - buf.resize(0); - } - } - void FlushThread() - { - // _isDying is already set: signal thread so it can see that too - _event.Release(); - } -private: - string _filename; - File _f; - int _currentBuf; - vector _buf[2]; - Event _event; - Mutex _mutex; -}; -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Mutex - -class Mutex : public Uncopyable -{ -public: - Mutex(); - ~Mutex(); -private: - void Acquire(); - bool TryAcquire(); - void Release(); -public: - // sub-class used to lock the Mutex - class Lock : public Uncopyable - { - public: - Lock ( Mutex& m ); - ~Lock(); - - private: - // private data - Mutex& _m; - }; - friend class Mutex::Lock; - - - // sub-class used to attempt to lock the mutex. Use operator bool() - // to test if the lock was successful - class TryLock : public Uncopyable - { - public: - TryLock ( Mutex& m ); - ~TryLock(); - operator bool () { return _bLocked; } - - private: - // private data - bool _bLocked; - Mutex& _m; - }; - friend class Mutex::TryLock; - -private: - // platform-specific stuff: -#ifdef WIN32 - HANDLE _h; -#elif defined(UNIX) - pthread_mutex_t _mutex; -public: operator pthread_mutex_t* () { return &_mutex; } -#else -# error unrecognized target -#endif -}; - -//////////////////////////////////////////////////////////////////////////////// -// Event - -class Event : public Uncopyable -{ -public: - Event(); - ~Event(); - void Release(); // put into signaled state - void Wait(); - -private: -#ifdef WIN32 - HANDLE _handle; -#elif defined(UNIX) - //Sem util functions - void sem_init(); - int sem_P(); - int sem_V(); - void sem_destroy(); - - int sem_id; - //pthread_cond_t _cond; - //Mutex _mutex; -#else -# error unrecognized target -#endif - //DECLARE_PTR(Event,(),()); -}; //DECLARE_SPTR(Event,(),()); - -#endif//__RELIWIN32_H diff --git a/irc/ArchBlackmann/SockUtils.cpp b/irc/ArchBlackmann/SockUtils.cpp deleted file mode 100644 index 3398b8d88c1..00000000000 --- a/irc/ArchBlackmann/SockUtils.cpp +++ /dev/null @@ -1,504 +0,0 @@ -// SockUtils.cpp - Some basic socket utility functions. -// (C) 2002-2004 Royce Mitchell III -// This file is under the BSD & LGPL licenses - -#include -#include "SockUtils.h" -#ifdef WIN32 -# ifndef SD_SEND // defined in winsock2.h, but not winsock.h -# define SD_SEND 1 -# endif -# define snprintf _snprintf -# ifdef _MSC_VER -# pragma comment ( lib, "ws2_32.lib" ) -# endif//_MSC_VER -#elif defined(UNIX) -# include -# include "string.h" // memset -# include // hostent -# include //inet_addr -# include -# define SD_SEND SHUT_WR //bah thou shalt name thy defines the same -#else -# error unrecognized target -#endif -//// Constants ///////////////////////////////////////////////////////// -const int kBufferSize = 1024; -// creates broadcast address -SockAddrIn::SockAddrIn() -{ - memset ( this, 0, sizeof(sockaddr_in) ); - sin_family = AF_INET; -} -SockAddrIn::SockAddrIn ( const char* szAddr, u_short iPort ) -{ - memset ( this, 0, sizeof(sockaddr_in) ); - sin_family = AF_INET; - sin_addr.s_addr = suLookupAddress(szAddr); - sin_port = htons(iPort); -} -SockAddrIn::SockAddrIn ( in_addr_t iAddr, u_short iPort ) -{ - memset ( this, 0, sizeof(sockaddr_in) ); - sin_family = AF_INET; - sin_addr.s_addr = iAddr; - sin_port = htons(iPort); -} -bool suStartup() -{ -#ifdef WIN32 - WSADATA wsaData; - if ( WSAStartup ( MAKEWORD(2,0), &wsaData ) ) - return false; - if ( wsaData.wVersion != MAKEWORD(2,0) ) - { - WSACleanup(); - return false; - } - return true; -#elif defined(UNIX) - // nothing special required here - return true; -#else -# error unrecognized target -#endif -} -//// suTcpSocket //////////////////////////////////////////////// -// Creates a TCP socket. -SOCKET suTcpSocket() -{ - SOCKET so = socket ( AF_INET, SOCK_STREAM, 0 ); -#if defined(_DEBUG) && defined(WIN32) - if ( so == INVALID_SOCKET && WSANOTINITIALISED == WSAGetLastError() ) - MessageBox ( NULL, "You forgot to call suStartup()!", "SockUtils", MB_OK|MB_ICONEXCLAMATION ); -#endif - return so; -} -//// suUdpSocket //////////////////////////////////////////////// -// Creates a UDP socket. Compensates for new "functionality" introduced -// in Win2K with regards to select() calls -// MS Transport Provider IOCTL to control -// reporting PORT_UNREACHABLE messages -// on UDP sockets via recv/WSARecv/etc. -// Path TRUE in input buffer to enable (default if supported), -// FALSE to disable. -#ifndef SIO_UDP_CONNRESET -#define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR,12) -#endif//SIO_UDP_CONNRESET -SOCKET suUdpSocket() -{ - SOCKET so = socket ( AF_INET, SOCK_DGRAM, 0 ); -#if defined(_DEBUG) && defined(WIN32) - if ( so == INVALID_SOCKET && WSANOTINITIALISED == WSAGetLastError() ) - MessageBox ( NULL, "You forgot to call suStartup()!", "SockUtils", MB_OK|MB_ICONEXCLAMATION ); -#endif -#ifdef WIN32 - // for Windows 2000, disable new behavior... - // see: http://www-pc.uni-regensburg.de/systemsw/W2KPRO/UPDATE/POSTSP1/Q263823.htm - // this code is innocuous on other win32 platforms - DWORD dwBytesReturned = 0; - BOOL bNewBehavior = FALSE; - // disable new Win2K behavior using - // IOCTL: SIO_UDP_CONNRESET - // we don't care about return value :) - WSAIoctl(so, SIO_UDP_CONNRESET, - &bNewBehavior, sizeof(bNewBehavior), - NULL, 0, &dwBytesReturned, - NULL, NULL); -#endif - return so; -} -//// suShutdownConnection //////////////////////////////////////////////// -// Gracefully shuts the connection sd down. Returns true if it was able -// to shut it down nicely, false if we had to "slam" it shut. -// (either way, the socket does get closed) -bool suShutdownConnection(SOCKET sd) -{ - if ( sd == INVALID_SOCKET ) - return true; - // Disallow any further data sends. This will tell the other side - // that we want to go away now. If we skip this step, we don't - // shut the connection down nicely. - if (shutdown(sd, SD_SEND) == SOCKET_ERROR) - { - closesocket(sd); - return false; - } - // Receive any extra data still sitting on the socket. After all - // data is received, this call will block until the remote host - // acknowledges the TCP control packet sent by the shutdown above. - // Then we'll get a 0 back from recv, signalling that the remote - // host has closed its side of the connection. - char acReadBuffer[kBufferSize]; - for ( ;; ) - { - int nNewBytes = recv(sd, acReadBuffer, kBufferSize, 0); - if (nNewBytes == SOCKET_ERROR) - { - closesocket(sd); - return false; - } - else if (nNewBytes != 0) - { - // FYI, received (nNewBytes) unexpected bytes during shutdown. - } - else - { - // Okay, we're done! - break; - } - } - // Close the socket. - if (closesocket(sd) == SOCKET_ERROR) - { - return false; - } - return true; -} -//// suLookupAddress //////////////////////////////////////////////// -// Basically converts a name address to an ip address -in_addr_t suLookupAddress ( const char* pcHost ) -{ - in_addr_t nRemoteAddr = inet_addr(pcHost); - if ( nRemoteAddr == INADDR_NONE ) - { - // pcHost isn't a dotted IP, so resolve it through DNS - hostent* pHE = gethostbyname(pcHost); - if ( pHE == 0 ) - { -#if defined(_DEBUG) && defined(WIN32) - if ( WSANOTINITIALISED == WSAGetLastError() ) - MessageBox ( NULL, "You forgot to call suStartup()!", "SockUtils", MB_OK|MB_ICONEXCLAMATION ); -#endif - return INADDR_NONE; - } - nRemoteAddr = *((in_addr_t*)pHE->h_addr_list[0]); - } - return nRemoteAddr; -} -bool suConnect ( SOCKET so, in_addr_t iAddress, u_short iPort ) -{ - SockAddrIn sinRemote ( iAddress, iPort ); - if ( SOCKET_ERROR == connect(so,sinRemote,sizeof(sinRemote)) ) - { -#if defined(_DEBUG) && defined(WIN32) - if ( WSANOTINITIALISED == WSAGetLastError() ) - MessageBox ( NULL, "You forgot to call suStartup()!", "SockUtils", MB_OK|MB_ICONEXCLAMATION ); -#endif - return false; - } - return true; -} -bool suConnect ( SOCKET so, const char* szAddress, u_short iPort ) -{ - return suConnect ( so, suLookupAddress(szAddress), iPort ); -} -//// suEstablishConnection //////////////////////////////////////////////// -// creates a socket of the specified type, connects to the ip address/port -// requested, and returns the SOCKET created -SOCKET suEstablishConnection ( in_addr_t iAddress, u_short iPort, int type ) -{ - // Create a socket - if ( type != SOCK_STREAM && type != SOCK_DGRAM ) - return INVALID_SOCKET; - SOCKET so = socket(AF_INET, type, 0); - if ( so == INVALID_SOCKET ) - return so; - if ( !suConnect(so, iAddress, iPort) ) - { - closesocket(so); - return INVALID_SOCKET; - } - return so; -} -//// suEstablishConnection //////////////////////////////////////////////// -// creates a socket of the specified type, connects to the address/port -// requested, and returns the SOCKET created -SOCKET suEstablishConnection ( const char* szAddress, u_short iPort, int type ) -{ - return suEstablishConnection ( suLookupAddress ( szAddress ), iPort, type ); -} -//// suBroadcast //////////////////////////////////////////////// -// takes a previously created broadcast-enabled UDP socket, and broadcasts -// a message on the local network -bool suBroadcast ( SOCKET so, u_short port, const char* buf, int len /* = -1 */ ) -{ - if ( len == -1 ) - len = (int)strlen(buf); -#if 1 - SockAddrIn to ( INADDR_BROADCAST, port ); -#else // some strange MS OS's don't broadcast to localhost... - SockAddrIn to ( "127.0.0.1", port ); - if ( SOCKET_ERROR == sendto ( so, buf, len, 0, to, sizeof(to) ) ) - return false; - to.sin_addr.s_addr = INADDR_BROADCAST; -#endif - if ( SOCKET_ERROR == sendto ( so, buf, len, 0, to, sizeof(to) ) ) - return false; - return true; -} -//// suRecv //////////////////////////////////////////////// -// retrieves data sent to our TCP socket. If no data, waits for -// a period of timeout ms. -// returns bytes received -// -1 == SOCKET_ERROR -// -2 == timed out waiting for data -int suRecv ( SOCKET so, char* buf, int buflen, int timeout ) -{ - struct timeval to; - fd_set rread; - int res; - FD_ZERO(&rread); // clear the fd_set - FD_SET(so,&rread); // indicate which socket(s) we want to check - memset((char *)&to,0,sizeof(to)); // clear the timeval struct - to.tv_sec = timeout; // timeout select after (timeout) seconds - // select returns > 0 if there is an event on the socket - res = select((int)so+1, &rread, (fd_set *)0, (fd_set *)0, &to ); - if (res < 0) - return -1; // socket error - // there was an event on the socket - if ( (res>0) && (FD_ISSET(so,&rread)) ) - return recv ( so, buf, buflen, 0 ); - return -2; -} -//// suRecvFrom //////////////////////////////////////////////// -// retrieves data sent to our UDP socket. If no data, waits for -// a period of timeout ms. -// returns bytes received -// returns bytes received -// -1 == SOCKET_ERROR -// -2 == timed out waiting for data -int suRecvFrom ( SOCKET so, char* buf, int buflen, int timeout, sockaddr_in* from, socklen_t* fromlen ) -{ - struct timeval to; - fd_set rread; - int res; - FD_ZERO(&rread); // clear the fd_set - FD_SET(so,&rread); // indicate which socket(s) we want to check - memset((char *)&to,0,sizeof(to)); // clear the timeval struct - to.tv_sec = timeout; // timeout select after (timeout) seconds - // select returns > 0 if there is an event on the socket - res = select((int)so+1, &rread, (fd_set *)0, (fd_set *)0, &to ); - if (res < 0) - return -1; // socket error - // there was an event on the socket - if ( (res>0) && (FD_ISSET(so,&rread)) ) - return recvfrom ( so, buf, buflen, 0, (sockaddr*)from, fromlen ); - return -2; // timeout -} -//// suBind //////////////////////////////////////////////// -// binds a UDP socket to an interface & port to receive -// data on that port -bool suBind ( SOCKET so, in_addr_t iInterfaceAddress, u_short iListenPort, bool bReuseAddr /* = false */ ) -{ - SockAddrIn sinInterface ( iInterfaceAddress, iListenPort ); - if ( bReuseAddr ) - { - int optval = -1; // true - if ( SOCKET_ERROR == setsockopt ( so, SOL_SOCKET, SO_REUSEADDR, (const char*)&optval, sizeof(optval) ) ) - { -#if defined(_DEBUG) && defined(WIN32) - if ( WSANOTINITIALISED == WSAGetLastError() ) - MessageBox ( NULL, "You forgot to call suStartup()!", "SockUtils", MB_OK|MB_ICONEXCLAMATION ); -#endif - return false; - } - } - if ( SOCKET_ERROR == bind(so, sinInterface, sizeof(sinInterface)) ) - { - int err = SUERRNO; - if ( err != EADDRINUSE ) - return false; -#if defined(_DEBUG) && defined(WIN32) - if ( WSANOTINITIALISED == WSAGetLastError() ) - MessageBox ( NULL, "You forgot to call suStartup()!", "SockUtils", MB_OK|MB_ICONEXCLAMATION ); -#endif - } - return true; -} -//// suBind //////////////////////////////////////////////// -// binds a UDP socket to an interface & port to receive -// data on that port -bool suBind ( SOCKET so, const char* szInterfaceAddress, u_short iListenPort, bool bReuseAddr /* = false */ ) -{ - in_addr_t iInterfaceAddr = inet_addr(szInterfaceAddress); - if ( iInterfaceAddr == INADDR_NONE ) - return false; - return suBind ( so, iInterfaceAddr, iListenPort, bReuseAddr ); -} -//// suEnableBroadcast //////////////////////////////////////////////// -// in order to send broadcast messages on a UDP socket, this function -// must be called first -bool suEnableBroadcast ( SOCKET so, bool bEnable /* = true */ ) -{ - int optval = bEnable ? -1 : 0; - if ( SOCKET_ERROR == setsockopt ( so, SOL_SOCKET, SO_BROADCAST, (const char*)&optval, sizeof(optval) ) ) - return false; - return true; -} -//// suErrDesc //////////////////////////////////////////////// -// returns text description of error code -const char* suErrDesc ( int err ) -{ - static char errbuf[256]; -#ifdef WIN32 - switch ( err ) - { -#define X(E) case E: return #E; - X(WSAEINTR) X(WSAEBADF) - X(WSAEACCES) X(WSAEFAULT) - X(WSAEINVAL) X(WSAEMFILE) - X(WSAEWOULDBLOCK) X(WSAEINPROGRESS) - X(WSAEALREADY) X(WSAENOTSOCK) - X(WSAEDESTADDRREQ) X(WSAEMSGSIZE) - X(WSAEPROTOTYPE) X(WSAENOPROTOOPT) - X(WSAEPROTONOSUPPORT) X(WSAESOCKTNOSUPPORT) - X(WSAEOPNOTSUPP) X(WSAEPFNOSUPPORT) - X(WSAEAFNOSUPPORT) X(WSAEADDRINUSE) - X(WSAEADDRNOTAVAIL) X(WSAENETDOWN) - X(WSAENETUNREACH) X(WSAENETRESET) - X(WSAECONNABORTED) X(WSAECONNRESET) - X(WSAENOBUFS) X(WSAEISCONN) - X(WSAENOTCONN) X(WSAESHUTDOWN) - X(WSAETOOMANYREFS) X(WSAETIMEDOUT) - X(WSAECONNREFUSED) X(WSAELOOP) - X(WSAENAMETOOLONG) X(WSAEHOSTDOWN) - X(WSAEHOSTUNREACH) X(WSAENOTEMPTY) - X(WSAEPROCLIM) X(WSAEUSERS) - X(WSAEDQUOT) X(WSAESTALE) - X(WSAEREMOTE) X(WSASYSNOTREADY) - X(WSAVERNOTSUPPORTED) X(WSANOTINITIALISED) - X(WSAEDISCON) X(WSAENOMORE) - X(WSAECANCELLED) X(WSAEINVALIDPROCTABLE) - X(WSAEINVALIDPROVIDER) X(WSAEPROVIDERFAILEDINIT) - X(WSASYSCALLFAILURE) X(WSASERVICE_NOT_FOUND) - X(WSATYPE_NOT_FOUND) X(WSA_E_NO_MORE) - X(WSA_E_CANCELLED) X(WSAEREFUSED) -#undef X - } - snprintf ( errbuf, sizeof(errbuf), "Unknown socket error (%lu)", err ); - errbuf[sizeof(errbuf)-1] = '\0'; - return errbuf; -#elif defined(UNIX) - perror(errbuf); - return errbuf; -#else -# error unrecognized target -#endif -} -#if defined(UNICODE) || defined(_UNICODE) -in_addr_t suLookupAddress ( const wchar_t* pcHost ) -{ - int len = wcslen(pcHost); - char* p = new char[len+1]; - wcstombs ( p, pcHost, len ); - p[len] = 0; - in_addr_t rc = suLookupAddress ( p ); - delete[] p; - return rc; -} -bool suBroadcast ( SOCKET so, u_short port, const wchar_t* buf, int len /* = -1 */ ) -{ - char* p = new char[len+1]; - wcstombs ( p, buf, len ); - p[len] = 0; - bool rc = suBroadcast ( so, port, p, len ); - delete[] p; - return rc; -} -int suRecv ( SOCKET so, wchar_t* buf, int buflen, int timeout ) -{ - char* p = new char[buflen+1]; - int rc = suRecv ( so, p, buflen, timeout ); - p[buflen] = 0; - mbstowcs ( buf, p, buflen ); - delete[] p; - return rc; -} -int suRecvFrom ( SOCKET so, wchar_t* buf, int buflen, int timeout, sockaddr_in* from, int* fromlen ) -{ - char* p = new char[buflen+1]; - int rc = suRecvFrom ( so, p, buflen, timeout, from, fromlen ); - p[buflen] = 0; - mbs2wcs ( buf, p, buflen ); - delete[] p; - return rc; -} -bool suBind ( SOCKET so, const wchar_t* szInterfaceAddress, u_short iListenPort, bool bReuseAddr /* = false */ ) -{ - int len = wcslen(szInterfaceAddress); - char* p = new char[len+1]; - wcstombs ( p, szInterfaceAddress, len ); - p[len] = 0; - bool rc = suBind ( so, p, iListenPort, bReuseAddr ); - delete[] p; - return rc; -} -#endif//UNICODE - -suBufferedRecvSocket::suBufferedRecvSocket ( SOCKET so ) - : suSocket ( so ), _off(0), _len(0) -{ -} - -int suBufferedRecvSocket::recvUntil ( std::string& buf, char until, int timeout ) -{ - if ( !_len ) - _off = 0; - else if ( _off > (sizeof(_buf)>>1) ) - { - memmove ( _buf, &_buf[_off], _len ); - _off = 0; - } - char* poff = &_buf[_off]; - for ( ;; ) - { - char* p = (char*)memchr ( poff, until, _len ); - if ( p /*&& p < &poff[_len]*/ ) - { - int ret_len = p-poff+1; - buf.resize ( ret_len ); - memmove ( &buf[0], poff, ret_len ); - _off += ret_len; - _len -= ret_len; - return ret_len; - } - int rc = suRecv ( *this, &poff[_len], sizeof(_buf)-_len-_off, timeout ); - if ( rc < 0 ) - { - if ( _len ) - { - rc = _len; - buf.resize ( rc ); - memmove ( &buf[0], &_buf[_off], rc ); - _len = 0; - } - return rc; - } - _len += rc; - } -} - -void suBufferedRecvSocket::recvPending() -{ - if ( !_len ) - _off = 0; - else if ( _off > (sizeof(_buf)>>1) ) - { - memmove ( _buf, &_buf[_off], _len ); - _off = 0; - } - char* poff = &_buf[_off]; - while ( sizeof(_buf)-_len-_off ) - { - int rc = suRecv ( *this, &poff[_len], sizeof(_buf)-_len-_off, 1 ); - if ( rc <= 0 ) - break; - _len += rc; - } -} - -bool suBufferedRecvSocket::recvInStr ( char c ) -{ - return NULL != memchr ( &_buf[_off], c, _len ); -} diff --git a/irc/ArchBlackmann/SockUtils.h b/irc/ArchBlackmann/SockUtils.h deleted file mode 100644 index 60853f05964..00000000000 --- a/irc/ArchBlackmann/SockUtils.h +++ /dev/null @@ -1,132 +0,0 @@ -// SockUtils.h - Declarations for the Winsock utility functions module. -// (C) 2002-2004 Royce Mitchell III -// This file is under the BSD & LGPL licenses - -#ifndef __SOCKUTILS_H -#define __SOCKUTILS_H - -#include -#ifdef WIN32 -# include -# define in_addr_t u_long -# define SUERRNO WSAGetLastError() -# define EADDRINUSE WSAEADDRINUSE -# define ENOTSOCK WSAENOTSOCK -# define socklen_t int -#elif defined(UNIX) -# include -# include -# include -# include -# include -# define closesocket(so) close(so) -# define SOCKET int -# define INVALID_SOCKET -1 -# define SOCKET_ERROR -1 -# define SUERRNO errno -# ifdef MACOSX -# define socklen_t int //Stupid mac -# endif -#else -# error unrecognized target -#endif - -#include - -extern bool suStartup(); -extern SOCKET suTcpSocket(); -extern SOCKET suUdpSocket(); -extern bool suShutdownConnection(SOCKET sd); -extern in_addr_t suLookupAddress ( const char* pcHost ); -extern bool suConnect ( SOCKET so, in_addr_t iAddress, u_short iPort ); -extern bool suConnect ( SOCKET so, const char* szAddress, u_short iPort ); -extern SOCKET suEstablishConnection ( in_addr_t iAddress, u_short iPort, int type ); -extern SOCKET suEstablishConnection ( const char* szAddress, u_short iPort, int type ); -extern bool suBroadcast ( SOCKET so, u_short port, const char* buf, int len = -1 ); -extern int suRecv ( SOCKET so, char* buf, int buflen, int timeout ); -extern int suRecvFrom ( SOCKET so, char* buf, int buflen, int timeout, sockaddr_in* from, socklen_t* fromlen ); -extern bool suBind ( SOCKET so, in_addr_t iInterfaceAddress, u_short iListenPort, bool bReuseAddr = false ); -extern bool suBind ( SOCKET so, const char* szInterfaceAddress, u_short iListenPort, bool bReuseAddr = false ); -extern bool suEnableBroadcast ( SOCKET so, bool bEnable = true ); -extern const char* suErrDesc ( int err ); - -#if defined(UNICODE) || defined(_UNICODE) -extern in_addr_t suLookupAddress ( const wchar_t* pcHost ); -extern bool suBroadcast ( SOCKET so, u_short port, const wchar_t* buf, int len = -1 ); -extern int suRecv ( SOCKET so, wchar_t* buf, int buflen, int timeout ); -extern int suRecvFrom ( SOCKET so, wchar_t* buf, int buflen, int timeout, sockaddr_in* from, int* fromlen ); -extern bool suBind ( SOCKET so, const wchar_t* szInterfaceAddress, u_short iListenPort, bool bReuseAddr = false ); -#endif//UNICODE - -class suSocket -{ - SOCKET _so; -public: - suSocket ( SOCKET so = INVALID_SOCKET ) : _so(so) - { - } - const suSocket& operator = ( SOCKET so ) - { - assert ( _so == INVALID_SOCKET ); // must Detach() or Close() existing socket first - _so = so; - return *this; - } - virtual ~suSocket() - { - Close(); - } - void Close() - { - if ( _so != INVALID_SOCKET ) - { - //suShutdownConnection ( _so ); // TODO - only valid on TCP sockets - closesocket ( _so ); - _so = INVALID_SOCKET; - } - } - operator SOCKET() const - { - return _so; - } - SOCKET Attach ( SOCKET so ) - { - SOCKET old = Detach(); - _so = so; - return old; - } - SOCKET Detach() - { - SOCKET so = _so; - _so = INVALID_SOCKET; - return so; - } - -private: - // disable copy semantics - suSocket ( const suSocket& ); - const suSocket& operator = ( const suSocket& ); -}; - -class suBufferedRecvSocket : public suSocket -{ - char _buf[2048]; - int _off; - int _len; -public: - suBufferedRecvSocket ( SOCKET so = INVALID_SOCKET ); - int recvUntil ( std::string& buf, char until, int timeout ); - void recvPending(); - bool recvInStr ( char c ); -}; - -class SockAddrIn : public sockaddr_in -{ -public: - SockAddrIn(); // creates broadcast address - SockAddrIn ( const char* szAddr, u_short iPort ); - SockAddrIn ( in_addr_t iAddr, u_short iPort ); - operator sockaddr* () { return (sockaddr*)this; } - operator sockaddr_in* () { return (sockaddr_in*)this; } -}; - -#endif//__SOCKUTILS_H diff --git a/irc/ArchBlackmann/SplitJoin.cpp b/irc/ArchBlackmann/SplitJoin.cpp deleted file mode 100644 index f7dd8a4c9d7..00000000000 --- a/irc/ArchBlackmann/SplitJoin.cpp +++ /dev/null @@ -1,96 +0,0 @@ -// SplitJoin.cpp -// -// This code is copyright 2003-2004 Royce Mitchell III -// and released under the BSD & LGPL licenses - -#ifdef _MSC_VER -#pragma warning ( disable : 4786 ) // MSVC6 can't handle too-long template names -#endif//_MSC_VER - -//#include - -#include "SplitJoin.h" - -#include - -using std::string; -using std::vector; -//using std::stringstream; - -static const char* quotes = "\"\'"; - -bool Split ( vector& vec, const char* csv, char sep, bool merge ) -{ - string scsv ( csv ); - char* col = &scsv[0]; - vec.resize ( 0 ); - for ( ;; ) - { - char* p = col; - while ( isspace(*p) && *p != sep ) - p++; - char quote = 0; - if ( strchr ( quotes, *p ) ) - quote = *p++; - while ( *p && (*p != sep || quote) ) - { - if ( *p++ == quote ) - break; - } - - while ( isspace(*p) && *p != sep ) - p++; - - if ( *p && *p != sep ) - return false; - - string scol ( col, p-col ); - - //quote = scol[0]; - if ( quote ) - { - if ( scol[scol.size()-1] == quote ) - scol = string ( &scol[1], scol.size()-2 ); - } - - if ( scol.length() || !merge ) - vec.push_back ( scol ); - - if ( !*p ) - break; - - col = p + 1; - } - return true; -} - -bool Join ( string& csv, vector& vec, char sep ) -{ - csv.resize(0); - for ( int i = 0; i < vec.size(); i++ ) - { - if ( i ) - csv += sep; - string& s = vec[i]; - if ( strchr ( s.c_str(), sep ) ) - { - if ( strchr ( s.c_str(), '\"' ) ) - { - if ( strchr ( s.c_str(), '\'' ) ) - return false; // the sep, " and ' are all in the string, can't build valid output - csv += '\''; - csv += s; - csv += '\''; - } - else - { - csv += '\"'; - csv += s; - csv += '\"'; - } - } - else - csv += s; - } - return true; -} diff --git a/irc/ArchBlackmann/SplitJoin.h b/irc/ArchBlackmann/SplitJoin.h deleted file mode 100644 index 8f1311457f7..00000000000 --- a/irc/ArchBlackmann/SplitJoin.h +++ /dev/null @@ -1,32 +0,0 @@ -// SplitJoin.h -// -// This code is copyright 2003-2004 Royce Mitchell III -// and released under the BSD & LGPL licenses - -#ifndef SPLITJOIN_H -#define SPLITJOIN_H - -#include -#include - -bool Split ( - std::vector& vec, - const char* csv, - char sep=',', - bool merge=false ); - -bool Join ( - std::string& csv, - std::vector& vec, - char sep=',' ); - -inline bool Split ( - std::vector& vec, - const std::string& csv, - char sep=',', - bool merge=false ) -{ - return Split ( vec, csv.c_str(), sep, merge ); -} - -#endif//SPLIT_H diff --git a/irc/ArchBlackmann/ThreadPool.cpp b/irc/ArchBlackmann/ThreadPool.cpp deleted file mode 100644 index c545cd7b91b..00000000000 --- a/irc/ArchBlackmann/ThreadPool.cpp +++ /dev/null @@ -1,240 +0,0 @@ -// ThreadPool.cpp -// This file is (C) 2003-2004 Royce Mitchell III -// and released under the LGPL & BSD licenses - -#include -using std::vector; -#include "ThreadPool.h" -#include "QueueT.h" -#include "auto_vector.h" -#include "verify.h" -#include "ReliMT.h" - -class PoolableThread : public ActiveObject -{ -public: - PoolableThread ( ThreadPoolImpl& ); - ~PoolableThread() - { - Kill(); - } - void InitThread(); - void Run(); - void FlushThread(); - - ThreadPoolImpl& _pool; -}; - -class ThreadPoolLaunchData -{ -public: - ThreadPoolFunc* pFun; - void* pArg; -}; - -template -class AtomicCounter : public Uncopyable -{ - Mutex _m; - T _t; -public: - AtomicCounter ( T init = 0 ) : _t(init) - { - } - AtomicCounter ( const AtomicCounter& t ) - { - //Mutex::Lock l ( _m ); // don't need to lock since this is a ctor - Mutex::Lock l2 ( t._m ); - _t = t._t; - } - const AtomicCounter& operator = ( const AtomicCounter& t ) - { - Mutex::Lock l ( _m ); - Mutex::Lock l2 ( t._m ); - _t = t._t; - return *this; - } - T operator ++ () - { - Mutex::Lock l ( _m ); - T t = _t++; - return t; - } - const AtomicCounter& operator ++ ( int ) - { - Mutex::Lock l ( _m ); - ++_t; - return *this; - } - T operator -- () - { - Mutex::Lock l ( _m ); - T t = _t--; - return t; - } - const AtomicCounter& operator -- ( int ) - { - Mutex::Lock l ( _m ); - --_t; - return *this; - } - const AtomicCounter& operator += ( T t ) - { - Mutex::Lock l ( _m ); - return _t += t; - return *this; - } - const AtomicCounter& operator -= ( T t ) - { - Mutex::Lock l ( _m ); - return _t -= t; - return *this; - } - operator const T& () const - { - //Mutex::Lock l ( _m ); - return _t; - } - T operator !() const - { - //Mutex::Lock l ( _m ); - return !_t; - } -}; - -class ThreadPoolImpl : public Uncopyable -{ -public: - ThreadPoolImpl() : _isDying(false), _idleThreads(0) - { - } - - ~ThreadPoolImpl() - { - } - - void Shutdown() - { - _isDying = true; - while ( _idleThreads ) - { - _threadWaitEvent.Release(); - _threadStartEvent.Wait(); // let thread actually get a grip - } - } - - void Launch ( ThreadPoolFunc* pFun, void* pArg ) - { - // this mutex is necessary to make sure we never have a conflict - // between checking !_idleThreads and the call to _threadStartEvent.Wait() - // basically if 2 threads call Launch() simultaneously, and there is only - // 1 idle thread, it's possible that a new thread won't be created to - // satisfy the 2nd request until an existing thread finishes. - Mutex::Lock launchlock ( _launchMutex ); - - ASSERT ( pFun ); - ThreadPoolLaunchData* data; - { - Mutex::Lock lock ( _vectorMutex ); - if ( !_spareData.size() ) - _spareData.push_back ( new ThreadPoolLaunchData() ); - data = _spareData.pop_back().release(); - if ( !_idleThreads ) - _threads.push_back ( new PoolableThread(*this) ); - } - - data->pFun = pFun; - data->pArg = pArg; - verify ( _pendingData.Add ( data ) ); - _threadWaitEvent.Release(); // tell a thread to do it's thing... - _threadStartEvent.Wait(); // wait on a thread to pick up the request - } - - // functions for threads to call... - ThreadPoolLaunchData* GetPendingData() - { - ThreadPoolLaunchData* data = NULL; - ++_idleThreads; - _threadWaitEvent.Wait(); // waits until there's a request - --_idleThreads; - _threadStartEvent.Release(); // tell requester we got it - if ( _isDying ) - return NULL; - _pendingData.Get ( data ); - ASSERT ( data ); - return data; - } - - void RecycleData ( ThreadPoolLaunchData* data ) - { - Mutex::Lock lock ( _vectorMutex ); - _spareData.push_back ( data ); - } - - bool _isDying; - Mutex _vectorMutex, _launchMutex; - auto_vector _threads; - auto_vector _spareData; - CQueueT _pendingData; - Event _threadWaitEvent, _threadStartEvent; - AtomicCounter _idleThreads; -}; - -/////////////////////////////////////////////////////////////////////////////// -// ThreadPool - -/*static*/ ThreadPool& ThreadPool::Instance() -{ - static ThreadPool tp; - return tp; -} - -ThreadPool::ThreadPool() : _pimpl ( new ThreadPoolImpl ) -{ -}; - -ThreadPool::~ThreadPool() -{ - _pimpl->Shutdown(); - delete _pimpl; - _pimpl = 0; -} - -void ThreadPool::Launch ( ThreadPoolFunc* pFun, void* pArg ) -{ - _pimpl->Launch ( pFun, pArg ); -} - -int ThreadPool::IdleThreads() -{ - return _pimpl->_idleThreads; -} - -/////////////////////////////////////////////////////////////////////////////// -// PoolableThread - -PoolableThread::PoolableThread ( ThreadPoolImpl& pool ) : _pool(pool) -{ - Start(); -} - -void PoolableThread::InitThread() -{ -} - -void PoolableThread::Run() -{ - ThreadPoolLaunchData* data; - while ( !_isDying ) - { - data = _pool.GetPendingData(); // enter wait state if none... - if ( !data ) // NULL data means kill thread - break; - (*data->pFun) ( data->pArg ); // call the function - _pool.RecycleData ( data ); - } -} - -void PoolableThread::FlushThread() -{ -} diff --git a/irc/ArchBlackmann/ThreadPool.h b/irc/ArchBlackmann/ThreadPool.h deleted file mode 100644 index 84e36f3993c..00000000000 --- a/irc/ArchBlackmann/ThreadPool.h +++ /dev/null @@ -1,28 +0,0 @@ -// ThreadPool.h -// This file is (C) 2003-2004 Royce Mitchell III -// and released under the LGPL & BSD licenses - -#ifndef THREADPOOL_H -#define THREADPOOL_H - -#include "ReliMT.h" - -typedef void THREADAPI ThreadPoolFunc ( void* ); - -class ThreadPoolImpl; - -class ThreadPool : public Uncopyable -{ -public: - static ThreadPool& Instance(); - ~ThreadPool(); - - void Launch ( ThreadPoolFunc* pFun, void* pArg ); - int IdleThreads(); - -private: - ThreadPool(); - ThreadPoolImpl *_pimpl; -}; - -#endif// THREADPOOL_H diff --git a/irc/ArchBlackmann/auto_ptr.h b/irc/ArchBlackmann/auto_ptr.h deleted file mode 100644 index 861501eb8e7..00000000000 --- a/irc/ArchBlackmann/auto_ptr.h +++ /dev/null @@ -1,87 +0,0 @@ -// auto_ptr.h -// This file is (C) 2002-2003 Royce Mitchell III -// and released under the LGPL & BSD licenses - -#ifndef AUTO_PTR_H -#define AUTO_PTR_H - -template -class auto_ptr -{ -public: - typedef T element_type; - - explicit auto_ptr(T *p = 0) : _p(p) - { - } - - auto_ptr(auto_ptr& rhs) : _p(rhs.release()) - { - } - - auto_ptr& operator=(auto_ptr& rhs) - { - if ( &rhs != this ) - { - dispose(); - _p = rhs.release(); - } - return *this; - } - - auto_ptr& set ( auto_ptr& rhs ) - { - if ( &rhs != this ) - { - dispose(); - _p = rhs.release(); - } - return *this; - } - - ~auto_ptr() - { - dispose(); - } - - void dispose() - { - if ( _p ) - { - delete _p; - _p = 0; - } - } - - T& operator[] ( int i ) - { - return _p[i]; - } - - T& operator*() const - { - return *_p; - } - - T* operator->() const - { - return _p; - } - - T* get() const - { - return _p; - } - - T* release() - { - T* p = _p; - _p = 0; - return p; - } - -private: - T* _p; -}; - -#endif//AUTO_PTR_H diff --git a/irc/ArchBlackmann/auto_vector.h b/irc/ArchBlackmann/auto_vector.h deleted file mode 100644 index 730c6302af8..00000000000 --- a/irc/ArchBlackmann/auto_vector.h +++ /dev/null @@ -1,141 +0,0 @@ -// auto_vector.h -// This file is (C) 2002-2004 Royce Mitchell III -// and released under the LGPL & BSD licenses - -#ifndef AUTO_VECTOR_H -#define AUTO_VECTOR_H - -#include -#include "verify.h" -#include "auto_ptr.h" - -template -class auto_vector -{ -public: - explicit auto_vector ( size_t capacity = 0 ) - : _arr(0), _capacity(0), _end(0) - { - if ( capacity != 0 ) - _arr = new auto_ptr[capacity]; - _capacity = capacity; - } - - ~auto_vector() - { - delete []_arr; - } - - size_t size() const - { - return _end; - } - - const auto_ptr& operator [] ( size_t i ) const - { - ASSERT ( i < _end ); - return _arr[i]; - } - - auto_ptr& operator [] ( size_t i ) - { - ASSERT ( i < _end ); - return _arr[i]; - } - - void assign ( size_t i, auto_ptr& p ) - { - ASSERT ( i < _end ); - _arr[i] = p; - } - - void assign_direct ( size_t i, T * p ) - { - ASSERT ( i < _end ); - reserve ( i + 1 ); - _arr[i].reset ( p ); - } - - void push_back ( auto_ptr& p ) - { - reserve ( _end + 1 ); - _arr[_end++] = p; - } - - auto_ptr& back() - { - ASSERT ( _end != 0 ); - return _arr[_end-1]; - } - - void push_back ( T * p ) - { - reserve ( _end + 1 ); - auto_ptr tmp(p); - _arr[_end++] = tmp; - //GCC is pedantic, this is an error. - //_arr[_end++] = auto_ptr(p); - } - - auto_ptr pop_back() - { - ASSERT ( _end != 0 ); - if ( !_end ) - { - auto_ptr tmp((T*)0); - return tmp; - //GCC, this is an error. - //return auto_ptr(NULL); - } - return _arr[--_end]; - } - - void resize ( size_t newSize ) - { - ASSERT ( newSize >= 0 ); - reserve ( newSize ); // make sure we have at least this much room - _end = newSize; - } - - void reserve ( size_t reqCapacity ) - { - if ( reqCapacity <= _capacity ) - return; - size_t newCapacity = 2 * _capacity; - if ( reqCapacity > newCapacity ) - newCapacity = reqCapacity; - // allocate new array - auto_ptr * arrNew = new auto_ptr [newCapacity]; - // transfer all entries - for ( size_t i = 0; i < _capacity; ++i ) - arrNew[i] = _arr[i]; - _capacity = newCapacity; - // free old memory - delete[] _arr; - // substitute new array for old array - _arr = arrNew; - } - - void remove ( size_t off ) - { - size_t last = _end-1; - if ( off == last ) - resize ( last ); - else if ( off < last ) - { - auto_ptr tmp ( pop_back().release() ); - _arr[off] = tmp; - } - } - - //typedef const_auto_iterator const_iterator; - //const_iterator begin () const { return _arr; } - //const_iterator end () const { return _arr + _end; } - -private: - auto_ptr *_arr; - size_t _capacity; - size_t _end; -}; - -#endif//AUTO_VECTOR_H diff --git a/irc/ArchBlackmann/base64.cpp b/irc/ArchBlackmann/base64.cpp deleted file mode 100644 index 6fdc8528698..00000000000 --- a/irc/ArchBlackmann/base64.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// base64.cpp - -#include "base64.h" - -using std::string; - -static const char* alfabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - -string base64_encode ( const string& sInput ) -{ - unsigned char x=0, topbit=0; - int v=0; - string sOutput; - do - { - if ( topbit < 6 ) - { - x++; - v <<= 8; - if ( x <= sInput.length() ) v += sInput[x-1]; - topbit += 8; - } - topbit -= 6; - if ( x > sInput.length() && !v ) - break; - sOutput += alfabet[(v >> topbit) & 63]; - v &= (1 << topbit) - 1; - } while ( x < sInput.length() || v ); - int eq = (8 - (sOutput.length() % 4)) % 4; - while ( eq-- ) - sOutput += '='; - return sOutput; -} - -string base64_decode ( const string& sInput ) -{ - unsigned char x=0, topbit=0; - int v=0, inlen = sInput.length(); - string sOutput; - while ( inlen && sInput[inlen-1] == '=' ) - inlen--; - do - { - while ( topbit < 8 ) - { - x++; - v <<= 6; - if ( x <= inlen ) v += (strchr(alfabet, sInput[x-1]) - alfabet); - topbit += 6; - } - topbit -= 8; - if ( x > inlen && !v ) - break; - sOutput += (char)((v >> topbit) & 255); - v &= ((1 << topbit) - 1); - } while ( x <= inlen || v ); - return sOutput; -} diff --git a/irc/ArchBlackmann/base64.h b/irc/ArchBlackmann/base64.h deleted file mode 100644 index e307b7aeaca..00000000000 --- a/irc/ArchBlackmann/base64.h +++ /dev/null @@ -1,12 +0,0 @@ -// base64.h - -#ifndef BASE64_H -#define BASE64_H - -#include - -std::string base64_encode ( const std::string& s ); - -std::string base64_decode ( const std::string& s ); - -#endif//BASE64_H diff --git a/irc/ArchBlackmann/chomp.cpp b/irc/ArchBlackmann/chomp.cpp deleted file mode 100644 index 5a3a2080018..00000000000 --- a/irc/ArchBlackmann/chomp.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// chomp.cpp -// This file is (C) 2004 Royce Mitchell III -// and released under the BSD & LGPL licenses - -#include "chomp.h" - -std::string chomp ( const std::string& s ) -{ - const char* p = &s[0]; - const char* p2 = &s[0] + s.size(); - while ( p2 > p && strchr("\r\n", p2[-1]) ) - p2--; - return std::string ( p, p2-p ); -} - diff --git a/irc/ArchBlackmann/chomp.h b/irc/ArchBlackmann/chomp.h deleted file mode 100644 index 80bd8dce071..00000000000 --- a/irc/ArchBlackmann/chomp.h +++ /dev/null @@ -1,13 +0,0 @@ -// chomp.h -// This file is (C) 2004 Royce Mitchell III -// and released under the BSD & LGPL licenses - -#ifndef CHOMP_H -#define CHOMP_H - -#include - -std::string chomp ( const std::string& s ); - -#endif//TRIM_H - diff --git a/irc/ArchBlackmann/config.h b/irc/ArchBlackmann/config.h deleted file mode 100644 index fab1e9c841c..00000000000 --- a/irc/ArchBlackmann/config.h +++ /dev/null @@ -1,7 +0,0 @@ - - -#define SERVER "irc.freenode.net" -#define BOTNAME "ArchBlackmann" -#define CHANNEL "#ReactOS" -#define MODE "+i" -#define PASS "ilovebunnies" diff --git a/irc/ArchBlackmann/cram_md5.cpp b/irc/ArchBlackmann/cram_md5.cpp deleted file mode 100644 index d4c37cf49aa..00000000000 --- a/irc/ArchBlackmann/cram_md5.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// cram_md5.cpp -// This file is (C) 2004 Royce Mitchell III -// and released under the BSD & LGPL licenses - -#include "MD5.h" -#include "cram_md5.h" -#include "base64.h" - -using std::string; - -string cram_md5 ( const string& username, const string& password, const string& greeting ) -{ - string challenge = base64_decode ( greeting ); - - string hmac = HMAC_MD5 ( password, challenge ); - //printf ( "(cram_md5): hmac = %s\n", hmac.c_str() ); - string raw_response = username; - raw_response += " "; - raw_response += hmac; - //printf ( "(cram_md5): raw_response = %s\n", raw_response.c_str() ); - - return base64_encode ( raw_response ); -} diff --git a/irc/ArchBlackmann/cram_md5.h b/irc/ArchBlackmann/cram_md5.h deleted file mode 100644 index c0741b8efde..00000000000 --- a/irc/ArchBlackmann/cram_md5.h +++ /dev/null @@ -1,15 +0,0 @@ -// cram_md5.h -// This file is (C) 2004 Royce Mitchell III -// and released under the BSD & LGPL licenses - -#ifndef CRAM_MD5_H -#define CRAM_MD5_H - -#include - -std::string cram_md5 ( - const std::string& username, - const std::string& password, - const std::string& greeting ); - -#endif//CRAM_MD5_H diff --git a/irc/ArchBlackmann/curse.txt b/irc/ArchBlackmann/curse.txt deleted file mode 100644 index ddec893b813..00000000000 --- a/irc/ArchBlackmann/curse.txt +++ /dev/null @@ -1 +0,0 @@ -semprini \ No newline at end of file diff --git a/irc/ArchBlackmann/cursecop.txt b/irc/ArchBlackmann/cursecop.txt deleted file mode 100644 index 6144752de03..00000000000 --- a/irc/ArchBlackmann/cursecop.txt +++ /dev/null @@ -1,10 +0,0 @@ -You should have your mouth washed out with soap! -This is a clean channel... please watch your language -Please try to keep it clean -Hey, there's children present ( I'm not even a year old yet! ) -Could you find a less-offensive way to express yourself, please? -Such language :( -Those aren't nice words to use -Oh, my poor innocent ears :( -Help! My mind is being corrupted! -filthy mouths are not appreciated here diff --git a/irc/ArchBlackmann/dev.txt b/irc/ArchBlackmann/dev.txt deleted file mode 100644 index 5415e0a3e6c..00000000000 --- a/irc/ArchBlackmann/dev.txt +++ /dev/null @@ -1,15 +0,0 @@ -Royce3 -kjk_hyperion -tamlin -GvG -filip2307 -hardon -w3seek -arty -sedwards -Exception -blight_ -jimtabor -mtempel -Gge -Alex_Ionescu diff --git a/irc/ArchBlackmann/func.txt b/irc/ArchBlackmann/func.txt deleted file mode 100644 index 7173404eac1..00000000000 --- a/irc/ArchBlackmann/func.txt +++ /dev/null @@ -1,580 +0,0 @@ -CcCanIWrite -CcCopyRead -CcCopyWrite -CcDeferWrite -CcFastCopyRead -CcFastCopyWrite -CcFlushCache -CcGetDirtyPages -CcGetFileObjectFromBcb -CcGetFileObjectFromSectionPtrs -CcGetFlushedValidData -CcGetLsnForFileObject -CcInitializeCacheMap -CcIsThereDirtyData -CcMapData -CcMdlRead -CcMdlReadComplete -CcMdlWriteAbort -CcMdlWriteComplete -CcPinMappedData -CcPinRead -CcPrepareMdlWrite -CcPreparePinWrite -CcPurgeCacheSection -CcRemapBcb -CcRepinBcb -CcScheduleReadAhead -CcSetAdditionalCacheAttributes -CcSetBcbOwnerPointer -CcSetDirtyPageThreshold -CcSetDirtyPinnedData -CcSetFileSizes -CcSetLogHandleForFile -CcSetReadAheadGranularity -CcUninitializeCacheMap -CcUnpinData -CcUnpinDataForThread -CcUnpinRepinnedBcb -CcWaitForCurrentLazyWriterActivity -CcZeroData -DbgLoadImageSymbols -DbgQueryDebugFilterState -DbgSetDebugFilterState -EVENT_TYPE -ExAcquireResourceExclusive -ExAcquireResourceExclusiveLite -ExAcquireResourceSharedLite -ExAcquireSharedStarveExclusive -ExAcquireSharedWaitForExclusive -ExAllocateFromZone -ExAllocatePool -ExAllocatePoolWithQuota -ExAllocatePoolWithQuotaTag -ExAllocatePoolWithTag -ExConvertExclusiveToSharedLite -ExCreateCallback -ExDeleteNPagedLookasideList -ExDeletePagedLookasideList -ExDeleteResource -ExDeleteResourceLite -ExDisableResourceBoostLite -ExEnumHandleTable -ExExtendZone -ExFreePool -ExGetCurrentProcessorCounts -ExGetCurrentProcessorCpuUsage -ExGetExclusiveWaiterCount -ExGetPreviousMode -ExGetSharedWaiterCount -ExInitializeNPagedLookasideList -ExInitializePagedLookasideList -ExInitializeResource -ExInitializeResourceLite -ExInitializeZone -ExInterlockedAddLargeInteger -ExInterlockedAddUlong -ExInterlockedDecrementLong -ExInterlockedExchangeUlong -ExInterlockedExtendZone -ExInterlockedIncrementLong -ExInterlockedInsertHeadList -ExInterlockedInsertTailList -ExInterlockedPopEntryList -ExInterlockedPushEntryList -ExInterlockedRemoveHeadList -ExIsProcessorFeaturePresent -ExIsResourceAcquiredExclusiveLite -ExIsResourceAcquiredSharedLite -ExLocalTimeToSystemTime -ExNotifyCallback -ExPostSystemEvent -ExQueryPoolBlockSize -ExQueueWorkItem -ExRaiseAccessViolation -ExRaiseDatatypeMisalignment -ExRaiseException -ExRaiseHardError -ExRaiseStatus -ExRegisterCallback -ExReinitializeResourceLite -ExReleaseResource -ExReleaseResourceForThread -ExReleaseResourceForThreadLite -ExRosDumpPagedPoolByTag -ExRosQueryPoolTag -ExSetResourceOwnerPointer -ExSetTimerResolution -ExSystemExceptionFilter -ExSystemTimeToLocalTime -ExTryToAcquireResourceExclusiveLite -ExUnregisterCallback -ExUuidCreate -ExVerifySuite -FsRtlAcquireFileExclusive -FsRtlAddMcbEntry -FsRtlAddToTunnelCache -FsRtlAllocateFileLock -FsRtlAllocatePool -FsRtlAllocatePoolWithQuota -FsRtlAllocatePoolWithQuotaTag -FsRtlAllocatePoolWithTag -FsRtlAllocateResource -FsRtlAreNamesEqual -FsRtlBalanceReads -FsRtlCheckLockForReadAccess -FsRtlCheckLockForWriteAccess -FsRtlCopyRead -FsRtlCopyWrite -FsRtlFastCheckLockForRead -FsRtlFastCheckLockForWrite -FsRtlFastUnlockAll -FsRtlFastUnlockAllByKey -FsRtlFastUnlockSingle -FsRtlFindInTunnelCache -FsRtlFreeFileLock -FsRtlGetFileSize -FsRtlGetNextFileLock -FsRtlGetNextMcbEntry -FsRtlIncrementCcFastReadNoWait -FsRtlIncrementCcFastReadNotPossible -FsRtlIncrementCcFastReadResourceMiss -FsRtlIncrementCcFastReadWait -FsRtlInitializeFileLock -FsRtlInitializeMcb -FsRtlInitializeTunnelCache -FsRtlInsertPerFileObjectContext -FsRtlInsertPerStreamContext -FsRtlIsDbcsInExpression -FsRtlIsFatDbcsLegal -FsRtlIsHpfsDbcsLegal -FsRtlIsNameInExpression -FsRtlLookupLastLargeMcbEntryAndIndex -FsRtlLookupLastMcbEntry -FsRtlLookupMcbEntry -FsRtlLookupPerFileObjectContext -FsRtlLookupPerStreamContextInternal -FsRtlMdlRead -FsRtlMdlReadComplete -FsRtlMdlReadCompleteDev -FsRtlMdlReadDev -FsRtlMdlWriteComplete -FsRtlMdlWriteCompleteDev -FsRtlNotifyChangeDirectory -FsRtlNotifyCleanup -FsRtlNotifyFilterChangeDirectory -FsRtlNotifyFilterReportChange -FsRtlNotifyFullChangeDirectory -FsRtlNotifyFullReportChange -FsRtlNotifyReportChange -FsRtlNotifyUninitializeSync -FsRtlNumberOfRunsInMcb -FsRtlPostPagingFileStackOverflow -FsRtlPostStackOverflow -FsRtlPrepareMdlWrite -FsRtlPrepareMdlWriteDev -FsRtlPrivateLock -FsRtlProcessFileLock -FsRtlRegisterFileSystemFilterCallbacks -FsRtlReleaseFile -FsRtlRemoveMcbEntry -FsRtlRemovePerFileObjectContext -FsRtlRemovePerStreamContext -FsRtlResetLargeMcb -FsRtlSyncVolumes -FsRtlTeardownPerStreamContexts -FsRtlTruncateMcb -FsRtlUninitializeFileLock -FsRtlUninitializeMcb -HalAdjustResourceList -HalAllocateCommonBuffer -HalAssignSlotResources -HalCalibratePerformanceCounter -HalFlushCommonBuffer -HalFreeCommonBuffer -HalGetAdapter -HalGetBusData -HalGetBusDataByOffset -HalGetDmaAlignmentRequirement -HalMakeBeep -HalQueryDisplayParameters -HalQueryRealTimeClock -HalReadDmaCounter -HalRequestIpi -HalSetBusData -HalSetBusDataByOffset -HalSetDisplayParameters -HalSetRealTimeClock -HalStartNextProcessor -IoAcquireCancelSpinLock -IoAcquireRemoveLockEx -IoAcquireVpbSpinLock -IoAllocateAdapterChannel -IoAllocateController -IoAllocateDriverObjectExtension -IoAllocateErrorLogEntry -IoAllocateIrp -IoAllocateMdl -IoAllocateWorkItem -IoAssignResources -IoAttachDevice -IoAttachDeviceByPointer -IoAttachDeviceToDeviceStack -IoAttachDeviceToDeviceStackSafe -IoBuildAsynchronousFsdRequest -IoBuildDeviceIoControlRequest -IoBuildPartialMdl -IoBuildSynchronousFsdRequest -IoCallDriver -IoCancelFileOpen -IoCancelIrp -IoCheckQuerySetFileInformation -IoCheckQuerySetVolumeInformation -IoCheckQuotaBufferValidity -IoCheckShareAccess -IoCompleteRequest -IoConnectInterrupt -IoCreateController -IoCreateDevice -IoCreateDisk -IoCreateDriver -IoCreateFile -IoCreateFileSpecifyDeviceObjectHint -IoCreateNotificationEvent -IoCreateStreamFileObject -IoCreateStreamFileObjectEx -IoCreateStreamFileObjectLite -IoCreateSymbolicLink -IoCreateSynchronizationEvent -IoCreateUnprotectedSymbolicLink -IoDeleteController -IoDeleteDevice -IoDeleteDriver -IoDeleteSymbolicLink -IoDetachDevice -IoDisconnectInterrupt -IoEnqueueIrp -IoEnumerateDeviceObjectList -IoFlushAdapterBuffers -IoForwardIrpSynchronously -IoFreeAdapterChannel -IoFreeController -IoFreeErrorLogEntry -IoFreeIrp -IoFreeMapRegisters -IoFreeMdl -IoFreeWorkItem -IoGetAttachedDevice -IoGetAttachedDeviceReference -IoGetBaseFileSystemDeviceObject -IoGetBootDiskInformation -IoGetConfigurationInformation -IoGetCurrentProcess -IoGetDeviceAttachmentBaseRef -IoGetDeviceInterfaceAlias -IoGetDeviceInterfaces -IoGetDeviceObjectPointer -IoGetDeviceProperty -IoGetDeviceToVerify -IoGetDiskDeviceObject -IoGetDriverObjectExtension -IoGetFileObjectGenericMapping -IoGetInitialStack -IoGetLowerDeviceObject -IoGetRelatedDeviceObject -IoGetRequestorProcess -IoGetRequestorProcessId -IoGetRequestorSessionId -IoGetStackLimits -IoGetTopLevelIrp -IoInitializeIrp -IoInitializeRemoveLockEx -IoInitializeTimer -IoInvalidateDeviceRelations -IoInvalidateDeviceState -IoIsFileOriginRemote -IoIsOperationSynchronous -IoIsSystemThread -IoIsValidNameGraftingBuffer -IoMakeAssociatedIrp -IoMapTransfer -IoOpenDeviceInstanceKey -IoOpenDeviceInterfaceRegistryKey -IoOpenDeviceRegistryKey -IoPageRead -IoPnPDeliverServicePowerNotification -IoQueryDeviceDescription -IoQueryDeviceEnumInfo -IoQueryFileDosDeviceName -IoQueryFileInformation -IoQueryVolumeInformation -IoQueueThreadIrp -IoQueueWorkItem -IoRaiseHardError -IoRaiseInformationalHardError -IoReadDiskSignature -IoReadPartitionTableEx -IoRegisterBootDriverReinitialization -IoRegisterDeviceInterface -IoRegisterDriverReinitialization -IoRegisterFileSystem -IoRegisterFsRegistrationChange -IoRegisterLastChanceShutdownNotification -IoRegisterPlugPlayNotification -IoRegisterShutdownNotification -IoReleaseCancelSpinLock -IoReleaseRemoveLockAndWaitEx -IoReleaseRemoveLockEx -IoReleaseVpbSpinLock -IoRemoveShareAccess -IoReportDetectedDevice -IoReportHalResourceUsage -IoReportResourceForDetection -IoReportResourceUsage -IoReportTargetDeviceChange -IoReportTargetDeviceChangeAsynchronous -IoRequestDeviceEject -IoReuseIrp -IoSetCompletionRoutineEx -IoSetDeviceInterfaceState -IoSetDeviceToVerify -IoSetFileOrigin -IoSetHardErrorOrVerifyDevice -IoSetInformation -IoSetIoCompletion -IoSetPartitionInformationEx -IoSetShareAccess -IoSetStartIoAttributes -IoSetSystemPartition -IoSetThreadHardErrorMode -IoSetTopLevelIrp -IoStartNextPacket -IoStartNextPacketByKey -IoStartPacket -IoStartTimer -IoStopTimer -IoSynchronousInvalidateDeviceRelations -IoSynchronousPageWrite -IoUnregisterFileSystem -IoUnregisterFsRegistrationChange -IoUnregisterPlugPlayNotification -IoUnregisterShutdownNotification -IoUpdateShareAccess -IoValidateDeviceIoControlAccess -IoVerifyPartitionTable -IoVerifyVolume -IoVolumeDeviceToDosName -IoWMIAllocateInstanceIds -IoWMIDeviceObjectToInstanceName -IoWMIExecuteMethod -IoWMIHandleToInstanceName -IoWMIOpenBlock -IoWMIQueryAllData -IoWMIQueryAllDataMultiple -IoWMIQuerySingleInstance -IoWMIQuerySingleInstanceMultiple -IoWMIRegistrationControl -IoWMISetNotificationCallback -IoWMISetSingleInstance -IoWMISetSingleItem -IoWMISuggestInstanceName -IoWMIWriteEvent -IoWriteErrorLogEntry -IoWritePartitionTableEx -KPRIORITY -KdPortGetByte -KdPortPollByte -KdPortPutByte -Ke386QueryIoAccessMap -Ke386SetIoAccessMap -KeAcquireInterruptSpinLock -KeAreApcsDisabled -KeCapturePersistentThreadState -KeDeregisterBugCheckReasonCallback -KeFindConfigurationEntry -KeFindConfigurationNextEntry -KeFlushEntireTb -KeFlushQueuedDpcs -KeGetRecommendedSharedDataAlignment -KeIsExecutingDpc -KeQueryActiveProcessors -KeQueryPerformanceCounter -KeQueryPriorityThread -KeQueryRuntimeThread -KeQuerySystemTime -KeQueryTickCount -KeQueryTimeIncrement -KeRaiseIrql -KeRaiseIrqlToDpcLevel -KeRaiseUserException -KeReadStateEvent -KeRegisterBugCheckCallback -KeRegisterBugCheckReasonCallback -KeReleaseInterruptSpinLock -KeReleaseMutant -KeReleaseMutex -KeReleaseSemaphore -KeReleaseSpinLock -KeReleaseSpinLockFromDpcLevel -KeReleaseSpinLockFromDpcLevel -KeRemoveByKeyDeviceQueue -KeRemoveByKeyDeviceQueueIfBusy -KeRemoveDeviceQueue -KeRemoveEntryDeviceQueue -KeRemoveSystemServiceTable -KeRestoreFloatingPointState -KeRevertToUserAffinityThread -KeRosDumpStackFrames -KeRosGetStackFrames -KeRosPrintAddress -KeSaveFloatingPointState -KeSetDmaIoCoherency -KeSetEvent -KeSetEventBoostPriority -KeSetIdealProcessorThread -KeSetKernelStackSwapEnable -KeSetProfileIrql -KeSetSystemAffinityThread -KeSetTimeIncrement -KeTerminateThread -KeUserModeCallback -KeWaitForMutexObject -KeWaitForSingleObject -KiCoprocessorError -KiUnexpectedInterrupt -LONG -LdrFindResourceDirectory_U -MmAddPhysicalMemory -MmAddVerifierThunks -MmAdjustWorkingSetSize -MmAdvanceMdl -MmAllocateContiguousMemory -MmAllocateContiguousMemorySpecifyCache -MmAllocateMappingAddress -MmAllocateNonCachedMemory -MmBuildMdlForNonPagedPool -MmCanFileBeTruncated -MmCreateMdl -MmCreateSection -MmDbgTranslatePhysicalAddress -MmDisableModifiedWriteOfSection -MmFlushImageSection -MmForceSectionClosed -MmFreeContiguousMemory -MmFreeMappingAddress -MmFreeNonCachedMemory -MmGetPhysicalAddress -MmGetPhysicalMemoryRanges -MmGetSystemRoutineAddress -MmGetVirtualForPhysical -MmGrowKernelStack -MmIsAddressValid -MmIsDriverVerifying -MmIsNonPagedSystemAddressValid -MmIsRecursiveIoFault -MmIsThisAnNtAsSystem -MmIsVerifierEnabled -MmLockPagableDataSection -MmLockPagableImageSection -MmLockPagableSectionByHandle -MmMapIoSpace -MmMapLockedPages -MmMapLockedPagesWithReservedMapping -MmMapMemoryDumpMdl -MmMapUserAddressesToPage -MmMapVideoDisplay -MmMapViewInSessionSpace -MmMapViewInSystemSpace -MmMapViewOfSection -MmMarkPhysicalMemoryAsBad -MmMarkPhysicalMemoryAsGood -MmPageEntireDriver -MmPrefetchPages -MmProbeAndLockPages -MmProbeAndLockProcessPages -MmProbeAndLockSelectedPages -MmProtectMdlSystemAddress -MmQuerySystemSize -MmRemovePhysicalMemory -MmResetDriverPaging -MmSecureVirtualMemory -MmSetAddressRangeModified -MmSetBankedSection -MmSizeOfMdl -MmTrimAllSystemPagableMemory -MmUnlockPagableImageSection -MmUnlockPages -MmUnmapIoSpace -MmUnmapLockedPages -MmUnmapReservedMapping -MmUnmapVideoDisplay -MmUnmapViewInSessionSpace -MmUnmapViewInSystemSpace -MmUnmapViewOfSection -MmUnsecureVirtualMemory -OUT -ObCreateObject -PEJOB -PEPROCESS -PKBUGCHECK_CALLBACK_RECORD -PKDEVICE_QUEUE_ENTRY -PKIRQL -PULONG -PVOID -PW32_THREAD_CALLBACK -PoCallDriver -PoRegisterDeviceForIdleDetection -PoRegisterSystemState -PoRequestPowerIrp -PoSetDeviceBusy -PoSetPowerState -PoSetSystemState -PoStartNextPowerIrp -PoUnregisterSystemState -ProbeForRead -ProbeForWrite -PsAssignImpersonationToken -PsCreateSystemProcess -PsCreateSystemThread -PsGetCurrentProcessId -PsGetCurrentThreadId -PsImpersonateClient -PsReferenceImpersonationToken -PsReferencePrimaryToken -PsRevertThreadToSelf -PsRevertToSelf -PsTerminateSystemThread -READ_PORT_BUFFER_UCHAR -READ_PORT_BUFFER_ULONG -READ_PORT_BUFFER_USHORT -READ_PORT_UCHAR -READ_PORT_ULONG -READ_PORT_USHORT -SeAssignSecurityEx -SeAuditHardLinkCreation -SeAuditingFileEvents -SeAuditingFileEventsWithContext -SeAuditingFileOrGlobalEvents -SeAuditingHardLinkEvents -SeAuditingHardLinkEventsWithContext -SeCaptureSecurityDescriptor -SeCaptureSubjectContext -SeCloseObjectAuditAlarm -SeCreateAccessState -SeCreateClientSecurityFromSubjectContext -SeFilterToken -SeImpersonateClientEx -SePrivilegeObjectAuditAlarm -SeQueryInformationToken -SeQuerySessionIdToken -SeReleaseSecurityDescriptor -SeSetSecurityDescriptorInfoEx -SeTokenIsAdmin -SeTokenIsRestricted -SeTokenIsWriteRestricted -WRITE_PORT_BUFFER_UCHAR -WRITE_PORT_BUFFER_ULONG -WRITE_PORT_BUFFER_USHORT -WRITE_PORT_UCHAR -WRITE_PORT_ULONG -WRITE_PORT_USHORT diff --git a/irc/ArchBlackmann/grovel.txt b/irc/ArchBlackmann/grovel.txt deleted file mode 100644 index 21137b50e13..00000000000 --- a/irc/ArchBlackmann/grovel.txt +++ /dev/null @@ -1,10 +0,0 @@ -/me bows humbly and begs %s's forgiveness -%s is soo cool... I hope to be like him some day -/me hides in a corner and hopes %s doesn't beat him with the whipping noodle again -/me prostrates at %s's feet and begs his majesty's forgiveness -%s: please don't hurt me! -I'm not worthy... I'm not worthy... -/me sings %s's praises to the world! -/me thinks %s is smarter than %dev% -%s: oh please may I defrag your sock drawer? -/me gives %s a cookie, hoping it will make up for breaking %func% the other day... diff --git a/irc/ArchBlackmann/idle.txt b/irc/ArchBlackmann/idle.txt deleted file mode 100644 index d3bf9c4dec5..00000000000 --- a/irc/ArchBlackmann/idle.txt +++ /dev/null @@ -1 +0,0 @@ -/me is bored diff --git a/irc/ArchBlackmann/irql.txt b/irc/ArchBlackmann/irql.txt deleted file mode 100644 index f585ced2ad1..00000000000 --- a/irc/ArchBlackmann/irql.txt +++ /dev/null @@ -1,9 +0,0 @@ -PASSIVE_LEVEL -APC_LEVEL -DISPATCH_LEVEL -PROFILE_LEVEL -CLOCK1_LEVEL -IPI_LEVEL -POWER_LEVEL -HIGH_LEVEL -SYNCH_LEVEL \ No newline at end of file diff --git a/irc/ArchBlackmann/makefile b/irc/ArchBlackmann/makefile deleted file mode 100644 index 0fac5b953f0..00000000000 --- a/irc/ArchBlackmann/makefile +++ /dev/null @@ -1,38 +0,0 @@ -TARGET := ArchBlackmann.exe - -.PHONY: all - -all: $(TARGET) - -CPP=mingw32-g++ -CFLAGS := -DWIN32 -D_DEBUG -D_CONSOLE -D_MBCS -LFLAGS := -LIBS := -lstdc++ -lws2_32 - -SRCS := ArchBlackmann.cpp \ - base64.cpp \ - chomp.cpp \ - cram_md5.cpp \ - File.cpp \ - IRCClient.cpp \ - MD5.cpp \ - panic.cpp \ - ReliMT.cpp \ - SockUtils.cpp \ - SplitJoin.cpp \ - ssprintf.cpp \ - ThreadPool.cpp \ - trim.cpp - -OBJS := $(SRCS:.cpp=.o) - -$(TARGET): $(OBJS) - $(CPP) $(LFLAGS) -o $@ $(OBJS) $(LIBS) - -.cpp.o: $< - $(CPP) $(CFLAGS) -c $< -o $@ - -.PHONY: clean -clean: - -@del $(TARGET) - -@del $(OBJS) diff --git a/irc/ArchBlackmann/module.txt b/irc/ArchBlackmann/module.txt deleted file mode 100644 index b9956a73854..00000000000 --- a/irc/ArchBlackmann/module.txt +++ /dev/null @@ -1,13 +0,0 @@ -the kernel -ntoskrnl -win32k -msafd -ws2_32 -user32 -shell32 -the cache manager -tdi -the scheduler -the thread queue -the message queue -atapi \ No newline at end of file diff --git a/irc/ArchBlackmann/nogrovel.txt b/irc/ArchBlackmann/nogrovel.txt deleted file mode 100644 index bbeecf0d275..00000000000 --- a/irc/ArchBlackmann/nogrovel.txt +++ /dev/null @@ -1,5 +0,0 @@ -/me slaps %s with a large trout -recycle(%s) -Did I hear something? Musta been a %s-fly... Where's that fly-swatter? -%s: go away son, you bother me.... -/me beats %s with the whipping noodle diff --git a/irc/ArchBlackmann/panic.cpp b/irc/ArchBlackmann/panic.cpp deleted file mode 100644 index 3ad0604b311..00000000000 --- a/irc/ArchBlackmann/panic.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// panic.cpp -// This file is (C) 2003-2004 Royce Mitchell III -// and released under the BSD & LGPL licenses - -#include -#include -#include -#ifdef WIN32 -#include -#include -#endif//WIN32 -#include "panic.h" - -void panic ( const char* format, ... ) -{ - va_list arg; - int done; - - va_start(arg, format); -#if defined(WIN32) && !defined(_CONSOLE) - char buf[4096]; - _vsnprintf ( buf, sizeof(buf)-1, format, arg ); - MessageBox ( NULL, buf, "Panic!", MB_OK|MB_ICONEXCLAMATION ); -#else - done = vprintf(format, arg); - printf ( "\n" ); -#endif - va_end(arg); -#if defined(WIN32) && defined(_CONSOLE) - printf ( "Press any key to exit\n" ); - (void)getch(); -#endif//WIN32 && _CONSOLE - exit ( -1 ); -} diff --git a/irc/ArchBlackmann/panic.h b/irc/ArchBlackmann/panic.h deleted file mode 100644 index e15cafab27f..00000000000 --- a/irc/ArchBlackmann/panic.h +++ /dev/null @@ -1,18 +0,0 @@ -// panic.h -// This file is (C) 2003-2004 Royce Mitchell III -// and released under the BSD & LGPL licenses - -#ifndef PANIC_H -#define PANIC_H - -void panic ( const char* format, ... ); - -#define suAssert(expr) if ( !(expr) ) panic ( "%s(%lu): SOCKET ERROR %s\nExpression: %s\n", __FILE__, __LINE__, suErrDesc(SUERRNO), #expr ) - -#if defined(DEBUG) || defined(_DEBUG) -# define suVerify(expr) suAssert(expr) -#else -# define suVerify(expr) expr -#endif - -#endif//PANIC_H diff --git a/irc/ArchBlackmann/period.txt b/irc/ArchBlackmann/period.txt deleted file mode 100644 index 380a6fefe38..00000000000 --- a/irc/ArchBlackmann/period.txt +++ /dev/null @@ -1,11 +0,0 @@ -minute -hour -day -week -fortnight -month -year -decade -century -millenium -eon \ No newline at end of file diff --git a/irc/ArchBlackmann/readme.txt b/irc/ArchBlackmann/readme.txt deleted file mode 100644 index 89f9da7369e..00000000000 --- a/irc/ArchBlackmann/readme.txt +++ /dev/null @@ -1,44 +0,0 @@ -This doc can be also found on the wiki. - -ArchBlackman is a IRC-Chat bot of the #reactos irc channel. He has been coded by Royce3 and DrFred (mbosma) currently runs him. - - -If some one use a swear word he'll tell him not to do so and you can also ask him something technical about reactos. :) - -Besides this he also knows some commands. The systax for giving him commands "ArchBlackmann: !grovel". (don't forget to address him) - - - !grovel - This is the only command that non ops can do (No Parameter) - - !kiss - - !hug - - !give - - !say - You can tell him to say something on the channel via PrivateMessage - - -ArchBlackmann know what he should say from some text files. They can be found on the svn-dir. But can also edit them online if you are op using: - - - !add - - !remove - -List that are used directly to create responses are: - - - tech - here are the sentences ArchBlackmann says when he finds his name - - curse - this are the curses he looks for - - cursecop - this the responces to them - - grovel - this is said when an op does the grovel command - - nogrovel - this when someone else does it - -The remaining lists are not used directly, but by the other lists. - -They are: - - - dev - - func - - irql - - module - - period - - status - - stru - - type - -And they are used like this: - /me thinks %s is smarter than %dev% \ No newline at end of file diff --git a/irc/ArchBlackmann/ssprintf.cpp b/irc/ArchBlackmann/ssprintf.cpp deleted file mode 100644 index 9f55d12f637..00000000000 --- a/irc/ArchBlackmann/ssprintf.cpp +++ /dev/null @@ -1,998 +0,0 @@ -// ssprintf.cpp - -#include -#include -#include -#include -#include "ssprintf.h" - -#ifdef _MSC_VER -#define alloca _alloca -#endif//_MSC_VER - -typedef __int64 LONGLONG; -typedef unsigned __int64 ULONGLONG; - -typedef struct { - unsigned int mantissa:23; - unsigned int exponent:8; - unsigned int sign:1; -} ieee_float_t; - -typedef struct { - unsigned int mantissal:32; - unsigned int mantissah:20; - unsigned int exponent:11; - unsigned int sign:1; -} ieee_double_t; - -typedef struct { - unsigned int mantissal:32; - unsigned int mantissah:32; - unsigned int exponent:15; - unsigned int sign:1; - unsigned int empty:16; -} ieee_long_double_t; - -std::string ssprintf ( const char* fmt, ... ) -{ - va_list arg; - va_start(arg, fmt); - std::string f = ssvprintf ( fmt, arg ); - va_end(arg); - return f; -} - -#define ZEROPAD 1 /* pad with zero */ -#define SIGN 2 /* unsigned/signed long */ -#define PLUS 4 /* show plus */ -#define SPACE 8 /* space if plus */ -#define LEFT 16 /* left justified */ -#define SPECIAL 32 /* 0x */ -#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */ -#define ZEROTRUNC 128 /* truncate zero 's */ - - -static int skip_atoi(const char **s) -{ - int i=0; - - while (isdigit(**s)) - i = i*10 + *((*s)++) - '0'; - return i; -} - - -static int do_div(LONGLONG *n,int base) -{ - int __res = ((ULONGLONG) *n) % (unsigned) base; - *n = ((ULONGLONG) *n) / (unsigned) base; - return __res; -} - - -static bool number(std::string& f, LONGLONG num, int base, int size, int precision ,int type) -{ - char c,sign,tmp[66]; - const char *digits="0123456789abcdefghijklmnopqrstuvwxyz"; - int i; - - if (type & LARGE) - digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - if (type & LEFT) - type &= ~ZEROPAD; - if (base < 2 || base > 36) - return 0; - c = (type & ZEROPAD) ? '0' : ' '; - sign = 0; - if (type & SIGN) { - if (num < 0) { - sign = '-'; - num = -num; - size--; - } else if (type & PLUS) { - sign = '+'; - size--; - } else if (type & SPACE) { - sign = ' '; - size--; - } - } - if (type & SPECIAL) { - if (base == 16) - size -= 2; - else if (base == 8) - size--; - } - i = 0; - if (num == 0) - tmp[i++]='0'; - else while (num != 0) - tmp[i++] = digits[do_div(&num,base)]; - if (i > precision) - precision = i; - size -= precision; - if (!(type&(ZEROPAD+LEFT))) - while(size-->0) - f += ' '; - if (sign) - f += sign; - if (type & SPECIAL) - { - if (base==8) - f += '0'; - else if (base==16) - { - f += '0'; - f += digits[33]; - } - } - if (!(type & LEFT)) - { - while (size-- > 0) - f += c; - } - while (i < precision--) - { - f += '0'; - } - while (i-- > 0) - { - f += tmp[i]; - } - while (size-- > 0) - { - f += ' '; - } - return true; -} - - -static bool numberf(std::string& f, double __n, char exp_sign, int size, int precision, int type) -{ - double exponent = 0.0; - double e; - long ie; - - //int x; - char *buf, *tmp; - int i = 0; - int j = 0; - //int k = 0; - - double frac, intr; - double p; - char sign; - char c; - char ro = 0; - int result; - - union - { - double* __n; - ieee_double_t* n; - } n; - - n.__n = &__n; - - if ( exp_sign == 'g' || exp_sign == 'G' || exp_sign == 'e' || exp_sign == 'E' ) { - ie = ((unsigned int)n.n->exponent - (unsigned int)0x3ff); - exponent = ie/3.321928; - } - - if ( exp_sign == 'g' || exp_sign == 'G' ) { - type |= ZEROTRUNC; - if ( exponent < -4 || fabs(exponent) >= precision ) - exp_sign -= 2; // g -> e and G -> E - } - - if ( exp_sign == 'e' || exp_sign == 'E' ) { - frac = modf(exponent,&e); - if ( frac > 0.5 ) - e++; - else if ( frac < -0.5 ) - e--; - - result = numberf(f,__n/pow(10.0L,e),'f',size-4, precision, type); - if (result < 0) - return false; - f += exp_sign; - size--; - ie = (long)e; - type = LEFT | PLUS; - if ( ie < 0 ) - type |= SIGN; - - result = number(f,ie, 10,2, 2,type ); - if (result < 0) - return false; - return true; - } - - if ( exp_sign == 'f' ) { - buf = (char*)alloca(4096); - if (type & LEFT) { - type &= ~ZEROPAD; - } - - c = (type & ZEROPAD) ? '0' : ' '; - sign = 0; - if (type & SIGN) { - if (__n < 0) { - sign = '-'; - __n = fabs(__n); - size--; - } else if (type & PLUS) { - sign = '+'; - size--; - } else if (type & SPACE) { - sign = ' '; - size--; - } - } - - frac = modf(__n,&intr); - - // # flags forces a . and prevents trucation of trailing zero's - - if ( precision > 0 ) { - //frac = modfl(__n,&intr); - i = precision-1; - while ( i >= 0 ) { - frac*=10.0L; - frac = modf(frac, &p); - buf[i] = (int)p + '0'; - i--; - } - i = precision; - size -= precision; - - ro = 0; - if ( frac > 0.5 ) { - ro = 1; - } - - if ( precision >= 1 || type & SPECIAL) { - buf[i++] = '.'; - size--; - } - } - - if ( intr == 0.0 ) { - buf[i++] = '0'; - size--; - } - else { - while ( intr > 0.0 ) { - p = intr; - intr/=10.0L; - modf(intr, &intr); - - p -= 10.0*intr; - - buf[i++] = (int)p + '0'; - size--; - } - } - - j = 0; - while ( j < i && ro == 1) { - if ( buf[j] >= '0' && buf[j] <= '8' ) { - buf[j]++; - ro = 0; - } - else if ( buf[j] == '9' ) { - buf[j] = '0'; - } - j++; - } - if ( ro == 1 ) - buf[i++] = '1'; - - buf[i] = 0; - - size -= precision; - if (!(type&(ZEROPAD+LEFT))) - { - while(size-->0) - f += ' '; - } - if (sign) - { - f += sign; - } - - if (!(type&(ZEROPAD+LEFT))) - while(size-->0) - { - f += ' '; - } - if (type & SPECIAL) { - } - - if (!(type & LEFT)) - while (size-- > 0) - { - f += c; - } - - tmp = buf; - if ( type & ZEROTRUNC && ((type & SPECIAL) != SPECIAL) ) - { - j = 0; - while ( j < i && ( *tmp == '0' || *tmp == '.' )) - { - tmp++; - i--; - } - } -// else -// while (i < precision--) -// putc('0', f); - while (i-- > 0) - { - f += tmp[i]; - } - while (size-- > 0) - { - f += ' '; - } - } - return true; -} - - -static bool numberfl(std::string& f, long double __n, char exp_sign, int size, int precision, int type) -{ - long double exponent = 0.0; - long double e; - long ie; - - //int x; - char *buf, *tmp; - int i = 0; - int j = 0; - //int k = 0; - - long double frac, intr; - long double p; - char sign; - char c; - char ro = 0; - - int result; - - union - { - long double* __n; - ieee_long_double_t* n; - } n; - - n.__n = &__n; - - if ( exp_sign == 'g' || exp_sign == 'G' || exp_sign == 'e' || exp_sign == 'E' ) { - ie = ((unsigned int)n.n->exponent - (unsigned int)0x3fff); - exponent = ie/3.321928; - } - - if ( exp_sign == 'g' || exp_sign == 'G' ) { - type |= ZEROTRUNC; - if ( exponent < -4 || fabs(exponent) >= precision ) - exp_sign -= 2; // g -> e and G -> E - } - - if ( exp_sign == 'e' || exp_sign == 'E' ) { - frac = modfl(exponent,&e); - if ( frac > 0.5 ) - e++; - else if ( frac < -0.5 ) - e--; - - result = numberf(f,__n/powl(10.0L,e),'f',size-4, precision, type); - if (result < 0) - return false; - f += exp_sign; - size--; - ie = (long)e; - type = LEFT | PLUS; - if ( ie < 0 ) - type |= SIGN; - - result = number(f,ie, 10,2, 2,type ); - if (result < 0) - return false; - return true; - } - - if ( exp_sign == 'f' ) - { - - buf = (char*)alloca(4096); - if (type & LEFT) - { - type &= ~ZEROPAD; - } - - c = (type & ZEROPAD) ? '0' : ' '; - sign = 0; - if (type & SIGN) - { - if (__n < 0) - { - sign = '-'; - __n = fabs(__n); - size--; - } else if (type & PLUS) - { - sign = '+'; - size--; - } else if (type & SPACE) - { - sign = ' '; - size--; - } - } - - frac = modfl(__n,&intr); - - // # flags forces a . and prevents trucation of trailing zero's - if ( precision > 0 ) - { - //frac = modfl(__n,&intr); - - i = precision-1; - while ( i >= 0 ) - { - frac*=10.0L; - frac = modfl((long double)frac, &p); - buf[i] = (int)p + '0'; - i--; - } - i = precision; - size -= precision; - - ro = 0; - if ( frac > 0.5 ) - { - ro = 1; - } - - if ( precision >= 1 || type & SPECIAL) - { - buf[i++] = '.'; - size--; - } - } - - if ( intr == 0.0 ) - { - buf[i++] = '0'; - size--; - } - else - { - while ( intr > 0.0 ) - { - p=intr; - intr/=10.0L; - modfl(intr, &intr); - - p -= 10.0L*intr; - - buf[i++] = (int)p + '0'; - size--; - } - } - - j = 0; - while ( j < i && ro == 1) { - if ( buf[j] >= '0' && buf[j] <= '8' ) - { - buf[j]++; - ro = 0; - } - else if ( buf[j] == '9' ) - { - buf[j] = '0'; - } - j++; - } - if ( ro == 1 ) - buf[i++] = '1'; - - buf[i] = 0; - - size -= precision; - if (!(type&(ZEROPAD+LEFT))) - { - while(size-->0) - f += ' '; - } - if (sign) - { - f += sign; - } - - if (!(type&(ZEROPAD+LEFT))) - { - while(size-->0) - f += ' '; - } - if (type & SPECIAL) { - } - - if (!(type & LEFT)) - while (size-- > 0) - { - f += c; - } - tmp = buf; - if ( type & ZEROTRUNC && ((type & SPECIAL) != SPECIAL) ) - { - j = 0; - while ( j < i && ( *tmp == '0' || *tmp == '.' )) - { - tmp++; - i--; - } - } -// else -// while (i < precision--) -// putc( '0', f); - while (i-- > 0) - { - f += tmp[i]; - } - while (size-- > 0) - { - f += ' '; - } - } - return true; -} - -static int stringa(std::string& f, const char* s, int len, int field_width, int precision, int flags) -{ - int i, done = 0; - if (s == NULL) - { - s = ""; - len = 6; - } - else - { - if (len == -1) - { - len = 0; - while ((unsigned int)len < (unsigned int)precision && s[len]) - len++; - } - else - { - if ((unsigned int)len > (unsigned int)precision) - len = precision; - } - } - if (!(flags & LEFT)) - while (len < field_width--) - { - f += ' '; - done++; - } - for (i = 0; i < len; ++i) - { - f += *s++; - done++; - } - while (len < field_width--) - { - f += ' '; - done++; - } - return done; -} - -static int stringw(std::string& f, const wchar_t* sw, int len, int field_width, int precision, int flags) -{ - int i, done = 0; - if (sw == NULL) - { - sw = L""; - len = 6; - } - else - { - if (len == -1) - { - len = 0; - while ((unsigned int)len < (unsigned int)precision && sw[len]) - len++; - } - else - { - if ((unsigned int)len > (unsigned int)precision) - len = precision; - } - } - if (!(flags & LEFT)) - while (len < field_width--) - { - f += ' '; - done++; - } - for (i = 0; i < len; ++i) - { -#define MY_MB_CUR_MAX 1 - char mb[MY_MB_CUR_MAX]; - int mbcount, j; - mbcount = wctomb(mb, *sw++); - if (mbcount <= 0) - { - break; - } - for (j = 0; j < mbcount; j++) - { - f += mb[j]; - done++; - } - } - while (len < field_width--) - { - f += ' '; - done++; - } - return done; -} - -#define _isnanl _isnan -#define _finitel _finite - -std::string ssvprintf ( const char *fmt, va_list args ) -{ - ULONGLONG num; - int base; - long double _ldouble; - double _double; - const char *s; - const wchar_t* sw; - int result; - std::string f; - - int flags; /* flags to number() */ - - int field_width; /* width of output field */ - int precision; /* min. # of digits for integers; max - number of chars for from string */ - int qualifier = 0; /* 'h', 'l', 'L' or 'I64' for integer fields */ - - for (; *fmt ; ++fmt) - { - if (*fmt != '%') - { - f += *fmt; - continue; - } - - /* process flags */ - flags = 0; - repeat: - ++fmt; /* this also skips first '%' */ - switch (*fmt) { - case '-': flags |= LEFT; goto repeat; - case '+': flags |= PLUS; goto repeat; - case ' ': flags |= SPACE; goto repeat; - case '#': flags |= SPECIAL; goto repeat; - case '0': flags |= ZEROPAD; goto repeat; - } - - /* get field width */ - field_width = -1; - if (isdigit(*fmt)) - field_width = skip_atoi(&fmt); - else if (*fmt == '*') { - ++fmt; - /* it's the next argument */ - field_width = va_arg(args, int); - if (field_width < 0) { - field_width = -field_width; - flags |= LEFT; - } - } - - /* get the precision */ - precision = -1; - if (*fmt == '.') { - ++fmt; - if (isdigit(*fmt)) - precision = skip_atoi(&fmt); - else if (*fmt == '*') { - ++fmt; - /* it's the next argument */ - precision = va_arg(args, int); - } - if (precision < 0) - precision = 0; - } - - /* get the conversion qualifier */ - qualifier = 0; - // %Z can be just stand alone or as size_t qualifier - if ( *fmt == 'Z' ) { - qualifier = *fmt; - switch ( *(fmt+1)) { - case 'o': - case 'b': - case 'X': - case 'x': - case 'd': - case 'i': - case 'u': - ++fmt; - break; - default: - break; - } - } else if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || *fmt == 'w') { - qualifier = *fmt; - ++fmt; - } else if (*fmt == 'I' && *(fmt+1) == '6' && *(fmt+2) == '4') { - qualifier = *fmt; - fmt += 3; - } - - // go fine with ll instead of L - if ( *fmt == 'l' ) { - ++fmt; - qualifier = 'L'; - } - - /* default base */ - base = 10; - - switch (*fmt) { - case 'c': - if (!(flags & LEFT)) - while (--field_width > 0) - { - f += ' '; - } - if (qualifier == 'l' || qualifier == 'w') - { - f += (char)(unsigned char)(wchar_t) va_arg(args,int); - } - else - { - f += (char)(unsigned char) va_arg(args,int); - } - while (--field_width > 0) - { - f += ' '; - } - continue; - - case 'C': - if (!(flags & LEFT)) - while (--field_width > 0) - { - f += ' '; - } - if (qualifier == 'h') - { - f += (char)(unsigned char) va_arg(args,int); - } - else - { - f += (char)(unsigned char)(wchar_t) va_arg(args,int); - } - while (--field_width > 0) - { - f += ' '; - } - continue; - - case 's': - if (qualifier == 'l' || qualifier == 'w') { - /* print unicode string */ - sw = (const wchar_t*)va_arg(args, wchar_t *); - result = stringw(f, sw, -1, field_width, precision, flags); - } else { - /* print ascii string */ - s = va_arg(args, char *); - result = stringa(f, s, -1, field_width, precision, flags); - } - if (result < 0) - { - assert(!"TODO FIXME handle error better"); - return f; - } - continue; - - case 'S': - if (qualifier == 'h') { - /* print ascii string */ - s = va_arg(args, char *); - result = stringa(f, s, -1, field_width, precision, flags); - } else { - /* print unicode string */ - sw = (const wchar_t*)va_arg(args, wchar_t *); - result = stringw(f, sw, -1, field_width, precision, flags); - } - if (result < 0) - { - assert(!"TODO FIXME handle error better"); - return f; - } - continue; - - /*case 'Z': - if (qualifier == 'w') { - // print counted unicode string - PUNICODE_STRING pus = va_arg(args, PUNICODE_STRING); - if ((pus == NULL) || (pus->Buffer == NULL)) { - sw = NULL; - len = -1; - } else { - sw = pus->Buffer; - len = pus->Length / sizeof(WCHAR); - } - result = stringw(f, sw, len, field_width, precision, flags); - } else { - // print counted ascii string - PANSI_STRING pas = va_arg(args, PANSI_STRING); - if ((pas == NULL) || (pas->Buffer == NULL)) { - s = NULL; - len = -1; - } else { - s = pas->Buffer; - len = pas->Length; - } - result = stringa(f, s, -1, field_width, precision, flags); - } - if (result < 0) - return -1; - continue;*/ - - case 'e': - case 'E': - case 'f': - case 'g': - case 'G': - if (qualifier == 'l' || qualifier == 'L' ) { - _ldouble = va_arg(args, long double); - - if ( _isnanl(_ldouble) ) - { - f += "Nan"; - } - else if ( !_finitel(_ldouble) ) - { - if ( _ldouble < 0 ) - f += "-Inf"; - else - f += "+Inf"; - } else { - if ( precision == -1 ) - precision = 6; - result = numberfl(f,_ldouble,*fmt,field_width,precision,flags); - if (result < 0) - { - assert(!"TODO FIXME handle error better"); - return f; - } - } - } else { - _double = (double)va_arg(args, double); - - if ( _isnan(_double) ) - { - f += "Nan"; - } - else if ( !_finite(_double) ) - { - if ( _double < 0 ) - f += "-Inf"; - else - f += "+Inf"; - } - else - { - if ( precision == -1 ) - precision = 6; - result = numberf(f,_double,*fmt,field_width,precision,flags); - if (result < 0) - { - assert(!"TODO FIXME handle error better"); - return f; - } - } - } - continue; - - case 'p': - if (field_width == -1) { - field_width = 2*sizeof(void *); - flags |= ZEROPAD; - } - result = number(f, - (unsigned long) va_arg(args, void *), 16, - field_width, precision, flags); - if (result < 0) - { - assert(!"TODO FIXME handle error better"); - return f; - } - continue; - - case 'n': - if (qualifier == 'l') { - long * ip = va_arg(args, long *); - *ip = 0; - } else { - int * ip = va_arg(args, int *); - *ip = 0; - } - continue; - - /* integer number formats - set up the flags and "break" */ - case 'o': - base = 8; - break; - - case 'b': - base = 2; - break; - - case 'X': - flags |= LARGE; - case 'x': - base = 16; - break; - - case 'd': - case 'i': - flags |= SIGN; - case 'u': - break; - - default: - if (*fmt != '%') - { - f += '%'; - } - if (*fmt) - { - f += *fmt; - } - else - --fmt; - continue; - } - - if (qualifier == 'I') - num = va_arg(args, ULONGLONG); - else if (qualifier == 'l') { - if (flags & SIGN) - num = va_arg(args, long); - else - num = va_arg(args, unsigned long); - } - else if (qualifier == 'h') { - if (flags & SIGN) - num = va_arg(args, int); - else - num = va_arg(args, unsigned int); - } - else if (flags & SIGN) - num = va_arg(args, int); - else - num = va_arg(args, unsigned int); - result = number(f, num, base, field_width, precision, flags); - if (result < 0) - { - assert(!"TODO FIXME handle error better"); - return f; - } - } - //putc('\0',f); - return f; -} diff --git a/irc/ArchBlackmann/ssprintf.h b/irc/ArchBlackmann/ssprintf.h deleted file mode 100644 index aa04411a1e5..00000000000 --- a/irc/ArchBlackmann/ssprintf.h +++ /dev/null @@ -1,12 +0,0 @@ -// ssprintf.h - -#ifndef SSPRINTF_H -#define SSPRINTF_H - -#include -#include - -std::string ssprintf ( const char* fmt, ... ); -std::string ssvprintf ( const char* fmt, va_list args ); - -#endif//SSPRINTF_H diff --git a/irc/ArchBlackmann/status.txt b/irc/ArchBlackmann/status.txt deleted file mode 100644 index a883e41ad36..00000000000 --- a/irc/ArchBlackmann/status.txt +++ /dev/null @@ -1,654 +0,0 @@ -RPC_NT_ALREADY_LISTENING -RPC_NT_ALREADY_REGISTERED -RPC_NT_CALL_FAILED -RPC_NT_CALL_FAILED_DNE -RPC_NT_CANT_CREATE_ENDPOINT -RPC_NT_INVALID_BINDING -RPC_NT_INVALID_ENDPOINT_FORMAT -RPC_NT_INVALID_NETWORK_OPTIONS -RPC_NT_INVALID_NET_ADDR -RPC_NT_INVALID_RPC_PROTSEQ -RPC_NT_INVALID_STRING_BINDING -RPC_NT_INVALID_STRING_UUID -RPC_NT_INVALID_TIMEOUT -RPC_NT_NOT_LISTENING -RPC_NT_NO_BINDINGS -RPC_NT_NO_CALL_ACTIVE -RPC_NT_NO_ENDPOINT_FOUND -RPC_NT_NO_PROTSEQS -RPC_NT_NO_PROTSEQS_REGISTERED -RPC_NT_OBJECT_NOT_FOUND -RPC_NT_OUT_OF_RESOURCES -RPC_NT_PROTOCOL_ERROR -RPC_NT_PROTSEQ_NOT_SUPPORTED -RPC_NT_SERVER_TOO_BUSY -RPC_NT_SERVER_UNAVAILABLE -RPC_NT_SS_IN_NULL_CONTEXT -RPC_NT_TYPE_ALREADY_REGISTERED -RPC_NT_UNKNOWN_IF -RPC_NT_UNKNOWN_MGR_TYPE -RPC_NT_WRONG_KIND_OF_BINDING -STATUS_ABANDONED -STATUS_ABANDONED_WAIT_0 -STATUS_ABANDONED_WAIT_63 -STATUS_ABIOS_INVALID_COMMAND -STATUS_ABIOS_INVALID_LID -STATUS_ABIOS_INVALID_SELECTOR -STATUS_ABIOS_LID_ALREADY_OWNED -STATUS_ABIOS_LID_NOT_EXIST -STATUS_ABIOS_NOT_LID_OWNER -STATUS_ABIOS_NOT_PRESENT -STATUS_ABIOS_SELECTOR_NOT_AVAILABLE -STATUS_ACCESS_DENIED -STATUS_ACCESS_VIOLATION -STATUS_ACCOUNT_DISABLED -STATUS_ACCOUNT_EXPIRED -STATUS_ACCOUNT_LOCKED_OUT -STATUS_ACCOUNT_RESTRICTION -STATUS_ADAPTER_HARDWARE_ERROR -STATUS_ADDRESS_ALREADY_ASSOCIATED -STATUS_ADDRESS_ALREADY_EXISTS -STATUS_ADDRESS_CLOSED -STATUS_ADDRESS_NOT_ASSOCIATED -STATUS_AGENTS_EXHAUSTED -STATUS_ALERTED -STATUS_ALIAS_EXISTS -STATUS_ALLOCATE_BUCKET -STATUS_ALLOTTED_SPACE_EXCEEDED -STATUS_ALREADY_COMMITTED -STATUS_ALREADY_DISCONNECTED -STATUS_ALREADY_WIN32 -STATUS_APP_INIT_FAILURE -STATUS_ARBITRATION_UNHANDLED -STATUS_ARRAY_BOUNDS_EXCEEDED -STATUS_AUDIT_FAILED -STATUS_BACKUP_CONTROLLER -STATUS_BAD_COMPRESSION_BUFFER -STATUS_BAD_CURRENT_DIRECTORY -STATUS_BAD_DESCRIPTOR_FORMAT -STATUS_BAD_DEVICE_TYPE -STATUS_BAD_DLL_ENTRYPOINT -STATUS_BAD_FUNCTION_TABLE -STATUS_BAD_IMPERSONATION_LEVEL -STATUS_BAD_INHERITANCE_ACL -STATUS_BAD_INITIAL_PC -STATUS_BAD_INITIAL_STACK -STATUS_BAD_LOGON_SESSION_STATE -STATUS_BAD_MASTER_BOOT_RECORD -STATUS_BAD_NETWORK_NAME -STATUS_BAD_NETWORK_PATH -STATUS_BAD_REMOTE_ADAPTER -STATUS_BAD_SERVICE_ENTRYPOINT -STATUS_BAD_STACK -STATUS_BAD_TOKEN_TYPE -STATUS_BAD_VALIDATION_CLASS -STATUS_BAD_WORKING_SET_LIMIT -STATUS_BEGINNING_OF_MEDIA -STATUS_BIOS_FAILED_TO_CONNECT_INTERRUPT -STATUS_BREAKPOINT -STATUS_BUFFER_OVERFLOW -STATUS_BUFFER_TOO_SMALL -STATUS_BUS_RESET -STATUS_CANCELLED -STATUS_CANNOT_DELETE -STATUS_CANNOT_IMPERSONATE -STATUS_CANNOT_LOAD_REGISTRY_FILE -STATUS_CANT_ACCESS_DOMAIN_INFO -STATUS_CANT_DISABLE_MANDATORY -STATUS_CANT_OPEN_ANONYMOUS -STATUS_CANT_TERMINATE_SELF -STATUS_CANT_WAIT -STATUS_CARDBUS_NOT_SUPPORTED -STATUS_CHECKING_FILE_SYSTEM -STATUS_CHILD_MUST_BE_VOLATILE -STATUS_CLIENT_SERVER_PARAMETERS_INVALID -STATUS_COMMITMENT_LIMIT -STATUS_CONFLICTING_ADDRESSES -STATUS_CONNECTION_ABORTED -STATUS_CONNECTION_ACTIVE -STATUS_CONNECTION_COUNT_LIMIT -STATUS_CONNECTION_DISCONNECTED -STATUS_CONNECTION_INVALID -STATUS_CONNECTION_IN_USE -STATUS_CONNECTION_REFUSED -STATUS_CONNECTION_RESET -STATUS_CONTROL_C_EXIT -STATUS_CONVERT_TO_LARGE -STATUS_COULD_NOT_INTERPRET -STATUS_CRC_ERROR -STATUS_CTL_FILE_NOT_SUPPORTED -STATUS_DATATYPE_MISALIGNMENT -STATUS_DATA_ERROR -STATUS_DATA_LATE_ERROR -STATUS_DATA_NOT_ACCEPTED -STATUS_DATA_OVERRUN -STATUS_DEBUG_ATTACH_FAILED -STATUS_DELETE_PENDING -STATUS_DEVICE_ALREADY_ATTACHED -STATUS_DEVICE_BUSY -STATUS_DEVICE_CONFIGURATION_ERROR -STATUS_DEVICE_DATA_ERROR -STATUS_DEVICE_DOES_NOT_EXIST -STATUS_DEVICE_NOT_CONNECTED -STATUS_DEVICE_NOT_PARTITIONED -STATUS_DEVICE_NOT_READY -STATUS_DEVICE_OFF_LINE -STATUS_DEVICE_PAPER_EMPTY -STATUS_DEVICE_POWERED_OFF -STATUS_DEVICE_POWER_FAILURE -STATUS_DEVICE_PROTOCOL_ERROR -STATUS_DFS_EXIT_PATH_FOUND -STATUS_DFS_UNAVAILABLE -STATUS_DIRECTORY_NOT_EMPTY -STATUS_DISK_CORRUPT_ERROR -STATUS_DISK_FULL -STATUS_DISK_OPERATION_FAILED -STATUS_DISK_RECALIBRATE_FAILED -STATUS_DISK_RESET_FAILED -STATUS_DLL_INIT_FAILED -STATUS_DLL_INIT_FAILED_LOGOFF -STATUS_DLL_NOT_FOUND -STATUS_DOMAIN_CONTROLLER_NOT_FOUND -STATUS_DOMAIN_CTRLR_CONFIG_ERROR -STATUS_DOMAIN_EXISTS -STATUS_DOMAIN_LIMIT_EXCEEDED -STATUS_DOMAIN_TRUST_INCONSISTENT -STATUS_DRIVER_CANCEL_TIMEOUT -STATUS_DRIVER_ENTRYPOINT_NOT_FOUND -STATUS_DRIVER_INTERNAL_ERROR -STATUS_DRIVER_ORDINAL_NOT_FOUND -STATUS_DRIVER_UNABLE_TO_LOAD -STATUS_DUPLICATE_NAME -STATUS_DUPLICATE_OBJECTID -STATUS_EAS_NOT_SUPPORTED -STATUS_EA_CORRUPT_ERROR -STATUS_EA_LIST_INCONSISTENT -STATUS_EA_TOO_LARGE -STATUS_END_OF_FILE -STATUS_END_OF_MEDIA -STATUS_ENTRYPOINT_NOT_FOUND -STATUS_EOM_OVERFLOW -STATUS_EVALUATION_EXPIRATION -STATUS_EVENTLOG_CANT_START -STATUS_EVENTLOG_FILE_CHANGED -STATUS_EVENTLOG_FILE_CORRUPT -STATUS_EVENT_DONE -STATUS_EVENT_PENDING -STATUS_EXTRANEOUS_INFORMATION -STATUS_FAIL_CHECK -STATUS_FATAL_APP_EXIT -STATUS_FILEMARK_DETECTED -STATUS_FILES_OPEN -STATUS_FILE_CLOSED -STATUS_FILE_CORRUPT_ERROR -STATUS_FILE_DELETED -STATUS_FILE_FORCED_CLOSED -STATUS_FILE_INVALID -STATUS_FILE_IS_A_DIRECTORY -STATUS_FILE_IS_OFFLINE -STATUS_FILE_LOCK_CONFLICT -STATUS_FILE_RENAMED -STATUS_FLOAT_DENORMAL_OPERAND -STATUS_FLOAT_DIVIDE_BY_ZERO -STATUS_FLOAT_INEXACT_RESULT -STATUS_FLOAT_INVALID_OPERATION -STATUS_FLOAT_OVERFLOW -STATUS_FLOAT_STACK_CHECK -STATUS_FLOAT_UNDERFLOW -STATUS_FLOPPY_BAD_REGISTERS -STATUS_FLOPPY_ID_MARK_NOT_FOUND -STATUS_FLOPPY_UNKNOWN_ERROR -STATUS_FLOPPY_VOLUME -STATUS_FLOPPY_WRONG_CYLINDER -STATUS_FOUND_OUT_OF_SCOPE -STATUS_FREE_VM_NOT_AT_BASE -STATUS_FS_DRIVER_REQUIRED -STATUS_FT_MISSING_MEMBER -STATUS_FT_ORPHANING -STATUS_FT_READ_RECOVERING_FROM_BACKUP -STATUS_FT_WRITE_RECOVERY -STATUS_FULLSCREEN_MODE -STATUS_GENERIC_NOT_MAPPED -STATUS_GRACEFUL_DISCONNECT -STATUS_GROUP_EXISTS -STATUS_GUARD_PAGE_VIOLATION -STATUS_GUIDS_EXHAUSTED -STATUS_GUID_SUBSTITUTION_MADE -STATUS_HANDLES_CLOSED -STATUS_HANDLE_NOT_CLOSABLE -STATUS_HOST_UNREACHABLE -STATUS_ILLEGAL_CHARACTER -STATUS_ILLEGAL_DLL_RELOCATION -STATUS_ILLEGAL_FLOAT_CONTEXT -STATUS_ILLEGAL_FUNCTION -STATUS_ILLEGAL_INSTRUCTION -STATUS_ILL_FORMED_PASSWORD -STATUS_ILL_FORMED_SERVICE_ENTRY -STATUS_IMAGE_ALREADY_LOADED -STATUS_IMAGE_CHECKSUM_MISMATCH -STATUS_IMAGE_MACHINE_TYPE_MISMATCH -STATUS_IMAGE_MACHINE_TYPE_MISMATCH_EXE -STATUS_IMAGE_MP_UP_MISMATCH -STATUS_IMAGE_NOT_AT_BASE -STATUS_INCOMPATIBLE_FILE_MAP -STATUS_INFO_LENGTH_MISMATCH -STATUS_INSTANCE_NOT_AVAILABLE -STATUS_INSTRUCTION_MISALIGNMENT -STATUS_INSUFFICIENT_LOGON_INFO -STATUS_INSUFFICIENT_RESOURCES -STATUS_INSUFF_SERVER_RESOURCES -STATUS_INTEGER_DIVIDE_BY_ZERO -STATUS_INTEGER_OVERFLOW -STATUS_INTERNAL_DB_CORRUPTION -STATUS_INTERNAL_DB_ERROR -STATUS_INTERNAL_ERROR -STATUS_INVALID_ACCOUNT_NAME -STATUS_INVALID_ACL -STATUS_INVALID_ADDRESS -STATUS_INVALID_ADDRESS_COMPONENT -STATUS_INVALID_ADDRESS_WILDCARD -STATUS_INVALID_BLOCK_LENGTH -STATUS_INVALID_BUFFER_SIZE -STATUS_INVALID_CID -STATUS_INVALID_COMPUTER_NAME -STATUS_INVALID_CONNECTION -STATUS_INVALID_DEVICE_REQUEST -STATUS_INVALID_DEVICE_STATE -STATUS_INVALID_DISPOSITION -STATUS_INVALID_DOMAIN_ROLE -STATUS_INVALID_DOMAIN_STATE -STATUS_INVALID_EA_FLAG -STATUS_INVALID_EA_NAME -STATUS_INVALID_FILE_FOR_SECTION -STATUS_INVALID_GROUP_ATTRIBUTES -STATUS_INVALID_HANDLE -STATUS_INVALID_HW_PROFILE -STATUS_INVALID_ID_AUTHORITY -STATUS_INVALID_IMAGE_FORMAT -STATUS_INVALID_IMAGE_LE_FORMAT -STATUS_INVALID_IMAGE_NE_FORMAT -STATUS_INVALID_IMAGE_NOT_MZ -STATUS_INVALID_IMAGE_PROTECT -STATUS_INVALID_IMAGE_WIN_16 -STATUS_INVALID_INFO_CLASS -STATUS_INVALID_LDT_DESCRIPTOR -STATUS_INVALID_LDT_OFFSET -STATUS_INVALID_LDT_SIZE -STATUS_INVALID_LEVEL -STATUS_INVALID_LOCK_SEQUENCE -STATUS_INVALID_LOGON_HOURS -STATUS_INVALID_LOGON_TYPE -STATUS_INVALID_MEMBER -STATUS_INVALID_NETWORK_RESPONSE -STATUS_INVALID_OPLOCK_PROTOCOL -STATUS_INVALID_OWNER -STATUS_INVALID_PAGE_PROTECTION -STATUS_INVALID_PARAMETER -STATUS_INVALID_PARAMETER_1 -STATUS_INVALID_PARAMETER_10 -STATUS_INVALID_PARAMETER_11 -STATUS_INVALID_PARAMETER_12 -STATUS_INVALID_PARAMETER_2 -STATUS_INVALID_PARAMETER_3 -STATUS_INVALID_PARAMETER_4 -STATUS_INVALID_PARAMETER_5 -STATUS_INVALID_PARAMETER_6 -STATUS_INVALID_PARAMETER_7 -STATUS_INVALID_PARAMETER_8 -STATUS_INVALID_PARAMETER_9 -STATUS_INVALID_PARAMETER_MIX -STATUS_INVALID_PIPE_STATE -STATUS_INVALID_PLUGPLAY_DEVICE_PATH -STATUS_INVALID_PORT_ATTRIBUTES -STATUS_INVALID_PORT_HANDLE -STATUS_INVALID_PRIMARY_GROUP -STATUS_INVALID_QUOTA_LOWER -STATUS_INVALID_READ_MODE -STATUS_INVALID_SECURITY_DESCR -STATUS_INVALID_SERVER_STATE -STATUS_INVALID_SID -STATUS_INVALID_SUB_AUTHORITY -STATUS_INVALID_SYSTEM_SERVICE -STATUS_INVALID_UNWIND_TARGET -STATUS_INVALID_USER_BUFFER -STATUS_INVALID_VARIANT -STATUS_INVALID_VIEW_SIZE -STATUS_INVALID_VLM_OPERATION -STATUS_INVALID_VOLUME_LABEL -STATUS_INVALID_WORKSTATION -STATUS_IN_PAGE_ERROR -STATUS_IO_DEVICE_ERROR -STATUS_IO_PRIVILEGE_FAILED -STATUS_IO_REPARSE_DATA_INVALID -STATUS_IO_REPARSE_TAG_INVALID -STATUS_IO_REPARSE_TAG_MISMATCH -STATUS_IO_REPARSE_TAG_NOT_HANDLED -STATUS_IO_TIMEOUT -STATUS_IP_ADDRESS_CONFLICT1 -STATUS_IP_ADDRESS_CONFLICT2 -STATUS_KERNEL_APC -STATUS_KEY_DELETED -STATUS_KEY_HAS_CHILDREN -STATUS_LAST_ADMIN -STATUS_LICENSE_QUOTA_EXCEEDED -STATUS_LICENSE_VIOLATION -STATUS_LINK_FAILED -STATUS_LINK_TIMEOUT -STATUS_LM_CROSS_ENCRYPTION_REQUIRED -STATUS_LOCAL_DISCONNECT -STATUS_LOCAL_USER_SESSION_KEY -STATUS_LOCK_NOT_GRANTED -STATUS_LOGIN_TIME_RESTRICTION -STATUS_LOGIN_WKSTA_RESTRICTION -STATUS_LOGON_FAILURE -STATUS_LOGON_NOT_GRANTED -STATUS_LOGON_SERVER_CONFLICT -STATUS_LOGON_SESSION_COLLISION -STATUS_LOGON_SESSION_EXISTS -STATUS_LOGON_TYPE_NOT_GRANTED -STATUS_LOG_FILE_FULL -STATUS_LOG_HARD_ERROR -STATUS_LONGJUMP -STATUS_LOST_WRITEBEHIND_DATA -STATUS_LPC_REPLY_LOST -STATUS_LUIDS_EXHAUSTED -STATUS_MAPPED_ALIGNMENT -STATUS_MAPPED_FILE_SIZE_ZERO -STATUS_MARSHALL_OVERFLOW -STATUS_MEDIA_CHANGED -STATUS_MEDIA_CHECK -STATUS_MEDIA_WRITE_PROTECTED -STATUS_MEMBERS_PRIMARY_GROUP -STATUS_MEMBER_IN_ALIAS -STATUS_MEMBER_IN_GROUP -STATUS_MEMBER_NOT_IN_ALIAS -STATUS_MEMBER_NOT_IN_GROUP -STATUS_MEMORY_NOT_ALLOCATED -STATUS_MESSAGE_NOT_FOUND -STATUS_MISSING_SYSTEMFILE -STATUS_MORE_ENTRIES -STATUS_MORE_PROCESSING_REQUIRED -STATUS_MUTANT_LIMIT_EXCEEDED -STATUS_MUTANT_NOT_OWNED -STATUS_NAME_TOO_LONG -STATUS_NETLOGON_NOT_STARTED -STATUS_NETWORK_ACCESS_DENIED -STATUS_NETWORK_BUSY -STATUS_NETWORK_CREDENTIAL_CONFLICT -STATUS_NETWORK_NAME_DELETED -STATUS_NETWORK_UNREACHABLE -STATUS_NET_WRITE_FAULT -STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT -STATUS_NOLOGON_SERVER_TRUST_ACCOUNT -STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT -STATUS_NONCONTINUABLE_EXCEPTION -STATUS_NONEXISTENT_EA_ENTRY -STATUS_NONEXISTENT_SECTOR -STATUS_NONE_MAPPED -STATUS_NOTIFY_CLEANUP -STATUS_NOTIFY_ENUM_DIR -STATUS_NOT_ALL_ASSIGNED -STATUS_NOT_A_DIRECTORY -STATUS_NOT_A_REPARSE_POINT -STATUS_NOT_CLIENT_SESSION -STATUS_NOT_COMMITTED -STATUS_NOT_FOUND -STATUS_NOT_IMPLEMENTED -STATUS_NOT_LOCKED -STATUS_NOT_LOGON_PROCESS -STATUS_NOT_MAPPED_DATA -STATUS_NOT_MAPPED_VIEW -STATUS_NOT_REGISTRY_FILE -STATUS_NOT_SAME_DEVICE -STATUS_NOT_SERVER_SESSION -STATUS_NOT_SUPPORTED -STATUS_NOT_TINY_STREAM -STATUS_NO_BROWSER_SERVERS_FOUND -STATUS_NO_CALLBACK_ACTIVE -STATUS_NO_DATA_DETECTED -STATUS_NO_EAS_ON_FILE -STATUS_NO_EVENT_PAIR -STATUS_NO_GUID_TRANSLATION -STATUS_NO_IMPERSONATION_TOKEN -STATUS_NO_INHERITANCE -STATUS_NO_LDT -STATUS_NO_LOGON_SERVERS -STATUS_NO_LOG_SPACE -STATUS_NO_MATCH -STATUS_NO_MEDIA -STATUS_NO_MEDIA_IN_DEVICE -STATUS_NO_MEMORY -STATUS_NO_MORE_EAS -STATUS_NO_MORE_ENTRIES -STATUS_NO_MORE_FILES -STATUS_NO_MORE_MATCHES -STATUS_NO_PAGEFILE -STATUS_NO_QUOTAS_NO_ACCOUNT -STATUS_NO_SECURITY_ON_OBJECT -STATUS_NO_SPOOL_SPACE -STATUS_NO_SUCH_ALIAS -STATUS_NO_SUCH_DEVICE -STATUS_NO_SUCH_DOMAIN -STATUS_NO_SUCH_FILE -STATUS_NO_SUCH_GROUP -STATUS_NO_SUCH_LOGON_SESSION -STATUS_NO_SUCH_MEMBER -STATUS_NO_SUCH_PACKAGE -STATUS_NO_SUCH_PRIVILEGE -STATUS_NO_SUCH_USER -STATUS_NO_TOKEN -STATUS_NO_TRUST_LSA_SECRET -STATUS_NO_TRUST_SAM_ACCOUNT -STATUS_NO_USER_SESSION_KEY -STATUS_NO_YIELD_PERFORMED -STATUS_NT_CROSS_ENCRYPTION_REQUIRED -STATUS_NULL_LM_PASSWORD -STATUS_OBJECTID_EXISTS -STATUS_OBJECT_EXISTS -STATUS_OBJECT_NAME_COLLISION -STATUS_OBJECT_NAME_EXISTS -STATUS_OBJECT_NAME_INVALID -STATUS_OBJECT_NAME_NOT_FOUND -STATUS_OBJECT_PATH_INVALID -STATUS_OBJECT_PATH_NOT_FOUND -STATUS_OBJECT_PATH_SYNTAX_BAD -STATUS_OBJECT_TYPE_MISMATCH -STATUS_OPEN_FAILED -STATUS_OPLOCK_BREAK_IN_PROCESS -STATUS_OPLOCK_NOT_GRANTED -STATUS_ORDINAL_NOT_FOUND -STATUS_PAGEFILE_CREATE_FAILED -STATUS_PAGEFILE_QUOTA -STATUS_PAGEFILE_QUOTA_EXCEEDED -STATUS_PARITY_ERROR -STATUS_PARTIAL_COPY -STATUS_PARTITION_FAILURE -STATUS_PASSWORD_EXPIRED -STATUS_PASSWORD_MUST_CHANGE -STATUS_PASSWORD_RESTRICTION -STATUS_PATH_NOT_COVERED -STATUS_PENDING -STATUS_PIPE_BROKEN -STATUS_PIPE_BUSY -STATUS_PIPE_CLOSING -STATUS_PIPE_CONNECTED -STATUS_PIPE_DISCONNECTED -STATUS_PIPE_EMPTY -STATUS_PIPE_LISTENING -STATUS_PIPE_NOT_AVAILABLE -STATUS_PLUGPLAY_NO_DEVICE -STATUS_PORT_ALREADY_SET -STATUS_PORT_CONNECTION_REFUSED -STATUS_PORT_DISCONNECTED -STATUS_PORT_MESSAGE_TOO_LONG -STATUS_PORT_UNREACHABLE -STATUS_POSSIBLE_DEADLOCK -STATUS_PREDEFINED_HANDLE -STATUS_PRIMARY_TRANSPORT_CONNECT_FAILED -STATUS_PRINT_CANCELLED -STATUS_PRINT_QUEUE_FULL -STATUS_PRIVILEGED_INSTRUCTION -STATUS_PRIVILEGE_NOT_HELD -STATUS_PROCEDURE_NOT_FOUND -STATUS_PROCESS_IN_JOB -STATUS_PROCESS_IS_TERMINATING -STATUS_PROCESS_NOT_IN_JOB -STATUS_PROFILING_AT_LIMIT -STATUS_PROFILING_NOT_STARTED -STATUS_PROFILING_NOT_STOPPED -STATUS_PROPSET_NOT_FOUND -STATUS_PROTOCOL_UNREACHABLE -STATUS_PWD_HISTORY_CONFLICT -STATUS_PWD_TOO_RECENT -STATUS_PWD_TOO_SHORT -STATUS_QUOTA_EXCEEDED -STATUS_QUOTA_LIST_INCONSISTENT -STATUS_RANGE_LIST_CONFLICT -STATUS_RANGE_NOT_FOUND -STATUS_RANGE_NOT_LOCKED -STATUS_RECEIVE_EXPEDITED -STATUS_RECEIVE_PARTIAL -STATUS_RECEIVE_PARTIAL_EXPEDITED -STATUS_RECOVERY_FAILURE -STATUS_REDIRECTOR_HAS_OPEN_HANDLES -STATUS_REDIRECTOR_NOT_STARTED -STATUS_REDIRECTOR_PAUSED -STATUS_REDIRECTOR_STARTED -STATUS_REGISTRY_CORRUPT -STATUS_REGISTRY_IO_FAILED -STATUS_REGISTRY_QUOTA_LIMIT -STATUS_REGISTRY_RECOVERED -STATUS_REMOTE_DISCONNECT -STATUS_REMOTE_NOT_LISTENING -STATUS_REMOTE_RESOURCES -STATUS_REMOTE_SESSION_LIMIT -STATUS_REPARSE -STATUS_REPLY_MESSAGE_MISMATCH -STATUS_REQUEST_ABORTED -STATUS_REQUEST_NOT_ACCEPTED -STATUS_RESOURCE_DATA_NOT_FOUND -STATUS_RESOURCE_LANG_NOT_FOUND -STATUS_RESOURCE_NAME_NOT_FOUND -STATUS_RESOURCE_NOT_OWNED -STATUS_RESOURCE_TYPE_NOT_FOUND -STATUS_RETRY -STATUS_REVISION_MISMATCH -STATUS_RXACT_COMMITTED -STATUS_RXACT_COMMIT_FAILURE -STATUS_RXACT_COMMIT_NECESSARY -STATUS_RXACT_INVALID_STATE -STATUS_RXACT_STATE_CREATED -STATUS_SAM_INIT_FAILURE -STATUS_SECRET_TOO_LONG -STATUS_SECTION_NOT_EXTENDED -STATUS_SECTION_NOT_IMAGE -STATUS_SECTION_PROTECTION -STATUS_SECTION_TOO_BIG -STATUS_SEGMENT_NOTIFICATION -STATUS_SEMAPHORE_LIMIT_EXCEEDED -STATUS_SERIAL_COUNTER_TIMEOUT -STATUS_SERIAL_MORE_WRITES -STATUS_SERIAL_NO_DEVICE_INITED -STATUS_SERVER_DISABLED -STATUS_SERVER_HAS_OPEN_HANDLES -STATUS_SERVER_NOT_DISABLED -STATUS_SERVICE_NOTIFICATION -STATUS_SETMARK_DETECTED -STATUS_SHARED_IRQ_BUSY -STATUS_SHARING_PAUSED -STATUS_SHARING_VIOLATION -STATUS_SINGLE_STEP -STATUS_SOME_NOT_MAPPED -STATUS_SPECIAL_ACCOUNT -STATUS_SPECIAL_GROUP -STATUS_SPECIAL_USER -STATUS_STACK_OVERFLOW -STATUS_STACK_OVERFLOW_READ -STATUS_SUCCESS -STATUS_SUSPEND_COUNT_EXCEEDED -STATUS_SYNCHRONIZATION_REQUIRED -STATUS_SYSTEM_PROCESS_TERMINATED -STATUS_THREAD_IS_TERMINATING -STATUS_THREAD_NOT_IN_PROCESS -STATUS_THREAD_WAS_SUSPENDED -STATUS_TIMEOUT -STATUS_TIMER_NOT_CANCELED -STATUS_TIMER_RESOLUTION_NOT_SET -STATUS_TIMER_RESUME_IGNORED -STATUS_TIME_DIFFERENCE_AT_DC -STATUS_TOKEN_ALREADY_IN_USE -STATUS_TOO_LATE -STATUS_TOO_MANY_ADDRESSES -STATUS_TOO_MANY_COMMANDS -STATUS_TOO_MANY_CONTEXT_IDS -STATUS_TOO_MANY_GUIDS_REQUESTED -STATUS_TOO_MANY_LINKS -STATUS_TOO_MANY_LUIDS_REQUESTED -STATUS_TOO_MANY_NAMES -STATUS_TOO_MANY_NODES -STATUS_TOO_MANY_OPENED_FILES -STATUS_TOO_MANY_PAGING_FILES -STATUS_TOO_MANY_SECRETS -STATUS_TOO_MANY_SESSIONS -STATUS_TOO_MANY_SIDS -STATUS_TOO_MANY_THREADS -STATUS_TRANSACTION_ABORTED -STATUS_TRANSACTION_INVALID_ID -STATUS_TRANSACTION_INVALID_TYPE -STATUS_TRANSACTION_NO_MATCH -STATUS_TRANSACTION_NO_RELEASE -STATUS_TRANSACTION_RESPONDED -STATUS_TRANSACTION_TIMED_OUT -STATUS_TRUSTED_DOMAIN_FAILURE -STATUS_TRUSTED_RELATIONSHIP_FAILURE -STATUS_TRUST_FAILURE -STATUS_UNABLE_TO_DECOMMIT_VM -STATUS_UNABLE_TO_DELETE_SECTION -STATUS_UNABLE_TO_FREE_VM -STATUS_UNABLE_TO_LOCK_MEDIA -STATUS_UNABLE_TO_UNLOAD_MEDIA -STATUS_UNDEFINED_CHARACTER -STATUS_UNEXPECTED_IO_ERROR -STATUS_UNEXPECTED_MM_CREATE_ERR -STATUS_UNEXPECTED_MM_EXTEND_ERR -STATUS_UNEXPECTED_MM_MAP_ERROR -STATUS_UNEXPECTED_NETWORK_ERROR -STATUS_UNHANDLED_EXCEPTION -STATUS_UNKNOWN_REVISION -STATUS_UNMAPPABLE_CHARACTER -STATUS_UNRECOGNIZED_MEDIA -STATUS_UNRECOGNIZED_VOLUME -STATUS_UNSUCCESSFUL -STATUS_UNSUPPORTED_COMPRESSION -STATUS_UNWIND -STATUS_USER_APC -STATUS_USER_EXISTS -STATUS_USER_MAPPED_FILE -STATUS_USER_SESSION_DELETED -STATUS_VALIDATE_CONTINUE -STATUS_VARIABLE_NOT_FOUND -STATUS_VDM_HARD_ERROR -STATUS_VERIFY_REQUIRED -STATUS_VIRTUAL_CIRCUIT_CLOSED -STATUS_VOLUME_DISMOUNTED -STATUS_VOLUME_MOUNTED -STATUS_WAIT_0 -STATUS_WAIT_63 -STATUS_WAKE_SYSTEM_DEBUGGER -STATUS_WAS_LOCKED -STATUS_WAS_UNLOCKED -STATUS_WORKING_SET_LIMIT_RANGE -STATUS_WORKING_SET_QUOTA -STATUS_WRONG_PASSWORD -STATUS_WRONG_PASSWORD_CORE -STATUS_WRONG_VOLUME -STATUS_WX86_BREAKPOINT -STATUS_WX86_CONTINUE -STATUS_WX86_CREATEWX86TIB -STATUS_WX86_EXCEPTION_CHAIN -STATUS_WX86_EXCEPTION_CONTINUE -STATUS_WX86_EXCEPTION_LASTCHANCE -STATUS_WX86_FLOAT_STACK_CHECK -STATUS_WX86_INTERNAL_ERROR -STATUS_WX86_SINGLE_STEP -STATUS_WX86_UNSIMULATE \ No newline at end of file diff --git a/irc/ArchBlackmann/stru.txt b/irc/ArchBlackmann/stru.txt deleted file mode 100644 index e3a9ccd728d..00000000000 --- a/irc/ArchBlackmann/stru.txt +++ /dev/null @@ -1,7 +0,0 @@ -FAST_MUTEX -KPCR -PEB -TEB -SPINLOCK -APC -DPC diff --git a/irc/ArchBlackmann/tech.txt b/irc/ArchBlackmann/tech.txt deleted file mode 100644 index b95f426dcc9..00000000000 --- a/irc/ArchBlackmann/tech.txt +++ /dev/null @@ -1,73 +0,0 @@ -What do you think I am, your personal tech support? -You *know* a %stru% is non-re-entrant, right? -The answer to that is so simple, I'm not going to waste my time telling you. -Well, of course... if you're not below DISPATCH_LEVEL, ros is gonna explode on ya when you try to do that ( duh! ). -I don't think that functionality has been implemented, yet. -What do you mean it crashed? It can't crash there! -Wow. That's a new one. -Ask %dev%, I bet he knows.. he knows everything... -When's the last time you rebuilt? -Have you tried a make clean? -Is it plugged in? -Well it works on *my* system :P -Well don't do that, and you won't have that problem. -Didn't we already fix that? -Well... I don't know.. I just have that code disabled in my tree. -Try surrounding it with parenthesis. -Don't you know going around dereferncing null pointers all day can be hazardous to your health? -Well, duh! -There's a bit in cr3 for problems like that. -Just add a field to the %stru% to keep track of it! -Don't worry about it... the garbage collector in %module% will clean it up for you. -Did I do that? -Didn't %dev% fix that already? -Yes, I think I've seen that bug before... no... that was another program. -I could tell you, but then I'd have to unlink() you. -Well if you'd get some sleep, maybe you'd figure it out... not all of us can keep the hours %dev% can... -You did what? Uh oh... that can't be good. -Well... I could tell you, but the answer's pretty complicated. Why don't you wait to read about it in the book I'm writing. -Yeah, that's happened to me, before, too. All you have to do is wrap it in an SEH block and forget about it. -Just put a NULL dereference in there and commit it. It helps get bugs fixed fast! (Not that I would know) -ASSERT is your friend! -I dunno.. but I bet %dev% could find it for you. -I hereby declare that code is perfect. Your problem must be elsewhere. -I wrote that code... it must be perfect. -$#@!$ One of these days I'm gonna throw %module% out the window!!! Sorry, what were you saying? -maybe I broke it in my last commit. Maybe I did it on purpose... -Have you tried debugging it? I got a can of Raid... -Just delete it, it can't be that important ( You should see all the useless cruft I got rid of in %module% ) -Try queueing a work item... -My %stru% fell in love with some %stru% in %module%, and %module% has been hell since... -Maybe the PEB is getting corrupted. Try allocating a new PEB and overwriting the old one. That's what I did last time I had a bug like that. -Hmm.. that seems to have been introduced by my last commit... I bet CVS mixed up the bits during the commit. -It can't possibly be my fault, so I don't care. -I'm not experiencing that problem, perhaps it's all in your mind. -Well... like a good friend of mine said... "Don't Panic!" -It just shows you how far ReactOS has come along! A %period% ago a bug like that wouldn't have even been possible! -Just surround the code with an #if 0/#endif block, it solves all my problems! -You know.. if %dev% would just finish %module% for us, we wouldn't be having this problem. -I say we move on to the next function, since we can't seem to figure this one out. -Well, sure, that would have been my first guess, too.... TEN YEARS AGO :p -yup, that sounds like a problem. -If I wanted to talk about VB, I'd go bug Alex... -ask %dev% -Thank you for that amazingly keen insight, Commander Obvious. -Sorry, can't help you right now, trying to track down this bug %dev% caused in %module% -I dont know about that, but I just fixed a problem in %module% for %dev% -How should I know? I'm still trying to figure out this main() thing... ooh! wanna see what I did in %module%? -lol! -*wink* -;) -42 -It's gonna take me over %period% to fix all %dev%'s bugs in %module% :( -How could %func% return %status%!? It bet %dev% broke it! I didn't touch it... honest! no.. really! (me hides) -It's fine if you get %status% there ... just ignore the destruction, and call %func% instead. -%dev% said %status% isn't really an error in this context because we expect %module% to be toast by now -heh, I'm still trying to figure out why %func% is returning %status% when I call it from %module%... -%dev% said it's okay to ignore that as long as you're below %irql% -erm, what do you mean? -damn, I do that all the time -if you want a reply that sounds right, I'd say that %func% support for that is vital to the future of %module% -Sounds like you're having a problem with %func%. I hate that thing... don't talk to me about it. -Just return %status% and forget about it. Someone else will fix it, later. -Blah blah blah... sheesh... can't you figure out *anything*? \ No newline at end of file diff --git a/irc/ArchBlackmann/trim.cpp b/irc/ArchBlackmann/trim.cpp deleted file mode 100644 index c721f25dded..00000000000 --- a/irc/ArchBlackmann/trim.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// trim.cpp -// This file is (C) 2004 Royce Mitchell III -// and released under the BSD & LGPL licenses - -#include "trim.h" - -std::string trim ( const std::string& s ) -{ - const char* p = &s[0]; - const char* p2 = p + s.size(); - while ( *p == ' ' ) - p++; - while ( p2 > p && p2[-1] == ' ' ) - p2--; - return std::string ( p, p2-p ); -} - diff --git a/irc/ArchBlackmann/trim.h b/irc/ArchBlackmann/trim.h deleted file mode 100644 index 4f2ba721f4b..00000000000 --- a/irc/ArchBlackmann/trim.h +++ /dev/null @@ -1,13 +0,0 @@ -// trim.h -// This file is (C) 2004 Royce Mitchell III -// and released under the BSD & LGPL licenses - -#ifndef TRIM_H -#define TRIM_H - -#include - -std::string trim ( const std::string& s ); - -#endif//TRIM_H - diff --git a/irc/ArchBlackmann/type.txt b/irc/ArchBlackmann/type.txt deleted file mode 100644 index 2e10f9f9882..00000000000 --- a/irc/ArchBlackmann/type.txt +++ /dev/null @@ -1,1000 +0,0 @@ -ACCESS_MASK -ACCESS_STATE -APC_LEVEL -ARBITER_ACTION -ARBITER_ACTION -ARBITER_CONFLICT_INFO -ARBITER_FLAG_BOOT_CONFIG -ARBITER_INTERFACE -ARBITER_LIST_ENTRY -ARBITER_PARAMETERS -ARBITER_PARTIAL -ARBITER_REQUEST_SOURCE -ARBITER_RESULT -AT_EXTENDABLE_FILE -AT_RESERVED -AT_ROUND_TO_PAGE -BOOTDISK_INFORMATION -BOOTDISK_INFORMATION_EX -BUS_INTERFACE_STANDARD -BUS_QUERY_ID_TYPE -BaseAddresses[PCI_TYPE0_ADDRESSES] -BaseAddresses[PCI_TYPE1_ADDRESSES] -CLIENT_ID -CLOCK1_LEVEL -CLOCK2_LEVEL -CM_EISA_FUNCTION_INFORMATION -CM_EISA_FUNCTION_INFORMATION.FunctionFlags -CM_EISA_SLOT_INFORMATION -CM_EISA_SLOT_INFORMATION.ReturnCode -CM_FLOPPY_DEVICE_DATA -CM_FULL_RESOURCE_DESCRIPTOR -CM_INT13_DRIVE_PARAMETER -CM_KEYBOARD_DEVICE_DATA -CM_MCA_POS_DATA -CM_PARTIAL_RESOURCE_DESCRIPTOR -CM_PARTIAL_RESOURCE_DESCRIPTOR.Flags -CM_PARTIAL_RESOURCE_DESCRIPTOR.ShareDisposition -CM_PARTIAL_RESOURCE_DESCRIPTOR.Type -CM_PARTIAL_RESOURCE_LIST -CM_POWER_DATA -CM_RESOURCE_DMA_16 -CM_RESOURCE_DMA_32 -CM_RESOURCE_DMA_8 -CM_RESOURCE_DMA_8_AND_16 -CM_RESOURCE_DMA_BUS_MASTER -CM_RESOURCE_DMA_TYPE_A -CM_RESOURCE_DMA_TYPE_B -CM_RESOURCE_DMA_TYPE_F -CM_RESOURCE_INTERRUPT_LATCHED -CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE -CM_RESOURCE_LIST -CM_RESOURCE_MEMORY_24 -CM_RESOURCE_MEMORY_CACHEABLE -CM_RESOURCE_MEMORY_COMBINEDWRITE -CM_RESOURCE_MEMORY_PREFETCHABLE -CM_RESOURCE_MEMORY_READ_ONLY -CM_RESOURCE_MEMORY_READ_WRITE -CM_RESOURCE_MEMORY_WRITE_ONLY -CM_RESOURCE_PORT_10_BIT_DECODE -CM_RESOURCE_PORT_12_BIT_DECODE -CM_RESOURCE_PORT_16_BIT_DECODE -CM_RESOURCE_PORT_IO -CM_RESOURCE_PORT_MEMORY -CM_RESOURCE_PORT_PASSIVE_DECODE -CM_RESOURCE_PORT_POSITIVE_DECODE -CM_RESOURCE_PORT_WINDOW_DECODE -CM_SCSI_DEVICE_DATA -CM_SERIAL_DEVICE_DATA -CM_SHARE_DISPOSITION -CONFIGURATION_INFORMATION -CONFIGURATION_TYPE -CONFIGURATION_TYPE -CONTAINING_RECORD -CONTROLLER_OBJECT -CREATE_DISK -CREATE_DISK_GPT -CREATE_DISK_MBR -CREATE_FILE_TYPE -CREATE_FILE_TYPE -DBG_STATUS_BUGCHECK_FIRST -DBG_STATUS_BUGCHECK_SECOND -DBG_STATUS_CONTROL_C -DBG_STATUS_DEBUG_CONTROL -DBG_STATUS_FATAL -DBG_STATUS_SYSRQ -DBG_STATUS_WORKER -DEVICE_CAPABILITIES -DEVICE_DESCRIPTION -DEVICE_DESCRIPTION.Version -DEVICE_DESCRIPTION_VERSION -DEVICE_DESCRIPTION_VERSION1 -DEVICE_DESCRIPTION_VERSION2 -DEVICE_INTERFACE_CHANGE_NOTIFICATION -DEVICE_OBJECT -DEVICE_OBJECT.AlignmentRequirement -DEVICE_OBJECT.Characteristics -DEVICE_OBJECT.DeviceType -DEVICE_OBJECT.Flags -DEVICE_POWER_STATE -DEVICE_REGISTRY_PROPERTY -DEVICE_REGISTRY_PROPERTY -DEVICE_RELATIONS -DEVICE_RELATION_TYPE -DEVICE_RELATION_TYPE -DEVICE_TEXT_TYPE -DEVICE_TYPE -DEVICE_USAGE_NOTIFICATION_TYPE -DIRECTORY_ALL_ACCESS -DIRECTORY_CREATE_OBJECT -DIRECTORY_CREATE_SUBDIRECTORY -DIRECTORY_QUERY -DIRECTORY_TRAVERSE -DISK_SIGNATURE -DISPATCHER_HEADER -DISPATCH_LEVEL -DMA_ADAPTER -DMA_CONFIGURATION_BYTE0 -DMA_CONFIGURATION_BYTE1 -DMA_OPERATIONS -DMA_SPEED -DMA_WIDTH -DO_BUFFERED_IO -DO_BUS_ENUMERATED_DEVICE -DO_DEVICE_HAS_NAME -DO_DEVICE_INITIALIZING -DO_DIRECT_IO -DO_EXCLUSIVE -DO_LONG_TERM_REQUESTS -DO_LOW_PRIORITY_FILESYSTEM -DO_MAP_IO_BUFFER -DO_NEVER_LAST_DEVICE -DO_POWER_INRUSH -DO_POWER_PAGABLE -DO_SHUTDOWN_REGISTERED -DO_SYSTEM_BOOT_PARTITION -DO_VERIFY_VOLUME -DRIVER_EXTENSION -DRIVER_OBJECT -DRIVER_VERIFIER_FORCE_IRQL_CHECKING -DRIVER_VERIFIER_INJECT_ALLOCATION_FAILURES -DRIVER_VERIFIER_IO_CHECKING -DRIVER_VERIFIER_SPECIAL_POOLING -DRIVER_VERIFIER_THUNK_PAIRS -DRIVER_VERIFIER_TRACK_POOL_ALLOCATIONS -DRIVE_LAYOUT_INFORMATION_GPT -DRIVE_LAYOUT_INFORMATION_MBR -DUPLICATE_CLOSE_SOURCE -DUPLICATE_SAME_ACCESS -DUPLICATE_SAME_ATTRIBUTES -EFLAG_SELECT -EFLAG_SIGN -EFLAG_ZERO -EISA_DMA_CONFIGURATION -EISA_EMPTY_SLOT -EISA_FREE_FORM_DATA -EISA_FUNCTION_ENABLED -EISA_HAS_DMA_ENTRY -EISA_HAS_INFORMATION -EISA_HAS_IRQ_ENTRY -EISA_HAS_MEMORY_ENTRY -EISA_HAS_PORT_INIT_ENTRY -EISA_HAS_PORT_RANGE -EISA_HAS_TYPE_ENTRY -EISA_INVALID_BIOS_CALL -EISA_INVALID_CONFIGURATION -EISA_INVALID_FUNCTION -EISA_INVALID_SLOT -EISA_IRQ_CONFIGURATION -EISA_IRQ_DESCRIPTOR -EISA_MEMORY_CONFIGURATION -EISA_MEMORY_TYPE -EISA_PORT_CONFIGURATION -EISA_PORT_DESCRIPTOR -ERESOURCE_THREAD -ES_CONTINUOUS -ES_DISPLAY_REQUIRED -ES_SYSTEM_REQUIRED -ES_USER_PRESENT -EVENT_INCREMENT -EVENT_TYPE -EVENT_TYPE -EXECUTION_STATE -EX_POOL_PRIORITY -EX_POOL_PRIORITY -FAST_IO_DISPATCH -FAST_MUTEX -FIELD_OFFSET -FILE_128_BYTE_ALIGNMENT -FILE_256_BYTE_ALIGNMENT -FILE_32_BYTE_ALIGNMENT -FILE_512_BYTE_ALIGNMENT -FILE_64_BYTE_ALIGNMENT -FILE_ADD_FILE -FILE_ADD_SUBDIRECTORY -FILE_ALIGNMENT_INFORMATION -FILE_ALL_ACCESS -FILE_ANY_ACCESS -FILE_APPEND_DATA -FILE_ATTRIBUTE_ARCHIVE -FILE_ATTRIBUTE_COMPRESSED -FILE_ATTRIBUTE_DEVICE -FILE_ATTRIBUTE_DIRECTORY -FILE_ATTRIBUTE_ENCRYPTED -FILE_ATTRIBUTE_HIDDEN -FILE_ATTRIBUTE_NORMAL -FILE_ATTRIBUTE_NOT_CONTENT_INDEXED -FILE_ATTRIBUTE_OFFLINE -FILE_ATTRIBUTE_READONLY -FILE_ATTRIBUTE_REPARSE_POINT -FILE_ATTRIBUTE_SPARSE_FILE -FILE_ATTRIBUTE_SYSTEM -FILE_ATTRIBUTE_TAG_INFORMATION -FILE_ATTRIBUTE_TEMPORARY -FILE_ATTRIBUTE_VALID_FLAGS -FILE_ATTRIBUTE_VALID_SET_FLAGS -FILE_AUTOGENERATED_DEVICE_NAME -FILE_BASIC_INFORMATION -FILE_BYTE_ALIGNMENT -FILE_COMPLETE_IF_OPLOCKED -FILE_COPY_STRUCTURED_STORAGE -FILE_CREATE -FILE_CREATED -FILE_CREATE_PIPE_INSTANCE -FILE_CREATE_TREE_CONNECTION -FILE_DELETE_CHILD -FILE_DELETE_ON_CLOSE -FILE_DEVICE_8042_PORT -FILE_DEVICE_ACPI -FILE_DEVICE_BATTERY -FILE_DEVICE_BEEP -FILE_DEVICE_BUS_EXTENDER -FILE_DEVICE_CD_ROM -FILE_DEVICE_CD_ROM_FILE_SYSTEM -FILE_DEVICE_CHANGER -FILE_DEVICE_CONTROLLER -FILE_DEVICE_DATALINK -FILE_DEVICE_DFS -FILE_DEVICE_DFS_FILE_SYSTEM -FILE_DEVICE_DFS_VOLUME -FILE_DEVICE_DISK -FILE_DEVICE_DISK_FILE_SYSTEM -FILE_DEVICE_DVD -FILE_DEVICE_FILE_SYSTEM -FILE_DEVICE_FIPS -FILE_DEVICE_FULLSCREEN_VIDEO -FILE_DEVICE_INPORT_PORT -FILE_DEVICE_IS_MOUNTED -FILE_DEVICE_KEYBOARD -FILE_DEVICE_KS -FILE_DEVICE_KSEC -FILE_DEVICE_MAILSLOT -FILE_DEVICE_MASS_STORAGE -FILE_DEVICE_MIDI_IN -FILE_DEVICE_MIDI_OUT -FILE_DEVICE_MODEM -FILE_DEVICE_MOUSE -FILE_DEVICE_MULTI_UNC_PROVIDER -FILE_DEVICE_NAMED_PIPE -FILE_DEVICE_NETWORK -FILE_DEVICE_NETWORK_BROWSER -FILE_DEVICE_NETWORK_FILE_SYSTEM -FILE_DEVICE_NETWORK_REDIRECTOR -FILE_DEVICE_NULL -FILE_DEVICE_PARALLEL_PORT -FILE_DEVICE_PHYSICAL_NETCARD -FILE_DEVICE_PRINTER -FILE_DEVICE_SCANNER -FILE_DEVICE_SCREEN -FILE_DEVICE_SECURE_OPEN -FILE_DEVICE_SERENUM -FILE_DEVICE_SERIAL_MOUSE_PORT -FILE_DEVICE_SERIAL_PORT -FILE_DEVICE_SMARTCARD -FILE_DEVICE_SMB -FILE_DEVICE_SOUND -FILE_DEVICE_STREAMS -FILE_DEVICE_TAPE -FILE_DEVICE_TAPE_FILE_SYSTEM -FILE_DEVICE_TERMSRV -FILE_DEVICE_TRANSPORT -FILE_DEVICE_UNKNOWN -FILE_DEVICE_VDM -FILE_DEVICE_VIDEO -FILE_DEVICE_VIRTUAL_DISK -FILE_DEVICE_WAVE_IN -FILE_DEVICE_WAVE_OUT -FILE_DIRECTORY_FILE -FILE_DISPOSITION_INFORMATION -FILE_DOES_NOT_EXIST -FILE_END_OF_FILE_INFORMATION -FILE_EXECUTE -FILE_EXISTS -FILE_FLOPPY_DISKETTE -FILE_FS_DEVICE_INFORMATION -FILE_FULL_EA_INFORMATION -FILE_GENERIC_EXECUTE -FILE_GENERIC_READ -FILE_GENERIC_WRITE -FILE_INFORMATION_CLASS -FILE_INFORMATION_CLASS -FILE_LIST_DIRECTORY -FILE_LONG_ALIGNMENT -FILE_MAXIMUM_DISPOSITION -FILE_NAME_INFORMATION -FILE_NETWORK_OPEN_INFORMATION -FILE_NON_DIRECTORY_FILE -FILE_NO_COMPRESSION -FILE_NO_EA_KNOWLEDGE -FILE_NO_INTERMEDIATE_BUFFERING -FILE_OBJECT.Flags -FILE_OBJECT -FILE_OCTA_ALIGNMENT -FILE_OPEN -FILE_OPENED -FILE_OPEN_BY_FILE_ID -FILE_OPEN_FOR_BACKUP_INTENT -FILE_OPEN_FOR_FREE_SPACE_QUERY -FILE_OPEN_FOR_RECOVERY -FILE_OPEN_IF -FILE_OPEN_NO_RECALL -FILE_OPEN_REPARSE_POINT -FILE_OVERWRITE -FILE_OVERWRITE_IF -FILE_OVERWRITTEN -FILE_POSITION_INFORMATION -FILE_QUAD_ALIGNMENT -FILE_RANDOM_ACCESS -FILE_READ_ACCESS -FILE_READ_ATTRIBUTES -FILE_READ_DATA -FILE_READ_EA -FILE_READ_ONLY_DEVICE -FILE_REMOTE_DEVICE -FILE_REMOVABLE_MEDIA -FILE_RESERVE_OPFILTER -FILE_SEQUENTIAL_ONLY -FILE_SHARE_DELETE -FILE_SHARE_READ -FILE_SHARE_VALID_FLAGS -FILE_SHARE_WRITE -FILE_SPECIAL_ACCESS -FILE_STANDARD_INFORMATION -FILE_STRUCTURED_STORAGE -FILE_SUPERSEDE -FILE_SUPERSEDED -FILE_SYNCHRONOUS_IO_ALERT -FILE_SYNCHRONOUS_IO_NONALERT -FILE_TRAVERSE -FILE_USE_FILE_POINTER_POSITION -FILE_VALID_DATA_LENGTH_INFORMATION -FILE_VALID_MAILSLOT_OPTION_FLAGS -FILE_VALID_OPTION_FLAGS -FILE_VALID_PIPE_OPTION_FLAGS -FILE_VALID_SET_FLAGS -FILE_VIRTUAL_VOLUME -FILE_WORD_ALIGNMENT -FILE_WRITE_ACCESS -FILE_WRITE_ATTRIBUTES -FILE_WRITE_DATA -FILE_WRITE_EA -FILE_WRITE_ONCE_MEDIA -FILE_WRITE_THROUGH -FILE_WRITE_TO_END_OF_FILE -FO_ALERTABLE_IO -FO_CACHE_SUPPORTED -FO_CLEANUP_COMPLETE -FO_DELETE_ON_CLOSE -FO_DIRECT_DEVICE_OPEN -FO_FILE_FAST_IO_READ -FO_FILE_MODIFIED -FO_FILE_OBJECT_HAS_EXTENSION -FO_FILE_OPEN -FO_FILE_OPEN_CANCELLED -FO_FILE_SIZE_CHANGED -FO_GENERATE_AUDIT_ON_CLOSE -FO_HANDLE_CREATED -FO_MAILSLOT -FO_NAMED_PIPE -FO_NO_INTERMEDIATE_BUFFERING -FO_OPENED_CASE_SENSITIVE -FO_RANDOM_ACCESS -FO_REMOTE_ORIGIN -FO_SEQUENTIAL_ONLY -FO_STREAM_FILE -FO_SYNCHRONOUS_IO -FO_TEMPORARY_FILE -FO_VOLUME_OPEN -FO_WRITE_THROUGH -FS_INFORMATION_CLASS -GENERAL_LOOKASIDE -GENERAL_LOOKASIDE_S -HASH_STRING_ALGORITHM_DEFAULT -HASH_STRING_ALGORITHM_INVALID -HASH_STRING_ALGORITHM_X65599 -HIGH_LEVEL -HIGH_PRIORITY -HWPROFILE_CHANGE_NOTIFICATION -IMAGE_ADDRESSING_MODE_32BIT -IMAGE_INFO -INITIAL_PRIVILEGE_COUNT -INITIAL_PRIVILEGE_SET -INTERFACE_TYPE -INTERFACE_TYPE -INTERLOCKED_RESULT -IO_ALLOCATION_ACTION -IO_ALLOCATION_ACTION -IO_CD_ROM_INCREMENT -IO_COMPLETION_CONTEXT -IO_CSQ -IO_CSQ_IRP_CONTEXT -IO_DISK_INCREMENT -IO_ERROR_LOG_PACKET -IO_KEYBOARD_INCREMENT -IO_MAILSLOT_INCREMENT -IO_MOUSE_INCREMENT -IO_NAMED_PIPE_INCREMENT -IO_NETWORK_INCREMENT -IO_NOTIFICATION_EVENT_CATEGORY -IO_NOTIFICATION_EVENT_CATEGORY -IO_NO_INCREMENT -IO_PARALLEL_INCREMENT -IO_REMOVE_LOCK -IO_REMOVE_LOCK_COMMON_BLOCK -IO_REMOVE_LOCK_DBG_BLOCK -IO_RESOURCE_ALTERNATIVE -IO_RESOURCE_DEFAULT -IO_RESOURCE_DESCRIPTOR -IO_RESOURCE_DESCRIPTOR -IO_RESOURCE_DESCRIPTOR.Option -IO_RESOURCE_LIST -IO_RESOURCE_PREFERRED -IO_RESOURCE_REQUIREMENTS_LIST -IO_SECURITY_CONTEXT -IO_SERIAL_INCREMENT -IO_SOUND_INCREMENT -IO_STACK_LOCATION -IO_STACK_LOCATION.Control -IO_STATUS_BLOCK -IO_VIDEO_INCREMENT -IPI_LEVEL -IRP_MJ_CLEANUP -IRP_MJ_CLOSE -IRP_MJ_CREATE -IRP_MJ_CREATE_MAILSLOT -IRP_MJ_CREATE_NAMED_PIPE -IRP_MJ_DEVICE_CHANGE -IRP_MJ_DEVICE_CONTROL -IRP_MJ_DIRECTORY_CONTROL -IRP_MJ_FILE_SYSTEM_CONTROL -IRP_MJ_FLUSH_BUFFERS -IRP_MJ_INTERNAL_DEVICE_CONTROL -IRP_MJ_LOCK_CONTROL -IRP_MJ_MAXIMUM_FUNCTION -IRP_MJ_PNP -IRP_MJ_PNP_POWER -IRP_MJ_POWER -IRP_MJ_QUERY_EA -IRP_MJ_QUERY_INFORMATION -IRP_MJ_QUERY_QUOTA -IRP_MJ_QUERY_SECURITY -IRP_MJ_QUERY_VOLUME_INFORMATION -IRP_MJ_READ -IRP_MJ_SCSI -IRP_MJ_SET_EA -IRP_MJ_SET_INFORMATION -IRP_MJ_SET_QUOTA -IRP_MJ_SET_SECURITY -IRP_MJ_SET_VOLUME_INFORMATION -IRP_MJ_SHUTDOWN -IRP_MJ_SYSTEM_CONTROL -IRP_MJ_WRITE -IRP_MN_CANCEL_REMOVE_DEVICE -IRP_MN_CANCEL_STOP_DEVICE -IRP_MN_CHANGE_SINGLE_INSTANCE -IRP_MN_CHANGE_SINGLE_ITEM -IRP_MN_COMPLETE -IRP_MN_COMPLETE_MDL -IRP_MN_COMPLETE_MDL_DPC -IRP_MN_COMPRESSED -IRP_MN_DEVICE_USAGE_NOTIFICATION -IRP_MN_DISABLE_COLLECTION -IRP_MN_DISABLE_EVENTS -IRP_MN_DPC -IRP_MN_EJECT -IRP_MN_ENABLE_COLLECTION -IRP_MN_ENABLE_EVENTS -IRP_MN_EXECUTE_METHOD -IRP_MN_FILTER_RESOURCE_REQUIREMENTS -IRP_MN_KERNEL_CALL -IRP_MN_LOAD_FILE_SYSTEM -IRP_MN_LOCK -IRP_MN_MDL -IRP_MN_MDL_DPC -IRP_MN_MOUNT_VOLUME -IRP_MN_NORMAL -IRP_MN_NOTIFY_CHANGE_DIRECTORY -IRP_MN_POWER_SEQUENCE -IRP_MN_QUERY_ALL_DATA -IRP_MN_QUERY_BUS_INFORMATION -IRP_MN_QUERY_CAPABILITIES -IRP_MN_QUERY_DEVICE_RELATIONS -IRP_MN_QUERY_DEVICE_TEXT -IRP_MN_QUERY_DIRECTORY -IRP_MN_QUERY_ID -IRP_MN_QUERY_INTERFACE -IRP_MN_QUERY_LEGACY_BUS_INFORMATION -IRP_MN_QUERY_PNP_DEVICE_STATE -IRP_MN_QUERY_POWER -IRP_MN_QUERY_REMOVE_DEVICE -IRP_MN_QUERY_RESOURCES -IRP_MN_QUERY_RESOURCE_REQUIREMENTS -IRP_MN_QUERY_SINGLE_INSTANCE -IRP_MN_QUERY_STOP_DEVICE -IRP_MN_READ_CONFIG -IRP_MN_REGINFO -IRP_MN_REGINFO_EX -IRP_MN_REMOVE_DEVICE -IRP_MN_SCSI_CLASS -IRP_MN_SET_LOCK -IRP_MN_SET_POWER -IRP_MN_START_DEVICE -IRP_MN_STOP_DEVICE -IRP_MN_SURPRISE_REMOVAL -IRP_MN_TRACK_LINK -IRP_MN_UNLOCK_ALL -IRP_MN_UNLOCK_ALL_BY_KEY -IRP_MN_UNLOCK_SINGLE -IRP_MN_USER_FS_REQUEST -IRP_MN_VERIFY_VOLUME -IRP_MN_WAIT_WAKE -IRP_MN_WRITE_CONFIG -KBUGCHECK_BUFFER_DUMP_STATE -KBUGCHECK_CALLBACK_RECORD -KDEVICE_QUEUE -KDEVICE_QUEUE_ENTRY -KDPC_DATA -KDPC_IMPORTANCE -KDPC_IMPORTANCE -KD_DEBUGGER_ENABLED -KD_DEBUGGER_NOT_PRESENT -KEYBOARD_ALT_KEY_DOWN -KEYBOARD_CAPS_LOCK_ON -KEYBOARD_CTRL_KEY_DOWN -KEYBOARD_INSERT_ON -KEYBOARD_LEFT_SHIFT_DOWN -KEYBOARD_NUM_LOCK_ON -KEYBOARD_RIGHT_SHIFT_DOWN -KEYBOARD_SCROLL_LOCK_ON -KEY_BASIC_INFORMATION -KEY_FULL_INFORMATION -KEY_INFORMATION_CLASS -KEY_INFORMATION_CLASS -KEY_NODE_INFORMATION -KEY_VALUE_BASIC_INFORMATION -KEY_VALUE_ENTRY -KEY_VALUE_FULL_INFORMATION -KEY_VALUE_INFORMATION_CLASS -KEY_VALUE_INFORMATION_CLASS -KEY_VALUE_PARTIAL_INFORMATION -KEY_VALUE_PARTIAL_INFORMATION_ALIGN64 -KEY_VALUE_Xxx.Type -KFLOATING_SAVE -KINTERRUPT_MODE -KINTERRUPT_MODE -KI_USER_SHARED_DATA -KLOCK_QUEUE_HANDLE -KPCR_TIB -KPROCESSOR_MODE -KPROFILE_SOURCE -KSPIN_LOCK_QUEUE -KSPIN_LOCK_QUEUE_NUMBER -KWAIT_BLOCK -KWAIT_REASON -KWAIT_REASON -LARGE_INTEGER -LOCK_OPERATION -LOCK_OPERATION -LOCK_QUEUE_OWNER -LOCK_QUEUE_WAIT -LOW_LEVEL -LOW_PRIORITY -LOW_REALTIME_PRIORITY -MAXIMUM_PRIORITY -MAXIMUM_PROCESSORS -MAXIMUM_VOLUME_LABEL_LENGTH -MAXIMUM_WAIT_OBJECTS -MDL_ALLOCATED_FIXED_SIZE -MDL_ALLOCATED_MUST_SUCCEED -MDL_FREE_EXTRA_PTES -MDL_IO_PAGE_READ -MDL_IO_SPACE -MDL_MAPPED_TO_SYSTEM_VA -MDL_MAPPING_CAN_FAIL -MDL_MAPPING_FLAGS -MDL_NETWORK_HEADER -MDL_PAGES_LOCKED -MDL_PARENT_MAPPED_SYSTEM_VA -MDL_PARTIAL -MDL_PARTIAL_HAS_BEEN_MAPPED -MDL_SOURCE_IS_NONPAGED_POOL -MDL_SOURCE_IS_NONPAGED_POOL -MDL_WRITE_OPERATION -MEMORY_CACHING_TYPE -MEMORY_CACHING_TYPE -MEMORY_CACHING_TYPE_ORIG -METHOD_BUFFERED -METHOD_IN_DIRECT -METHOD_NEITHER -METHOD_OUT_DIRECT -MMFLUSH_TYPE -MMFLUSH_TYPE -MM_HIGHEST_USER_ADDRESS -MM_LOWEST_SYSTEM_ADDRESS -MM_LOWEST_USER_ADDRESS -MM_PAGE_PRIORITY -MM_PAGE_PRIORITY -MM_SYSTEM_RANGE_START -MM_SYSTEM_SIZE -MM_USER_PROBE_ADDRESS -MajorFunction[IRP_MJ_MAXIMUM_FUNCTION -NPAGED_LOOKASIDE_LIST -OBJECT_HANDLE_INFORMATION -OBJECT_NAME_INFORMATION -OWNER_ENTRY -PACCESS_MASK -PACCESS_STATE -PAGED_LOOKASIDE_LIST -PAGE_SHIFT -PAGE_SIZE -PALLOCATE_FUNCTION -PANSI_STRING -PARBITER_CONFLICT_INFO -PARTITION_INFORMATION_MBR -PARTITION_STYLE -PASSIVE_LEVEL -PCALLBACK_FUNCTION -PCALLBACK_OBJECT -PCI_BRIDGE_TYPE -PCI_CARDBUS_BRIDGE_TYPE -PCI_COMMON_CONFIG -PCI_COMMON_CONFIG.Command -PCI_COMMON_CONFIG.HeaderType -PCI_COMMON_CONFIG.Status -PCI_DEVICE_TYPE -PCI_ENABLE_BUS_MASTER -PCI_ENABLE_FAST_BACK_TO_BACK -PCI_ENABLE_IO_SPACE -PCI_ENABLE_MEMORY_SPACE -PCI_ENABLE_PARITY -PCI_ENABLE_SERR -PCI_ENABLE_SPECIAL_CYCLES -PCI_ENABLE_VGA_COMPATIBLE_PALETTE -PCI_ENABLE_WAIT_CYCLE -PCI_ENABLE_WRITE_AND_INVALIDATE -PCI_MULTIFUNCTION -PCI_SLOT_NUMBER -PCI_STATUS_66MHZ_CAPABLE -PCI_STATUS_CAPABILITIES_LIST -PCI_STATUS_DATA_PARITY_DETECTED -PCI_STATUS_DETECTED_PARITY_ERROR -PCI_STATUS_DEVSEL -PCI_STATUS_FAST_BACK_TO_BACK -PCI_STATUS_RECEIVED_MASTER_ABORT -PCI_STATUS_RECEIVED_TARGET_ABORT -PCI_STATUS_SIGNALED_SYSTEM_ERROR -PCI_STATUS_SIGNALED_TARGET_ABORT -PCI_STATUS_UDF_SUPPORTED -PCI_TYPE0_ADDRESSES -PCI_TYPE1_ADDRESSES -PCI_TYPE2_ADDRESSES -PCLIENT_ID -PCM_PARTIAL_RESOURCE_DESCRIPTOR -PCM_PARTIAL_RESOURCE_LIST -PCM_RESOURCE_LIST -PCONFIGURATION_TYPE -PCONTROLLER_OBJECT -PCREATE_DISK -PCREATE_PROCESS_NOTIFY_ROUTINE -PCREATE_THREAD_NOTIFY_ROUTINE -PCR_MAJOR_VERSION -PCR_MINOR_VERSION -PCUNICODE_STRING -PDCAP_D0_SUPPORTED -PDCAP_D1_SUPPORTED -PDCAP_D2_SUPPORTED -PDCAP_D3_SUPPORTED -PDCAP_WAKE_FROM_D0_SUPPORTED -PDCAP_WAKE_FROM_D1_SUPPORTED -PDCAP_WAKE_FROM_D2_SUPPORTED -PDCAP_WAKE_FROM_D3_SUPPORTED -PDCAP_WARM_EJECT_SUPPORTED -PDEVICE_CHANGE_COMPLETE_CALLBACK -PDEVICE_DESCRIPTION -PDEVICE_OBJECT -PDISK_SIGNATURE -PDMA_ADAPTER -PDRIVER_CANCEL -PDRIVER_CONTROL -PDRIVER_LIST_CONTROL -PDRIVER_NOTIFICATION_CALLBACK_ROUTINE -PDRIVER_OBJECT -PDRIVER_REINITIALIZE -PD_Capabilities -PD_D1Latency -PD_D2Latency -PD_D3Latency -PD_MostRecentPowerState -PD_PowerStateMapping[PowerSystemMaximum] -PD_Size -PEX_CALLBACK_FUNCTION -PFAST_MUTEX -PFILE_BASIC_INFORMATION -PFILE_NETWORK_OPEN_INFORMATION -PFILE_OBJECT -PFILE_STANDARD_INFORMATION -PFREE_FUNCTION -PGENERIC_MAPPING -PHYSICAL_ADDRESS -PHYSICAL_MEMORY_RANGE -PIMAGE_INFO -PINTERFACE_TYPE -PIO_APC_ROUTINE -PIO_COMPLETION_ROUTINE -PIO_CSQ -PIO_CSQ_ACQUIRE_LOCK -PIO_CSQ_COMPLETE_CANCELED_IRP -PIO_CSQ_INSERT_IRP -PIO_CSQ_IRP_CONTEXT -PIO_CSQ_PEEK_NEXT_IRP -PIO_CSQ_RELEASE_LOCK -PIO_CSQ_REMOVE_IRP -PIO_QUERY_DEVICE_ROUTINE -PIO_REMOVE_LOCK -PIO_RESOURCE_DESCRIPTOR -PIO_RESOURCE_REQUIREMENTS_LIST -PIO_STACK_LOCATION -PIO_STATUS_BLOCK -PIO_TIMER_ROUTINE -PIO_WORKITEM -PIO_WORKITEM_ROUTINE -PKBUGCHECK_CALLBACK_RECORD -PKBUGCHECK_CALLBACK_ROUTINE -PKDEFERRED_ROUTINE -PKDEVICE_QUEUE -PKDEVICE_QUEUE_ENTRY -PKEY_VALUE_FULL_INFORMATION -PKFLOATING_SAVE -PKKERNEL_ROUTINE -PKLOCK_QUEUE_HANDLE -PKNORMAL_ROUTINE -PKRUNDOWN_ROUTINE -PKSERVICE_ROUTINE -PKSPIN_LOCK -PKSTART_ROUTINE -PKSYNCHRONIZE_ROUTINE -PKWAIT_BLOCK -PLARGE_INTEGER -PLIST_ENTRY -PLOAD_IMAGE_NOTIFY_ROUTINE -PLUGPLAY_NOTIFICATION_HEADER -PLUGPLAY_REGKEY_CURRENT_HWPROFILE -PLUGPLAY_REGKEY_DEVICE -PLUGPLAY_REGKEY_DRIVER -PNPAGED_LOOKASIDE_LIST -PNPNOTIFY_DEVICE_INTERFACE_INCLUDE_EXISTING_INTERFACES -PNP_BUS_INFORMATION -PNP_DEVICE_DISABLED -PNP_DEVICE_DONT_DISPLAY_IN_UI -PNP_DEVICE_FAILED -PNP_DEVICE_NOT_DISABLEABLE -PNP_DEVICE_REMOVED -PNP_DEVICE_RESOURCE_REQUIREMENTS_CHANGED -PNP_DEVICE_STATE -POBJECT_ATTRIBUTES -POBJECT_HANDLE_INFORMATION -POBJECT_TYPE -POINTER_ALIGNMENT -POOL_TAGGING -POOL_TYPE -POOL_TYPE -POWER_LEVEL -POWER_SEQUENCE -POWER_STATE -POWER_STATE -POWER_STATE_TYPE -POWER_STATE_TYPE -PPAGED_LOOKASIDE_LIST -PPFN_NUMBER -PPHYSICAL_ADDRESS -PPRIVILEGE_SET -PP_LOOKASIDE_LIST -PREQUEST_POWER_COMPLETE -PRIVILEGE_SET.Control -PRIVILEGE_SET_ALL_NECESSARY -PRKDEVICE_QUEUE_ENTRY -PROFILE_LEVEL -PROTECTED_POOL -PRTL_BITMAP -PRTL_BITMAP_RUN -PRTL_CONFLICT_RANGE_CALLBACK -PRTL_OSVERSIONINFOEXW -PRTL_QUERY_REGISTRY_TABLE -PRTL_RANGE -PRTL_RANGE_LIST -PRTL_RANGE_LIST_ITERATOR -PSCATTER_GATHER_LIST -PSECTION_OBJECT -PSECTION_OBJECT_POINTERS -PSECURITY_DESCRIPTOR -PSECURITY_SUBJECT_CONTEXT -PSHARE_ACCESS -PSINGLE_LIST_ENTRY -PSIZE_T -PSLIST_ENTRY -PSLIST_HEADER -PSYSCTL_IRP_DISPOSITION -PTIMER_APC_ROUTINE -PTIME_FIELDS -PTIME_UPDATE_NOTIFY_ROUTINE -PULONG_PTR -PUNICODE_STRING -PWMILIB_CONTEXT -Privilege[INITIAL_PRIVILEGE_COUNT] -REG_BINARY -REG_DWORD -REG_DWORD_BIG_ENDIAN -REG_DWORD_LITTLE_ENDIAN -REG_EXPAND_SZ -REG_FULL_RESOURCE_DESCRIPTOR -REG_LINK -REG_MULTI_SZ -REG_NONE -REG_QWORD -REG_QWORD_LITTLE_ENDIAN -REG_RESOURCE_LIST -REG_RESOURCE_REQUIREMENTS_LIST -REG_SZ -RESOURCE_HASH_TABLE_SIZE -RESOURCE_TRANSLATION_DIRECTION -RESOURCE_TRANSLATION_DIRECTION -RESTRICTED_POINTER -RESULT_NEGATIVE -RESULT_POSITIVE -RESULT_ZERO -RTL_BITMAP -RTL_BITMAP_RUN -RTL_OSVERSIONINFOEXW -RTL_OSVERSIONINFOW -RTL_QUERY_REGISTRY_DELETE -RTL_QUERY_REGISTRY_DIRECT -RTL_QUERY_REGISTRY_NOEXPAND -RTL_QUERY_REGISTRY_NOVALUE -RTL_QUERY_REGISTRY_REQUIRED -RTL_QUERY_REGISTRY_SUBKEY -RTL_QUERY_REGISTRY_TABLE -RTL_QUERY_REGISTRY_TABLE.Flags -RTL_QUERY_REGISTRY_TOPKEY -RTL_RANGE -RTL_RANGE_CONFLICT -RTL_RANGE_LIST -RTL_RANGE_LIST_ADD_IF_CONFLICT -RTL_RANGE_LIST_ADD_SHARED -RTL_RANGE_LIST_ITERATOR -RTL_RANGE_LIST_MERGE_IF_CONFLICT -RTL_RANGE_LIST_NULL_CONFLICT_OK -RTL_RANGE_LIST_SHARED_OK -RTL_RANGE_SHARED -RTL_REGISTRY_ABSOLUTE -RTL_REGISTRY_CONTROL -RTL_REGISTRY_DEVICEMAP -RTL_REGISTRY_HANDLE -RTL_REGISTRY_OPTIONAL -RTL_REGISTRY_SERVICES -RTL_REGISTRY_USER -RTL_REGISTRY_WINDOWS_NT -Range[PCI_TYPE2_ADDRESSES -SCATTER_GATHER_ELEMENT -SCATTER_GATHER_LIST -SECTION_INHERIT -SECTION_OBJECT_POINTERS -SECURITY_INFORMATION -SECURITY_OPERATION_CODE -SECURITY_SUBJECT_CONTEXT -SEC_NO_CHANGE -SEMAPHORE_INCREMENT -SHARE_ACCESS -SIZE_T -SL_ALLOW_RAW_MOUNT -SL_CASE_SENSITIVE -SL_EXCLUSIVE_LOCK -SL_FAIL_IMMEDIATELY -SL_FORCE_ACCESS_CHECK -SL_FT_SEQUENTIAL_WRITE -SL_INDEX_SPECIFIED -SL_INVOKE_ON_CANCEL -SL_INVOKE_ON_ERROR -SL_INVOKE_ON_SUCCESS -SL_KEY_SPECIFIED -SL_OPEN_PAGING_FILE -SL_OPEN_TARGET_DIRECTORY -SL_OVERRIDE_VERIFY_VOLUME -SL_PENDING_RETURNED -SL_RESTART_SCAN -SL_RETURN_SINGLE_ENTRY -SL_WATCH_TREE -SL_WRITE_THROUGH -SSDT_ENTRY -SUITE_TYPE -SUITE_TYPE -SYMBOLIC_LINK_ALL_ACCESS -SYMBOLIC_LINK_QUERY -SYNCH_LEVEL -TARGET_DEVICE_CUSTOM_NOTIFICATION -TARGET_DEVICE_REMOVAL_NOTIFICATION -TIMER_TYPE -TIMER_TYPE -TIME_FIELDS -TRACE_INFORMATION_CLASS -TRACE_INFORMATION_CLASS -TRANSLATOR_INTERFACE -ULONG_PTR -VER_AND -VER_BUILDNUMBER -VER_CONDITION_MASK -VER_EQUAL -VER_GREATER -VER_GREATER_EQUAL -VER_LESS -VER_LESS_EQUAL -VER_MAJORVERSION -VER_MINORVERSION -VER_NUM_BITS_PER_CONDITION_MASK -VER_OR -VER_PLATFORMID -VER_PRODUCT_TYPE -VER_SERVICEPACKMAJOR -VER_SERVICEPACKMINOR -VER_SUITENAME -VPB_LOCKED -VPB_MOUNTED -VPB_PERSISTENT -VPB_RAW_MOUNT -VPB_REMOVE_PENDING -VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH -WAIT_CONTEXT_BLOCK -WAIT_TYPE -WMI_NOTIFICATION_CALLBACK -WORK_QUEUE_ITEM -WORK_QUEUE_TYPE -WORK_QUEUE_TYPE -DEVICE_DESCRIPTION -DEVICE_OBJECT -DEVICE_OBJECT -DEVOBJ_EXTENSION -DMA_ADAPTER -DRIVER_CONTROL -DRIVER_OBJECT -DRIVER_OBJECT -EPROCESS -FILE_OBJECT -FILE_OBJECT -FirstEntry -GENERAL_LOOKASIDE -IO_CSQ -IO_CSQ -IO_STACK_LOCATION -IO_STATUS_BLOCK -IRP -IRP -IrpSp -IrpSp -KAPC -KDPC -KDPC -KPCR -KPCR -KPRCB -KPRCB -KSPIN_LOCK_QUEUE -KTHREAD -KTSS -KTSS -KWAIT_BLOCK -ListEntry -MDL -MDL -NT_TIB -NextIrpSp -PCI_HEADER_TYPE_0 -PCI_HEADER_TYPE_1 -PCI_HEADER_TYPE_2 -SCATTER_GATHER_LIST -SCSI_REQUEST_BLOCK -SECTION_OBJECT -SET_PARTITION_INFORMATION_EX -X86_ -va_list -TIMER_TYPE -ULONG -VOID diff --git a/irc/ArchBlackmann/verify.h b/irc/ArchBlackmann/verify.h deleted file mode 100644 index 5d491cfef41..00000000000 --- a/irc/ArchBlackmann/verify.h +++ /dev/null @@ -1,37 +0,0 @@ -// verify.h -// This code is (C) 2003-2004 Royce Mitchell III -// and released under the LGPL & BSD licenses - -#ifndef VERIFY_H -#define VERIFY_H - -//#include - -#ifdef ASSERT -#undef ASSERT -#endif//ASSERT - -#include "panic.h" - -#if defined(DEBUG) || defined(_DEBUG) -inline void AssertHandler ( bool b, const char* str ) -{ - if ( !b ) - panic ( str ); -} -# define ASSERT(x) AssertHandler((x) ? true : false, #x ) -#else -# define ASSERT(x) -#endif - -#ifdef verify -#undef verify -#endif//verify - -#if defined(DEBUG) || defined(_DEBUG) -# define verify(x) ASSERT(x) -#else -# define verify(x) x -#endif - -#endif//VERIFY_H diff --git a/irc/TechBot/CHMLibrary/AssemblyInfo.cs b/irc/TechBot/CHMLibrary/AssemblyInfo.cs deleted file mode 100644 index dbacda112e8..00000000000 --- a/irc/TechBot/CHMLibrary/AssemblyInfo.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following -// attributes. -// -// change them to the information which is associated with the assembly -// you compile. - -[assembly: AssemblyTitle("")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has following format : -// -// Major.Minor.Build.Revision -// -// You can specify all values by your own or you can build default build and revision -// numbers with the '*' character (the default): - -[assembly: AssemblyVersion("1.0.*")] - -// The following attributes specify the key for the sign of your assembly. See the -// .NET Framework documentation for more information about signing. -// This is not required, if you don't want signing let these attributes like they're. -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/BinaryReaderHelp.cs b/irc/TechBot/CHMLibrary/CHMDecoding/BinaryReaderHelp.cs deleted file mode 100644 index 64c9668eb30..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/BinaryReaderHelp.cs +++ /dev/null @@ -1,274 +0,0 @@ -using System; -using System.Collections; -using System.IO; -using System.Text; -using System.Globalization; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// The class BinaryReaderHelp implements static helper methods for extracting binary data - /// from a binary reader object. - /// - internal class BinaryReaderHelp - { - /// - /// Internal helper method to extract null-terminated strings from a binary reader - /// - /// reference to the binary reader - /// offset in the stream - /// true if the offset value should be used - /// encoder used for text encoding - /// An extracted string value - internal static string ExtractString(ref BinaryReader binReader, int offset, bool noOffset, Encoding encoder) - { - string strReturn = ""; - - if(encoder == null) - encoder = Encoding.ASCII; - - ArrayList nameBytes = new ArrayList(); - byte curByte; - - if(!noOffset) - binReader.BaseStream.Seek(offset, SeekOrigin.Begin); - - if(binReader.BaseStream.Position >= binReader.BaseStream.Length) - return ""; - - curByte = binReader.ReadByte(); - while( (curByte != (byte)0) && (binReader.BaseStream.Position < binReader.BaseStream.Length) ) - { - nameBytes.Add( curByte ); - curByte = binReader.ReadByte(); - } - - byte[] name = (byte[]) (nameBytes.ToArray(System.Type.GetType("System.Byte"))); - strReturn = encoder.GetString(name,0,name.Length); - - return strReturn; - } - - /// - /// Internal helper method to extract a string with a specific length from the binary reader - /// - /// reference to the binary reader - /// length of the string (number of bytes) - /// offset in the stream - /// true if the offset value should be used - /// encoder used for text encoding - /// An extracted string value - internal static string ExtractString(ref BinaryReader binReader, int length, int offset, bool noOffset, Encoding encoder) - { - string strReturn = ""; - - if(length == 0) - return ""; - - if(encoder == null) - encoder = Encoding.ASCII; - - ArrayList nameBytes = new ArrayList(); - byte curByte; - - if(!noOffset) - binReader.BaseStream.Seek(offset, SeekOrigin.Begin); - - if(binReader.BaseStream.Position >= binReader.BaseStream.Length) - return ""; - - curByte = binReader.ReadByte(); - while( (curByte != (byte)0) && (nameBytes.Count < length) && (binReader.BaseStream.Position < binReader.BaseStream.Length) ) - { - nameBytes.Add( curByte ); - - if(nameBytes.Count < length) - curByte = binReader.ReadByte(); - } - - byte[] name = (byte[]) (nameBytes.ToArray(System.Type.GetType("System.Byte"))); - strReturn = encoder.GetString(name,0,name.Length); - - return strReturn; - } - - /// - /// Internal helper method to extract a string with a specific length from the binary reader - /// - /// reference to the binary reader - /// reference to a bool vairable which will receive true if the - /// string terminator \0 was found. false indicates that the end of the stream was reached. - /// offset in the stream - /// true if the offset value should be used - /// encoder used for text encoding - /// An extracted string value - internal static string ExtractString(ref BinaryReader binReader, ref bool bFoundTerminator, int offset, bool noOffset, Encoding encoder) - { - string strReturn = ""; - - ArrayList nameBytes = new ArrayList(); - byte curByte; - - if(encoder == null) - encoder = Encoding.ASCII; - - if(!noOffset) - binReader.BaseStream.Seek(offset, SeekOrigin.Begin); - - if(binReader.BaseStream.Position >= binReader.BaseStream.Length) - return ""; - - curByte = binReader.ReadByte(); - while( (curByte != (byte)0) && (binReader.BaseStream.Position < binReader.BaseStream.Length) ) - { - nameBytes.Add( curByte ); - curByte = binReader.ReadByte(); - - if( curByte == (byte)0 ) - { - bFoundTerminator = true; - } - } - - byte[] name = (byte[]) (nameBytes.ToArray(System.Type.GetType("System.Byte"))); - strReturn = encoder.GetString(name,0,name.Length); - - return strReturn; - } - - /// - /// Internal helper method to extract a null-terminated UTF-16/UCS-2 strings from a binary reader - /// - /// reference to the binary reader - /// offset in the stream - /// true if the offset value should be used - /// encoder used for text encoding - /// An extracted string value - internal static string ExtractUTF16String(ref BinaryReader binReader, int offset, bool noOffset, Encoding encoder) - { - string strReturn = ""; - - ArrayList nameBytes = new ArrayList(); - byte curByte; - int lastByte=-1; - - if(!noOffset) - binReader.BaseStream.Seek(offset, SeekOrigin.Begin); - - if(binReader.BaseStream.Position >= binReader.BaseStream.Length) - return ""; - - if(encoder == null) - encoder = Encoding.Unicode; - - curByte = binReader.ReadByte(); - int nCnt = 0; - while( ((curByte != (byte)0) || (lastByte != 0) ) && (binReader.BaseStream.Position < binReader.BaseStream.Length) ) - { - nameBytes.Add( curByte ); - - if(nCnt%2 == 0) - lastByte = (int)curByte; - - curByte = binReader.ReadByte(); - - nCnt++; - } - - byte[] name = (byte[]) (nameBytes.ToArray(System.Type.GetType("System.Byte"))); - strReturn = Encoding.Unicode.GetString(name,0,name.Length); - - // apply text encoding - name = Encoding.Default.GetBytes(strReturn); - strReturn = encoder.GetString(name,0,name.Length); - - return strReturn; - } - - /// - /// Internal helper for reading ENCINT encoded integer values - /// - /// reference to the reader - /// a long value - internal static long ReadENCINT(ref BinaryReader binReader) - { - long nRet = 0; - byte buffer = 0; - int shift = 0; - - if(binReader.BaseStream.Position >= binReader.BaseStream.Length) - return nRet; - - do - { - buffer = binReader.ReadByte(); - nRet |= ((long)((buffer & (byte)0x7F))) << shift; - shift += 7; - - }while ( (buffer & (byte)0x80) != 0); - - return nRet; - } - - /// - /// Reads an s/r encoded value from the byte array and decodes it into an integer - /// - /// a byte array containing all bits (contains only 0 or 1 elements) - /// scale param for encoding - /// root param for encoding - /// current index in the wclBits array - /// Returns an decoded integer value. - internal static int ReadSRItem(byte[] wclBits, int s, int r, ref int nBitIndex) - { - int nRet = 0; - int q = r; - - int nPref1Cnt = 0; - - while( wclBits[nBitIndex++] == 1) - { - nPref1Cnt++; - } - - if(nPref1Cnt == 0) - { - int nMask = 0; - - for(int nbits=0; nbits - /// The class CHMBtree implements methods/properties to decode the binary help index. - /// This class automatically creates an index arraylist for the current CHMFile instance. - /// It does not store the index internally ! - /// - /// The binary index can be found in the storage file $WWKeywordLinks/BTree - internal sealed class CHMBtree : IDisposable - { - /// - /// Constant specifying the size of the string blocks - /// - private const int BLOCK_SIZE = 2048; - /// - /// Internal flag specifying if the object is going to be disposed - /// - private bool disposed = false; - /// - /// Internal member storing the binary file data - /// - private byte[] _binaryFileData = null; - /// - /// Internal member storing flags - /// - private int _flags = 0; - /// - /// Internal member storing the data format - /// - private byte[] _dataFormat = new byte[16]; - /// - /// Internal member storing the index of the last listing block - /// - private int _indexOfLastListingBlock = 0; - /// - /// Internal member storing the index of the root block - /// - private int _indexOfRootBlock = 0; - /// - /// Internal member storing the number of blocks - /// - private int _numberOfBlocks = 0; - /// - /// Internal member storing the tree depth. - /// (1 if no index blocks, 2 one level of index blocks, ...) - /// - private int _treeDepth = 0; - /// - /// Internal member storing the number of keywords in the file - /// - private int _numberOfKeywords = 0; - /// - /// Internal member storing the codepage - /// - private int _codePage = 0; - /// - /// true if the index is from a CHI or CHM file, else CHW - /// - private bool _isCHI_CHM = true; - /// - /// Internal member storing the associated chmfile object - /// - private CHMFile _associatedFile = null; - /// - /// Internal flag specifying if we have to read listing or index blocks - /// - private bool _readListingBlocks = true; - /// - /// Internal member storing an indexlist of the current file. - /// - private ArrayList _indexList = new ArrayList(); - - /// - /// Constructor of the class - /// - /// binary file data of the $WWKeywordLinks/BTree file - /// associated chm file - public CHMBtree(byte[] binaryFileData, CHMFile associatedFile) - { - if( associatedFile == null) - { - throw new ArgumentException("CHMBtree.ctor() - Associated CHMFile must not be null !", "associatedFile"); - } - - _binaryFileData = binaryFileData; - _associatedFile = associatedFile; - DecodeData(); - - // clear internal binary data after extraction - _binaryFileData = null; - } - - /// - /// Decodes the binary file data and fills the internal properties - /// - /// true if succeeded - private bool DecodeData() - { - bool bRet = true; - - MemoryStream memStream = new MemoryStream(_binaryFileData); - BinaryReader binReader = new BinaryReader(memStream); - - int nCurOffset = 0; - int nTemp = 0; - - // decode header - binReader.ReadChars(2); // 2chars signature (not important) - - _flags = (int)binReader.ReadInt16(); // WORD flags - - binReader.ReadInt16(); // size of blocks (always 2048) - - _dataFormat = binReader.ReadBytes(16); - - binReader.ReadInt32(); // unknown DWORD - - _indexOfLastListingBlock = binReader.ReadInt32(); - _indexOfRootBlock = binReader.ReadInt32(); - - binReader.ReadInt32(); // unknown DWORD - - _numberOfBlocks = binReader.ReadInt32(); - _treeDepth = binReader.ReadInt16(); - _numberOfKeywords = binReader.ReadInt32(); - _codePage = binReader.ReadInt32(); - - binReader.ReadInt32(); // lcid DWORD - - nTemp = binReader.ReadInt32(); - _isCHI_CHM = (nTemp==1); - - binReader.ReadInt32(); // unknown DWORD - binReader.ReadInt32(); // unknown DWORD - binReader.ReadInt32(); // unknown DWORD - binReader.ReadInt32(); // unknown DWORD - - // end of header decode - - while( (memStream.Position < memStream.Length) && (bRet) ) - { - nCurOffset = (int)memStream.Position; - byte [] dataBlock = binReader.ReadBytes(BLOCK_SIZE); - bRet &= DecodeBlock(dataBlock, ref nCurOffset, _treeDepth-1); - } - - return bRet; - } - - /// - /// Decodes a block of url-string data - /// - /// block of data - /// current file offset - /// number of index blocks - /// true if succeeded - private bool DecodeBlock( byte[] dataBlock, ref int nOffset, int indexBlocks ) - { - bool bRet = true; - int nblockOffset = nOffset; - - MemoryStream memStream = new MemoryStream(dataBlock); - BinaryReader binReader = new BinaryReader(memStream); - - int freeSpace = binReader.ReadInt16(); // length of freespace - int nrOfEntries = binReader.ReadInt16(); // number of entries - - bool bListingEndReached = false; - - //while( (memStream.Position < (memStream.Length-freeSpace)) && (bRet) ) - //{ - int nIndexOfPrevBlock = -1; - int nIndexOfNextBlock = -1; - int nIndexOfChildBlock = 0; - - if(_readListingBlocks) - { - nIndexOfPrevBlock = binReader.ReadInt32(); // -1 if this is the header - nIndexOfNextBlock = binReader.ReadInt32(); // -1 if this is the last block - } - else - { - nIndexOfChildBlock = binReader.ReadInt32(); - } - - for(int nE = 0; nE < nrOfEntries; nE++) - { - if(_readListingBlocks) - { - bListingEndReached = (nIndexOfNextBlock==-1); - - string keyWord = BinaryReaderHelp.ExtractUTF16String(ref binReader, 0, true, _associatedFile.TextEncoding); - - bool isSeeAlsoKeyword = (binReader.ReadInt16()!=0); - - int indent = binReader.ReadInt16(); // indent of entry - int nCharIndex = binReader.ReadInt32(); - - binReader.ReadInt32(); - - int numberOfPairs = binReader.ReadInt32(); - - int[] nTopics = new int[numberOfPairs]; - string[] seeAlso = new string[numberOfPairs]; - - for(int i=0; i < numberOfPairs; i++) - { - if(isSeeAlsoKeyword) - { - seeAlso[i] = BinaryReaderHelp.ExtractUTF16String(ref binReader, 0, true, _associatedFile.TextEncoding); - } - else - { - nTopics[i] = binReader.ReadInt32(); - } - } - - binReader.ReadInt32(); // unknown - - int nIndexOfThisEntry = binReader.ReadInt32(); - - IndexItem newItem = new IndexItem(_associatedFile, keyWord, isSeeAlsoKeyword, indent, nCharIndex, nIndexOfThisEntry, seeAlso, nTopics); - _indexList.Add(newItem); - } - else - { - string keyWord = BinaryReaderHelp.ExtractUTF16String(ref binReader, 0, true, _associatedFile.TextEncoding); - - bool isSeeAlsoKeyword = (binReader.ReadInt16()!=0); - - int indent = binReader.ReadInt16(); // indent of entry - int nCharIndex = binReader.ReadInt32(); - - binReader.ReadInt32(); - - int numberOfPairs = binReader.ReadInt32(); - - int[] nTopics = new int[numberOfPairs]; - string[] seeAlso = new string[numberOfPairs]; - - for(int i=0; i < numberOfPairs; i++) - { - if(isSeeAlsoKeyword) - { - seeAlso[i] = BinaryReaderHelp.ExtractUTF16String(ref binReader, 0, true, _associatedFile.TextEncoding); - } - else - { - nTopics[i] = binReader.ReadInt32(); - } - } - - int nIndexChild = binReader.ReadInt32(); - int nIndexOfThisEntry=-1; - - IndexItem newItem = new IndexItem(_associatedFile, keyWord, isSeeAlsoKeyword, indent, nCharIndex, nIndexOfThisEntry, seeAlso, nTopics); - _indexList.Add(newItem); - - } - } - //} - - binReader.ReadBytes(freeSpace); - - - if( bListingEndReached ) - _readListingBlocks = false; - - return bRet; - } - - /// - /// Gets the internal generated index list - /// - internal ArrayList IndexList - { - get { return _indexList; } - } - - /// - /// Implement IDisposable. - /// - public void Dispose() - { - Dispose(true); - // This object will be cleaned up by the Dispose method. - // Therefore, you should call GC.SupressFinalize to - // take this object off the finalization queue - // and prevent finalization code for this object - // from executing a second time. - GC.SuppressFinalize(this); - } - - /// - /// Dispose(bool disposing) executes in two distinct scenarios. - /// If disposing equals true, the method has been called directly - /// or indirectly by a user's code. Managed and unmanaged resources - /// can be disposed. - /// If disposing equals false, the method has been called by the - /// runtime from inside the finalizer and you should not reference - /// other objects. Only unmanaged resources can be disposed. - /// - /// disposing flag - private void Dispose(bool disposing) - { - // Check to see if Dispose has already been called. - if(!this.disposed) - { - // If disposing equals true, dispose all managed - // and unmanaged resources. - if(disposing) - { - // Dispose managed resources. - _binaryFileData = null; - } - } - disposed = true; - } - } -} diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/CHMFile.cs b/irc/TechBot/CHMLibrary/CHMDecoding/CHMFile.cs deleted file mode 100644 index a39ffc4d684..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/CHMFile.cs +++ /dev/null @@ -1,2061 +0,0 @@ -using System; -using System.Diagnostics; -using System.Collections; -using System.Collections.Specialized; -using System.IO; -using System.Text; -using System.Runtime.InteropServices; -using System.Globalization; -// using HtmlHelp.Storage; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// Internal enumeration for specifying the type of the html-help file - /// - internal enum HtmlHelpFileType - { - /// - /// CHM - compiled contents file - /// - /// A file with this extension must always exist. If the file would be too long, some parts - /// can be splitted into the filestypes below. - CHM = 0, - /// - /// CHI - compiled system file - /// - CHI = 1, - /// - /// CHQ - compiled fulltext search file - /// - CHQ = 2, - /// - /// CHW - compiled index file - /// - CHW = 3 - - } - - /// - /// The class CHMFile implemts methods and properties for handling a single chmfile. - /// - public sealed class CHMFile : IDisposable - { - /// - /// Internal member storing a reference to the hosting HtmlHelpSystem instance - /// - private HtmlHelpSystem _systemInstance = null; - /// - /// Internal flag specifying if only system data has been loaded - /// - private bool _onlySystem = false; - /// - /// Internal flag specifying if the object is going to be disposed - /// - private bool disposed = false; - /// - /// Internal arraylist containing the table of contents - /// - private ArrayList _toc = new ArrayList(); - /// - /// Internal arraylist containing items of the toc which are merge-Links - /// - private ArrayList _mergeLinks = new ArrayList(); - /// - /// Internal member storing the read information types - /// - private ArrayList _informationTypes = new ArrayList(); - /// - /// Internal member storing the read categories - /// - private ArrayList _categories = new ArrayList(); - /// - /// Internal arraylist containing the index (klinks) - /// - private ArrayList _indexKLinks = new ArrayList(); - /// - /// Internal arraylist containing the index (alinks) - /// - private ArrayList _indexALinks = new ArrayList(); - /// - /// Internal member storing the full filename - /// - private string _chmFileName = ""; - /// - /// Internal member storing the full filename of the chi-file (includes all system files) - /// The file name is zero-length if there is no chi-file - /// - private string _chiFileName = ""; - /// - /// Internal member storing the full filename of the chw-file (includes the help index) - /// The file name is zero-length if there is no chw-file - /// - private string _chwFileName = ""; - /// - /// Internal member storing the full filename of the chq-file (includes the fulltext contents) - /// The file name is zero-length if there is no chq-file - /// - private string _chqFileName = ""; - /// - /// Internal member storing the decoded information from the internal #SYSTEM file - /// - private CHMSystem _systemFile = null; - /// - /// Internal member storing the decoded information from the internal #IDXHDR file - /// - private CHMIdxhdr _idxhdrFile = null; - /// - /// Internal member storing the decoded information from the internal #STRINGS file - /// - private CHMStrings _stringsFile = null; - /// - /// Internal member storing the decoded information from the internal #URLSTR file - /// - private CHMUrlstr _urlstrFile = null; - /// - /// Internal member storing the decoded information from the internal #URLTBL file - /// - private CHMUrltable _urltblFile = null; - /// - /// Internal member storing the decoded information from the internal #TOPICS file - /// - private CHMTopics _topicsFile = null; - /// - /// Internal member storing the decoded information from the internal #TOCIDX file - /// - private CHMTocidx _tocidxFile = null; - /// - /// Internal member storing the decoded information from the internal binary index file (KLinks). - /// - private CHMBtree _kLinks = null; - /// - /// Internal member storing the decoded information from the internal binary index file (ALinks). - /// - private CHMBtree _aLinks = null; - /// - /// Internal member storing the fulltext searcher for this file - /// - private FullTextEngine _ftSearcher = null; - /// - /// Internal member storing the default encoder - /// - private Encoding _textEncoding = Encoding.GetEncoding(1252); // standard windows-1252 encoder - /// - /// Internal memebr storing the chm file info - /// - private ChmFileInfo _chmFileInfo = null; - /// - /// Internal flag specifying if the dump must be written (if enabled) - /// - private bool _mustWriteDump = false; - /// - /// Internal flag specifying if data was read using the dump - /// - private bool _dumpRead = false; - /// - /// Internal member for specifying the number of dump-reading trys. - /// If dump-reading fails, this is used that it will not be opened a second time - /// (in CHM-Systems with CHM, CHI, etc. files) - /// - private int _dumpReadTrys = 0; - /// - /// Internal member storing the dumping info instance - /// - private DumpingInfo _dmpInfo = null; - - private CHMStream.CHMStream _currentWrapper; - private CHMStream.CHMStream _baseStream=null; - public CHMStream.CHMStream BaseStream - { - get - { - if (_baseStream==null) - _baseStream=new CHMStream.CHMStream(this.ChmFilePath); - return _baseStream; - } - } - - /// - /// Creates a new instance of the class - /// - /// a reference to the hosting HtmlHelpSystem instance - /// chm file to read - public CHMFile(HtmlHelpSystem systemInstance, string chmFile) : this(systemInstance, chmFile, false, null) - { - } - - /// - /// Creates a new instance of the class - /// - /// a reference to the hosting HtmlHelpSystem instance - /// chm file to read - /// A dumping info class - public CHMFile(HtmlHelpSystem systemInstance, string chmFile, DumpingInfo dmpInfo) : this(systemInstance, chmFile, false, dmpInfo) - { - } - - /// - /// Creates a new instance of the class - /// - /// a reference to the hosting HtmlHelpSystem instance - /// chm file to read - /// true if only system data should be extracted (no index or toc) - internal CHMFile(HtmlHelpSystem systemInstance, string chmFile, bool onlySystemData) : this(systemInstance, chmFile, onlySystemData, null) - { - } - - /// - /// Creates a new instance of the class - /// - /// a reference to the hosting HtmlHelpSystem instance - /// chm file to read - /// true if only system data should be extracted (no index or toc) - /// A dumping info class - internal CHMFile(HtmlHelpSystem systemInstance, string chmFile, bool onlySystemData, DumpingInfo dmpInfo) - { - _systemInstance = systemInstance; - _dumpReadTrys=0; - - _dmpInfo = dmpInfo; - if(dmpInfo != null) - { - dmpInfo.ChmFile = this; - } - - if( ! chmFile.ToLower().EndsWith(".chm") ) - { - throw new ArgumentException("HtmlHelp file must have the extension .chm !", "chmFile"); - } - - _chmFileName = chmFile; - _chiFileName = ""; - - // Read the IStorage file system - if( File.Exists(chmFile) ) - { - _onlySystem = onlySystemData; - - DateTime dtStartHH = DateTime.Now; - - string sCHIName = _chmFileName.Substring(0, _chmFileName.Length-3) + "chi"; - string sCHQName = _chmFileName.Substring(0, _chmFileName.Length-3) + "chq"; - string sCHWName = _chmFileName.Substring(0, _chmFileName.Length-3) + "chw"; - - // If there is a CHI file present (this file includes the internal system files for the current chm file) - if( File.Exists(sCHIName) ) - { - _chiFileName = sCHIName; - - ReadFile(_chiFileName, HtmlHelpFileType.CHI); - } - - // If there is a CHW file present (this file includes the internal binary index of the help) - if(( File.Exists(sCHWName) ) && (!_onlySystem) ) - { - _chwFileName = sCHWName; - - ReadFile(_chwFileName, HtmlHelpFileType.CHW); - } - - // If there is a CHQ file present (this file includes the fulltext-search data) - if(( File.Exists(sCHQName) ) && (!_onlySystem) ) - { - _chqFileName = sCHQName; - - ReadFile(_chqFileName, HtmlHelpFileType.CHQ); - } - - ReadFile(chmFile, HtmlHelpFileType.CHM); - - if(_mustWriteDump) - { - _mustWriteDump = !SaveDump(dmpInfo); - - } - - // check the default-topic setting - if(_systemFile.DefaultTopic.Length > 0) - { - CHMStream.CHMStream iw=null; - iw = new CHMStream.CHMStream(chmFile); - _currentWrapper=iw; - - // tryo to open the topic file - MemoryStream fileObject = iw.OpenStream( _systemFile.DefaultTopic); - if( fileObject != null) - { - // if succeed, the topic default topic is OK - fileObject.Close(); - } - else - { - // set the first topic of the toc-tree as default topic - if(_toc.Count > 0) - { - _systemFile.SetDefaultTopic( ((TOCItem) _toc[0]).Local ); - } - } - _currentWrapper=null; - } - else - { - // set the first topic of the toc-tree as default topic - if(_toc.Count > 0) - { - _systemFile.SetDefaultTopic( ((TOCItem) _toc[0]).Local ); - } - } - - _chmFileInfo = new ChmFileInfo(this); - } - else - { - throw new ArgumentException("File '" + chmFile + "' not found !", "chmFile"); - } - } - - /// - /// Read a IStorage file - /// - /// filename - /// type of file - private void ReadFile(string fname, HtmlHelpFileType type) - { - CHMStream.CHMStream iw=null; - iw=new CHMStream.CHMStream(); - iw.OpenCHM(fname); - _currentWrapper=iw; - MemoryStream fileObject=null; - - // ITStorageWrapper iw = null; - - // Open the internal chm system files and parse their content - // FileObject fileObject = null; - // iw = new ITStorageWrapper(fname, false); - - if( (type != HtmlHelpFileType.CHQ) && (type != HtmlHelpFileType.CHW) ) - { - fileObject = iw.OpenStream("#SYSTEM"); - if ((fileObject != null) && (fileObject.Length>0)) - _systemFile = new CHMSystem(fileObject.ToArray(), this); - - fileObject = iw.OpenStream("#IDXHDR"); - if ((fileObject != null) && (fileObject.Length>0)) - _idxhdrFile = new CHMIdxhdr(fileObject.ToArray(), this); - - // try to read Dump - if((!_dumpRead)&&(CheckDump(_dmpInfo))&&(_dumpReadTrys==0)) - { - _dumpReadTrys++; - _dumpRead = LoadDump(_dmpInfo); - } - - if( (!_dumpRead)||(!_dmpInfo.DumpStrings) ) - { - fileObject = iw.OpenStream( "#STRINGS"); - if ((fileObject != null) && (fileObject.Length>0)) - _stringsFile = new CHMStrings(fileObject.ToArray(), this); - } - - if( (!_dumpRead)||(!_dmpInfo.DumpUrlStr) ) - { - fileObject = iw.OpenStream( "#URLSTR"); - if ((fileObject != null) && (fileObject.Length>0)) - _urlstrFile = new CHMUrlstr(fileObject.ToArray(), this); - } - - if( (!_dumpRead)||(!_dmpInfo.DumpUrlTbl) ) - { - fileObject = iw.OpenStream( "#URLTBL"); - if ((fileObject != null) && (fileObject.Length>0)) - _urltblFile = new CHMUrltable(fileObject.ToArray(), this); - } - - if( (!_dumpRead)||(!_dmpInfo.DumpTopics) ) - { - fileObject = iw.OpenStream( "#TOPICS"); - if ((fileObject != null) && (fileObject.Length>0)) - _topicsFile = new CHMTopics(fileObject.ToArray(), this); - } - - if(!_onlySystem) - { - if( (!_dumpRead)||(!_dmpInfo.DumpBinaryTOC) ) - { - fileObject = iw.OpenStream( "#TOCIDX"); - if( (fileObject != null) && (fileObject.Length>0) && (_systemFile.BinaryTOC) ) - { - _tocidxFile = new CHMTocidx(fileObject.ToArray(), this); - _toc = _tocidxFile.TOC; - } - } - } - - if( (_systemFile != null) && (!_onlySystem) ) - { - if(!_systemFile.BinaryTOC) - { - if( (!_dumpRead)||(!_dmpInfo.DumpTextTOC) ) - { - CHMStream.chmUnitInfo HHCInfo=iw.GetFileInfoByExtension(".hhc"); - if (HHCInfo!=null) - { - fileObject = iw.OpenStream(HHCInfo); - if ((fileObject != null) && (fileObject.Length>0)) - { - ASCIIEncoding ascii=new ASCIIEncoding(); - string fileString =ascii.GetString(fileObject.ToArray(),0,(int)fileObject.Length); - - _toc = HHCParser.ParseHHC(fileString, this); - } - - if(HHCParser.HasMergeLinks) - _mergeLinks = HHCParser.MergeItems; - } - } - } - } - } - - if( type != HtmlHelpFileType.CHQ ) // no index information in CHQ files (only fulltext search) - { - if( (_systemFile != null) && (!_onlySystem) ) - { - if( ! _systemFile.BinaryIndex ) - { - if( (!_dumpRead)||(!_dmpInfo.DumpTextIndex) ) - { - fileObject = iw.OpenStream( _systemFile.IndexFile); - if ((fileObject != null) && (fileObject.Length>0)) - { - - string fileString = this.TextEncoding.GetString(fileObject.ToArray(),0,(int)fileObject.Length); - // string fileString = fileObject.ReadFromFile(this.TextEncoding); - fileObject.Close(); - - _indexKLinks = HHKParser.ParseHHK(fileString, this); - _indexKLinks.Sort(); - } - } - } - else - { - if( (!_dumpRead)||(!_dmpInfo.DumpBinaryIndex) ) - { - fileObject=iw.OpenStream(@"$WWKeywordLinks\BTree"); - if ((fileObject != null) && (fileObject.Length>0)) - { - _kLinks = new CHMBtree(fileObject.ToArray(), this); - _indexKLinks = _kLinks.IndexList; - } - - fileObject =iw.OpenStream(@"$WWAssociativeLinks\BTree"); - if ((fileObject != null) && (fileObject.Length>0)) - { - _aLinks = new CHMBtree(fileObject.ToArray(), this); - _indexALinks = _aLinks.IndexList; - _indexALinks.Sort(); - } - } - } - } - } - - if( (type != HtmlHelpFileType.CHI) && (type != HtmlHelpFileType.CHW) ) - { - if( (_systemFile != null) && (!_onlySystem) ) - { - if( _systemFile.FullTextSearch) - { - if( (!_dumpRead)||(!_dmpInfo.DumpFullText) ) - { - fileObject = iw.OpenStream("$FIftiMain"); - if(( fileObject != null) && (fileObject .Length>0)) - _ftSearcher = new FullTextEngine(fileObject .ToArray(), this); - } - } - } - } - _currentWrapper=null; - } - - /// - /// Enumerates the files in the chm storage and gets all files matching a given extension. - /// - /// extension to return - /// Returns an arraylist of filenames or null if nothing found - /// On large CHMs, enumerations are very slow. Only use it if necessary ! - internal ArrayList EnumFilesByExtension(string extension) - { - ArrayList arrRet = new ArrayList(); - - CHMStream.CHMStream iw = null; - if(_currentWrapper == null) - iw = new CHMStream.CHMStream(_chmFileName); - else - iw = _currentWrapper; - - arrRet=iw.GetFileListByExtenstion(extension); - - if(arrRet.Count > 0) - return arrRet; - - return null; - } - - /// - /// Searches an TOC entry using the local - /// - /// local to search - /// Returns the TOC item - internal TOCItem GetTOCItemByLocal(string local) - { - return GetTOCItemByLocal(this.TOC, local); - } - - /// - /// Recursively searches an TOC entry using its local - /// - /// toc level list - /// local to search - /// Returns the TOC item - private TOCItem GetTOCItemByLocal(ArrayList arrTOC, string local) - { - TOCItem ret = null; - foreach(TOCItem curItem in arrTOC) - { - string scL = curItem.Local.ToLower(); - string sL = local.ToLower(); - - while(scL[0]=='/') // delete prefixing '/' - scL = scL.Substring(1); - - while(sL[0]=='/') // delete prefixing '/' - sL = sL.Substring(1); - - if(scL == sL) - return curItem; - - if(curItem.Children.Count > 0) - { - ret = GetTOCItemByLocal(curItem.Children, local); - if(ret != null) - return ret; - } - } - - return ret; - } - - /// - /// Removes a TOCItem from the toc - /// - /// item to remove - /// Returns true if removed - internal bool RemoveTOCItem(TOCItem rem) - { - if(rem == null) - return false; - - return RemoveTOCItem(this.TOC, rem); - } - - /// - /// Recursively searches a TOCItem and removes it if found - /// - /// toc level list - /// item to remove - /// Returns true if removed - private bool RemoveTOCItem(ArrayList arrTOC, TOCItem rem) - { - for(int i=0; i 0) - { - bool bRem = RemoveTOCItem(curItem.Children, rem); - if(bRem) - return true; - } - } - - return false; - } - - /// - /// Returns true if the HtmlHelpSystem instance contains 1 or more information types - /// - public bool HasInformationTypes - { - get { return (_informationTypes.Count>0); } - } - - /// - /// Returns true if the HtmlHelpSystem instance contains 1 or more categories - /// - public bool HasCategories - { - get { return (_categories.Count>0); } - } - - /// - /// Gets an ArrayList of InformationType items - /// - public ArrayList InformationTypes - { - get { return _informationTypes; } - } - - /// - /// Gets an ArrayList of Category items - /// - public ArrayList Categories - { - get { return _categories; } - } - - /// - /// Gets the information type specified by its name - /// - /// name of the information type to receive - /// Returns the Instance for the name or null if not found - public InformationType GetInformationType(string name) - { - if(HasInformationTypes) - { - for(int i=0; i<_informationTypes.Count;i++) - { - InformationType iT = _informationTypes[i] as InformationType; - - if(iT.Name == name) - return iT; - } - } - - return null; - } - - /// - /// Gets the category specifiyd by its name - /// - /// name of the category - /// Returns the Instance for the name or null if not found - public Category GetCategory(string name) - { - if(HasCategories) - { - for(int i=0; i<_categories.Count;i++) - { - Category cat = _categories[i] as Category; - - if(cat.Name == name) - return cat; - } - } - - return null; - } - - #region Dumping methods - - /// - /// Checks if a dump for this file exists and if it can be read - /// - /// dumping info class - /// true if it can be read - private bool CheckDump(DumpingInfo dmpInfo) - { - if(_dumpReadTrys<=0) - _mustWriteDump = false; - - if(_onlySystem) - return false; - - if( dmpInfo != null ) - { - if(_dumpReadTrys > 0) - return _mustWriteDump; - - _mustWriteDump = !dmpInfo.DumpExists; - return !_mustWriteDump; - } - - return false; - } - - /// - /// Saves the the toc and index into a data dump - /// - /// dumping info - /// true if succeed - private bool SaveDump(DumpingInfo dmpInfo) - { - if(dmpInfo == null) - return false; - - bool bRet = false; - - - BinaryWriter writer = dmpInfo.Writer; - - int nCnt = 0; - try - { - Debug.WriteLine("writing dump-file header"); - FileInfo fi = new FileInfo(_chmFileName); - string ftime = fi.LastWriteTime.ToString("dd.MM.yyyy HH:mm:ss.ffffff"); - - writer.Write("HtmlHelpSystem dump file 1.0"); - writer.Write(ftime); - writer.Write(_textEncoding.CodePage); - - // strings dumping - if(dmpInfo.DumpStrings) - { - writer.Write(true); // data should be in dump - - if(_stringsFile==null) - { - writer.Write(false); // data not supported by the chm - } - else - { - Debug.WriteLine("writing #STRINGS"); - writer.Write(true); // data supported and following - _stringsFile.Dump(ref writer); - } - } - else - { - writer.Write(false); // data is not in dump - } - - // urlstr dumping - if(dmpInfo.DumpUrlStr) - { - writer.Write(true); - - if(_urlstrFile==null) - { - writer.Write(false); - } - else - { - Debug.WriteLine("writing #URLSTR"); - writer.Write(true); - _urlstrFile.Dump(ref writer); - } - } - else - { - writer.Write(false); - } - - // urltbl dumping - if(dmpInfo.DumpUrlTbl) - { - writer.Write(true); - - if(_urltblFile==null) - { - writer.Write(false); - } - else - { - Debug.WriteLine("writing #URLTBL"); - writer.Write(true); - _urltblFile.Dump(ref writer); - } - } - else - { - writer.Write(false); - } - - // topics dumping - if(dmpInfo.DumpTopics) - { - writer.Write(true); - - if(_topicsFile==null) - { - writer.Write(false); - } - else - { - Debug.WriteLine("writing #TOPICS"); - writer.Write(true); - _topicsFile.Dump(ref writer); - } - } - else - { - writer.Write(false); - } - - // ftsearch dumping - if(dmpInfo.DumpFullText) - { - writer.Write(true); - - if(_ftSearcher==null) - { - writer.Write(false); - } - else - { - Debug.WriteLine("writing $FIftiMain"); - writer.Write(true); - _ftSearcher.Dump(ref writer); - } - } - else - { - writer.Write(false); - } - - // TOC dumping - bool bWriteTOC = false; - - if( (_systemFile.BinaryTOC) && (dmpInfo.DumpBinaryTOC) ) - { - Debug.WriteLine("writing binary TOC"); - bWriteTOC = true; - } - - if( (!_systemFile.BinaryTOC) && (dmpInfo.DumpTextTOC) ) - { - Debug.WriteLine("writing text-based TOC"); - bWriteTOC = true; - } - - writer.Write(bWriteTOC); - - if(bWriteTOC) - { - // write table of contents - writer.Write( _toc.Count ); - - for(nCnt=0; nCnt < _toc.Count; nCnt++) - { - TOCItem curItem = ((TOCItem)(_toc[nCnt])); - curItem.Dump( ref writer ); - } - } - - // Index dumping - bool bWriteIdx = false; - - if( (_systemFile.BinaryIndex) && (dmpInfo.DumpBinaryIndex) ) - { - Debug.WriteLine("writing binary index"); - bWriteIdx = true; - } - - if( (!_systemFile.BinaryIndex) && (dmpInfo.DumpTextIndex) ) - { - Debug.WriteLine("writing text-based index"); - bWriteIdx = true; - } - - writer.Write(bWriteIdx); - - if(bWriteIdx) - { - // write index - writer.Write( _indexALinks.Count ); - for(nCnt=0; nCnt < _indexALinks.Count; nCnt++) - { - IndexItem curItem = ((IndexItem)(_indexALinks[nCnt])); - curItem.Dump( ref writer ); - } - - writer.Write( _indexKLinks.Count ); - for(nCnt=0; nCnt < _indexKLinks.Count; nCnt++) - { - IndexItem curItem = ((IndexItem)(_indexKLinks[nCnt])); - curItem.Dump( ref writer ); - } - } - - // Information types dumping - writer.Write( _informationTypes.Count ); - - Debug.WriteLine("writing " + _informationTypes.Count.ToString() + " information types"); - - for(nCnt=0; nCnt<_informationTypes.Count;nCnt++) - { - InformationType curType = _informationTypes[nCnt] as InformationType; - - curType.Dump(ref writer); - } - - // Categories dumping - writer.Write( _categories.Count ); - - Debug.WriteLine("writing " + _categories.Count.ToString() + " categories"); - - for(nCnt=0; nCnt<_categories.Count; nCnt++) - { - Category curCat = _categories[nCnt] as Category; - - curCat.Dump( ref writer); - } - - bRet=true; - } - finally - { - dmpInfo.SaveData(); - } - - return bRet; - } - - /// - /// Parses a HHC file which is located in the current CHM. - /// - /// hhc file to parse - /// an arraylist with toc items - public ArrayList ParseHHC(string hhcFile) - { - ArrayList arrRet = new ArrayList(); - - CHMStream.CHMStream iw=null; - iw=new CHMStream.CHMStream(); - iw.OpenCHM(_chmFileName); - MemoryStream fileObject=null; - - fileObject = iw.OpenStream(hhcFile); - if( fileObject != null) - { - ASCIIEncoding ascii=new ASCIIEncoding(); - string fileString =ascii.GetString(fileObject.ToArray(),0,(int)fileObject.Length); - fileObject.Close(); - - arrRet = HHCParser.ParseHHC(fileString, this); - - if(HHCParser.HasMergeLinks) - { - foreach(TOCItem curItem in HHCParser.MergeItems) - { - _mergeLinks.Add(curItem); - } - } - } - - return arrRet; - } - - /// - /// Loads the toc and index from a data dump - /// - /// dumping info - /// true if succeed - private bool LoadDump(DumpingInfo dmpInfo) - { - if(dmpInfo == null) - return false; - - bool bRet = false; - - try - { - BinaryReader reader = dmpInfo.Reader; - - if(reader == null) - { - Debug.WriteLine("No reader returned !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; - } - - int nCnt = 0; - - Debug.WriteLine("reading dump-file header"); - FileInfo fi = new FileInfo(_chmFileName); - string ftime = fi.LastWriteTime.ToString("dd.MM.yyyy HH:mm:ss.ffffff"); - - string header = reader.ReadString(); - - if( header != "HtmlHelpSystem dump file 1.0") - { - Debug.WriteLine("Unsupported dump-file format !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; - } - - string ftimecheck = reader.ReadString(); - - reader.ReadInt32(); // codepage, we'll use the same as for the chm file which is already set. - -// if(ftimecheck != ftime) -// { -// Debug.WriteLine("Dump is out of date (CHM file changed during last dump creation) !"); -// dmpInfo.SaveData(); // closes the dump -// _mustWriteDump = true; -// return false; // force reload -// } - - - bool bFlag=false; // true if data should be in dump - bool bFlagSupp=false; // false if data is not supported by the chm - - bFlag = reader.ReadBoolean(); - - if(bFlag) - { - bFlagSupp = reader.ReadBoolean(); - - if(!dmpInfo.DumpStrings) - { - Debug.WriteLine("Dumped #STRINGS found but not expected !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - - if(bFlagSupp) - { - Debug.WriteLine("reading #STRINGS"); - _stringsFile = new CHMStrings(); - _stringsFile.SetCHMFile(this); - _stringsFile.ReadDump(ref reader); - } - } - else - { - if(dmpInfo.DumpStrings) - { - Debug.WriteLine("Dumped #STRINGS expected but not found !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - } - - bFlag = reader.ReadBoolean(); - - if(bFlag) - { - bFlagSupp = reader.ReadBoolean(); - - if(!dmpInfo.DumpUrlStr) - { - Debug.WriteLine("Dumped #URLSTR found but not expected !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - - if(bFlagSupp) - { - Debug.WriteLine("reading #URLSTR"); - _urlstrFile = new CHMUrlstr(); - _urlstrFile.SetCHMFile(this); - _urlstrFile.ReadDump(ref reader); - } - } - else - { - if(dmpInfo.DumpUrlStr) - { - Debug.WriteLine("Dumped #URLSTR expected but not found !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - } - - bFlag = reader.ReadBoolean(); - - if(bFlag) - { - bFlagSupp = reader.ReadBoolean(); - - if(!dmpInfo.DumpUrlTbl) - { - Debug.WriteLine("Dumped #URLTBL found but not expected !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - - if(bFlagSupp) - { - Debug.WriteLine("reading #URLTBL"); - _urltblFile = new CHMUrltable(); - _urltblFile.SetCHMFile(this); - _urltblFile.ReadDump(ref reader); - } - } - else - { - if(dmpInfo.DumpUrlTbl) - { - Debug.WriteLine("Dumped #URLTBL expected but not found !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - } - - bFlag = reader.ReadBoolean(); - - if(bFlag) - { - bFlagSupp = reader.ReadBoolean(); - - if(!dmpInfo.DumpTopics) - { - Debug.WriteLine("Dumped #TOPICS found but not expected !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - - if(bFlagSupp) - { - Debug.WriteLine("reading #TOPICS"); - _topicsFile = new CHMTopics(); - _topicsFile.SetCHMFile(this); - _topicsFile.ReadDump(ref reader); - } - } - else - { - if(dmpInfo.DumpTopics) - { - Debug.WriteLine("Dumped #TOPICS expected but not found !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - } - - bFlag = reader.ReadBoolean(); - - if(bFlag) - { - bFlagSupp = reader.ReadBoolean(); - - if(!dmpInfo.DumpFullText) - { - Debug.WriteLine("Dumped $FIftiMain found but not expected !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - - if(bFlagSupp) - { - Debug.WriteLine("reading $FIftiMain"); - _ftSearcher = new FullTextEngine(); - _ftSearcher.SetCHMFile(this); - _ftSearcher.ReadDump(ref reader); - } - } - else - { - if(dmpInfo.DumpFullText) - { - Debug.WriteLine("Dumped $FIftiMain expected but not found !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - } - - // read table of contents - _toc.Clear(); - bFlag = reader.ReadBoolean(); - - if(bFlag) - { - if((_systemFile.BinaryTOC)&&(!dmpInfo.DumpBinaryTOC)) - { - Debug.WriteLine("Binary TOC expected but not found !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - - if((!_systemFile.BinaryTOC)&&(!dmpInfo.DumpTextTOC)) - { - Debug.WriteLine("Text-based TOC expected but not found !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - - if(_systemFile.BinaryTOC) - Debug.WriteLine("reading binary TOC"); - else - Debug.WriteLine("reading text-based TOC"); - - int nTocCnt = reader.ReadInt32(); - - for(nCnt=0; nCnt < nTocCnt; nCnt++) - { - TOCItem item = new TOCItem(); - item.AssociatedFile = this; - item.ChmFile = _chmFileName; - item.ReadDump(ref reader); - if(item.MergeLink.Length > 0) - _mergeLinks.Add(item); - - _toc.Add(item); - } - } - else - { - if((_systemFile.BinaryTOC)&&(dmpInfo.DumpBinaryTOC)) - { - Debug.WriteLine("Binary TOC expected but no TOC dump !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - - if((!_systemFile.BinaryTOC)&&(dmpInfo.DumpTextTOC)) - { - Debug.WriteLine("Text-based TOC expected but no TOC dump !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - } - - // read index - _indexALinks.Clear(); - _indexKLinks.Clear(); - - bFlag = reader.ReadBoolean(); - - if(bFlag) - { - if((_systemFile.BinaryIndex)&&(!dmpInfo.DumpBinaryIndex)) - { - Debug.WriteLine("Binary index expected but not found !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - - if((!_systemFile.BinaryIndex)&&(!dmpInfo.DumpTextIndex)) - { - Debug.WriteLine("Binary index expected but not found !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - - if(_systemFile.BinaryIndex) - Debug.WriteLine("reading binary index"); - else - Debug.WriteLine("reading text-based index"); - - int nIndxaCnt = reader.ReadInt32(); - - for(nCnt=0; nCnt < nIndxaCnt; nCnt++) - { - IndexItem item = new IndexItem(); - item.ChmFile = this; - item.ReadDump(ref reader); - _indexALinks.Add(item); - } - - - int nIndxkCnt = reader.ReadInt32(); - - for(nCnt=0; nCnt < nIndxkCnt; nCnt++) - { - IndexItem item = new IndexItem(); - item.ChmFile = this; - item.ReadDump(ref reader); - _indexKLinks.Add(item); - } - } - else - { - if((_systemFile.BinaryIndex)&&(dmpInfo.DumpBinaryIndex)) - { - Debug.WriteLine("Binary index expected but no index in dump !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - - if((!_systemFile.BinaryIndex)&&(dmpInfo.DumpTextIndex)) - { - Debug.WriteLine("Text-based index expected but no index dump !"); - dmpInfo.SaveData(); // closes the dump - _mustWriteDump = true; - return false; // force reload - } - } - - // read information types from dump - int nITCnt = reader.ReadInt32(); - - Debug.WriteLine("Reading " + nITCnt.ToString() + " information types from dump !"); - - for(nCnt=0; nCnt - /// Gets the current storage wrapper. - /// - /// This property will return not null, if there are currently file read actions running ! - internal CHMStream.CHMStream CurrentStorageWrapper - { - get { return _currentWrapper;} - } - /// - /// Gets/sets the hosting HtmlHelpSystem instance - /// - internal HtmlHelpSystem SystemInstance - { - get { return _systemInstance; } - set { _systemInstance = value; } - } - /// - /// Gets an arraylist of TOC items which contains merg-links to other CHMs - /// - internal ArrayList MergLinks - { - get { return _mergeLinks; } - } - - /// - /// Gets the internal system file instance - /// - internal CHMSystem SystemFile - { - get { return _systemFile; } - } - - /// - /// Gets the internal idxhdr file instance - /// - internal CHMIdxhdr IdxHdrFile - { - get { return _idxhdrFile; } - } - - /// - /// Gets the internal strings file instance - /// - internal CHMStrings StringsFile - { - get { return _stringsFile; } - } - - /// - /// Gets the internal urlstr file instance - /// - internal CHMUrlstr UrlstrFile - { - get { return _urlstrFile; } - } - - /// - /// Gets the internal urltbl file instance - /// - internal CHMUrltable UrltblFile - { - get { return _urltblFile; } - } - - /// - /// Gets the internal topics file instance - /// - internal CHMTopics TopicsFile - { - get { return _topicsFile; } - } - - /// - /// Gets the internal tocidx file instance - /// - internal CHMTocidx TocidxFile - { - get { return _tocidxFile; } - } - - /// - /// Gets the internal btree file instance for alinks - /// - internal CHMBtree ALinksFile - { - get { return _aLinks; } - } - - /// - /// Gets the internal btree file instance for klinks - /// - internal CHMBtree KLinksFile - { - get { return _kLinks; } - } - - /// - /// Gets/Sets the text encoding - /// - internal Encoding TextEncoding - { - get { return _textEncoding; } - set { _textEncoding = value; } - } - - #endregion - - #region Properties from the #SYSTEM file - /// - /// Gets the file version of the chm file. - /// 2 for Compatibility=1.0, 3 for Compatibility=1.1 - /// - internal int FileVersion - { - get - { - if(_systemFile==null) - return 0; - - return _systemFile.FileVersion; - } - } - - /// - /// Gets the contents file name - /// - internal string ContentsFile - { - get - { - if(_systemFile==null) - return String.Empty; - - return _systemFile.ContentsFile; - } - } - - /// - /// Gets the index file name - /// - internal string IndexFile - { - get - { - if(_systemFile==null) - return String.Empty; - - return _systemFile.IndexFile; - } - } - - /// - /// Gets the default help topic - /// - internal string DefaultTopic - { - get - { - if(_systemFile==null) - return String.Empty; - - return _systemFile.DefaultTopic; - } - } - - /// - /// Gets the title of the help window - /// - internal string HelpWindowTitle - { - get - { - if(_systemFile==null) - return String.Empty; - - return _systemFile.Title; - } - } - - /// - /// Gets the flag if DBCS is in use - /// - internal bool DBCS - { - get - { - if(_systemFile==null) - return false; - - return _systemFile.DBCS; - } - } - - /// - /// Gets the flag if full-text-search is available - /// - internal bool FullTextSearch - { - get - { - if(_systemFile==null) - return false; - - return _systemFile.FullTextSearch; - } - } - - /// - /// Gets the flag if the file has ALinks - /// - internal bool HasALinks - { - get - { - if(_systemFile==null) - return false; - - return _systemFile.HasALinks; - } - } - - /// - /// Gets the flag if the file has KLinks - /// - internal bool HasKLinks - { - get - { - if(_systemFile==null) - return false; - - return _systemFile.HasKLinks; - } - } - - /// - /// Gets the default window name - /// - internal string DefaultWindow - { - get - { - if(_systemFile==null) - return String.Empty; - - return _systemFile.DefaultWindow; - } - } - - /// - /// Gets the file name of the compile file - /// - internal string CompileFile - { - get - { - if(_systemFile==null) - return String.Empty; - - return _systemFile.CompileFile; - } - } - - /// - /// Gets the flag if the chm has a binary index file - /// - internal bool BinaryIndex - { - get - { - if(_systemFile==null) - return false; - - return _systemFile.BinaryIndex; - } - } - - /// - /// Gets the flag if the chm has a binary index file - /// - internal string CompilerVersion - { - get - { - if(_systemFile==null) - return String.Empty; - - return _systemFile.CompilerVersion; - } - } - - /// - /// Gets the flag if the chm has a binary toc file - /// - internal bool BinaryTOC - { - get - { - if(_systemFile==null) - return false; - - return _systemFile.BinaryTOC; - } - } - - /// - /// Gets the font face of the read font property. - /// Empty string for default font. - /// - internal string FontFace - { - get - { - if(_systemFile==null) - return ""; - - return _systemFile.FontFace; - } - } - - /// - /// Gets the font size of the read font property. - /// 0 for default font size - /// - internal double FontSize - { - get - { - if(_systemFile==null) - return 0; - - return _systemFile.FontSize; - } - } - - /// - /// Gets the character set of the read font property - /// 1 for default - /// - internal int CharacterSet - { - get - { - if(_systemFile==null) - return 1; - - return _systemFile.CharacterSet; - } - } - - /// - /// Gets the codepage depending on the read font property - /// - internal int CodePage - { - get - { - if(_systemFile==null) - return CultureInfo.CurrentCulture.TextInfo.ANSICodePage; - - return _systemFile.CodePage; - } - } - - /// - /// Gets the assiciated culture info - /// - internal CultureInfo Culture - { - get - { - if(_systemFile==null) - return CultureInfo.CurrentCulture; - - return _systemFile.Culture; - } - } - - #endregion - - #region Properties from the #IDXHDR file - /// - /// Gets the number of topic nodes including the contents and index files - /// - internal int NumberOfTopicNodes - { - get - { - if(_idxhdrFile==null) - return 0; - - return _idxhdrFile.NumberOfTopicNodes; - } - } - - /// - /// Gets the ImageList string specyfied in the #IDXHDR file. - /// - /// This property uses the #STRINGS file to extract the string at a given offset. - internal string ImageList - { - get - { - if( (_stringsFile == null) || (_idxhdrFile == null) ) - return ""; - - return _stringsFile[ _idxhdrFile.ImageListOffset ]; - } - } - - /// - /// True if the value of the ImageType param of the - /// "text/site properties" object of the sitemap contents is "Folder". - /// - /// If this is set to true, the help will display folders instead of books - internal bool ImageTypeFolder - { - get - { - if(_idxhdrFile==null) - return false; - - return _idxhdrFile.ImageTypeFolder; - } - } - - /// - /// Gets the background setting - /// - internal int Background - { - get - { - if(_idxhdrFile==null) - return 0; - - return _idxhdrFile.Background; - } - } - - /// - /// Gets the foreground setting - /// - internal int Foreground - { - get - { - if(_idxhdrFile==null) - return 0; - - return _idxhdrFile.Foreground; - } - } - - /// - /// Gets the Font string specyfied in the #IDXHDR file. - /// - /// This property uses the #STRINGS file to extract the string at a given offset. - internal string FontName - { - get - { - if( (_stringsFile == null) || (_idxhdrFile == null) ) - return ""; - - return _stringsFile[ _idxhdrFile.FontOffset ]; - } - } - - /// - /// Gets the FrameName string specyfied in the #IDXHDR file. - /// - /// This property uses the #STRINGS file to extract the string at a given offset. - internal string FrameName - { - get - { - if( (_stringsFile == null) || (_idxhdrFile == null) ) - return ""; - - return _stringsFile[ _idxhdrFile.FrameNameOffset ]; - } - } - - /// - /// Gets the WindowName string specyfied in the #IDXHDR file. - /// - /// This property uses the #STRINGS file to extract the string at a given offset. - internal string WindowName - { - get - { - if( (_stringsFile == null) || (_idxhdrFile == null) ) - return ""; - - return _stringsFile[ _idxhdrFile.WindowNameOffset ]; - } - } - - /// - /// Gets a string array containing the merged file names - /// - internal string[] MergedFiles - { - get - { - if( (_stringsFile == null) || (_idxhdrFile == null) ) - return new string[0]; - - string[] saRet = new string[ _idxhdrFile.MergedFileOffsets.Count ]; - - for(int i=0; i < _idxhdrFile.MergedFileOffsets.Count; i++) - { - saRet[i] = _stringsFile[ (int)_idxhdrFile.MergedFileOffsets[i] ]; - } - - return saRet; - } - } - #endregion - - /// - /// Gets the file info associated with this instance - /// - public ChmFileInfo FileInfo - { - get { return _chmFileInfo; } - } - - /// - /// Gets the internal toc read from the text-based hhc file - /// - public ArrayList TOC - { - get { return _toc; } - } - - /// - /// Gets the internal index read from the chm file. - /// - public ArrayList IndexKLinks - { - get { return _indexKLinks; } - } - - /// - /// Gets the internal index read from the chm file. - /// - public ArrayList IndexALinks - { - get { return _indexALinks; } - } - - /// - /// Gets the full-text search engine for this file - /// - internal FullTextEngine FullTextSearchEngine - { - get { return _ftSearcher; } - } - - /// - /// Gets the full pathname of the file - /// - public string ChmFilePath - { - get { return _chmFileName; } - } - - /// - /// Gets the full pathname of the chi-file - /// The file name is zero-length if there is no chi-file - /// - public string ChiFilePath - { - get { return _chiFileName; } - } - - /// - /// Gets the full pathname of the chw-file - /// The file name is zero-length if there is no chw-file - /// - public string ChwFilePath - { - get { return _chwFileName; } - } - - /// - /// Gets the full pathname of the chq-file - /// The file name is zero-length if there is no chq-file - /// - public string ChqFilePath - { - get { return _chqFileName; } - } - - /// - /// Forms an URL for the web browser - /// - /// local resource - /// a url for the web-browser - internal string FormURL(string local) - { - if( (local.ToLower().IndexOf("http://") >= 0) || - (local.ToLower().IndexOf("https://") >= 0) || - (local.ToLower().IndexOf("mailto:") >= 0) || - (local.ToLower().IndexOf("ftp://") >= 0) || - (local.ToLower().IndexOf("ms-its:") >= 0)) - return local; - - return HtmlHelpSystem.UrlPrefix + _chmFileName + "::/" + local; - } - - /// - /// Implement IDisposable. - /// - public void Dispose() - { - Dispose(true); - // This object will be cleaned up by the Dispose method. - // Therefore, you should call GC.SupressFinalize to - // take this object off the finalization queue - // and prevent finalization code for this object - // from executing a second time. - GC.SuppressFinalize(this); - } - - /// - /// Dispose(bool disposing) executes in two distinct scenarios. - /// If disposing equals true, the method has been called directly - /// or indirectly by a user's code. Managed and unmanaged resources - /// can be disposed. - /// If disposing equals false, the method has been called by the - /// runtime from inside the finalizer and you should not reference - /// other objects. Only unmanaged resources can be disposed. - /// - /// disposing flag - private void Dispose(bool disposing) - { - // Check to see if Dispose has already been called. - if(!this.disposed) - { - // If disposing equals true, dispose all managed - // and unmanaged resources. - if(disposing) - { - // Dispose managed resources. - _toc.Clear(); - _indexKLinks.Clear(); - _indexALinks.Clear(); - - if(_systemFile!=null) - _systemFile.Dispose(); - - if(_idxhdrFile != null) - _idxhdrFile.Dispose(); - - if(_stringsFile != null) - _stringsFile.Dispose(); - - if(_urlstrFile != null) - _urlstrFile.Dispose(); - - if(_urltblFile != null) - _urltblFile.Dispose(); - - if(_topicsFile != null) - _topicsFile.Dispose(); - - if(_tocidxFile != null) - _tocidxFile.Dispose(); - - if(_kLinks != null) - _kLinks.Dispose(); - - if(_aLinks != null) - _aLinks.Dispose(); - - if(_ftSearcher != null) - _ftSearcher.Dispose(); - - if(_chmFileInfo != null) - _chmFileInfo = null; - } - } - disposed = true; - } - - } -} diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/CHMIdxhdr.cs b/irc/TechBot/CHMLibrary/CHMDecoding/CHMIdxhdr.cs deleted file mode 100644 index 7ac64ac3ea7..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/CHMIdxhdr.cs +++ /dev/null @@ -1,286 +0,0 @@ -using System; -using System.Collections; -using System.IO; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// The class CHMIdxhdr implements t properties which have been read from the #IDXHDR file. - /// - internal sealed class CHMIdxhdr : IDisposable - { - /// - /// Internal flag specifying if the object is going to be disposed - /// - private bool disposed = false; - /// - /// Internal member storing the binary file data - /// - private byte[] _binaryFileData = null; - /// - /// Internal member storing the number of topic nodes including the contents and index files - /// - private int _numberOfTopicNodes = 0; - /// - /// Internal member storing the offset in the #STRINGS file of the ImageList param of the "text/site properties" object of the sitemap contents - /// - private int _imageListOffset = 0; - /// - /// True if the value of the ImageType param of the "text/site properties" object of the sitemap contents is "Folder". - /// - private bool _imageTypeFolder = false; - /// - /// Internal member storing the background value - /// - private int _background = 0; - /// - /// Internal member storing the foreground value - /// - private int _foreground = 0; - /// - /// Internal member storing the offset in the #STRINGS file of the Font param of the "text/site properties" object of the sitemap contents - /// - private int _fontOffset = 0; - /// - /// Internal member storing the offset in the #STRINGS file of the FrameName param of the "text/site properties" object of the sitemap contents - /// - private int _frameNameOffset = 0; - /// - /// Internal member storing the offset in the #STRINGS file of the WindowName param of the "text/site properties" object of the sitemap contents - /// - private int _windowNameOffset = 0; - /// - /// Internal member storing the number of merged files - /// - private int _numberOfMergedFiles = 0; - /// - /// Internal member storing the offset in the #STRINGS file of the merged file names - /// - private ArrayList _mergedFileOffsets = new ArrayList(); - /// - /// Internal member storing the associated chmfile object - /// - private CHMFile _associatedFile = null; - - /// - /// Constructor of the class - /// - /// binary file data of the #IDXHDR file - /// associated CHMFile instance - public CHMIdxhdr(byte[] binaryFileData, CHMFile associatedFile) - { - _binaryFileData = binaryFileData; - _associatedFile = associatedFile; - DecodeData(); - } - - /// - /// Decodes the binary file data and fills the internal properties - /// - /// true if succeeded - private bool DecodeData() - { - bool bRet = true; - - MemoryStream memStream = new MemoryStream(_binaryFileData); - BinaryReader binReader = new BinaryReader(memStream); - - int nTemp = 0; - - // 4 character T#SM - binReader.ReadBytes(4); - // unknown timestamp DWORD - nTemp = binReader.ReadInt32(); - - // unknown 1 - nTemp = binReader.ReadInt32(); - - // number of topic nodes including the contents & index files - _numberOfTopicNodes = binReader.ReadInt32(); - - // unknown DWORD - nTemp = binReader.ReadInt32(); - - // offset in the strings file - _imageListOffset = binReader.ReadInt32(); - if( _imageListOffset == 0) - _imageListOffset = -1; // 0/-1 = none - - // unknown DWORD - nTemp = binReader.ReadInt32(); - - // 1 if the value of the ImageType param of the "text/site properties" object of the sitemap contents is "Folder". - nTemp = binReader.ReadInt32(); - _imageTypeFolder = (nTemp == 1); - - // offset in the strings file - _background = binReader.ReadInt32(); - // offset in the strings file - _foreground = binReader.ReadInt32(); - - // offset in the strings file - _fontOffset = binReader.ReadInt32(); - - // window styles DWORD - nTemp = binReader.ReadInt32(); - // window styles DWORD - nTemp = binReader.ReadInt32(); - - // unknown DWORD - nTemp = binReader.ReadInt32(); - - // offset in the strings file - _frameNameOffset = binReader.ReadInt32(); - if( _frameNameOffset == 0) - _frameNameOffset = -1; // 0/-1 = none - // offset in the strings file - _windowNameOffset = binReader.ReadInt32(); - if( _windowNameOffset == 0) - _windowNameOffset = -1; // 0/-1 = none - - // informations types DWORD - nTemp = binReader.ReadInt32(); - - // unknown DWORD - nTemp = binReader.ReadInt32(); - - // number of merged files in the merged file list DWORD - _numberOfMergedFiles = binReader.ReadInt32(); - - nTemp = binReader.ReadInt32(); - - for(int i = 0; i < _numberOfMergedFiles; i++) - { - // DWORD offset value of merged file - nTemp = binReader.ReadInt32(); - - if(nTemp > 0) - _mergedFileOffsets.Add(nTemp); - } - - return bRet; - } - - /// - /// Gets the number of topic nodes including the contents and index files - /// - public int NumberOfTopicNodes - { - get { return _numberOfTopicNodes; } - } - - /// - /// Gets the offset in the #STRINGS file of the ImageList - /// param of the "text/site properties" object of the sitemap contents - /// - public int ImageListOffset - { - get { return _imageListOffset; } - } - - /// - /// True if the value of the ImageType param of the - /// "text/site properties" object of the sitemap contents is "Folder". - /// - /// If this is set to true, the help will display folders instead of books - public bool ImageTypeFolder - { - get { return _imageTypeFolder; } - } - - /// - /// Gets the background setting - /// - public int Background - { - get { return _background; } - } - - /// - /// Gets the foreground setting - /// - public int Foreground - { - get { return _foreground; } - } - - /// - /// Gets the offset in the #STRINGS file of the Font - /// param of the "text/site properties" object of the sitemap contents - /// - public int WindowNameOffset - { - get { return _fontOffset; } - } - - /// - /// Gets the offset in the #STRINGS file of the FrameName - /// param of the "text/site properties" object of the sitemap contents - /// - public int FrameNameOffset - { - get { return _frameNameOffset; } - } - - /// - /// Gets the offset in the #STRINGS file of the WindowName - /// param of the "text/site properties" object of the sitemap contents - /// - public int FontOffset - { - get { return _windowNameOffset; } - } - - /// - /// Gets an array list of offset numbers in the #STRINGS file of the - /// merged file names. - /// - public ArrayList MergedFileOffsets - { - get { return _mergedFileOffsets; } - } - - /// - /// Implement IDisposable. - /// - public void Dispose() - { - Dispose(true); - // This object will be cleaned up by the Dispose method. - // Therefore, you should call GC.SupressFinalize to - // take this object off the finalization queue - // and prevent finalization code for this object - // from executing a second time. - GC.SuppressFinalize(this); - } - - /// - /// Dispose(bool disposing) executes in two distinct scenarios. - /// If disposing equals true, the method has been called directly - /// or indirectly by a user's code. Managed and unmanaged resources - /// can be disposed. - /// If disposing equals false, the method has been called by the - /// runtime from inside the finalizer and you should not reference - /// other objects. Only unmanaged resources can be disposed. - /// - /// disposing flag - private void Dispose(bool disposing) - { - // Check to see if Dispose has already been called. - if(!this.disposed) - { - // If disposing equals true, dispose all managed - // and unmanaged resources. - if(disposing) - { - // Dispose managed resources. - _binaryFileData = null; - _mergedFileOffsets = null; - } - - - } - disposed = true; - } - } -} diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/CHMStrings.cs b/irc/TechBot/CHMLibrary/CHMDecoding/CHMStrings.cs deleted file mode 100644 index 5942d4e8cfe..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/CHMStrings.cs +++ /dev/null @@ -1,256 +0,0 @@ -using System; -using System.IO; -using System.Collections; -using System.Collections.Specialized; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// The class CHMStrings implements a string collection read from the #STRINGS file - /// - internal sealed class CHMStrings : IDisposable - { - /// - /// Constant specifying the size of the string blocks - /// - private const int STRING_BLOCK_SIZE = 4096; - /// - /// Internal flag specifying if the object is going to be disposed - /// - private bool disposed = false; - /// - /// Internal member storing the binary file data - /// - private byte[] _binaryFileData = null; - /// - /// Internal member storing the string dictionary - /// - private Hashtable _stringDictionary = new Hashtable(); - /// - /// Internal member storing the associated chmfile object - /// - private CHMFile _associatedFile = null; - - /// - /// Constructor of the class - /// - /// binary file data of the #STRINGS file - /// associated chm file - public CHMStrings(byte[] binaryFileData, CHMFile associatedFile) - { - _binaryFileData = binaryFileData; - _associatedFile = associatedFile; - DecodeData(); - } - - - /// - /// Standard constructor - /// - internal CHMStrings() - { - } - - #region Data dumping - /// - /// Dump the class data to a binary writer - /// - /// writer to write the data - internal void Dump(ref BinaryWriter writer) - { - writer.Write( _stringDictionary.Count ); - - if (_stringDictionary.Count != 0) - { - IDictionaryEnumerator iDictionaryEnumerator = _stringDictionary.GetEnumerator(); - while (iDictionaryEnumerator.MoveNext()) - { - DictionaryEntry dictionaryEntry = (DictionaryEntry)iDictionaryEnumerator.Current; - writer.Write( Int32.Parse(dictionaryEntry.Key.ToString()) ); - writer.Write( dictionaryEntry.Value.ToString() ); - } - } - } - - /// - /// Reads the object data from a dump store - /// - /// reader to read the data - internal void ReadDump(ref BinaryReader reader) - { - int nCnt = reader.ReadInt32(); - - for(int i=0; i - /// Sets the associated CHMFile instance - /// - /// instance to set - internal void SetCHMFile(CHMFile associatedFile) - { - _associatedFile = associatedFile; - } - #endregion - - /// - /// Decodes the binary file data and fills the internal properties - /// - /// true if succeeded - private bool DecodeData() - { - bool bRet = true; - - MemoryStream memStream = new MemoryStream(_binaryFileData); - BinaryReader binReader = new BinaryReader(memStream); - - //binReader.ReadByte(); // file starts with a NULL character for 0-based offset indexing - - int nStringOffset = 0; - int nSubsetOffset = 0; - - while( (memStream.Position < memStream.Length) && (bRet) ) - { - nStringOffset = (int)memStream.Position; - byte [] stringBlock = binReader.ReadBytes(STRING_BLOCK_SIZE); - bRet &= DecodeBlock(stringBlock, ref nStringOffset, ref nSubsetOffset); - } - - return bRet; - } - - /// - /// Decodes a string block - /// - /// byte array which represents the string block - /// current string offset number - /// reference to a subset variable - /// true if succeeded - /// If a string crosses the end of a block then it will be cut off - /// without a NT and repeated in full, with a NT, at the start of the next block. - /// For eg "To customize the appearance of a contents file" might become - /// "To customize the (block ending)To customize the appearance of a contents file" - /// when there are 17 bytes left at the end of the block. - private bool DecodeBlock( byte[] stringBlock, ref int nStringOffset, ref int nSubsetOffset) - { - bool bRet = true; - - MemoryStream memStream = new MemoryStream(stringBlock); - BinaryReader binReader = new BinaryReader(memStream); - - while( (memStream.Position < memStream.Length) && (bRet) ) - { - bool bFoundTerminator = false; - - int nCurOffset = nStringOffset + (int)memStream.Position; - - string sTemp = BinaryReaderHelp.ExtractString(ref binReader, ref bFoundTerminator, 0, true, _associatedFile.TextEncoding); - - if(nSubsetOffset != 0) - { - _stringDictionary[nSubsetOffset.ToString()] = sTemp.ToString(); - } - else - { - _stringDictionary[nCurOffset.ToString()] = sTemp.ToString(); - } - - if( bFoundTerminator ) - { - nSubsetOffset = 0; - } - else - { - nSubsetOffset = nCurOffset; - } - } - - return bRet; - } - - /// - /// Indexer which returns the string at a given offset - /// - public string this[int offset] - { - get - { - if(offset == -1) - return String.Empty; - - string sTemp = (string)_stringDictionary[ offset.ToString() ]; - - if(sTemp == null) - return String.Empty; - - return sTemp; - } - } - - /// - /// Indexer which returns the string at a given offset - /// - public string this[string offset] - { - get - { - if(offset == "-1") - return String.Empty; - - string sTemp = (string)_stringDictionary[ offset ]; - - if(sTemp == null) - return String.Empty; - - return sTemp; - } - } - - /// - /// Implement IDisposable. - /// - public void Dispose() - { - Dispose(true); - // This object will be cleaned up by the Dispose method. - // Therefore, you should call GC.SupressFinalize to - // take this object off the finalization queue - // and prevent finalization code for this object - // from executing a second time. - GC.SuppressFinalize(this); - } - - /// - /// Dispose(bool disposing) executes in two distinct scenarios. - /// If disposing equals true, the method has been called directly - /// or indirectly by a user's code. Managed and unmanaged resources - /// can be disposed. - /// If disposing equals false, the method has been called by the - /// runtime from inside the finalizer and you should not reference - /// other objects. Only unmanaged resources can be disposed. - /// - /// disposing flag - private void Dispose(bool disposing) - { - // Check to see if Dispose has already been called. - if(!this.disposed) - { - // If disposing equals true, dispose all managed - // and unmanaged resources. - if(disposing) - { - // Dispose managed resources. - _binaryFileData = null; - _stringDictionary = null; - } - } - disposed = true; - } - } -} diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/CHMSystem.cs b/irc/TechBot/CHMLibrary/CHMDecoding/CHMSystem.cs deleted file mode 100644 index 042e243f5e1..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/CHMSystem.cs +++ /dev/null @@ -1,821 +0,0 @@ -using System; -using System.Collections; -using System.Diagnostics; -using System.IO; -using System.Text; -using System.Globalization; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// The class CHMSystem reads the #SYSTEM file of the chm and stores its settings - /// - internal sealed class CHMSystem : IDisposable - { - /// - /// Internal flag specifying if the object is going to be disposed - /// - private bool disposed = false; - /// - /// Internal member storing the binary file data - /// - private byte[] _binaryFileData = null; - /// - /// Internal member storing the file version - /// - private int _fileVersion = 0; - /// - /// Internal member storing the contents file path - /// - private string _contentsFile = ""; - /// - /// Internal member storing the index file path - /// - private string _indexFile = ""; - /// - /// Internal member storing the default help topic - /// - private string _defaultTopic = ""; - /// - /// Internal member storing the help-window title - /// - private string _title = ""; - /// - /// Internal flag if dbcs is on - /// - private bool _dbcs = false; - /// - /// Internal flag if fulltext search is enabled - /// - private bool _fullTextSearch = false; - /// - /// Internal flag if KLinks are in the file - /// - private bool _hasKLinks = false; - /// - /// Internal flag if ALinks are in the file - /// - private bool _hasALinks = false; - /// - /// Internal member storing the name of the default window - /// - private string _defaultWindow = ""; - /// - /// Internal member storing the filename of the compiled file - /// - private string _compileFile = ""; - /// - /// Internal flag storing the offset value of the binary index - /// - private uint _binaryIndexURLTableID = 0; - /// - /// Inernal member storing the compiler version this file was compiled - /// - private string _compilerVersion = ""; - /// - /// Internal flag storing the offset value of the binary TOC - /// - private uint _binaryTOCURLTableID = 0; - /// - /// Internal member storing the associated chmfile object - /// - private CHMFile _associatedFile = null; - /// - /// Internal member storing the default fontface, size, charset - /// - private string _defaultFont = ""; - /// - /// Internal member storing the culture info of the file - /// - private CultureInfo _culture; - - /// - /// Constructor of the class - /// - /// binary file data of the #SYSTEM file - /// associated chm file - public CHMSystem(byte[] binaryFileData, CHMFile associatedFile) - { - _binaryFileData = binaryFileData; - _associatedFile = associatedFile; - DecodeData(); - - if(_culture == null) - { - // Set the text encoder of the chm file to the read charset/codepage - _associatedFile.TextEncoding = Encoding.GetEncoding( this.CodePage ); - } - } - - /// - /// Decodes the binary file data and fills the internal properties - /// - /// true if succeeded - private bool DecodeData() - { - bool bRet = true; - - MemoryStream memStream = new MemoryStream(_binaryFileData); - BinaryReader binReader = new BinaryReader(memStream); - - // First entry = DWORD for version number - _fileVersion = (int) binReader.ReadInt32(); - - while( (memStream.Position < memStream.Length) && (bRet) ) - { - bRet &= DecodeEntry(ref binReader); - } - - return bRet; - } - - /// - /// Decodes an #system file entry - /// - /// binary reader reference - /// true if succeeded - private bool DecodeEntry(ref BinaryReader binReader) - { - bool bRet = true; - - int code = (int) binReader.ReadInt16(); // entry code, WORD - int length = (int) binReader.ReadInt16(); // length of entry - - switch(code) - { - case 0: - { - _contentsFile = BinaryReaderHelp.ExtractString(ref binReader,length, 0, true, _associatedFile.TextEncoding); - };break; - case 1: - { - _indexFile = BinaryReaderHelp.ExtractString(ref binReader,length, 0, true, _associatedFile.TextEncoding); - };break; - case 2: - { - _defaultTopic = BinaryReaderHelp.ExtractString(ref binReader,length, 0, true, _associatedFile.TextEncoding); - };break; - case 3: - { - _title = BinaryReaderHelp.ExtractString(ref binReader,length, 0, true, _associatedFile.TextEncoding); - };break; - case 4: - { - int nTemp = 0; - nTemp = binReader.ReadInt32(); // read DWORD LCID - _culture = new CultureInfo(nTemp); - - if(_culture != null) - _associatedFile.TextEncoding = Encoding.GetEncoding(_culture.TextInfo.ANSICodePage); - - nTemp = binReader.ReadInt32(); // read DWORD DBCS - _dbcs = (nTemp == 1); - - nTemp = binReader.ReadInt32(); // read DWORD Fulltext search - _fullTextSearch = (nTemp == 1); - - nTemp = binReader.ReadInt32(); // read DWORD has klinks - _hasKLinks = (nTemp != 0); - - nTemp = binReader.ReadInt32(); // read DWORD has alinks - _hasALinks = (nTemp != 0); - - // read the rest of code 4 (not important for us) - byte[] temp = new byte[length-(5*4)]; - temp = binReader.ReadBytes(length-(5*4)); - };break; - case 5: - { - _defaultWindow = BinaryReaderHelp.ExtractString(ref binReader,length, 0, true, _associatedFile.TextEncoding); - };break; - case 6: - { - _compileFile = BinaryReaderHelp.ExtractString(ref binReader,length, 0, true, _associatedFile.TextEncoding); - };break; - case 7: - { - if(_fileVersion > 2) - { - _binaryIndexURLTableID = (uint) binReader.ReadInt32(); - } - else - { - byte[] read = binReader.ReadBytes(length); - int i=read.Length; - } - };break; - case 8: - { - // abbreviation (not interresting for us) - byte[] read = binReader.ReadBytes(length); - int i=read.Length; - };break; - case 9: - { - _compilerVersion = BinaryReaderHelp.ExtractString(ref binReader,length, 0, true, _associatedFile.TextEncoding); - };break; - case 10: - { - // timestamp of the file (not interresting for us) - byte[] read = binReader.ReadBytes(length); - int i=read.Length; - };break; - case 11: - { - if(_fileVersion > 2) - { - _binaryTOCURLTableID = (uint) binReader.ReadInt32(); - } - else - { - byte[] read = binReader.ReadBytes(length); - int i=read.Length; - } - };break; - case 12: - { - // number of information bytes - byte[] read = binReader.ReadBytes(length); - int i=read.Length; - };break; - case 13: - { - // copy of file #idxhdr - byte[] read = binReader.ReadBytes(length); - int i=read.Length; - };break; - case 14: - { - // custom tabs for HH viewer - byte[] read = binReader.ReadBytes(length); - int i=read.Length; - };break; - case 15: - { - // a checksum - byte[] read = binReader.ReadBytes(length); - int i=read.Length; - };break; - case 16: - { - // Default Font=string,number,number - // The string is the name of the font, the first number is the - // point size & the last number is the character set used by the font. - // For acceptable values see *_CHARSET defines in wingdi.h from the - // Windows SDK or the same file in MinGW or Wine. - // Most of the time you will only want to use 0, which is the value for ANSI, - // which is the subset of ASCII used by Windows. - _defaultFont = BinaryReaderHelp.ExtractString(ref binReader,length, 0, true, _associatedFile.TextEncoding); - - };break; - default: - { - byte[] temp = new byte[length]; - temp = binReader.ReadBytes(length); - //bRet = false; - int i=temp.Length; - };break; - } - - return bRet; - } - - /// - /// Reads all HHC files and checks which one has the global object tag. - /// This hhc file will be returned as master hhc - /// - /// list of topics containing the extension hhc - /// true if the arraylist contains topic items - /// the filename of the found master toc - private string GetMasterHHC(ArrayList hhcTopics, bool TopicItemArrayList) - { - string sRet = ""; - - if( (hhcTopics!=null) && (hhcTopics.Count > 0) ) - { - if( TopicItemArrayList ) - { - if(hhcTopics.Count == 1) - { - sRet = ((TopicEntry)hhcTopics[0]).Locale; - } - else - { - foreach(TopicEntry curEntry in hhcTopics) - { - CHMStream.CHMStream iw=null; - MemoryStream fileObject=null; - - if( _associatedFile.CurrentStorageWrapper == null) - { - iw=new CHMStream.CHMStream(); - iw.OpenCHM(_associatedFile.ChmFilePath); - } - else - { - iw = _associatedFile.CurrentStorageWrapper; - } - - fileObject = iw.OpenStream(curEntry.Locale); - if( fileObject != null) - { - string fileString =_associatedFile.TextEncoding.GetString(fileObject.ToArray(),0,(int)fileObject.Length); - fileObject.Close(); - - if( HHCParser.HasGlobalObjectTag(fileString, _associatedFile) ) - { - sRet = curEntry.Locale; - break; - } - } - } - } - } - else - { - if(hhcTopics.Count == 1) - { - sRet = ((string)hhcTopics[0]); - } - else - { - foreach(string curEntry in hhcTopics) - { - CHMStream.CHMStream iw=null; - MemoryStream fileObject=null; - - if( _associatedFile.CurrentStorageWrapper == null) - { - iw=new CHMStream.CHMStream(); - iw.OpenCHM(_associatedFile.ChmFilePath); - } - else - { - iw = _associatedFile.CurrentStorageWrapper; - } - - fileObject = iw.OpenStream(curEntry); - if( fileObject != null) - { - string fileString =_associatedFile.TextEncoding.GetString(fileObject.ToArray(),0,(int)fileObject.Length); - fileObject.Close(); - - if( HHCParser.HasGlobalObjectTag(fileString, _associatedFile) ) - { - sRet = curEntry; - break; - } - } - } - } - } - } - - return sRet; - } - - /// - /// Gets the file version of the chm file. - /// 2 for Compatibility=1.0, 3 for Compatibility=1.1 - /// - public int FileVersion - { - get { return _fileVersion; } - } - - /// - /// Gets the contents file name - /// - public string ContentsFile - { - get - { - if( BinaryTOC ) // if the file contains a binary TOC - { - // make sure the CHMFile instance exists and has loaded the file #URLTBL - if( (_associatedFile != null) && (_associatedFile.UrltblFile != null ) ) - { - // Get an url-table entry by its unique id - UrlTableEntry entry = _associatedFile.UrltblFile.GetByUniqueID( this.BinaryTOCURLTableID ); - if(entry != null) - { - // entry found, return the url ( = filename ) - return entry.URL; - } - } - } - else - { - if(_contentsFile.Length <= 0) - { - string sCheck = "Table of Contents.hhc"; // default HHP contents filename - - if( (_associatedFile != null) && (_associatedFile.TopicsFile != null ) ) - { - TopicEntry te = _associatedFile.TopicsFile.GetByLocale( sCheck ); - - if( te == null) - { - sCheck = "toc.hhc"; // default HHP contents filename - - te = _associatedFile.TopicsFile.GetByLocale( sCheck ); - - if( te == null) - { - sCheck = CompileFile + ".hhc"; - - te = _associatedFile.TopicsFile.GetByLocale( sCheck ); - - if( te == null) - { - ArrayList arrExt = _associatedFile.TopicsFile.GetByExtension("hhc"); - - if( arrExt == null ) - { - arrExt = _associatedFile.EnumFilesByExtension("hhc"); - - if( arrExt == null ) - { - Debug.WriteLine("CHMSystem.ContentsFile - Failed, contents file not found !"); - } - else - { - if(arrExt.Count > 1) - { - sCheck = GetMasterHHC(arrExt, false); - _contentsFile = sCheck; - } - else - { - _contentsFile = ((string)arrExt[0]); - sCheck = _contentsFile; - } - } - } - else - { - if(arrExt.Count > 1) - { - sCheck = GetMasterHHC(arrExt, true); - _contentsFile = sCheck; - } - else - { - _contentsFile = ((TopicEntry)arrExt[0]).Locale; - sCheck = _contentsFile; - } - } - } - else - { - _contentsFile = sCheck; - } - } - else - { - _contentsFile = sCheck; - } - } - else - { - _contentsFile = sCheck; - } - } - - return sCheck; - } - } - - return _contentsFile; - } - } - - /// - /// Gets the index file name - /// - public string IndexFile - { - get - { - if( BinaryIndex ) // if the file contains a binary index - { - // make sure the CHMFile instance exists and has loaded the file #URLTBL - if( (_associatedFile != null) && (_associatedFile.UrltblFile != null ) ) - { - // Get an url-table entry by its unique id - UrlTableEntry entry = _associatedFile.UrltblFile.GetByUniqueID( this.BinaryIndexURLTableID ); - if(entry != null) - { - // entry found, return the url ( = filename ) - return entry.URL; - } - } - } - else - { - if(_indexFile.Length <= 0) - { - string sCheck = "Index.hhk"; // default HHP index filename - - if( (_associatedFile != null) && (_associatedFile.TopicsFile != null ) ) - { - TopicEntry te = _associatedFile.TopicsFile.GetByLocale( sCheck ); - - if( te == null) - { - sCheck = CompileFile + ".hhk"; - - te = _associatedFile.TopicsFile.GetByLocale( sCheck ); - - if( te == null) - { - ArrayList arrExt = _associatedFile.TopicsFile.GetByExtension("hhk"); - - if( arrExt == null ) - { - Debug.WriteLine("CHMSystem.IndexFile - Failed, index file not found !"); - } - else - { - _indexFile = ((TopicEntry)arrExt[0]).Locale; - sCheck = _indexFile; - } - } - else - { - _indexFile = sCheck; - } - } - else - { - _indexFile = sCheck; - } - } - - return sCheck; - } - } - return _indexFile; - } - } - - /// - /// Sets the default topic of this file - /// - /// new local value of the topic - internal void SetDefaultTopic(string local) - { - _defaultTopic = local; - } - - /// - /// Gets the default help topic - /// - public string DefaultTopic - { - get { return _defaultTopic; } - } - - /// - /// Gets the title of the help window - /// - public string Title - { - get { return _title; } - } - - /// - /// Gets the flag if DBCS is in use - /// - public bool DBCS - { - get { return _dbcs; } - } - - /// - /// Gets the flag if full-text-search is available - /// - public bool FullTextSearch - { - get { return _fullTextSearch; } - } - - /// - /// Gets the flag if the file has ALinks - /// - public bool HasALinks - { - get { return _hasALinks; } - } - - /// - /// Gets the flag if the file has KLinks - /// - public bool HasKLinks - { - get { return _hasKLinks; } - } - - /// - /// Gets the default window name - /// - public string DefaultWindow - { - get { return _defaultWindow; } - } - - /// - /// Gets the file name of the compile file - /// - public string CompileFile - { - get { return _compileFile; } - } - - /// - /// Gets the id of the binary index in the url table - /// - public uint BinaryIndexURLTableID - { - get { return _binaryIndexURLTableID; } - } - - /// - /// Gets the flag if the chm has a binary index file - /// - public bool BinaryIndex - { - get { return (_binaryIndexURLTableID>0); } - } - - /// - /// Gets the flag if the chm has a binary index file - /// - public string CompilerVersion - { - get { return _compilerVersion; } - } - - /// - /// Gets the id of the binary toc in the url table - /// - public uint BinaryTOCURLTableID - { - get { return _binaryTOCURLTableID; } - } - - /// - /// Gets the flag if the chm has a binary toc file - /// - public bool BinaryTOC - { - get { return (_binaryTOCURLTableID>0); } - } - - /// - /// Gets the font face of the read font property. - /// Empty string for default font. - /// - public string FontFace - { - get - { - if( _defaultFont.Length > 0) - { - string [] fontSplit = _defaultFont.Split( new char[]{','}); - if(fontSplit.Length > 0) - return fontSplit[0].Trim(); - } - - return ""; - } - } - - /// - /// Gets the font size of the read font property. - /// 0 for default font size - /// - public double FontSize - { - get - { - if( _defaultFont.Length > 0) - { - string [] fontSplit = _defaultFont.Split( new char[]{','}); - if(fontSplit.Length > 1) - return double.Parse(fontSplit[1].Trim()); - } - - return 0.0; - } - } - - /// - /// Gets the character set of the read font property - /// 1 for default - /// - public int CharacterSet - { - get - { - if( _defaultFont.Length > 0) - { - string [] fontSplit = _defaultFont.Split( new char[]{','}); - if(fontSplit.Length > 2) - return Int32.Parse(fontSplit[2].Trim()); - } - - return 0; - } - } - - /// - /// Gets the codepage depending on the read font property - /// - public int CodePage - { - get - { - // if we've read a LCID from the system file - // ignore the font-property settings and return - // the codepage generated from the culture info - if(_culture != null) - { - return _culture.TextInfo.ANSICodePage; - } - - int nRet = 1252; // default codepage windows-1252 - - int nCSet = CharacterSet; - - switch(nCSet) - { - case 0x00: nRet = 1252;break; // ANSI_CHARSET - case 0xCC: nRet = 1251;break; // RUSSIAN_CHARSET - case 0xEE: nRet = 1250;break; // EE_CHARSET - case 0xA1: nRet = 1253;break; // GREEK_CHARSET - case 0xA2: nRet = 1254;break; // TURKISH_CHARSET - case 0xBA: nRet = 1257;break; // BALTIC_CHARSET - case 0xB1: nRet = 1255;break; // HEBREW_CHARSET - case 0xB2: nRet = 1256;break; // ARABIC_CHARSET - case 0x80: nRet = 932;break; // SHIFTJIS_CHARSET - case 0x81: nRet = 949;break; // HANGEUL_CHARSET - case 0x86: nRet = 936;break; // GB2313_CHARSET - case 0x88: nRet = 950;break; // CHINESEBIG5_CHARSET - } - - return nRet; - } - } - - /// - /// Gets the assiciated culture info - /// - public CultureInfo Culture - { - get { return _culture; } - } - - /// - /// Implement IDisposable. - /// - public void Dispose() - { - Dispose(true); - // This object will be cleaned up by the Dispose method. - // Therefore, you should call GC.SupressFinalize to - // take this object off the finalization queue - // and prevent finalization code for this object - // from executing a second time. - GC.SuppressFinalize(this); - } - - /// - /// Dispose(bool disposing) executes in two distinct scenarios. - /// If disposing equals true, the method has been called directly - /// or indirectly by a user's code. Managed and unmanaged resources - /// can be disposed. - /// If disposing equals false, the method has been called by the - /// runtime from inside the finalizer and you should not reference - /// other objects. Only unmanaged resources can be disposed. - /// - /// disposing flag - private void Dispose(bool disposing) - { - // Check to see if Dispose has already been called. - if(!this.disposed) - { - // If disposing equals true, dispose all managed - // and unmanaged resources. - if(disposing) - { - // Dispose managed resources. - _binaryFileData = null; - } - - - } - disposed = true; - } - } -} diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/CHMTocidx.cs b/irc/TechBot/CHMLibrary/CHMDecoding/CHMTocidx.cs deleted file mode 100644 index d6ca1aa02c1..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/CHMTocidx.cs +++ /dev/null @@ -1,288 +0,0 @@ -using System; -using System.IO; -using System.Collections; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// The class CHMTocidx implements functions to decode the #TOCIDX internal file. - /// - internal sealed class CHMTocidx : IDisposable - { - /// - /// Constant specifying the size of the data blocks - /// - private const int BLOCK_SIZE = 0x1000; - /// - /// Internal flag specifying if the object is going to be disposed - /// - private bool disposed = false; - /// - /// Internal member storing the binary file data - /// - private byte[] _binaryFileData = null; - /// - /// Internal memebr storing the offset to the 20/28 byte structs - /// - private int _offset2028 = 0; - /// - /// Internal member storing the offset to the 16 byte structs - /// - private int _offset16structs = 0; - /// - /// Internal member storing the number of 16 byte structs - /// - private int _numberOf16structs = 0; - /// - /// Internal member storing the offset to the topic list - /// - private int _offsetOftopics = 0; - /// - /// Internal member storing the toc - /// - private ArrayList _toc = new ArrayList(); - /// - /// Internal member for offset seeking - /// - private Hashtable _offsetTable = new Hashtable(); - /// - /// Internal member storing the associated chmfile object - /// - private CHMFile _associatedFile = null; - - /// - /// Constructor of the class - /// - /// binary file data of the #TOCIDX file - /// associated chm file - public CHMTocidx(byte[] binaryFileData, CHMFile associatedFile) - { - _binaryFileData = binaryFileData; - _associatedFile = associatedFile; - DecodeData(); - - // clear internal binary data after extraction - _binaryFileData = null; - } - - /// - /// Decodes the binary file data and fills the internal properties - /// - /// true if succeeded - private bool DecodeData() - { - _toc = new ArrayList(); - _offsetTable = new Hashtable(); - - bool bRet = true; - - MemoryStream memStream = new MemoryStream(_binaryFileData); - BinaryReader binReader = new BinaryReader(memStream); - - int nCurOffset = 0; - - _offset2028 = binReader.ReadInt32(); - _offset16structs = binReader.ReadInt32(); - _numberOf16structs = binReader.ReadInt32(); - _offsetOftopics = binReader.ReadInt32(); - - binReader.BaseStream.Seek( _offset2028, SeekOrigin.Begin ); - - if( RecursivelyBuildTree(ref binReader, _offset2028, _toc, null) ) - { - binReader.BaseStream.Seek( _offset16structs, SeekOrigin.Begin ); - nCurOffset = (int)binReader.BaseStream.Position; - - for(int i=0; i < _numberOf16structs; i++) - { - int tocOffset = binReader.ReadInt32(); - int sqNr = binReader.ReadInt32(); - int topOffset = binReader.ReadInt32(); - int hhctopicIdx = binReader.ReadInt32(); - - nCurOffset = (int)binReader.BaseStream.Position; - - int topicIdx = -1; - // if the topic offset is within the range of the stream - // and is >= the offset of the first topic dword - if((topOffset < (binReader.BaseStream.Length - 4)) && (topOffset >= _offsetOftopics)) - { - // read the index of the topic for this item - binReader.BaseStream.Seek( topOffset, SeekOrigin.Begin); - topicIdx = binReader.ReadInt32(); - binReader.BaseStream.Seek( nCurOffset, SeekOrigin.Begin); - - - TOCItem item = (TOCItem)_offsetTable[tocOffset.ToString()]; - if( item != null) - { - if(( topicIdx < _associatedFile.TopicsFile.TopicTable.Count)&&(topicIdx>=0)) - { - TopicEntry te = (TopicEntry) (_associatedFile.TopicsFile.TopicTable[topicIdx]); - if( (te != null) && (item.TopicOffset < 0) ) - { - item.TopicOffset = te.EntryOffset; - } - - } - } - } - } - } - - return bRet; - } - - /// - /// Recursively reads the binary toc tree from the file - /// - /// reference to binary reader - /// offset of the first node in the current level - /// arraylist of TOCItems for the current level - /// parent item for the item - /// Returns true if succeeded - private bool RecursivelyBuildTree(ref BinaryReader binReader, int NodeOffset, ArrayList level, TOCItem parentItem) - { - bool bRet = true; - int nextOffset=0; - - int nReadOffset = (int)binReader.BaseStream.Position; - - binReader.BaseStream.Seek(NodeOffset, SeekOrigin.Begin); - - do - { - int nCurOffset = (int)binReader.BaseStream.Position; - - int unkn1 = binReader.ReadInt16(); // unknown - int unkn2 = binReader.ReadInt16(); // unknown - - int flag = binReader.ReadInt32(); - - int nFolderAdd = 0; - - if((_associatedFile != null) && (_associatedFile.ImageTypeFolder)) - { - // get the value which should be added, to display folders instead of books - if(HtmlHelpSystem.UseHH2TreePics) - nFolderAdd = 8; - else - nFolderAdd = 4; - } - - int nFolderImgIdx = (HtmlHelpSystem.UseHH2TreePics ? (TOCItem.STD_FOLDER_HH2+nFolderAdd) : (TOCItem.STD_FOLDER_HH1+nFolderAdd)); - int nFileImgIdx = (HtmlHelpSystem.UseHH2TreePics ? TOCItem.STD_FILE_HH2 : TOCItem.STD_FILE_HH1); - - int stdImage = ((flag & 0x4)!=0) ? nFolderImgIdx : nFileImgIdx; - - int stringOffset = binReader.ReadInt32(); - - int ParentOffset = binReader.ReadInt32(); - nextOffset = binReader.ReadInt32(); - - int firstChildOffset = 0; - int unkn3=0; - - if( (flag&0x4)!=0 ) - { - firstChildOffset = binReader.ReadInt32(); - unkn3 = binReader.ReadInt32(); // unknown - } - - TOCItem newItem = new TOCItem(); - newItem.ImageIndex = stdImage; - newItem.Offset = nCurOffset; - newItem.OffsetNext = nextOffset; - newItem.AssociatedFile = _associatedFile; - newItem.TocMode = DataMode.Binary; - newItem.Parent = parentItem; - - if( (flag&0x08) == 0) - { - // toc item doesn't have a local value (=> stringOffset = offset of strings file) - newItem.Name = _associatedFile.StringsFile[stringOffset]; - } - else - { - // this item has a topic entry (=> stringOffset = index of topic entry) - if((stringOffset < _associatedFile.TopicsFile.TopicTable.Count) && (stringOffset >= 0)) - { - TopicEntry te = (TopicEntry) (_associatedFile.TopicsFile.TopicTable[stringOffset]); - if(te != null) - { - newItem.TopicOffset = te.EntryOffset; - } - } - } - - _offsetTable[nCurOffset.ToString()] = newItem; - - // if this item has children (firstChildOffset > 0) - if( firstChildOffset > 0) - { - bRet &= RecursivelyBuildTree(ref binReader, firstChildOffset, newItem.Children, newItem); - } - - level.Add( newItem ); - - if(nCurOffset != nextOffset) - binReader.BaseStream.Seek(nextOffset, SeekOrigin.Begin); - - }while(nextOffset != 0); - - binReader.BaseStream.Seek(nReadOffset, SeekOrigin.Begin); - - return bRet; - } - - /// - /// Gets the internal read toc - /// - internal ArrayList TOC - { - get { return _toc; } - } - - /// - /// Implement IDisposable. - /// - public void Dispose() - { - Dispose(true); - // This object will be cleaned up by the Dispose method. - // Therefore, you should call GC.SupressFinalize to - // take this object off the finalization queue - // and prevent finalization code for this object - // from executing a second time. - GC.SuppressFinalize(this); - } - - /// - /// Dispose(bool disposing) executes in two distinct scenarios. - /// If disposing equals true, the method has been called directly - /// or indirectly by a user's code. Managed and unmanaged resources - /// can be disposed. - /// If disposing equals false, the method has been called by the - /// runtime from inside the finalizer and you should not reference - /// other objects. Only unmanaged resources can be disposed. - /// - /// disposing flag - private void Dispose(bool disposing) - { - // Check to see if Dispose has already been called. - if(!this.disposed) - { - // If disposing equals true, dispose all managed - // and unmanaged resources. - if(disposing) - { - // Dispose managed resources. - _binaryFileData = null; - _toc = null; - _offsetTable = null; - } - } - disposed = true; - } - } -} diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/CHMTopics.cs b/irc/TechBot/CHMLibrary/CHMDecoding/CHMTopics.cs deleted file mode 100644 index ce1451b53ef..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/CHMTopics.cs +++ /dev/null @@ -1,235 +0,0 @@ -using System; -using System.IO; -using System.Collections; -using System.Collections.Specialized; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// The class CHMTopics implements functionality to decode the #TOPICS internal file - /// - internal sealed class CHMTopics : IDisposable - { - /// - /// Internal flag specifying if the object is going to be disposed - /// - private bool disposed = false; - /// - /// Internal member storing the binary file data - /// - private byte[] _binaryFileData = null; - /// - /// Internal member storing the associated chmfile object - /// - private CHMFile _associatedFile = null; - /// - /// Internal member storing the topic list - /// - private ArrayList _topicTable = new ArrayList(); - - /// - /// Constructor of the class - /// - /// binary file data of the #TOPICS file - /// associated chm file - public CHMTopics(byte[] binaryFileData, CHMFile associatedFile) - { - _binaryFileData = binaryFileData; - _associatedFile = associatedFile; - DecodeData(); - - // clear internal binary data after extraction - _binaryFileData = null; - } - - - /// - /// Standard constructor - /// - internal CHMTopics() - { - } - - #region Data dumping - /// - /// Dump the class data to a binary writer - /// - /// writer to write the data - internal void Dump(ref BinaryWriter writer) - { - writer.Write( _topicTable.Count ); - foreach(TopicEntry curItem in _topicTable) - { - curItem.Dump(ref writer); - } - } - - /// - /// Reads the object data from a dump store - /// - /// reader to read the data - internal void ReadDump(ref BinaryReader reader) - { - int i=0; - int nCnt = reader.ReadInt32(); - - for(i=0; i - /// Sets the associated CHMFile instance - /// - /// instance to set - internal void SetCHMFile(CHMFile associatedFile) - { - _associatedFile = associatedFile; - - foreach(TopicEntry curEntry in _topicTable) - { - curEntry.SetCHMFile(associatedFile); - } - } - #endregion - - /// - /// Decodes the binary file data and fills the internal properties - /// - /// true if succeeded - private bool DecodeData() - { - bool bRet = true; - - MemoryStream memStream = new MemoryStream(_binaryFileData); - BinaryReader binReader = new BinaryReader(memStream); - - int nCurOffset = 0; - - while( (memStream.Position < memStream.Length) && (bRet) ) - { - int entryOffset = nCurOffset; - int tocIdx = binReader.ReadInt32(); - int titleOffset = binReader.ReadInt32(); - int urltablOffset = binReader.ReadInt32(); - int visibilityMode = binReader.ReadInt16(); - int unknownMode = binReader.ReadInt16(); - - TopicEntry newEntry = new TopicEntry(entryOffset, tocIdx, titleOffset, urltablOffset, visibilityMode, unknownMode, _associatedFile); - _topicTable.Add( newEntry ); - - nCurOffset = (int)memStream.Position; - } - - return bRet; - } - - /// - /// Gets the arraylist containing all topic entries. - /// - public ArrayList TopicTable - { - get - { - return _topicTable; - } - } - - /// - /// Gets the topic entry of a given offset - /// - public TopicEntry this[int offset] - { - get - { - foreach(TopicEntry curEntry in _topicTable) - if(curEntry.EntryOffset == offset) - return curEntry; - - return null; - } - } - - /// - /// Searches a topic by the locale name - /// - /// locale name to search - /// The topicentry instance if found, otherwise null - public TopicEntry GetByLocale(string locale) - { - foreach(TopicEntry curEntry in TopicTable) - { - if(curEntry.Locale.ToLower() == locale.ToLower()) - return curEntry; - } - - return null; - } - - /// - /// Searches the topics for all files with a given file extension - /// - /// extension to search - /// An arraylist of TopicEntry instances or null if no topic was found - public ArrayList GetByExtension(string fileExtension) - { - ArrayList arrRet = new ArrayList(); - - foreach(TopicEntry curEntry in TopicTable) - { - if(curEntry.Locale.ToLower().EndsWith(fileExtension.ToLower())) - arrRet.Add(curEntry); - } - - if(arrRet.Count > 0) - return arrRet; - - return null; - } - - /// - /// Implement IDisposable. - /// - public void Dispose() - { - Dispose(true); - // This object will be cleaned up by the Dispose method. - // Therefore, you should call GC.SupressFinalize to - // take this object off the finalization queue - // and prevent finalization code for this object - // from executing a second time. - GC.SuppressFinalize(this); - } - - /// - /// Dispose(bool disposing) executes in two distinct scenarios. - /// If disposing equals true, the method has been called directly - /// or indirectly by a user's code. Managed and unmanaged resources - /// can be disposed. - /// If disposing equals false, the method has been called by the - /// runtime from inside the finalizer and you should not reference - /// other objects. Only unmanaged resources can be disposed. - /// - /// disposing flag - private void Dispose(bool disposing) - { - // Check to see if Dispose has already been called. - if(!this.disposed) - { - // If disposing equals true, dispose all managed - // and unmanaged resources. - if(disposing) - { - // Dispose managed resources. - _binaryFileData = null; - _topicTable=null; - } - } - disposed = true; - } - } -} diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/CHMUrlstr.cs b/irc/TechBot/CHMLibrary/CHMDecoding/CHMUrlstr.cs deleted file mode 100644 index b87eebab58e..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/CHMUrlstr.cs +++ /dev/null @@ -1,308 +0,0 @@ -using System; -using System.IO; -using System.Collections; -using System.Collections.Specialized; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// The class CHMUrlstr implements a string collection storing the URL strings of the help file - /// - internal sealed class CHMUrlstr : IDisposable - { - /// - /// Constant specifying the size of the string blocks - /// - private const int BLOCK_SIZE = 0x1000; - /// - /// Internal flag specifying if the object is going to be disposed - /// - private bool disposed = false; - /// - /// Internal member storing the binary file data - /// - private byte[] _binaryFileData = null; - /// - /// Internal member storing the url dictionary - /// - private Hashtable _urlDictionary = new Hashtable(); - /// - /// Internal member storing the framename dictionary - /// - private Hashtable _framenameDictionary = new Hashtable(); - /// - /// Internal member storing the associated chmfile object - /// - private CHMFile _associatedFile = null; - - /// - /// Constructor of the class - /// - /// binary file data of the #URLSTR file - /// associated chm file - public CHMUrlstr(byte[] binaryFileData, CHMFile associatedFile) - { - _binaryFileData = binaryFileData; - _associatedFile = associatedFile; - DecodeData(); - - // clear internal binary data after extraction - _binaryFileData = null; - } - - /// - /// Standard constructor - /// - internal CHMUrlstr() - { - } - - #region Data dumping - /// - /// Dump the class data to a binary writer - /// - /// writer to write the data - internal void Dump(ref BinaryWriter writer) - { - writer.Write( _urlDictionary.Count ); - - if (_urlDictionary.Count != 0) - { - IDictionaryEnumerator iDictionaryEnumerator = _urlDictionary.GetEnumerator(); - while (iDictionaryEnumerator.MoveNext()) - { - DictionaryEntry dictionaryEntry = (DictionaryEntry)iDictionaryEnumerator.Current; - writer.Write( Int32.Parse(dictionaryEntry.Key.ToString()) ); - writer.Write( dictionaryEntry.Value.ToString() ); - } - } - - writer.Write( _framenameDictionary.Count ); - - if (_framenameDictionary.Count != 0) - { - IDictionaryEnumerator iDictionaryEnumerator = _framenameDictionary.GetEnumerator(); - while (iDictionaryEnumerator.MoveNext()) - { - DictionaryEntry dictionaryEntry = (DictionaryEntry)iDictionaryEnumerator.Current; - writer.Write( Int32.Parse(dictionaryEntry.Key.ToString()) ); - writer.Write( dictionaryEntry.Value.ToString() ); - } - } - } - - /// - /// Reads the object data from a dump store - /// - /// reader to read the data - internal void ReadDump(ref BinaryReader reader) - { - int i=0; - int nCnt = reader.ReadInt32(); - - for(i=0; i - /// Sets the associated CHMFile instance - /// - /// instance to set - internal void SetCHMFile(CHMFile associatedFile) - { - _associatedFile = associatedFile; - } - #endregion - - /// - /// Decodes the binary file data and fills the internal properties - /// - /// true if succeeded - private bool DecodeData() - { - bool bRet = true; - - MemoryStream memStream = new MemoryStream(_binaryFileData); - BinaryReader binReader = new BinaryReader(memStream); - - int nCurOffset = 0; - - while( (memStream.Position < memStream.Length) && (bRet) ) - { - nCurOffset = (int)memStream.Position; - byte [] dataBlock = binReader.ReadBytes(BLOCK_SIZE); - bRet &= DecodeBlock(dataBlock, ref nCurOffset); - } - - return bRet; - } - - /// - /// Decodes a block of url-string data - /// - /// block of data - /// current file offset - /// true if succeeded - private bool DecodeBlock( byte[] dataBlock, ref int nOffset ) - { - bool bRet = true; - int blockOffset = nOffset; - - MemoryStream memStream = new MemoryStream(dataBlock); - BinaryReader binReader = new BinaryReader(memStream); - - if(nOffset==0) - binReader.ReadByte(); // first block starts with an unknown byte - - while( (memStream.Position < (memStream.Length-8)) && (bRet) ) - { - int entryOffset = blockOffset + (int)memStream.Position; - - int urlOffset = binReader.ReadInt32(); - int frameOffset = binReader.ReadInt32(); - - - // There is one way to tell where the end of the URL/FrameName - // pairs occurs: Repeat the following: read 2 DWORDs and if both - // are less than the current offset then this is the start of the Local - // strings else skip two NT strings. - // if(( (urlOffset < (entryOffset+8)) && (frameOffset < (entryOffset+8)) )) - // { - // //TODO: add correct string reading if an offset has been found - // /* - // int curOffset = (int)memStream.Position; - // - // memStream.Seek( (long)(blockOffset-urlOffset), SeekOrigin.Begin); - // string sTemp = CHMReader.ExtractString(ref binReader, 0, true); - // - // memStream.Seek( (long)(blockOffset-frameOffset), SeekOrigin.Begin); - // sTemp = CHMReader.ExtractString(ref binReader, 0, true); - // - // memStream.Seek((long)curOffset, SeekOrigin.Begin); - // */ - // - // - // int curOffs = (int)memStream.Position; - // BinaryReaderHelp.ExtractString(ref binReader, 0, true, _associatedFile.TextEncoding); - // nOffset += (int)memStream.Position - curOffs; - // - // curOffs = (int)memStream.Position; - // BinaryReaderHelp.ExtractString(ref binReader, 0, true, _associatedFile.TextEncoding); - // nOffset += (int)memStream.Position - curOffs; - // } - // else - { - bool bFoundTerminator = false; - - string sTemp = BinaryReaderHelp.ExtractString(ref binReader, ref bFoundTerminator, 0, true, _associatedFile.TextEncoding); - - if(sTemp == "") - { - //nOffset = nOffset + 1 + (int)memStream.Length - (int)memStream.Position; - memStream.Seek(memStream.Length-1, SeekOrigin.Begin); - } - else - { - _urlDictionary[entryOffset.ToString()] = sTemp.ToString(); - _framenameDictionary[ entryOffset.ToString() ] = sTemp.ToString() ; - } - } - } - - return bRet; - } - - /// - /// Gets the url at a given offset - /// - /// offset of url - /// the url at the given offset - public string GetURLatOffset(int offset) - { - if(offset == -1) - return String.Empty; - - string sTemp = (string)_urlDictionary[ offset.ToString() ]; - - if(sTemp == null) - return String.Empty; - - return sTemp; - } - - /// - /// Gets the framename at a given offset - /// - /// offset of the framename - /// the frame name at the given offset - public string GetFrameNameatOffset(int offset) - { - if(offset == -1) - return String.Empty; - - string sTemp = (string)_framenameDictionary[ offset.ToString() ]; - - if(sTemp == null) - return String.Empty; - - return sTemp; - } - - /// - /// Implement IDisposable. - /// - public void Dispose() - { - Dispose(true); - // This object will be cleaned up by the Dispose method. - // Therefore, you should call GC.SupressFinalize to - // take this object off the finalization queue - // and prevent finalization code for this object - // from executing a second time. - GC.SuppressFinalize(this); - } - - /// - /// Dispose(bool disposing) executes in two distinct scenarios. - /// If disposing equals true, the method has been called directly - /// or indirectly by a user's code. Managed and unmanaged resources - /// can be disposed. - /// If disposing equals false, the method has been called by the - /// runtime from inside the finalizer and you should not reference - /// other objects. Only unmanaged resources can be disposed. - /// - /// disposing flag - private void Dispose(bool disposing) - { - // Check to see if Dispose has already been called. - if(!this.disposed) - { - // If disposing equals true, dispose all managed - // and unmanaged resources. - if(disposing) - { - // Dispose managed resources. - _binaryFileData = null; - _urlDictionary = null; - _framenameDictionary = null; - } - } - disposed = true; - } - } -} diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/CHMUrltable.cs b/irc/TechBot/CHMLibrary/CHMDecoding/CHMUrltable.cs deleted file mode 100644 index 79f718b84ce..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/CHMUrltable.cs +++ /dev/null @@ -1,245 +0,0 @@ -using System; -using System.IO; -using System.Collections; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// The class CHMUrltable implements methods to decode the #URLTBL internal file. - /// - internal sealed class CHMUrltable : IDisposable - { - /// - /// Constant specifying the size of the data blocks - /// - private const int BLOCK_SIZE = 0x1000; - /// - /// Constant specifying the number of records per block - /// - private const int RECORDS_PER_BLOCK = 341; - /// - /// Internal flag specifying if the object is going to be disposed - /// - private bool disposed = false; - /// - /// Internal member storing the binary file data - /// - private byte[] _binaryFileData = null; - /// - /// Internal member storing the url table - /// - private ArrayList _urlTable = new ArrayList(); - /// - /// Internal member storing the associated chmfile object - /// - private CHMFile _associatedFile = null; - - /// - /// Constructor of the class - /// - /// binary file data of the #URLTBL file - /// associated chm file - public CHMUrltable(byte[] binaryFileData, CHMFile associatedFile) - { - _binaryFileData = binaryFileData; - _associatedFile = associatedFile; - DecodeData(); - - // clear internal binary data after extraction - _binaryFileData = null; - } - - /// - /// Standard constructor - /// - internal CHMUrltable() - { - } - - #region Data dumping - /// - /// Dump the class data to a binary writer - /// - /// writer to write the data - internal void Dump(ref BinaryWriter writer) - { - writer.Write( _urlTable.Count ); - foreach(UrlTableEntry curItem in _urlTable) - { - curItem.Dump(ref writer); - } - } - - /// - /// Reads the object data from a dump store - /// - /// reader to read the data - internal void ReadDump(ref BinaryReader reader) - { - int i=0; - int nCnt = reader.ReadInt32(); - - for(i=0; i - /// Sets the associated CHMFile instance - /// - /// instance to set - internal void SetCHMFile(CHMFile associatedFile) - { - _associatedFile = associatedFile; - - foreach(UrlTableEntry curEntry in _urlTable) - { - curEntry.SetCHMFile(associatedFile); - } - } - #endregion - - /// - /// Decodes the binary file data and fills the internal properties - /// - /// true if succeeded - private bool DecodeData() - { - bool bRet = true; - - MemoryStream memStream = new MemoryStream(_binaryFileData); - BinaryReader binReader = new BinaryReader(memStream); - - int nCurOffset = 0; - - while( (memStream.Position < memStream.Length) && (bRet) ) - { - nCurOffset = (int)memStream.Position; - byte [] dataBlock = binReader.ReadBytes(BLOCK_SIZE); - bRet &= DecodeBlock(dataBlock, ref nCurOffset); - } - - return bRet; - } - - /// - /// Decodes a block of url-string data - /// - /// block of data - /// current file offset - /// true if succeeded - private bool DecodeBlock( byte[] dataBlock, ref int nOffset ) - { - bool bRet = true; - int blockOffset = nOffset; - - MemoryStream memStream = new MemoryStream(dataBlock); - BinaryReader binReader = new BinaryReader(memStream); - - for(int i=0; i < RECORDS_PER_BLOCK; i++) - { - int recordOffset = blockOffset + (int)memStream.Position; - - uint nuniqueID = (uint) binReader.ReadInt32(); // unknown dword - int ntopicsIdx = binReader.ReadInt32(); - int urlstrOffset = binReader.ReadInt32(); - - UrlTableEntry newEntry = new UrlTableEntry(nuniqueID, recordOffset, ntopicsIdx, urlstrOffset, _associatedFile); - _urlTable.Add(newEntry); - - if( memStream.Position >= memStream.Length) - break; - } - - if(dataBlock.Length == BLOCK_SIZE) - binReader.ReadInt32(); - - return bRet; - } - - /// - /// Gets the arraylist containing all urltable entries. - /// - public ArrayList UrlTable - { - get - { - return _urlTable; - } - } - - /// - /// Gets the urltable entry of a given offset - /// - public UrlTableEntry this[int offset] - { - get - { - foreach(UrlTableEntry curEntry in _urlTable) - if(curEntry.EntryOffset == offset) - return curEntry; - - return null; - } - } - - /// - /// Gets the urltable entry of a given uniqueID - /// - public UrlTableEntry GetByUniqueID(uint uniqueID) - { - foreach(UrlTableEntry curEntry in UrlTable) - { - if(curEntry.UniqueID == uniqueID) - return curEntry; - } - - return null; - } - - /// - /// Implement IDisposable. - /// - public void Dispose() - { - Dispose(true); - // This object will be cleaned up by the Dispose method. - // Therefore, you should call GC.SupressFinalize to - // take this object off the finalization queue - // and prevent finalization code for this object - // from executing a second time. - GC.SuppressFinalize(this); - } - - /// - /// Dispose(bool disposing) executes in two distinct scenarios. - /// If disposing equals true, the method has been called directly - /// or indirectly by a user's code. Managed and unmanaged resources - /// can be disposed. - /// If disposing equals false, the method has been called by the - /// runtime from inside the finalizer and you should not reference - /// other objects. Only unmanaged resources can be disposed. - /// - /// disposing flag - private void Dispose(bool disposing) - { - // Check to see if Dispose has already been called. - if(!this.disposed) - { - // If disposing equals true, dispose all managed - // and unmanaged resources. - if(disposing) - { - // Dispose managed resources. - _binaryFileData = null; - _urlTable = null; - } - } - disposed = true; - } - } -} diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/DumpingInfo.cs b/irc/TechBot/CHMLibrary/CHMDecoding/DumpingInfo.cs deleted file mode 100644 index f42fb98ee11..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/DumpingInfo.cs +++ /dev/null @@ -1,395 +0,0 @@ -using System; -using System.IO; -using System.Text; -using System.Diagnostics; -using System.Collections.Specialized; - -using ICSharpCode.SharpZipLib; -using ICSharpCode.SharpZipLib.Zip; -using ICSharpCode.SharpZipLib.Zip.Compression; -using ICSharpCode.SharpZipLib.Zip.Compression.Streams; - -using HtmlHelp; -// using HtmlHelp.Storage; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// Enumeration for specifying the dumping compression - /// - public enum DumpCompression - { - /// - /// None - no data compression will be used. - /// Fastest but most memory intensive - /// - None = 0, - /// - /// Minimum - a minimum data compression will be used. - /// Fast but not much data reduction - /// - Minimum = 1, - /// - /// Medium - a medium data compression will be used. - /// Slower but medium data reduction - /// - Medium = 2, - /// - /// Maximum - a maximum data compression will be used. - /// Slowest but maximum data reduction - /// - Maximum = 3 - } - - /// - /// Flags which specify which data should be dumped - /// - [FlagsAttribute()] - public enum DumpingFlags - { - /// - /// DumpTextTOC - if this flag is set, text-based TOCs (sitemap format) will be dumped - /// - DumpTextTOC = 1, - /// - /// DumpBinaryTOC - if this flag is set, binary TOCs will be dumped - /// - DumpBinaryTOC = 2, - /// - /// DumpTextIndex - if this flag is set, the text-based index (sitemap format) will be dumped - /// - DumpTextIndex = 4, - /// - /// DumpBinaryIndex - if this flag is set, the binary index will be dumped - /// - DumpBinaryIndex = 8, - /// - /// DumpStrings - if this flag is set, the internal #STRINGS file will be dumped - /// - DumpStrings = 16, - /// - /// DumpUrlStr - if this flag is set, the internal #URLSTR file will be dumped - /// - DumpUrlStr = 32, - /// - /// DumpUrlTbl - if this flag is set, the internal #URLTBL file will be dumped - /// - DumpUrlTbl = 64, - /// - /// DumpTopics - if this flag is set, the internal #TOPICS file will be dumped - /// - DumpTopics = 128, - /// - /// DumpFullText - if this flag is set, the internal $FIftiMain file will be dumped - /// - DumpFullText = 256 - } - - /// - /// The class DumpingInfo implements information properties for the CHMFile class - /// if and how data dumping should be used. - /// - public sealed class DumpingInfo - { - public bool m_bAllowSaveDump=true; - - private readonly static BitVector32.Section DumpFlags = BitVector32.CreateSection(512); - - private const string _dumpHeader = "HtmlHelpSystem dump file 1.0"; - - private string _outputDir = ""; // emtpy string means, same directory as chm file - private DumpCompression _compressionLevel = DumpCompression.Maximum; - private CHMFile _chmFile = null; - - private DeflaterOutputStream _outputStream = null; - private InflaterInputStream _inputStream = null; - - private BinaryWriter _writer = null; - private BinaryReader _reader = null; - - private BitVector32 _flags; - - /// - /// Constructor of the class - /// - /// Combine flag values to specify which data should be dumped. - /// output directory. emtpy string means, - /// same directory as chm file (only if destination = ExternalFile) - /// compression which should be used - public DumpingInfo(DumpingFlags flags, string outputDir, DumpCompression compressionLevel) - { - _flags = new BitVector32(0); - int i = _flags[DumpFlags]; - _flags[DumpFlags] = i | (int)flags; - - _outputDir = outputDir; - _compressionLevel = compressionLevel; - } - - /// - /// Gets the flag if text-based TOCs will be written to the dumping file - /// - public bool DumpTextTOC - { - get { return ((_flags[DumpFlags] & (int)DumpingFlags.DumpTextTOC) != 0); } - } - - /// - /// Gets the flag if binary TOCs will be written to the dumping file - /// - public bool DumpBinaryTOC - { - get { return ((_flags[DumpFlags] & (int)DumpingFlags.DumpBinaryTOC) != 0); } - } - - /// - /// Gets the flag if the text-based index will be written to the dumping file - /// - public bool DumpTextIndex - { - get { return ((_flags[DumpFlags] & (int)DumpingFlags.DumpTextIndex) != 0); } - } - - /// - /// Gets the flag if the binary index will be written to the dumping file - /// - public bool DumpBinaryIndex - { - get { return ((_flags[DumpFlags] & (int)DumpingFlags.DumpBinaryIndex) != 0); } - } - - /// - /// Gets the flag if the #STRINGS file will be written to the dumping file - /// - public bool DumpStrings - { - get { return ((_flags[DumpFlags] & (int)DumpingFlags.DumpStrings) != 0); } - } - - /// - /// Gets the flag if the #URLSTR file will be written to the dumping file - /// - public bool DumpUrlStr - { - get { return ((_flags[DumpFlags] & (int)DumpingFlags.DumpUrlStr) != 0); } - } - - /// - /// Gets the flag if the #URLTBL file will be written to the dumping file - /// - public bool DumpUrlTbl - { - get { return ((_flags[DumpFlags] & (int)DumpingFlags.DumpUrlTbl) != 0); } - } - - /// - /// Gets the flag if the #TOPICS file will be written to the dumping file - /// - public bool DumpTopics - { - get { return ((_flags[DumpFlags] & (int)DumpingFlags.DumpTopics) != 0); } - } - - /// - /// Gets the flag if the $FIftiMain file will be written to the dumping file - /// - public bool DumpFullText - { - get { return ((_flags[DumpFlags] & (int)DumpingFlags.DumpFullText) != 0); } - } - - /// - /// Gets the dump output directory. - /// - /// emtpy string means, same directory as chm file - /// If Destination is set to DumpingOutput.InternalFile this property will be ignored - public string OutputDir - { - get { return _outputDir; } - } - - /// - /// The compression level used. - /// - public DumpCompression CompressionLevel - { - get { return _compressionLevel; } - } - - /// - /// Gets/Sets the CHMFile instance associated with this object - /// - internal CHMFile ChmFile - { - get { return _chmFile; } - set { _chmFile = value; } - } - - /// - /// Translates the compression level to the deflater constants - /// - private int CompLvl - { - get - { - switch(CompressionLevel) - { - case DumpCompression.None: return Deflater.NO_COMPRESSION; - case DumpCompression.Minimum: return Deflater.BEST_SPEED; - case DumpCompression.Medium: return Deflater.DEFAULT_COMPRESSION; - case DumpCompression.Maximum: return Deflater.BEST_COMPRESSION; - } - - return Deflater.BEST_COMPRESSION; - } - } - - /// - /// Checks if a dump exists - /// - internal bool DumpExists - { - get - { - if(_flags[DumpFlags] == 0) - return false; - - // we have a reader or writer to the dump so it must exist - if( (_reader != null) || (_writer != null) ) - return true; - - string sDmpFile = _chmFile.ChmFilePath; - sDmpFile=sDmpFile.ToLower().Replace(".chm",".CHB"); - - return File.Exists(sDmpFile); - } - } - - /// - /// Gets a binary writer instance which allows you to write to the dump - /// - internal BinaryWriter Writer - { - get - { - if (m_bAllowSaveDump==false) - return null; - - if(_flags[DumpFlags] == 0) - throw new InvalidOperationException("Nothing to dump. No flags have been set !"); - - if(_reader != null) - throw new InvalidOperationException("Can't write and read at the same time !"); - - if(_chmFile == null) - throw new InvalidOperationException("Only usable with an associated CHMFile instance !"); - - if(_writer==null) - { - string sDmpFile = _chmFile.ChmFilePath; - sDmpFile=sDmpFile.ToLower().Replace(".chm",".CHB"); - StreamWriter stream = new StreamWriter(sDmpFile, false, _chmFile.TextEncoding); - - // write header info uncompressed - BinaryWriter _hwriter = new BinaryWriter(stream.BaseStream); - _hwriter.Write(_dumpHeader); - _hwriter.Write((int)CompressionLevel); - - if(_compressionLevel == DumpCompression.None) - { - _writer = new BinaryWriter(stream.BaseStream); - } - else - { - _outputStream = new DeflaterOutputStream(stream.BaseStream, new Deflater(CompLvl)); - - _writer = new BinaryWriter(_outputStream); - } - } - - return _writer; - - } - } - - /// - /// Gets a binary reader which allows you to read from the dump - /// - internal BinaryReader Reader - { - get - { - if(_writer != null) - throw new InvalidOperationException("Can't write and read at the same time !"); - - if(_chmFile == null) - throw new InvalidOperationException("Only usable with an associated CHMFile instance !"); - - if(_reader==null) - { - string sDmpFile = _chmFile.ChmFilePath; - sDmpFile=sDmpFile.ToLower().Replace(".chm",".CHB"); - StreamReader stream = new StreamReader(sDmpFile, _chmFile.TextEncoding); - - BinaryReader _hReader = new BinaryReader(stream.BaseStream); - string sH = _hReader.ReadString(); - - if(sH != _dumpHeader) - { - _hReader.Close(); - Debug.WriteLine("Unexpected dump-file header !"); - throw new FormatException("DumpingInfo.Reader - Unexpected dump-file header !"); - } - - _compressionLevel = (DumpCompression)_hReader.ReadInt32(); -// if(_compressionLevel != (DumpCompression)_hReader.ReadInt32()) -// { -// _hReader.Close(); -// return null; -// } - - if(_compressionLevel == DumpCompression.None) - { - _reader = new BinaryReader(stream.BaseStream); - } - else - { - _inputStream = new InflaterInputStream(stream.BaseStream, new Inflater()); - - _reader = new BinaryReader(_inputStream); - } - } - - return _reader; - } - } - - /// - /// Saves data and closes the dump - /// - /// true if succeed - internal bool SaveData() - { - if (m_bAllowSaveDump==false) - return true; - - if(_writer != null) - { - if(_writer!=null) - _writer.Close(); - _outputStream = null; - _writer = null; - } - - if(_reader != null) - { - if(_reader!=null) - _reader.Close(); - _inputStream = null; - _reader = null; - } - - return true; - } - } -} diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/FullTextEngine.cs b/irc/TechBot/CHMLibrary/CHMDecoding/FullTextEngine.cs deleted file mode 100644 index fc1d634d924..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/FullTextEngine.cs +++ /dev/null @@ -1,1131 +0,0 @@ -using System; -using System.Data; -using System.Diagnostics; -using System.Text; -using System.Text.RegularExpressions; -using System.IO; -using System.Collections; -using System.Globalization; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// The class FullTextSearcher implements a fulltext searcher for a single chm file ! - /// - internal sealed class FullTextEngine : IDisposable - { - #region Internal helper classes - /// - /// Internal class for decoding the header - /// - private sealed class FTHeader - { - /// - /// Internal member storing the number of indexed files - /// - private int _numberOfIndexFiles = 0; - /// - /// Internal member storing the offset of the root node - /// - private int _rootOffset = 0; - /// - /// Internal member storing the index-page count - /// - private int _pageCount = 0; - /// - /// Internal member storing the depth of the tree - /// - private int _depth = 0; - /// - /// Internal member storing the scale param for document index en-/decoding - /// - private byte _scaleDocIdx = 0; - /// - /// Internal member storing the scale param for code-count en-/decoding - /// - private byte _scaleCodeCnt = 0; - /// - /// Internal member storing the scale param for location codes en-/decoding - /// - private byte _scaleLocCodes = 0; - /// - /// Internal member storing the root param for document index en-/decoding - /// - private byte _rootDocIdx = 0; - /// - /// Internal member storing the root param for code-count en-/decoding - /// - private byte _rootCodeCnt = 0; - /// - /// Internal member storing the root param for location codes en-/decoding - /// - private byte _rootLocCodes = 0; - /// - /// Internal member storing the size of the nodes in bytes - /// - private int _nodeSize = 0; - /// - /// Internal member storing the length of the longest word - /// - private int _lengthOfLongestWord = 0; - /// - /// Internal member storing the total number of words - /// - private int _totalNumberOfWords = 0; - /// - /// Internal member storing the total number of unique words - /// - private int _numberOfUniqueWords = 0; - /// - /// Internal member storing the codepage identifier - /// - private int _codePage = 1252; - /// - /// Internal member storing the language code id - /// - private int _lcid = 1033; - /// - /// Internal member storing the text encoder - /// - private Encoding _textEncoder = Encoding.Default; - - /// - /// Constructor of the header - /// - /// binary data from which the header will be extracted - public FTHeader(byte[] binaryData) - { - DecodeHeader(binaryData); - } - - /// - /// Internal constructor for reading from dump - /// - internal FTHeader() - { - } - - /// - /// Decodes the binary header information and fills the members - /// - /// binary data from which the header will be extracted - private void DecodeHeader(byte[] binaryData) - { - MemoryStream memStream = new MemoryStream(binaryData); - BinaryReader binReader = new BinaryReader(memStream); - - binReader.ReadBytes(4); // 4 unknown bytes - - _numberOfIndexFiles = binReader.ReadInt32(); // number of indexed files - - binReader.ReadInt32(); // unknown - binReader.ReadInt32(); // unknown - - _pageCount = binReader.ReadInt32(); // page-count - _rootOffset = binReader.ReadInt32(); // file offset of the root node - _depth = binReader.ReadInt16(); // depth of the tree - - binReader.ReadInt32(); // unknown - - _scaleDocIdx = binReader.ReadByte(); - _rootDocIdx = binReader.ReadByte(); - _scaleCodeCnt = binReader.ReadByte(); - _rootCodeCnt = binReader.ReadByte(); - _scaleLocCodes = binReader.ReadByte(); - _rootLocCodes = binReader.ReadByte(); - - if( (_scaleDocIdx != 2) || ( _scaleCodeCnt != 2 ) || ( _scaleLocCodes != 2 ) ) - { - Debug.WriteLine("Unsupported scale for s/r encoding !"); - throw new InvalidOperationException("Unsupported scale for s/r encoding !"); - } - - binReader.ReadBytes(10); // unknown - - _nodeSize = binReader.ReadInt32(); - - binReader.ReadInt32(); // unknown - binReader.ReadInt32(); // not important - binReader.ReadInt32(); // not important - - _lengthOfLongestWord = binReader.ReadInt32(); - _totalNumberOfWords = binReader.ReadInt32(); - _numberOfUniqueWords = binReader.ReadInt32(); - - binReader.ReadInt32(); // not important - binReader.ReadInt32(); // not important - binReader.ReadInt32(); // not important - binReader.ReadInt32(); // not important - binReader.ReadInt32(); // not important - binReader.ReadInt32(); // not important - - binReader.ReadBytes(24); // not important - - _codePage = binReader.ReadInt32(); - _lcid = binReader.ReadInt32(); - - CultureInfo ci = new CultureInfo(_lcid); - _textEncoder = Encoding.GetEncoding( ci.TextInfo.ANSICodePage ); - - // rest of header is not important for us - } - - /// - /// Dump the class data to a binary writer - /// - /// writer to write the data - internal void Dump(ref BinaryWriter writer) - { - writer.Write( _numberOfIndexFiles ); - writer.Write( _rootOffset ); - writer.Write( _pageCount ); - writer.Write( _depth ); - writer.Write( _scaleDocIdx ); - writer.Write( _rootDocIdx ); - writer.Write( _scaleCodeCnt ); - writer.Write( _rootCodeCnt ); - writer.Write( _scaleLocCodes ); - writer.Write( _rootLocCodes ); - writer.Write( _nodeSize ); - writer.Write( _lengthOfLongestWord ); - writer.Write( _totalNumberOfWords ); - writer.Write( _numberOfUniqueWords ); - } - - /// - /// Reads the object data from a dump store - /// - /// reader to read the data - internal void ReadDump(ref BinaryReader reader) - { - _numberOfIndexFiles = reader.ReadInt32(); - _rootOffset = reader.ReadInt32(); - _pageCount = reader.ReadInt32(); - _depth = reader.ReadInt32(); - - _scaleDocIdx = reader.ReadByte(); - _rootDocIdx = reader.ReadByte(); - _scaleCodeCnt = reader.ReadByte(); - _rootCodeCnt = reader.ReadByte(); - _scaleLocCodes = reader.ReadByte(); - _rootLocCodes = reader.ReadByte(); - - _nodeSize = reader.ReadInt32(); - _lengthOfLongestWord = reader.ReadInt32(); - _totalNumberOfWords = reader.ReadInt32(); - _numberOfUniqueWords = reader.ReadInt32(); - } - - /// - /// Gets the number of indexed files - /// - public int IndexedFileCount - { - get { return _numberOfIndexFiles; } - } - - /// - /// Gets the file offset of the root node - /// - public int RootOffset - { - get { return _rootOffset; } - } - - /// - /// Gets the page count - /// - public int PageCount - { - get { return _pageCount; } - } - - /// - /// Gets the index depth - /// - public int Depth - { - get { return _depth; } - } - - /// - /// Gets the scale param for document index en-/decoding - /// - /// The scale and root method of integer encoding needs two parameters, - /// which I'll call s (scale) and r (root size). - /// The integer is encoded as two parts, p (prefix) and q (actual bits). - /// p determines how many bits are stored, as well as implicitly determining - /// the high-order bit of the integer. - public byte ScaleDocumentIndex - { - get { return _scaleDocIdx; } - } - - /// - /// Gets the root param for the document index en-/decoding - /// - /// The scale and root method of integer encoding needs two parameters, - /// which I'll call s (scale) and r (root size). - /// The integer is encoded as two parts, p (prefix) and q (actual bits). - /// p determines how many bits are stored, as well as implicitly determining - /// the high-order bit of the integer. - public byte RootDocumentIndex - { - get { return _rootDocIdx; } - } - - /// - /// Gets the scale param for the code-count en-/decoding - /// - /// The scale and root method of integer encoding needs two parameters, - /// which I'll call s (scale) and r (root size). - /// The integer is encoded as two parts, p (prefix) and q (actual bits). - /// p determines how many bits are stored, as well as implicitly determining - /// the high-order bit of the integer. - public byte ScaleCodeCount - { - get { return _scaleCodeCnt; } - } - - /// - /// Gets the root param for the code-count en-/decoding - /// - /// The scale and root method of integer encoding needs two parameters, - /// which I'll call s (scale) and r (root size). - /// The integer is encoded as two parts, p (prefix) and q (actual bits). - /// p determines how many bits are stored, as well as implicitly determining - /// the high-order bit of the integer. - public byte RootCodeCount - { - get { return _rootCodeCnt; } - } - - /// - /// Gets the scale param for the location codes en-/decoding - /// - /// The scale and root method of integer encoding needs two parameters, - /// which I'll call s (scale) and r (root size). - /// The integer is encoded as two parts, p (prefix) and q (actual bits). - /// p determines how many bits are stored, as well as implicitly determining - /// the high-order bit of the integer. - public byte ScaleLocationCodes - { - get { return _scaleLocCodes; } - } - - /// - /// Gets the root param for the location codes en-/decoding - /// - /// The scale and root method of integer encoding needs two parameters, - /// which I'll call s (scale) and r (root size). - /// The integer is encoded as two parts, p (prefix) and q (actual bits). - /// p determines how many bits are stored, as well as implicitly determining - /// the high-order bit of the integer. - public byte RootLocationCodes - { - get { return _rootLocCodes; } - } - - /// - /// Gets the size in bytes of each index/leaf node - /// - public int NodeSize - { - get { return _nodeSize; } - } - - /// - /// Gets the length of the longest word in the index - /// - private int LengthOfLongestWord - { - get { return _lengthOfLongestWord; } - } - - /// - /// Gets the total number of words indexed (including duplicates) - /// - public int TotalWordCount - { - get { return _totalNumberOfWords; } - } - - /// - /// Gets the total number of unique words indexed (excluding duplicates) - /// - public int UniqueWordCount - { - get { return _numberOfUniqueWords; } - } - - /// - /// Gets the codepage identifier - /// - public int CodePage - { - get { return _codePage; } - } - - /// - /// Gets the language code id - /// - public int LCID - { - get { return _lcid; } - } - - public Encoding TextEncoder - { - get - { - return _textEncoder; - } - } - } - - - /// - /// Internal class for easier hit recording and rate-calculation - /// - private sealed class HitHelper : IComparable - { - /// - /// Internal member storing the associated document index - /// - private int _documentIndex = 0; - /// - /// Internal member storing the title - /// - private string _title = ""; - /// - /// Internal member storing the locale - /// - private string _locale = ""; - /// - /// Internal member storing the location - /// - private string _location = ""; - /// - /// Internal member storing the url - /// - private string _url = ""; - /// - /// Internal member storing the rating - /// - private double _rating = 0; - /// - /// Internal member used for rating calculation - /// - private Hashtable _partialRating = new Hashtable(); - - /// - /// Constructor of the class - /// - /// document index - /// title - /// locale parameter - /// location - /// url of document - /// rating - public HitHelper(int documentIndex, string title, string locale, string location, string url, double rating) - { - _documentIndex = documentIndex; - _title = title; - _locale = locale; - _location = location; - _url = url; - _rating = rating; - } - - /// - /// Updates the rating for a found word - /// - /// word found - public void UpdateRating(string word) - { - if( _partialRating[word] == null) - { - _partialRating[word] = 100.0; - } - else - { - _partialRating[word] = ((double)_partialRating[word])*1.01; - } - - _rating = 0.0; - - foreach(double val in _partialRating.Values) - { - _rating += val; - } - } - - /// - /// Implements the CompareTo method of the IComparable interface. - /// Allows an easy sort by the document rating - /// - /// object to compare - /// 0 ... equal, -1 ... this instance is less than obj, 1 ... this instance is greater than obj - public int CompareTo(object obj) - { - if( obj is HitHelper ) - { - HitHelper hObj = (HitHelper)obj; - - return this.Rating.CompareTo( hObj.Rating ); - } - - return -1; - } - - /// - /// Gets the internal hashtable used for counting word hits of the document - /// - internal Hashtable PartialRating - { - get { return _partialRating; } - } - - /// - /// Gets the document index of the hit helper instance - /// - public int DocumentIndex - { - get { return _documentIndex; } - } - - /// - /// Gets the title - /// - public string Title - { - get { return _title; } - } - - /// - /// Gets the locale - /// - public string Locale - { - get { return _locale; } - } - - /// - /// Gets the location - /// - public string Location - { - get { return _location; } - } - - /// - /// Gets the url - /// - public string URL - { - get { return _url; } - } - - /// - /// Gets the rating - /// - public double Rating - { - get { return _rating; } - } - - } - - #endregion - - /// - /// Regular expression getting the text between to quotes - /// - private string RE_Quotes = @"\""(?.*?)\"""; - /// - /// Internal flag specifying if the object is going to be disposed - /// - private bool disposed = false; - /// - /// Internal member storing the binary file data - /// - private byte[] _binaryFileData = null; - /// - /// Internal datatable storing the search hits - /// - private DataTable _hits =null; - /// - /// Internal arraylist for hit management - /// - private ArrayList _hitsHelper = new ArrayList(); - /// - /// Internal member storing the header of the file - /// - private FTHeader _header = null; - /// - /// Internal member storing the associated chmfile object - /// - private CHMFile _associatedFile = null; - - /// - /// Constructor of the class - /// - /// binary file data of the $FIftiMain file - /// associated chm file - public FullTextEngine(byte[] binaryFileData, CHMFile associatedFile) - { - _binaryFileData = binaryFileData; - _associatedFile = associatedFile; - - if(_associatedFile.SystemFile.FullTextSearch) - { - _header = new FTHeader(_binaryFileData); // reading header - } - } - - /// - /// Standard constructor - /// - internal FullTextEngine() - { - } - - #region Data dumping - /// - /// Dump the class data to a binary writer - /// - /// writer to write the data - internal void Dump(ref BinaryWriter writer) - { - _header.Dump(ref writer); - writer.Write( _binaryFileData.Length ); - writer.Write(_binaryFileData); - } - - /// - /// Reads the object data from a dump store - /// - /// reader to read the data - internal void ReadDump(ref BinaryReader reader) - { - _header = new FTHeader(); - _header.ReadDump(ref reader); - - int nCnt = reader.ReadInt32(); - _binaryFileData = reader.ReadBytes(nCnt); - } - - /// - /// Sets the associated CHMFile instance - /// - /// instance to set - internal void SetCHMFile(CHMFile associatedFile) - { - _associatedFile = associatedFile; - } - #endregion - - /// - /// Gets a flag if full-text searching is available for this chm file. - /// - public bool CanSearch - { - get { return (_associatedFile.SystemFile.FullTextSearch && (_header != null) ); } - } - - /// - /// Performs a fulltext search of a single file. - /// - /// word(s) or phrase to search - /// true if partial word should be matched also - /// ( if this is true a search of 'support' will match 'supports', otherwise not ) - /// true if only search in titles - /// Hits are available through the Hists property. - public bool Search(string search, bool partialMatches, bool titleOnly) - { - return Search(search, -1, partialMatches, titleOnly); - } - - /// - /// Performs a fulltext search of a single file. - /// - /// word(s) or phrase to search - /// max hits. If this number is reached, the search will be interrupted - /// true if partial word should be matched also - /// ( if this is true a search of 'support' will match 'supports', otherwise not ) - /// true if only search in titles - /// Hits are available through the Hists property. - public bool Search(string search, int MaxHits, bool partialMatches, bool titleOnly) - { - if(CanSearch) - { - string searchString = search; - - // Check if this is a quoted string - bool IsQuoted = (search.IndexOf("\"")>-1); - - if(IsQuoted) - searchString = search.Replace("\"",""); // remove the quotes during search - - bool bRet = true; - - _hitsHelper = null; - _hitsHelper = new ArrayList(); - - _hits = null; - CreateHitsTable(); - - string[] words = searchString.Split(new char[] {' '}); - - for(int i=0; i= MaxHits) - break; - } - - if(bRet && IsQuoted) - { - FinalizeQuoted(search); - } - - if(bRet) - { - _hitsHelper.Sort(); - - int nhCount = MaxHits; - - if( MaxHits < 0) - { - nhCount = _hitsHelper.Count; - } - - if( nhCount > _hitsHelper.Count ) - nhCount = _hitsHelper.Count; - - // create hits datatable - for(int i=nhCount; i > 0; i--) - { - HitHelper curHlp = (HitHelper)(_hitsHelper[i-1]); - - DataRow newRow = _hits.NewRow(); - - newRow["Rating"] = curHlp.Rating; - newRow["Title"] = curHlp.Title; - newRow["Locale"] = curHlp.Locale; - newRow["Location"] = curHlp.Location; - newRow["URL"] = curHlp.URL; - - _hits.Rows.Add( newRow ); - } - } - return bRet; - } - - return false; - } - - /// - /// Gets rid of all search hits which doesn't match the quoted phrase - /// - /// full search string entered by the user - /// Phrase search is not possible using the internal full-text index. We're just filtering all - /// documents which don't contain all words of the phrase. - private void FinalizeQuoted(string search) - { - Regex quoteRE = new Regex(RE_Quotes, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); - int innerTextIdx = quoteRE.GroupNumberFromName("innerText"); - int nIndex = 0; - - // get all phrases - while( quoteRE.IsMatch(search, nIndex) ) - { - Match m = quoteRE.Match(search, nIndex); - - string phrase = m.Groups["innerText"].Value; - - string[] wordsInPhrase = phrase.Split( new char[] {' '} ); - int nCnt = _hitsHelper.Count; - - for(int i=0; i < _hitsHelper.Count; i++) - { - if( ! CheckHit( ((HitHelper)(_hitsHelper[i])), wordsInPhrase) ) - _hitsHelper.RemoveAt(i--); - } - - nIndex = m.Index+m.Length; - } - } - - /// - /// Eliminates all search hits where not all of the words have been found - /// - /// hithelper instance to check - /// word list - private bool CheckHit(HitHelper hit, string[] wordsInPhrase) - { - - for(int i=0; i - /// Performs a search for a single word in the index - /// - /// word to search - /// maximal hits to return - /// true if partial word should be matched also - /// ( if this is true a search of 'support' will match 'supports', otherwise not ) - /// true if only search in titles - /// Returns true if succeeded - private bool SearchSingleWord(string word,int MaxHits, bool partialMatches, bool titleOnly) - { - string wordLower = word.ToLower(); - - MemoryStream memStream = new MemoryStream(_binaryFileData); - BinaryReader binReader = new BinaryReader(memStream); - - // seek to root node - binReader.BaseStream.Seek( _header.RootOffset, SeekOrigin.Begin ); - - if( _header.Depth > 2 ) - { - // unsupported index depth - Debug.WriteLine("FullTextSearcher.SearchSingleWord() - Failed with message: Unsupported index depth !"); - Debug.WriteLine("File: " + _associatedFile.ChmFilePath); - Debug.WriteLine(" "); - return false; - } - - if( _header.Depth > 1 ) - { - // seek to the right leaf node ( if depth == 1, we are at the leaf node) - int freeSpace = binReader.ReadInt16(); - - for(int i=0; i < _header.PageCount; ++i) - { - // exstract index entries - int nWLength = (int)binReader.ReadByte(); - int nCPosition = (int)binReader.ReadByte(); - - string sName = BinaryReaderHelp.ExtractString(ref binReader, nWLength-1, 0, true, _header.TextEncoder); - - int nLeafOffset = binReader.ReadInt32(); - binReader.ReadInt16(); // unknown - - if( sName.CompareTo(wordLower) >= 0) - { - // store current position - long curPos = binReader.BaseStream.Position; - - // seek to leaf offset - binReader.BaseStream.Seek( nLeafOffset, SeekOrigin.Begin ); - - // read leafnode - ReadLeafNode(ref binReader, word, MaxHits, partialMatches, titleOnly); - - // return to current position and continue reading index nodes - binReader.BaseStream.Seek( curPos, SeekOrigin.Begin ); - } - } - } - - return true; - } - - /// - /// Reads a leaf node and extracts documents which holds the searched word - /// - /// reference to the reader - /// word to search - /// maximal hits to return - /// true if partial word should be matched also - /// ( if this is true a search of 'support' will match 'supports', otherwise not ) - /// true if only search in titles - private void ReadLeafNode(ref BinaryReader binReader, string word, int MaxHits, bool partialMatches, bool titleOnly) - { - int nNextPageOffset = binReader.ReadInt32(); - binReader.ReadInt16(); // unknown - int lfreeSpace = binReader.ReadInt16(); - string curFullWord = ""; - bool bFound = false; - string wordLower = word.ToLower(); - - for(;;) - { - if(binReader.BaseStream.Position >= binReader.BaseStream.Length) - break; - - int nWLength = (int)binReader.ReadByte(); - - if(nWLength == 0) - break; - - int nCPosition = (int)binReader.ReadByte(); - - string sName = BinaryReaderHelp.ExtractString(ref binReader, nWLength-1, 0, true, _header.TextEncoder); - - int Context = (int)binReader.ReadByte(); // 0...body tag, 1...title tag, others unknown - - long nrOfWCL = BinaryReaderHelp.ReadENCINT(ref binReader); - int wclOffset = binReader.ReadInt32(); - - binReader.ReadInt16(); // unknown - - long bytesOfWCL = BinaryReaderHelp.ReadENCINT(ref binReader); - - if( nCPosition > 0) - { - curFullWord = CombineStrings(curFullWord, sName, nCPosition); - } - else - { - curFullWord = sName; - } - - bFound = false; - if(partialMatches) - bFound = ( curFullWord.IndexOf(wordLower) >= 0 ); - else - bFound = (curFullWord == wordLower); - - if( bFound ) - { - if( (titleOnly && (Context==1)) || (!titleOnly) ) - { - // store actual offset - long curPos = binReader.BaseStream.Position; - - // found the word, begin with WCL encoding - binReader.BaseStream.Seek(wclOffset, SeekOrigin.Begin ); - - byte[] wclBytes = binReader.ReadBytes((int)bytesOfWCL); - - DecodeWCL(wclBytes, MaxHits, word); - - // back and continue reading leafnodes - binReader.BaseStream.Seek(curPos, SeekOrigin.Begin ); - } - } - } - } - - /// - /// Decodes the s/r encoded WordCodeList (=wcl) and creates hit entries - /// - /// wcl encoded byte array - /// maximal hits - /// the word to find - private void DecodeWCL(byte[] wclBytes,int MaxHits, string word) - { - byte[] wclBits = new byte[ wclBytes.Length*8 ]; - - int nBitIdx=0; - - for(int i=0; i (byte)0 ? (byte)1 : (byte)0; - nBitIdx++; - } - } - - nBitIdx = 0; - - int nDocIdx = 0; // delta encoded - - while(nBitIdx < wclBits.Length) - { - nDocIdx += BinaryReaderHelp.ReadSRItem(wclBits, _header.ScaleDocumentIndex, _header.RootDocumentIndex, ref nBitIdx); - int nCodeCnt = BinaryReaderHelp.ReadSRItem(wclBits, _header.ScaleCodeCount, _header.RootCodeCount, ref nBitIdx); - - int nWordLocation = 0; // delta encoded - - for(int locidx=0; locidx MaxHits) - return; - - hitObj = new HitHelper(nDocIdx, ((TopicEntry)(_associatedFile.TopicsFile.TopicTable[nDocIdx])).Title, - ((TopicEntry)(_associatedFile.TopicsFile.TopicTable[nDocIdx])).Locale, _associatedFile.CompileFile, - ((TopicEntry)(_associatedFile.TopicsFile.TopicTable[nDocIdx])).URL, 0.0); - - for(int k=0;k - /// Combines a "master" word with a partial word. - /// - /// the master word - /// the partial word - /// position to place the parial word - /// returns a combined string - private string CombineStrings(string word, string partial, int partialPosition) - { - string sCombined = word; - int i=0; - - for(i=0; i (sCombined.Length-1) ) - { - sCombined += partial[i]; - } - else - { - StringBuilder sb = new StringBuilder(sCombined); - - sb.Replace( sCombined[partialPosition+i], partial[i], partialPosition+i, 1); - sCombined = sb.ToString(); - } - } - - if(! ((i+partialPosition) > (sCombined.Length-1)) ) - { - sCombined = sCombined.Substring(0, partialPosition+partial.Length); - } - - return sCombined; - } - - /// - /// Gets the HitHelper instance for a specific document index - /// - /// document index - /// The reference of the hithelper instance for this document index, otherwise null - private HitHelper DocumentHit(int index) - { - foreach(HitHelper curObj in _hitsHelper) - { - if( curObj.DocumentIndex == index) - return curObj; - } - - return null; - } - - /// - /// Creates a DataTable for storing the hits - /// - private void CreateHitsTable() - { - _hits = new DataTable("FT_Search_Hits"); - - DataColumn ftColumn; - - ftColumn = new DataColumn(); - ftColumn.DataType = System.Type.GetType("System.Double"); - ftColumn.ColumnName = "Rating"; - ftColumn.ReadOnly = false; - ftColumn.Unique = false; - - _hits.Columns.Add(ftColumn); - - ftColumn = new DataColumn(); - ftColumn.DataType = System.Type.GetType("System.String"); - ftColumn.ColumnName = "Title"; - ftColumn.ReadOnly = false; - ftColumn.Unique = false; - - _hits.Columns.Add(ftColumn); - - ftColumn = new DataColumn(); - ftColumn.DataType = System.Type.GetType("System.String"); - ftColumn.ColumnName = "Locale"; - ftColumn.ReadOnly = false; - ftColumn.Unique = false; - - _hits.Columns.Add(ftColumn); - - ftColumn = new DataColumn(); - ftColumn.DataType = System.Type.GetType("System.String"); - ftColumn.ColumnName = "Location"; - ftColumn.ReadOnly = false; - ftColumn.Unique = false; - - _hits.Columns.Add(ftColumn); - - ftColumn = new DataColumn(); - ftColumn.DataType = System.Type.GetType("System.String"); - ftColumn.ColumnName = "URL"; - ftColumn.ReadOnly = false; - ftColumn.Unique = false; - - _hits.Columns.Add(ftColumn); - } - - /// - /// Gets an datatable containing the hits of the last search - /// - public DataTable Hits - { - get { return _hits; } - } - - /// - /// Implement IDisposable. - /// - public void Dispose() - { - Dispose(true); - // This object will be cleaned up by the Dispose method. - // Therefore, you should call GC.SupressFinalize to - // take this object off the finalization queue - // and prevent finalization code for this object - // from executing a second time. - GC.SuppressFinalize(this); - } - - /// - /// Dispose(bool disposing) executes in two distinct scenarios. - /// If disposing equals true, the method has been called directly - /// or indirectly by a user's code. Managed and unmanaged resources - /// can be disposed. - /// If disposing equals false, the method has been called by the - /// runtime from inside the finalizer and you should not reference - /// other objects. Only unmanaged resources can be disposed. - /// - /// disposing flag - private void Dispose(bool disposing) - { - // Check to see if Dispose has already been called. - if(!this.disposed) - { - // If disposing equals true, dispose all managed - // and unmanaged resources. - if(disposing) - { - // Dispose managed resources. - _binaryFileData = null; - } - } - disposed = true; - } - } -} diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/HHCParser.cs b/irc/TechBot/CHMLibrary/CHMDecoding/HHCParser.cs deleted file mode 100644 index 73482712291..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/HHCParser.cs +++ /dev/null @@ -1,593 +0,0 @@ -using System; -using System.Collections; -using System.Text; -using System.Text.RegularExpressions; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// The class HHCParser implements a parser for HHC contents files. - /// - internal sealed class HHCParser - { - /// - /// regular expressions for replacing the sitemap boundary tags - /// - private static string RE_ULOpening = @"\"; // will be replaced by a '(' for nested parsing - private static string RE_ULClosing = @"\"; // will be replaced by a ')' for nested parsing - - /// - /// Matching ul-tags - /// - private static string RE_ULBoundaries = @"\(?.*)\"; - /// - /// Matching the nested tree structure. - /// - private static string RE_NestedBoundaries = @"\( (?> [^()]+ | \( (?) | \) (?<-DEPTH>) )* (?(DEPTH)(?!)) \)"; - /// - /// Matching object-tags - /// - private static string RE_ObjectBoundaries = @"\.*?)\"; - /// - /// Matching param tags - /// - private static string RE_ParamBoundaries = @"\.*?)\>"; - /// - /// Extracting tag attributes - /// - private const string RE_QuoteAttributes = @"( |\t)*(?[\-a-zA-Z0-9]*)( |\t)*=( |\t)*(?[\""\'])?(?.*?(?(attributeTD)\k|([\s>]|.$)))"; - - /// - /// private regular expressionobjects - /// - private static Regex ulRE; - private static Regex NestedRE; - private static Regex ObjectRE; - private static Regex ParamRE; - private static Regex AttributesRE; - - /// - /// Internal member storing the list of TOCItems which are holding merge links - /// - private static ArrayList _mergeItems = null; - - /// - /// Internal member storing the last read regular topic item. - /// This is used to handle "Merge" entries and add them as child to this instance. - /// - private static TOCItem _lastTopicItem = null; - - /// - /// Parses a HHC file and returns an ArrayList with the table of contents (TOC) tree - /// - /// string content of the hhc file - /// CHMFile instance - /// Returns an ArrayList with the table of contents (TOC) tree - public static ArrayList ParseHHC(string hhcFile, CHMFile chmFile) - { - _lastTopicItem = null; - _mergeItems = null; // clear merged item list - ArrayList tocList = new ArrayList(); - - ulRE = new Regex(RE_ULBoundaries, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); - NestedRE = new Regex(RE_NestedBoundaries, RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); - ObjectRE = new Regex(RE_ObjectBoundaries, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); - ParamRE = new Regex(RE_ParamBoundaries, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); - AttributesRE = new Regex(RE_QuoteAttributes, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); - - int innerTextIdx = ulRE.GroupNumberFromName("innerText"); - - if( ulRE.IsMatch(hhcFile, 0) ) - { - Match m = ulRE.Match(hhcFile, 0); - - int nFirstUL = 0; - - nFirstUL = hhcFile.ToLower().IndexOf("
    "); - - if(nFirstUL == -1) - nFirstUL = hhcFile.ToLower().IndexOf(""); - - if( ObjectRE.IsMatch(hhcFile, 0) ) // first object block contains information types and categories - { - Match mO = ObjectRE.Match(hhcFile, 0); - int iOTxt = ObjectRE.GroupNumberFromName("innerText"); - - string globalText = mO.Groups[iOTxt].Value; - - if( mO.Groups[iOTxt].Index <= nFirstUL) - ParseGlobalSettings( globalText, chmFile ); - } - - // parse toc tree - string innerText = m.Groups["innerText"].Value; - - innerText = innerText.Replace("(", "("); - innerText = innerText.Replace(")", ")"); - innerText = Regex.Replace(innerText, RE_ULOpening, "(", RegexOptions.IgnoreCase); - innerText = Regex.Replace(innerText, RE_ULClosing, ")", RegexOptions.IgnoreCase); - - ParseTree( innerText, null, tocList, chmFile ); - - } - - return tocList; - } - - /// - /// Checks if the hhc file contains a global object tag. - /// - /// string content of the hhc file - /// chm file - /// true if the hhc content contains a global object tag - public static bool HasGlobalObjectTag(string hhcFile, CHMFile chmFile) - { - bool bRet = false; - - ulRE = new Regex(RE_ULBoundaries, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); - ObjectRE = new Regex(RE_ObjectBoundaries, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); - - int innerTextIdx = ulRE.GroupNumberFromName("innerText"); - - if( ulRE.IsMatch(hhcFile, 0) ) - { - Match m = ulRE.Match(hhcFile, 0); - - int nFirstUL = 0; - - nFirstUL = hhcFile.ToLower().IndexOf("
      "); - - if(nFirstUL == -1) - nFirstUL = hhcFile.ToLower().IndexOf(""); - - if( ObjectRE.IsMatch(hhcFile, 0) ) // first object block contains information types and categories - { - Match mO = ObjectRE.Match(hhcFile, 0); - int iOTxt = ObjectRE.GroupNumberFromName("innerText"); - - string globalText = mO.Groups[iOTxt].Value; - - if( mO.Groups[iOTxt].Index <= nFirstUL) - bRet = true; - } - } - - return bRet; - } - - /// - /// Gets true if the previously done parsing found merge-links - /// - public static bool HasMergeLinks - { - get - { - if(_mergeItems==null) - return false; - - return _mergeItems.Count > 0; - } - } - - /// - /// Gets all TOCItem references which are holding merge-links - /// - public static ArrayList MergeItems - { - get { return _mergeItems; } - } - - /// - /// Recursively parses a sitemap tree - /// - /// content text - /// Parent for all read items - /// arraylist which receives the extracted nodes - /// CHMFile instance - private static void ParseTree( string text, TOCItem parent, ArrayList arrNodes, CHMFile chmFile ) - { - string strPreItems="", strPostItems=""; - string innerText = ""; - - int nIndex = 0; - - while( NestedRE.IsMatch(text, nIndex) ) - { - Match m = NestedRE.Match(text, nIndex); - - innerText = m.Value.Substring( 1, m.Length-2); - - strPreItems = text.Substring(nIndex,m.Index-nIndex); - - ParseItems(strPreItems, parent, arrNodes, chmFile); - - if((arrNodes.Count>0) && (innerText.Length > 0) ) - { - TOCItem p = ((TOCItem)(arrNodes[arrNodes.Count-1])); - ParseTree( innerText, p, p.Children, chmFile ); - } - - nIndex = m.Index+m.Length; - } - - if( nIndex == 0) - { - strPostItems = text.Substring(nIndex, text.Length-nIndex); - ParseItems(strPostItems, parent, arrNodes, chmFile); - } - else if( nIndex < text.Length-1) - { - strPostItems = text.Substring(nIndex, text.Length-nIndex); - ParseTree(strPostItems, parent, arrNodes, chmFile); - } - } - - /// - /// Parses tree nodes from the text - /// - /// text containing the items - /// Parent for all read items - /// arraylist where the nodes should be added - /// CHMFile instance - private static void ParseItems( string itemstext, TOCItem parent, ArrayList arrNodes, CHMFile chmFile) - { - int innerTextIdx = ObjectRE.GroupNumberFromName("innerText"); - int innerPTextIdx = ParamRE.GroupNumberFromName("innerText"); - - // get group-name indexes - int nameIndex = AttributesRE.GroupNumberFromName("attributeName"); - int valueIndex = AttributesRE.GroupNumberFromName("attributeValue"); - int tdIndex = AttributesRE.GroupNumberFromName("attributeTD"); - - int nObjStartIndex = 0; - - while( ObjectRE.IsMatch(itemstext, nObjStartIndex) ) - { - Match m = ObjectRE.Match(itemstext, nObjStartIndex); - - string innerText = m.Groups[innerTextIdx].Value; - - TOCItem tocItem = new TOCItem(); - tocItem.TocMode = DataMode.TextBased; - tocItem.AssociatedFile = chmFile; - tocItem.Parent = parent; - - // read parameters - int nParamIndex = 0; - - while( ParamRE.IsMatch(innerText, nParamIndex) ) - { - Match mP = ParamRE.Match(innerText, nParamIndex); - - string innerP = mP.Groups[innerPTextIdx].Value; - - string paramName = ""; - string paramValue = ""; - - int nAttrIdx = 0; - - while( AttributesRE.IsMatch( innerP, nAttrIdx ) ) - { - Match mA = AttributesRE.Match(innerP, nAttrIdx); - - string attributeName = mA.Groups[nameIndex].Value; - string attributeValue = mA.Groups[valueIndex].Value; - string attributeTD = mA.Groups[tdIndex].Value; - - if(attributeTD.Length > 0) - { - // delete the trailing textqualifier - if( attributeValue.Length > 0) - { - int ltqi = attributeValue.LastIndexOf( attributeTD ); - - if(ltqi >= 0) - { - attributeValue = attributeValue.Substring(0,ltqi); - } - } - } - - if( attributeName.ToLower() == "name") - { - paramName = HttpUtility.HtmlDecode(attributeValue); // for unicode encoded values - } - - if( attributeName.ToLower() == "value") - { - paramValue = HttpUtility.HtmlDecode(attributeValue); // for unicode encoded values - // delete trailing / - while((paramValue.Length>0)&&(paramValue[paramValue.Length-1] == '/')) - paramValue = paramValue.Substring(0,paramValue.Length-1); - - } - - nAttrIdx = mA.Index+mA.Length; - } - - tocItem.Params[paramName] = paramValue; - switch(paramName.ToLower()) - { - case "name": - { - tocItem.Name = paramValue; - };break; - case "local": - { - tocItem.Local = paramValue.Replace("../", "").Replace("./", ""); - };break; - case "imagenumber": - { - tocItem.ImageIndex = Int32.Parse(paramValue); - tocItem.ImageIndex-=1; - - int nFolderAdd = 0; - - if((chmFile != null) && (chmFile.ImageTypeFolder)) - { - // get the value which should be added, to display folders instead of books - if(HtmlHelpSystem.UseHH2TreePics) - nFolderAdd = 8; - else - nFolderAdd = 4; - } - - if(tocItem.ImageIndex%2 != 0) - { - if(tocItem.ImageIndex==1) - tocItem.ImageIndex=0; - } - if(HtmlHelpSystem.UseHH2TreePics) - if( tocItem.ImageIndex == 0) - tocItem.ImageIndex = TOCItem.STD_FOLDER_HH2+nFolderAdd; - };break; - case "merge": // this item contains topics or a full TOC from a merged CHM - { - tocItem.MergeLink = paramValue; - - // "register" this item as merge-link - if(_mergeItems==null) - _mergeItems=new ArrayList(); - - _mergeItems.Add(tocItem); - - };break; - case "type": // information type assignment for item - { - tocItem.InfoTypeStrings.Add( paramValue ); - };break; - } - - nParamIndex = mP.Index+mP.Length; - } - - tocItem.ChmFile = chmFile.ChmFilePath; - - if(tocItem.MergeLink.Length > 0) - { - if(_lastTopicItem != null) - { - tocItem.Parent = _lastTopicItem; - _lastTopicItem.Children.Add(tocItem); - } - else - arrNodes.Add( tocItem ); - } - else - { - _lastTopicItem = tocItem; - arrNodes.Add( tocItem ); - } - - nObjStartIndex = m.Index+m.Length; - } - } - - /// - /// Parses the very first <OBJECT> tag in the sitemap file and extracts - /// information types and categories. - /// - /// text of the object tag - /// CHMFile instance - private static void ParseGlobalSettings(string sText, CHMFile chmFile) - { - int innerPTextIdx = ParamRE.GroupNumberFromName("innerText"); - - // get group-name indexes - int nameIndex = AttributesRE.GroupNumberFromName("attributeName"); - int valueIndex = AttributesRE.GroupNumberFromName("attributeValue"); - int tdIndex = AttributesRE.GroupNumberFromName("attributeTD"); - - // read parameters - int nParamIndex = 0; - - // 0... unknown - // 1... inclusinve info type name - // 2... exclusive info type name - // 3... hidden info type name - // 4... category name - // 5... incl infotype name for category - // 6... excl infotype name for category - // 7... hidden infotype name for category - int prevItem = 0; - - string sName = ""; - string sDescription = ""; - string curCategory = ""; - - while( ParamRE.IsMatch(sText, nParamIndex) ) - { - Match mP = ParamRE.Match(sText, nParamIndex); - - string innerP = mP.Groups[innerPTextIdx].Value; - - string paramName = ""; - string paramValue = ""; - - int nAttrIdx = 0; - - while( AttributesRE.IsMatch( innerP, nAttrIdx ) ) - { - Match mA = AttributesRE.Match(innerP, nAttrIdx); - - string attributeName = mA.Groups[nameIndex].Value; - string attributeValue = mA.Groups[valueIndex].Value; - string attributeTD = mA.Groups[tdIndex].Value; - - if(attributeTD.Length > 0) - { - // delete the trailing textqualifier - if( attributeValue.Length > 0) - { - int ltqi = attributeValue.LastIndexOf( attributeTD ); - - if(ltqi >= 0) - { - attributeValue = attributeValue.Substring(0,ltqi); - } - } - } - - if( attributeName.ToLower() == "name") - { - paramName = HttpUtility.HtmlDecode(attributeValue); // for unicode encoded values - } - - if( attributeName.ToLower() == "value") - { - paramValue = HttpUtility.HtmlDecode(attributeValue); // for unicode encoded values - // delete trailing / - while((paramValue.Length>0)&&(paramValue[paramValue.Length-1] == '/')) - paramValue = paramValue.Substring(0,paramValue.Length-1); - - } - - nAttrIdx = mA.Index+mA.Length; - } - - switch(paramName.ToLower()) - { - case "savetype": // inclusive information type name - { - prevItem = 1; - sName = paramValue; - };break; - case "savetypedesc": // description of information type - { - InformationTypeMode mode = InformationTypeMode.Inclusive; - sDescription = paramValue; - - if( prevItem == 1) - mode = InformationTypeMode.Inclusive; - if( prevItem == 2) - mode = InformationTypeMode.Exclusive; - if( prevItem == 3) - mode = InformationTypeMode.Hidden; - - if( chmFile.GetInformationType( sName ) == null) - { - // check if the HtmlHelpSystem already holds such an information type - if( chmFile.SystemInstance.GetInformationType( sName ) == null) - { - // info type not found yet - - InformationType newType = new InformationType(sName, sDescription, mode); - chmFile.InformationTypes.Add(newType); - } - else - { - InformationType sysType = chmFile.SystemInstance.GetInformationType( sName ); - chmFile.InformationTypes.Add( sysType ); - } - } - - prevItem = 0; - };break; - case "saveexclusive": // exclusive information type name - { - prevItem = 2; - sName = paramValue; - };break; - case "savehidden": // hidden information type name - { - prevItem = 3; - sName = paramValue; - };break; - case "category": // category name - { - prevItem = 4; - sName = paramValue; - curCategory = sName; - };break; - case "categorydesc": // category description - { - sDescription = paramValue; - - if( chmFile.GetCategory( sName ) == null) - { - // check if the HtmlHelpSystem already holds such a category - if( chmFile.SystemInstance.GetCategory( sName ) == null) - { - // add category - Category newCat = new Category(sName, sDescription); - chmFile.Categories.Add(newCat); - } - else - { - Category sysCat = chmFile.SystemInstance.GetCategory( sName ); - chmFile.Categories.Add( sysCat ); - } - } - - prevItem = 0; - };break; - case "type": // inclusive information type which is member of the previously read category - { - prevItem = 5; - sName = paramValue; - };break; - case "typedesc": // description of type for category - { - sDescription = paramValue; - Category cat = chmFile.GetCategory( curCategory ); - - if( cat != null) - { - // category found - InformationType infoType = chmFile.GetInformationType( sName ); - - if( infoType != null) - { - if( !cat.ContainsInformationType(infoType)) - { - infoType.SetCategoryFlag(true); - cat.AddInformationType(infoType); - } - } - } - - prevItem = 0; - };break; - case "typeexclusive": // exclusive information type which is member of the previously read category - { - prevItem = 6; - sName = paramValue; - };break; - case "typehidden": // hidden information type which is member of the previously read category - { - prevItem = 7; - sName = paramValue; - };break; - default: - { - prevItem = 0; - sName = ""; - sDescription = ""; - };break; - } - - nParamIndex = mP.Index+mP.Length; - } - } - } -} diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/HHCParser2.cs b/irc/TechBot/CHMLibrary/CHMDecoding/HHCParser2.cs deleted file mode 100644 index bdb988a8665..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/HHCParser2.cs +++ /dev/null @@ -1,220 +0,0 @@ -using System; -using System.Collections; -using System.Text; -using System.Text.RegularExpressions; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// The class HHCParser implements a parser for HHC contents files. - /// - // internal sealed class HHCParser : IHHCParser - public class HHCParser2 - { - static private string m_text1=""; - static private string m_text2=""; - static private int m_CurrentPos=0; - - /// - /// Parses a HHC file and returns an ArrayList with the table of contents (TOC) tree - /// - /// string content of the hhc file - /// CHMFile instance - /// Returns an ArrayList with the table of contents (TOC) tree - public static ArrayList ParseHHC(string hhcFile, CHMFile chmFile) - { - DateTime StartTime=DateTime.Now; - - ArrayList tocList = new ArrayList(); - - m_text2=hhcFile; - m_text1=hhcFile.ToLower(); - - int idx=m_text1.IndexOf("
        "); - if (idx==-1) - return null; - m_CurrentPos=idx+4; - - ParamRE = new Regex(RE_ParamBoundaries, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); - AttributesRE = new Regex(RE_QuoteAttributes, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); - - ParseTree(tocList,chmFile); - - DateTime EndTime=DateTime.Now; - TimeSpan Diff=EndTime-StartTime; - string x=Diff.ToString(); - - return tocList; - } - - /// - /// Recursively parses a sitemap tree - /// - /// content text - /// arraylist which receives the extracted nodes - /// CHMFile instance - static private void ParseTree( ArrayList arrNodes, CHMFile chmFile ) - { - bool bProcessing=true; - do - { - bProcessing=false; - - // Indent - int idxa=m_text1.IndexOf("
          ",m_CurrentPos); - int idxb=m_text1.IndexOf("
        • ",m_CurrentPos); - int idxc=m_text1.IndexOf("
        ",m_CurrentPos); - - if ((idxa-1)) - { - bProcessing=true; - m_CurrentPos=idxa+4; - if (arrNodes.Count<1) - { - ParseTree(arrNodes,chmFile); - } - else - { - ParseTree(((TOCItem)(arrNodes[arrNodes.Count-1])).Children,chmFile); - } - continue; - } - - // new item - if ((idxb-1)) - { - - bProcessing=true; - m_CurrentPos=idxb+4; - - int idx2=m_text1.IndexOf("",idx2+7); - if (idx3!=-1) - { - string text=m_text2.Substring(idx2,idx3-idx2); - - m_CurrentPos=idx3+9; - - // Parse items in text. - TOCItem tocItem=ParseItems(text, chmFile); - if (tocItem!=null) - { - arrNodes.Add(tocItem); - } - } - } - } - - // Undent - if ((idxc-1)) - { - m_CurrentPos=idxc+5; - bProcessing=true; - return; - } - } - while (bProcessing); - } - - - private static string RE_ParamBoundaries = @"\.*?)\>"; - private const string RE_QuoteAttributes = @"( |\t)*(?[\-a-zA-Z0-9]*)( |\t)*=( |\t)*(?[\""\'])?(?.*?(?(attributeTD)\k|([\s>]|.$)))"; - private static Regex ParamRE; - private static Regex AttributesRE; - - /// - /// Parses tree nodes from the text - /// - /// text containing the items - /// arraylist where the nodes should be added - /// CHMFile instance - private static TOCItem ParseItems( string itemstext, CHMFile chmFile) - { - int innerPTextIdx = ParamRE.GroupNumberFromName("innerText"); - - // get group-name indexes - int nameIndex = AttributesRE.GroupNumberFromName("attributeName"); - int valueIndex = AttributesRE.GroupNumberFromName("attributeValue"); - int tdIndex = AttributesRE.GroupNumberFromName("attributeTD"); - - TOCItem tocItem = new TOCItem(); - - // read parameters - int nParamIndex = 0; - - while( ParamRE.IsMatch(itemstext, nParamIndex) ) - { - Match mP = ParamRE.Match(itemstext, nParamIndex); - - string innerP = mP.Groups[innerPTextIdx].Value; - - string paramName = ""; - string paramValue = ""; - - int nAttrIdx = 0; - - while( AttributesRE.IsMatch( innerP, nAttrIdx ) ) - { - Match mA = AttributesRE.Match(innerP, nAttrIdx); - - string attributeName = mA.Groups[nameIndex].Value; - string attributeValue = mA.Groups[valueIndex].Value; - string attributeTD = mA.Groups[tdIndex].Value; - - if(attributeTD.Length > 0) - { - // delete the trailing textqualifier - if( attributeValue.Length > 0) - { - int ltqi = attributeValue.LastIndexOf( attributeTD ); - - if(ltqi >= 0) - { - attributeValue = attributeValue.Substring(0,ltqi); - } - } - } - - if( attributeName.ToLower() == "name") - { - paramName = attributeValue; - } - - if( attributeName.ToLower() == "value") - { - paramValue = attributeValue; - } - - nAttrIdx = mA.Index+mA.Length; - } - - tocItem.Params[paramName] = paramValue; - switch(paramName.ToLower()) - { - case "name": - { - tocItem.Name = paramValue; - };break; - case "local": - { - tocItem.Local = paramValue; - };break; - case "imagenumber": - { - tocItem.ImageIndex = Int32.Parse(paramValue); - - if( tocItem.ImageIndex == 2) - tocItem.ImageIndex = TOCItem.STD_FOLDER_HH1; - };break; - } - - nParamIndex = mP.Index+mP.Length; - } - - tocItem.ChmFile = chmFile.ChmFilePath; - return tocItem; - } - } -} diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/HHKParser.cs b/irc/TechBot/CHMLibrary/CHMDecoding/HHKParser.cs deleted file mode 100644 index 63f1c136799..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/HHKParser.cs +++ /dev/null @@ -1,550 +0,0 @@ -using System; -using System.IO; -using System.Collections; -using System.Text; -using System.Text.RegularExpressions; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// The class HHKParser implements a parser for HHK contents files. - /// - internal sealed class HHKParser - { - /// - /// regular expressions for replacing the sitemap boundary tags - /// - private static string RE_ULOpening = @"\"; // will be replaced by a '(' for nested parsing - private static string RE_ULClosing = @"\"; // will be replaced by a ')' for nested parsing - - /// - /// Matching ul-tags - /// - private static string RE_ULBoundaries = @"\(?.*)\"; - /// - /// Matching the nested tree structure. - /// - private static string RE_NestedBoundaries = @"\( (?> [^()]+ | \( (?) | \) (?<-DEPTH>) )* (?(DEPTH)(?!)) \)"; - /// - /// Matching object-tags - /// - private static string RE_ObjectBoundaries = @"\.*?)\"; - /// - /// Matching param tags - /// - private static string RE_ParamBoundaries = @"\.*?)\>"; - /// - /// Extracting tag attributes - /// - private const string RE_QuoteAttributes = @"( |\t)*(?[\-a-zA-Z0-9]*)( |\t)*=( |\t)*(?[\""\'])?(?.*?(?(attributeTD)\k|([\s>]|.$)))"; - - /// - /// private regular expressionobjects - /// - private static Regex ulRE; - private static Regex NestedRE; - private static Regex ObjectRE; - private static Regex ParamRE; - private static Regex AttributesRE; - - /// - /// Parses a HHK file and returns an ArrayList with the index tree - /// - /// string content of the hhk file - /// CHMFile instance - /// Returns an ArrayList with the index tree - public static ArrayList ParseHHK(string hhkFile, CHMFile chmFile) - { - ArrayList indexList = new ArrayList(); - - ulRE = new Regex(RE_ULBoundaries, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); - NestedRE = new Regex(RE_NestedBoundaries, RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); - ObjectRE = new Regex(RE_ObjectBoundaries, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); - ParamRE = new Regex(RE_ParamBoundaries, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); - AttributesRE = new Regex(RE_QuoteAttributes, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.Singleline); - - int innerTextIdx = ulRE.GroupNumberFromName("innerText"); - - if( ulRE.IsMatch(hhkFile, 0) ) - { - Match m = ulRE.Match(hhkFile, 0); - - if( ObjectRE.IsMatch(hhkFile, 0) ) // first object block contains information types and categories - { - Match mO = ObjectRE.Match(hhkFile, 0); - int iOTxt = ObjectRE.GroupNumberFromName("innerText"); - - string globalText = mO.Groups[iOTxt].Value; - - ParseGlobalSettings( globalText, chmFile ); - } - - string innerText = m.Groups["innerText"].Value; - - innerText = innerText.Replace("(", "("); - innerText = innerText.Replace(")", ")"); - innerText = Regex.Replace(innerText, RE_ULOpening, "(", RegexOptions.IgnoreCase); - innerText = Regex.Replace(innerText, RE_ULClosing, ")", RegexOptions.IgnoreCase); - - ParseTree( innerText, null, indexList, chmFile ); - } - - return indexList; - } - - /// - /// Recursively parses a sitemap tree - /// - /// content text - /// Parent for all read items - /// arraylist which receives the extracted nodes - /// CHMFile instance - private static void ParseTree( string text, IndexItem parent, ArrayList arrNodes, CHMFile chmFile ) - { - string strPreItems="", strPostItems=""; - string innerText = ""; - - int nIndex = 0; - - while( NestedRE.IsMatch(text, nIndex) ) - { - Match m = NestedRE.Match(text, nIndex); - - innerText = m.Value.Substring( 1, m.Length-2); - - strPreItems = text.Substring(nIndex,m.Index-nIndex); - - ParseItems(strPreItems, parent, arrNodes, chmFile); - - if((arrNodes.Count>0) && (innerText.Length > 0) ) - { - IndexItem p = ((IndexItem)(arrNodes[arrNodes.Count-1])); - ParseTree( innerText, p, arrNodes, chmFile ); - } - - nIndex = m.Index+m.Length; - } - - if( nIndex == 0) - { - strPostItems = text.Substring(nIndex, text.Length-nIndex); - ParseItems(strPostItems, parent, arrNodes, chmFile); - } - else if( nIndex < text.Length-1) - { - strPostItems = text.Substring(nIndex, text.Length-nIndex); - ParseTree(strPostItems, parent, arrNodes, chmFile); - } - } - - - /// - /// Parses nodes from the text - /// - /// text containing the items - /// parent index item - /// arraylist where the nodes should be added - /// CHMFile instance - private static void ParseItems( string itemstext, IndexItem parentItem, ArrayList arrNodes, CHMFile chmFile) - { - int innerTextIdx = ObjectRE.GroupNumberFromName("innerText"); - int innerPTextIdx = ParamRE.GroupNumberFromName("innerText"); - - // get group-name indexes - int nameIndex = AttributesRE.GroupNumberFromName("attributeName"); - int valueIndex = AttributesRE.GroupNumberFromName("attributeValue"); - int tdIndex = AttributesRE.GroupNumberFromName("attributeTD"); - - int nObjStartIndex = 0; - int nLastObjStartIndex = 0; - string sKeyword = ""; - - while( ObjectRE.IsMatch(itemstext, nObjStartIndex) ) - { - Match m = ObjectRE.Match(itemstext, nObjStartIndex); - - string innerText = m.Groups[innerTextIdx].Value; - - IndexItem idxItem = new IndexItem(); - - // read parameters - int nParamIndex = 0; - int nNameCnt = 0; - - string paramTitle = ""; - string paramLocal = ""; - bool bAdded = false; - - while( ParamRE.IsMatch(innerText, nParamIndex) ) - { - Match mP = ParamRE.Match(innerText, nParamIndex); - - string innerP = mP.Groups[innerPTextIdx].Value; - - string paramName = ""; - string paramValue = ""; - - int nAttrIdx = 0; - //sKeyword = ""; - - while( AttributesRE.IsMatch( innerP, nAttrIdx ) ) - { - Match mA = AttributesRE.Match(innerP, nAttrIdx); - - string attributeName = mA.Groups[nameIndex].Value; - string attributeValue = mA.Groups[valueIndex].Value; - string attributeTD = mA.Groups[tdIndex].Value; - - if(attributeTD.Length > 0) - { - // delete the trailing textqualifier - if( attributeValue.Length > 0) - { - int ltqi = attributeValue.LastIndexOf( attributeTD ); - - if(ltqi >= 0) - { - attributeValue = attributeValue.Substring(0,ltqi); - } - } - } - - if( attributeName.ToLower() == "name") - { - paramName = HttpUtility.HtmlDecode(attributeValue); // for unicode encoded values - nNameCnt++; - } - - if( attributeName.ToLower() == "value") - { - paramValue = HttpUtility.HtmlDecode(attributeValue); // for unicode encoded values - // delete trailing / - while((paramValue.Length>0)&&(paramValue[paramValue.Length-1] == '/')) - paramValue = paramValue.Substring(0,paramValue.Length-1); - } - - nAttrIdx = mA.Index+mA.Length; - } - - if( nNameCnt == 1) // first "Name" param = keyword - { - sKeyword = ""; - - if(parentItem != null) - sKeyword = parentItem.KeyWordPath + ","; - - string sOldKW = sKeyword; - - sKeyword += paramValue; - - IndexItem idxFind = FindByKeyword(arrNodes, sKeyword); - - if(idxFind != null) - { - idxItem = idxFind; - } - else - { - if( sKeyword.Split(new char[] {','}).Length > 1 ) - { - idxItem.CharIndex = sKeyword.Length - paramValue.Length; - } - else - { - sKeyword = paramValue; - sOldKW = sKeyword; - idxItem.CharIndex = 0; - } - - idxItem.KeyWordPath = sKeyword; - idxItem.Indent = sKeyword.Split(new char[] {','}).Length - 1; - idxItem.IsSeeAlso = false; - - sKeyword = sOldKW; - } - } - else - { - - if( (nNameCnt > 2) && (paramName.ToLower()=="name") ) - { - bAdded = true; - IndexTopic idxTopic = new IndexTopic(paramTitle, paramLocal, chmFile.CompileFile, chmFile.ChmFilePath); - - idxItem.Topics.Add( idxTopic ); - - paramTitle = ""; - paramLocal = ""; - } - - switch(paramName.ToLower()) - { - case "name": - //case "keyword": - { - paramTitle = paramValue; - };break; - case "local": - { - paramLocal = paramValue.Replace("../", "").Replace("./", ""); - };break; - case "type": // information type assignment for item - { - idxItem.InfoTypeStrings.Add( paramValue ); - };break; - case "see also": - { - idxItem.AddSeeAlso(paramValue); - idxItem.IsSeeAlso = true; - bAdded = true; - };break; - } - } - - nParamIndex = mP.Index+mP.Length; - } - - if(!bAdded) - { - bAdded=false; - IndexTopic idxTopic = new IndexTopic(paramTitle, paramLocal, chmFile.CompileFile, chmFile.ChmFilePath); - - idxItem.Topics.Add( idxTopic ); - - paramTitle = ""; - paramLocal = ""; - } - - idxItem.ChmFile = chmFile; - arrNodes.Add( idxItem ); - - nLastObjStartIndex = nObjStartIndex; - nObjStartIndex = m.Index+m.Length; - } - } - - /// - /// Searches an index-keyword in the index list - /// - /// index list to search - /// keyword to find - /// Returns an IndexItem instance if found, otherwise null. - private static IndexItem FindByKeyword(ArrayList indexList, string Keyword) - { - foreach(IndexItem curItem in indexList) - { - if( curItem.KeyWordPath == Keyword) - return curItem; - } - - return null; - } - - /// - /// Parses the very first <OBJECT> tag in the sitemap file and extracts - /// information types and categories. - /// - /// text of the object tag - /// CHMFile instance - private static void ParseGlobalSettings(string sText, CHMFile chmFile) - { - int innerPTextIdx = ParamRE.GroupNumberFromName("innerText"); - - // get group-name indexes - int nameIndex = AttributesRE.GroupNumberFromName("attributeName"); - int valueIndex = AttributesRE.GroupNumberFromName("attributeValue"); - int tdIndex = AttributesRE.GroupNumberFromName("attributeTD"); - - // read parameters - int nParamIndex = 0; - - // 0... unknown - // 1... inclusinve info type name - // 2... exclusive info type name - // 3... hidden info type name - // 4... category name - // 5... incl infotype name for category - // 6... excl infotype name for category - // 7... hidden infotype name for category - int prevItem = 0; - - string sName = ""; - string sDescription = ""; - string curCategory = ""; - - while( ParamRE.IsMatch(sText, nParamIndex) ) - { - Match mP = ParamRE.Match(sText, nParamIndex); - - string innerP = mP.Groups[innerPTextIdx].Value; - - string paramName = ""; - string paramValue = ""; - - int nAttrIdx = 0; - - while( AttributesRE.IsMatch( innerP, nAttrIdx ) ) - { - Match mA = AttributesRE.Match(innerP, nAttrIdx); - - string attributeName = mA.Groups[nameIndex].Value; - string attributeValue = mA.Groups[valueIndex].Value; - string attributeTD = mA.Groups[tdIndex].Value; - - if(attributeTD.Length > 0) - { - // delete the trailing textqualifier - if( attributeValue.Length > 0) - { - int ltqi = attributeValue.LastIndexOf( attributeTD ); - - if(ltqi >= 0) - { - attributeValue = attributeValue.Substring(0,ltqi); - } - } - } - - if( attributeName.ToLower() == "name") - { - paramName = HttpUtility.HtmlDecode(attributeValue); // for unicode encoded values - } - - if( attributeName.ToLower() == "value") - { - paramValue = HttpUtility.HtmlDecode(attributeValue); // for unicode encoded values - // delete trailing / - while((paramValue.Length>0)&&(paramValue[paramValue.Length-1] == '/')) - paramValue = paramValue.Substring(0,paramValue.Length-1); - - } - - nAttrIdx = mA.Index+mA.Length; - } - - switch(paramName.ToLower()) - { - case "savetype": // inclusive information type name - { - prevItem = 1; - sName = paramValue; - };break; - case "savetypedesc": // description of information type - { - InformationTypeMode mode = InformationTypeMode.Inclusive; - sDescription = paramValue; - - if( prevItem == 1) - mode = InformationTypeMode.Inclusive; - if( prevItem == 2) - mode = InformationTypeMode.Exclusive; - if( prevItem == 3) - mode = InformationTypeMode.Hidden; - - if( chmFile.GetInformationType( sName ) == null) - { - // check if the HtmlHelpSystem already holds such an information type - if( chmFile.SystemInstance.GetInformationType( sName ) == null) - { - // info type not found yet - - InformationType newType = new InformationType(sName, sDescription, mode); - chmFile.InformationTypes.Add(newType); - } - else - { - InformationType sysType = chmFile.SystemInstance.GetInformationType( sName ); - chmFile.InformationTypes.Add( sysType ); - } - } - - prevItem = 0; - };break; - case "saveexclusive": // exclusive information type name - { - prevItem = 2; - sName = paramValue; - };break; - case "savehidden": // hidden information type name - { - prevItem = 3; - sName = paramValue; - };break; - case "category": // category name - { - prevItem = 4; - sName = paramValue; - curCategory = sName; - };break; - case "categorydesc": // category description - { - sDescription = paramValue; - - if( chmFile.GetCategory( sName ) == null) - { - // check if the HtmlHelpSystem already holds such a category - if( chmFile.SystemInstance.GetCategory( sName ) == null) - { - // add category - Category newCat = new Category(sName, sDescription); - chmFile.Categories.Add(newCat); - } - else - { - Category sysCat = chmFile.SystemInstance.GetCategory( sName ); - chmFile.Categories.Add( sysCat ); - } - } - - prevItem = 0; - };break; - case "type": // inclusive information type which is member of the previously read category - { - prevItem = 5; - sName = paramValue; - };break; - case "typedesc": // description of type for category - { - sDescription = paramValue; - Category cat = chmFile.GetCategory( curCategory ); - - if( cat != null) - { - // category found - InformationType infoType = chmFile.GetInformationType( sName ); - - if( infoType != null) - { - if( !cat.ContainsInformationType(infoType)) - { - infoType.SetCategoryFlag(true); - cat.AddInformationType(infoType); - } - } - } - - prevItem = 0; - };break; - case "typeexclusive": // exclusive information type which is member of the previously read category - { - prevItem = 6; - sName = paramValue; - };break; - case "typehidden": // hidden information type which is member of the previously read category - { - prevItem = 7; - sName = paramValue; - };break; - default: - { - prevItem = 0; - sName = ""; - sDescription = ""; - };break; - } - - nParamIndex = mP.Index+mP.Length; - } - } - } -} diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/TopicEntry.cs b/irc/TechBot/CHMLibrary/CHMDecoding/TopicEntry.cs deleted file mode 100644 index 16bde7d9d0d..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/TopicEntry.cs +++ /dev/null @@ -1,245 +0,0 @@ -using System; -using System.IO; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// The class TopicEntry stores the data for one topic entry - /// - internal sealed class TopicEntry - { - /// - /// Internal member storing the offset of this topic entry - /// - private int _entryOffset = 0; - /// - /// Internal member storing the index of the binary toc - /// - private int _tocidxOffset = 0; - /// - /// Internal member storing the string offset of the title - /// - private int _titleOffset = 0; - /// - /// Internal member storuing the urltable offset - /// - private int _urltableOffset = 0; - /// - /// Internal member storing the visibility mode - /// - private int _visibilityMode = 0; - /// - /// Internal member storing an unknown mode - /// - private int _unknownMode = 0; - /// - /// Internal member storing the associated chmfile object - /// - private CHMFile _associatedFile = null; - - /// - /// Constructor of the class - /// - /// offset of this entry - /// offset in the binary toc index - /// offset of the title (in the #STRINGS file) - /// offset in the urltable containing the urlstr offset for the url - /// visibility mode 2 indicates not in contents, 6 indicates that it is in the contents, 0/4 something else (unknown) - /// 0, 2, 4, 8, 10, 12, 16, 32 (unknown) - public TopicEntry(int entryOffset, int tocidxOffset, int titleOffset, int urltableOffset, int visibilityMode, int unknownMode) :this(entryOffset, tocidxOffset, titleOffset, urltableOffset, visibilityMode, unknownMode, null) - { - - } - - /// - /// Constructor of the class - /// - /// offset of this entry - /// offset in the binary toc index - /// offset of the title (in the #STRINGS file) - /// offset in the urltable containing the urlstr offset for the url - /// visibility mode 2 indicates not in contents, 6 indicates that it is in the contents, 0/4 something else (unknown) - /// 0, 2, 4, 8, 10, 12, 16, 32 (unknown) - /// associated chmfile object - internal TopicEntry(int entryOffset, int tocidxOffset, int titleOffset, int urltableOffset, int visibilityMode, int unknownMode, CHMFile associatedFile) - { - _entryOffset = entryOffset; - _tocidxOffset = tocidxOffset; - _titleOffset = titleOffset; - _urltableOffset = urltableOffset; - _visibilityMode = visibilityMode; - _unknownMode = unknownMode; - _associatedFile = associatedFile; - } - - /// - /// Standard constructor - /// - internal TopicEntry() - { - } - - #region Data dumping - /// - /// Dump the class data to a binary writer - /// - /// writer to write the data - internal void Dump(ref BinaryWriter writer) - { - writer.Write( _entryOffset ); - writer.Write( _tocidxOffset ); - writer.Write( _titleOffset ); - writer.Write( _urltableOffset ); - writer.Write( _visibilityMode ); - writer.Write( _unknownMode ); - } - - /// - /// Reads the object data from a dump store - /// - /// reader to read the data - internal void ReadDump(ref BinaryReader reader) - { - _entryOffset = reader.ReadInt32(); - _tocidxOffset = reader.ReadInt32(); - _titleOffset = reader.ReadInt32(); - _urltableOffset = reader.ReadInt32(); - _visibilityMode = reader.ReadInt32(); - _unknownMode = reader.ReadInt32(); - } - - /// - /// Sets the associated CHMFile instance - /// - /// instance to set - internal void SetCHMFile(CHMFile associatedFile) - { - _associatedFile = associatedFile; - } - #endregion - - /// - /// Gets the associated chm file - /// - internal CHMFile ChmFile - { - get { return _associatedFile; } - } - - /// - /// Gets the offset of this entry - /// - internal int EntryOffset - { - get { return _entryOffset; } - } - - /// - /// Gets the tocidx offset - /// - internal int TOCIdxOffset - { - get { return _tocidxOffset; } - } - - /// - /// Gets the title offset of the #STRINGS file - /// - internal int TitleOffset - { - get { return _titleOffset; } - } - - /// - /// Gets the urltable offset - /// - internal int UrlTableOffset - { - get { return _urltableOffset; } - } - - /// - /// Gets the title of the topic entry - /// - public string Title - { - get - { - if( _associatedFile == null) - return String.Empty; - - if( _associatedFile.StringsFile == null) - return String.Empty; - - string sTemp = (string)_associatedFile.StringsFile[ _titleOffset ]; - - if(sTemp == null) - return String.Empty; - - return sTemp; - } - } - - /// - /// Gets the url of the topic - /// - public string Locale - { - get - { - if( _associatedFile == null) - return String.Empty; - - if( _associatedFile.UrltblFile == null) - return String.Empty; - - UrlTableEntry utEntry = (UrlTableEntry)_associatedFile.UrltblFile[ _urltableOffset ]; - - if(utEntry == null) - return String.Empty; - - if(utEntry.URL == "") - return String.Empty; - - return utEntry.URL; - } - } - - /// - /// Gets the URL of this topic - /// - public string URL - { - get - { - if(Locale.Length <= 0) - return "about:blank"; - - if( (Locale.ToLower().IndexOf("http://") >= 0) || - (Locale.ToLower().IndexOf("https://") >= 0) || - (Locale.ToLower().IndexOf("mailto:") >= 0) || - (Locale.ToLower().IndexOf("ftp://") >= 0) || - (Locale.ToLower().IndexOf("ms-its:") >= 0)) - return Locale; - - return HtmlHelpSystem.UrlPrefix + _associatedFile.ChmFilePath + "::/" + Locale; - } - } - - /// - /// Gets the visibility mode - /// - public int VisibilityMode - { - get { return _visibilityMode; } - } - - /// - /// Gets the unknown mode - /// - public int UknownMode - { - get { return _unknownMode; } - } - } -} diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/UrlTableEntry.cs b/irc/TechBot/CHMLibrary/CHMDecoding/UrlTableEntry.cs deleted file mode 100644 index 53391ce2f05..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/UrlTableEntry.cs +++ /dev/null @@ -1,175 +0,0 @@ -using System; -using System.IO; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// The class UrlTableEntry stores data for an URL-Table entry - /// - internal sealed class UrlTableEntry - { - /// - /// Internal member storing the offset of this entry - /// - private int _entryOffset = 0; - /// - /// Internal member storing a unique id - /// - private uint _uniqueID = 0; - /// - /// Internal member storing the topics index - /// - private int _topicsIndex = 0; - /// - /// Internal member storing the offset in the urlstr table - /// - private int _urlStrOffset = 0; - /// - /// Internal member storing the associated chmfile object - /// - private CHMFile _associatedFile = null; - - /// - /// Constructor of the class - /// - /// unique id - /// offset of the entry - /// topic index - /// urlstr offset for filename - public UrlTableEntry(uint uniqueID, int entryOffset, int topicIndex, int urlstrOffset) : this(uniqueID, entryOffset, topicIndex, urlstrOffset, null) - { - } - - /// - /// Constructor of the class - /// - /// unique id - /// offset of the entry - /// topic index - /// urlstr offset for filename - /// associated chm file - internal UrlTableEntry(uint uniqueID, int entryOffset, int topicIndex, int urlstrOffset, CHMFile associatedFile) - { - _uniqueID = uniqueID; - _entryOffset = entryOffset; - _topicsIndex = topicIndex; - _urlStrOffset = urlstrOffset; - _associatedFile = associatedFile; - } - - /// - /// Standard constructor - /// - internal UrlTableEntry() - { - } - - #region Data dumping - /// - /// Dump the class data to a binary writer - /// - /// writer to write the data - internal void Dump(ref BinaryWriter writer) - { - writer.Write( _urlStrOffset ); - writer.Write( _entryOffset ); - writer.Write( _topicsIndex ); - writer.Write( _urlStrOffset ); - } - - /// - /// Reads the object data from a dump store - /// - /// reader to read the data - internal void ReadDump(ref BinaryReader reader) - { - _urlStrOffset = reader.ReadInt32(); - _entryOffset = reader.ReadInt32(); - _topicsIndex = reader.ReadInt32(); - _urlStrOffset = reader.ReadInt32(); - } - - /// - /// Sets the associated CHMFile instance - /// - /// instance to set - internal void SetCHMFile(CHMFile associatedFile) - { - _associatedFile = associatedFile; - } - #endregion - - /// - /// Gets the unique id of the entry - /// - internal uint UniqueID - { - get {return _uniqueID; } - } - - /// - /// Gets the offset of the entry - /// - internal int EntryOffset - { - get {return _entryOffset; } - } - - /// - /// Gets the topics index - /// - internal int TopicIndex - { - get {return _topicsIndex; } - } - - /// - /// Gets the urlstr offset - /// - internal int UrlstrOffset - { - get { return _urlStrOffset; } - } - - /// - /// Gets the url of the entry - /// - public string URL - { - get - { - if(_associatedFile == null) - return String.Empty; - - if(_associatedFile.UrlstrFile == null) - return String.Empty; - - string sTemp = (string)_associatedFile.UrlstrFile.GetURLatOffset( _urlStrOffset ); - - if( sTemp == null) - return String.Empty; - - return sTemp; - } - } - - /// - /// Gets the associated topic for this url entry - /// - internal TopicEntry Topic - { - get - { - if(_associatedFile == null) - return null; - - if(_associatedFile.TopicsFile == null) - return null; - - TopicEntry tentry = _associatedFile.TopicsFile[ _topicsIndex*16 ]; - - return tentry; - } - } - } -} diff --git a/irc/TechBot/CHMLibrary/CHMDecoding/enumerations.cs b/irc/TechBot/CHMLibrary/CHMDecoding/enumerations.cs deleted file mode 100644 index 0e2d314ecd6..00000000000 --- a/irc/TechBot/CHMLibrary/CHMDecoding/enumerations.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; - -namespace HtmlHelp.ChmDecoding -{ - /// - /// Enumeration for specifying the extraction mode of an toc or index item. - /// - public enum DataMode - { - /// - /// TextBased - this item comes from a text-based sitemap file - /// - TextBased = 0, - /// - /// Binary - this item was extracted out of a binary stream - /// - Binary = 1 - } -} diff --git a/irc/TechBot/CHMLibrary/CHMLibrary.cmbx b/irc/TechBot/CHMLibrary/CHMLibrary.cmbx deleted file mode 100644 index 7209cbb462c..00000000000 --- a/irc/TechBot/CHMLibrary/CHMLibrary.cmbx +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/irc/TechBot/CHMLibrary/CHMLibrary.csproj b/irc/TechBot/CHMLibrary/CHMLibrary.csproj deleted file mode 100644 index 3ab019a4eca..00000000000 --- a/irc/TechBot/CHMLibrary/CHMLibrary.csproj +++ /dev/null @@ -1,85 +0,0 @@ - - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {72E5CCA1-6318-4D62-964D-CB23A5C743B5} - Library - Properties - CHMLibrary - CHMLibrary - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {E32307F1-623A-4E62-826F-56CDD4B23A54} - Compression - - - \ No newline at end of file diff --git a/irc/TechBot/CHMLibrary/CHMLibrary.prjx b/irc/TechBot/CHMLibrary/CHMLibrary.prjx deleted file mode 100644 index 3a888b43106..00000000000 --- a/irc/TechBot/CHMLibrary/CHMLibrary.prjx +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/irc/TechBot/CHMLibrary/Category.cs b/irc/TechBot/CHMLibrary/Category.cs deleted file mode 100644 index d1ae4e74d44..00000000000 --- a/irc/TechBot/CHMLibrary/Category.cs +++ /dev/null @@ -1,201 +0,0 @@ -using System; -using System.Collections; -using System.IO; - -using HtmlHelp.ChmDecoding; - -namespace HtmlHelp -{ - /// - /// The class Category implements methods/properties for handling an information category - /// - /// Note: Information types and categories allow users to filter help contents. - /// They are only supported if using sitemap TOC and/or sitemap Index. - public class Category - { - private string _name = ""; - private string _description = ""; - private ArrayList _infoTypes = null; - private int _referenceCount = 1; - - /// - /// Standard constructor - /// - public Category() : this("","") - { - } - - /// - /// Standard constructor - /// - /// name of the category - /// description - public Category(string name, string description) : this(name, description, new ArrayList()) - { - } - /// - /// Standard constructor - /// - /// name of the category - /// description - /// Arraylist of InformationType instances which applies to this category - public Category(string name, string description, ArrayList linkedInformationTypes) - { - _name = name; - _description = description; - _infoTypes = linkedInformationTypes; - } - - #region Data dumping - /// - /// Dump the class data to a binary writer - /// - /// writer to write the data - internal void Dump(ref BinaryWriter writer) - { - writer.Write( _name ); - writer.Write( _description ); - - writer.Write( _infoTypes.Count ); - - for(int i=0; i<_infoTypes.Count;i++) - { - InformationType curType = _infoTypes[i] as InformationType; - writer.Write( curType.Name ); - } - - } - - /// - /// Reads the object data from a dump store - /// - /// reader to read the data - /// current CHMFile instance which reads from dump - internal void ReadDump(ref BinaryReader reader, CHMFile chmFile) - { - _name = reader.ReadString(); - _description = reader.ReadString(); - - int nCnt = reader.ReadInt32(); - - for(int i=0; i - /// Merges the lineked information types from cat into this instance - /// - /// category instance - internal void MergeInfoTypes(Category cat) - { - if(cat!=null) - { - if(cat.InformationTypes.Count > 0) - { - for(int i=0;i - /// Gets/Sets the reference count of this information type instance - /// - internal int ReferenceCount - { - get { return _referenceCount; } - set { _referenceCount = value; } - } - - /// - /// Gets/Sets the name of the information type - /// - public string Name - { - get { return _name; } - set { _name = value; } - } - - /// - /// Gets/Sets the description of the information type - /// - public string Description - { - get { return _description; } - set { _name = value; } - } - - /// - /// Gets an ArrayList with the linked Information types - /// - public ArrayList InformationTypes - { - get { return _infoTypes; } - } - - /// - /// Adds a new information type to the category - /// - /// - public void AddInformationType(InformationType type) - { - _infoTypes.Add(type); - } - - /// - /// Removes an information type from the category - /// - /// - public void RemoveInformationType(InformationType type) - { - _infoTypes.Remove(type); - } - - /// - /// Checks if the category contains an information type - /// - /// information type instance to check - /// Return true if the information type is part of this category - public bool ContainsInformationType(InformationType type) - { - return _infoTypes.Contains(type); - } - - /// - /// Checks if the category contains an information type - /// - /// name of the information type - /// Return true if the information type is part of this category - public bool ContainsInformationType(string name) - { - for(int i=0;i<_infoTypes.Count;i++) - { - InformationType curType = _infoTypes[i] as InformationType; - - if(curType.Name == name) - return true; - } - - return false; - } - } -} diff --git a/irc/TechBot/CHMLibrary/ChmFileInfo.cs b/irc/TechBot/CHMLibrary/ChmFileInfo.cs deleted file mode 100644 index 15f6a1e266f..00000000000 --- a/irc/TechBot/CHMLibrary/ChmFileInfo.cs +++ /dev/null @@ -1,478 +0,0 @@ -using System; -using System.Collections; -using System.Text; -using System.IO; -using System.Globalization; -using System.Diagnostics; -using System.ComponentModel; - -using HtmlHelp.ChmDecoding; -// using HtmlHelp.Storage; - -namespace HtmlHelp -{ - /// - /// The class ChmFileInfo only extracts system information from a CHM file. - /// It doesn't build the index and table of contents. - /// - public class ChmFileInfo - { - /// - /// Internal member storing the full filename - /// - private string _chmFileName = ""; - /// - /// Internal member storing the associated chmfile object - /// - private CHMFile _associatedFile = null; - - /// - /// Constructor for extrating the file information of the provided file. - /// The constructor opens the chm-file and reads its system data. - /// - /// full file name which information should be extracted - public ChmFileInfo(string chmFile) - { - if(!File.Exists(chmFile)) - throw new ArgumentException("Chm file must exist on disk !", "chmFileName"); - - if( ! chmFile.ToLower().EndsWith(".chm") ) - throw new ArgumentException("HtmlHelp file must have the extension .chm !", "chmFile"); - - _chmFileName = chmFile; - _associatedFile = new CHMFile(null, chmFile, true); // only load system data of chm - } - - /// - /// Internal constructor used in the class CHMFile. - /// - /// associated chm file - internal ChmFileInfo(CHMFile associatedFile) - { - _associatedFile = associatedFile; - - if( _associatedFile == null) - throw new ArgumentException("Associated CHMFile instance must not be null !", "associatedFile"); - } - - #region default info properties - /// - /// Gets the full filename of the chm file - /// - public string ChmFileName - { - get - { - return _associatedFile.ChmFilePath; - } - } - - /// - /// Gets a FileInfo instance for the chm file. - /// - public FileInfo FileInfo - { - get { return new FileInfo(_associatedFile.ChmFilePath); } - } - #endregion - - #region #SYSTEM properties - /// - /// Gets the file version of the chm file. - /// 2 for Compatibility=1.0, 3 for Compatibility=1.1 - /// - public int FileVersion - { - get - { - if(_associatedFile != null) - return _associatedFile.FileVersion; - - return 0; - } - } - - /// - /// Gets the contents file name - /// - - public string ContentsFile - { - get - { - if(_associatedFile != null) - return _associatedFile.ContentsFile; - - return ""; - } - } - - /// - /// Gets the index file name - /// - - public string IndexFile - { - get - { - if(_associatedFile != null) - return _associatedFile.IndexFile; - - return ""; - } - } - - /// - /// Gets the default help topic - /// - - public string DefaultTopic - { - get - { - if(_associatedFile != null) - return _associatedFile.DefaultTopic; - - return ""; - } - } - - /// - /// Gets the title of the help window - /// - - public string HelpWindowTitle - { - get - { - if(_associatedFile != null) - return _associatedFile.HelpWindowTitle; - - return ""; - } - } - - /// - /// Gets the flag if DBCS is in use - /// - - public bool DBCS - { - get - { - if(_associatedFile != null) - return _associatedFile.DBCS; - - return false; - } - } - - /// - /// Gets the flag if full-text-search is available - /// - - public bool FullTextSearch - { - get - { - if(_associatedFile != null) - return _associatedFile.FullTextSearch; - - return false; - } - } - - /// - /// Gets the flag if the file has ALinks - /// - - public bool HasALinks - { - get - { - if(_associatedFile != null) - return _associatedFile.HasALinks; - - return false; - } - } - - /// - /// Gets the flag if the file has KLinks - /// - - public bool HasKLinks - { - get - { - if(_associatedFile != null) - return _associatedFile.HasKLinks; - - return false; - } - } - - /// - /// Gets the default window name - /// - - public string DefaultWindow - { - get - { - if(_associatedFile != null) - return _associatedFile.DefaultWindow; - - return ""; - } - } - - /// - /// Gets the file name of the compile file - /// - - public string CompileFile - { - get - { - if(_associatedFile != null) - return _associatedFile.CompileFile; - - return ""; - } - } - - /// - /// Gets the flag if the chm has a binary index file - /// - - public bool BinaryIndex - { - get - { - if(_associatedFile != null) - return _associatedFile.BinaryIndex; - - return false; - } - } - - /// - /// Gets the flag if the chm has a binary index file - /// - - public string CompilerVersion - { - get - { - if(_associatedFile != null) - return _associatedFile.CompilerVersion; - - return ""; - } - } - - /// - /// Gets the flag if the chm has a binary toc file - /// - - public bool BinaryTOC - { - get - { - if(_associatedFile != null) - return _associatedFile.BinaryTOC; - - return false; - } - } - - /// - /// Gets the font face of the read font property. - /// Empty string for default font. - /// - - public string FontFace - { - get - { - if(_associatedFile != null) - return _associatedFile.FontFace; - - return ""; - } - } - - /// - /// Gets the font size of the read font property. - /// 0 for default font size - /// - - public double FontSize - { - get - { - if(_associatedFile != null) - return _associatedFile.FontSize; - - return 0.0; - } - } - - /// - /// Gets the character set of the read font property - /// 1 for default - /// - - public int CharacterSet - { - get - { - if(_associatedFile != null) - return _associatedFile.CharacterSet; - - return 1; - } - } - - /// - /// Gets the codepage depending on the read font property - /// - - public int CodePage - { - get - { - if(_associatedFile != null) - return _associatedFile.CodePage; - - return 0; - } - } - - /// - /// Gets the assiciated culture info - /// - public CultureInfo Culture - { - get - { - if(_associatedFile != null) - return _associatedFile.Culture; - - return CultureInfo.CurrentCulture; - } - } - #endregion - - #region #IDXHDR properties - /// - /// Gets the number of topic nodes including the contents and index files - /// - - public int NumberOfTopicNodes - { - get - { - if(_associatedFile != null) - return _associatedFile.NumberOfTopicNodes; - - return 0; - } - } - - /// - /// Gets the ImageList string specyfied in the #IDXHDR file. - /// - /// This property uses the #STRINGS file to extract the string at a given offset. - - public string ImageList - { - get - { - if(_associatedFile != null) - return _associatedFile.ImageList; - - return ""; - } - } - - /// - /// Gets the background setting - /// - - public int Background - { - get - { - if(_associatedFile != null) - return _associatedFile.Background; - - return 0; - } - } - - /// - /// Gets the foreground setting - /// - - public int Foreground - { - get - { - if(_associatedFile != null) - return _associatedFile.Foreground; - - return 0; - } - } - - /// - /// Gets the FrameName string specyfied in the #IDXHDR file. - /// - /// This property uses the #STRINGS file to extract the string at a given offset. - - public string FrameName - { - get - { - if(_associatedFile != null) - return _associatedFile.FrameName; - - return ""; - } - } - - /// - /// Gets the WindowName string specyfied in the #IDXHDR file. - /// - /// This property uses the #STRINGS file to extract the string at a given offset. - - public string WindowName - { - get - { - if(_associatedFile != null) - return _associatedFile.WindowName; - - return ""; - } - } - - /// - /// Gets a string array containing the merged file names - /// - public string[] MergedFiles - { - get - { - if(_associatedFile != null) - return _associatedFile.MergedFiles; - - return new string[0]; - } - } - - #endregion - } -} diff --git a/irc/TechBot/CHMLibrary/Default.build b/irc/TechBot/CHMLibrary/Default.build deleted file mode 100644 index 6363074a8db..00000000000 --- a/irc/TechBot/CHMLibrary/Default.build +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/irc/TechBot/CHMLibrary/HtmlHelpSystem.cs b/irc/TechBot/CHMLibrary/HtmlHelpSystem.cs deleted file mode 100644 index 966cd3d7205..00000000000 --- a/irc/TechBot/CHMLibrary/HtmlHelpSystem.cs +++ /dev/null @@ -1,894 +0,0 @@ -using System; -using System.IO; -using System.Collections; -using System.Data; - -using HtmlHelp.ChmDecoding; - -namespace HtmlHelp -{ - /// - /// The class HtmlHelpSystem implements the main object for reading chm files - /// - public sealed class HtmlHelpSystem - { - /// - /// Private shared instance of current HtmlHelpSystem class - /// - private static HtmlHelpSystem _current=null; - /// - /// Internal member storing the attached files - /// - private ArrayList _chmFiles = new ArrayList(); - /// - /// Internal member storing a merged table of contents - /// - private TableOfContents _toc = new TableOfContents(); - /// - /// Internal member storing a merged index - /// - private Index _index = new Index(); - /// - /// URL prefix for specifying a chm destination - /// - private static string _urlPrefix = "ms-its:"; - /// - /// Internal flag specifying if the system should use the tree-images list - /// from HtmlHelp2. If false the standard CHM-Viewer pics will be used. - /// - private static bool _useHH2TreePics = false; - /// - /// Internal member storing the read information types - /// - private ArrayList _informationTypes = new ArrayList(); - /// - /// Internal member storing the read categories - /// - private ArrayList _categories = new ArrayList(); - - /// - /// Gets/Sets the url prefix for specifying a chm destination - /// - public static string UrlPrefix - { - get { return _urlPrefix; } - set { _urlPrefix = value; } - } - - public CHMStream.CHMStream BaseStream - { - get - { - CHMFile chm=(CHMFile)_chmFiles[0]; - return chm.BaseStream; - } - } - - /// - /// Gets/Sets the flag specifying if the system should use the tree-images list - /// from HtmlHelp2. If false the standard CHM-Viewer pics will be used. - /// - public static bool UseHH2TreePics - { - get { return _useHH2TreePics; } - set { _useHH2TreePics = value; } - } - - /// - /// Gets the current HtmlHelpSystem instance - /// - public static HtmlHelpSystem Current - { - get - { - return _current; - } - } - - /// - /// Standard constructor - /// - public HtmlHelpSystem() : this("") - { - } - - /// - /// Constructor of the reader class - /// - /// chm file to attach with the reader - public HtmlHelpSystem(string chmFile) - { - _current = this; - OpenFile(chmFile); - } - - - /// - /// Opens a chm file and creates - /// - /// full file path of the chm file to open - /// If you call this method, all existing merged files will be cleared. - public void OpenFile(string chmFile) - { - OpenFile(chmFile, null); - } - - /// - /// Opens a chm file and creates - /// - /// full file path of the chm file to open - /// dumping info - /// If you call this method, all existing merged files will be cleared. - public void OpenFile(string chmFile, DumpingInfo dmpInfo) - { - if( File.Exists(chmFile ) ) - { - _chmFiles.Clear(); - _toc.Clear(); - _index.Clear(); - _informationTypes.Clear(); - _categories.Clear(); - - CHMFile newFile = new CHMFile(this, chmFile, dmpInfo); - - _toc = new TableOfContents( newFile.TOC ); - _index = new Index( newFile.IndexKLinks, newFile.IndexALinks ); - - _chmFiles.Add(newFile); - // add all infotypes and categories of the read file to this system instance - MergeFileInfoTypesCategories(newFile); - - // check if the file has a merged files list - if( newFile.MergedFiles.Length > 0 ) - { - // extract the path of the chm file (usually merged files are in the same path) - FileInfo fi = new FileInfo(chmFile); - string sPath = fi.DirectoryName; - - for(int i=0; i 0) - { - if(sFile[1] != ':') // no full path setting - { - sFile = Path.Combine(sPath, sFile); - } - - MergeFile(sFile, dmpInfo, true); - } - } - - // if (newFile.MergLinks.Count>0) - // RecalculateMergeLinks(newFile); - - RemoveMergeLinks(); // clear all merge-links which have no target ! - } - } - } - - /// - /// Merges a chm file to the current help contents - /// - /// full file path of the chm file to merge - public void MergeFile(string chmFile) - { - MergeFile(chmFile, null); - } - - /// - /// Merges a chm file to the current help contents - /// - /// full file path of the chm file to merge - /// dumping info - public void MergeFile(string chmFile, DumpingInfo dmpInfo) - { - MergeFile(chmFile, dmpInfo, false); - } - - /// - /// Merges a chm file to the current help contents - /// - /// full file path of the chm file to merge - /// dumping info - /// true if the merge is done because a merged file list - /// was found in the previously loaded CHM. - internal void MergeFile(string chmFile, DumpingInfo dmpInfo, bool mergedFileList) - { - if( File.Exists(chmFile ) ) - { - if( _chmFiles.Count == 1) - { - // if we open the first file, we directly point into the toc and index of this file. - // So that we don't merge the new toc's indexe's into the first file, we have to - // clone the internal arraylists first to a new instance of the toc/index holder classes. - ArrayList atoc = _toc.TOC; - ArrayList alinks = _index.ALinks; - ArrayList klinks = _index.KLinks; - - _toc = new TableOfContents(); - _index = new Index(); - - _toc.MergeToC( atoc ); - _index.MergeIndex( alinks, IndexType.AssiciativeLinks ); - _index.MergeIndex( klinks, IndexType.KeywordLinks ); - } - - CHMFile newFile = new CHMFile(this, chmFile, dmpInfo); - - if(mergedFileList) // if we've called this method due to a merged file list merge - { - RecalculateMergeLinks(newFile); - - _toc.MergeToC( newFile.TOC, _chmFiles ); - _index.MergeIndex( newFile.IndexALinks, IndexType.AssiciativeLinks ); - _index.MergeIndex( newFile.IndexKLinks, IndexType.KeywordLinks ); - - _chmFiles.Add(newFile); - - // add all infotypes and categories of the read file to this system instance - MergeFileInfoTypesCategories(newFile); - } - else - { - _toc.MergeToC( newFile.TOC, _chmFiles ); - _index.MergeIndex( newFile.IndexALinks, IndexType.AssiciativeLinks ); - _index.MergeIndex( newFile.IndexKLinks, IndexType.KeywordLinks ); - - _chmFiles.Add(newFile); - - // add all infotypes and categories of the read file to this system instance - MergeFileInfoTypesCategories(newFile); - - // check if the file has a merged files list - if( newFile.MergedFiles.Length > 0 ) - { - // extract the path of the chm file (usually merged files are in the same path) - FileInfo fi = new FileInfo(chmFile); - string sPath = fi.DirectoryName; - - for(int i=0; i 0) - { - if(sFile[1] != ':') // no full path setting - { - sFile = Path.Combine(sPath, sFile); - } - - MergeFile(sFile, dmpInfo, true); - } - } - - RemoveMergeLinks(); // clear all merge-links which have no target ! - } - } - } - } - - /// - /// Checks all Merg-links read till now. Checks if the merg-link points to the - /// file currentFile. If yes the link will be replaced by the contents of the - /// merged file. - /// - /// Current CHMFile instance - internal void RecalculateMergeLinks(CHMFile currentFile) - { - foreach(CHMFile curFile in _chmFiles) - { - if( curFile.MergLinks.Count > 0) - { - for(int i=0; i 3) // merge info contains path name - { - sFName = sSplit[0] + ":" + sSplit[1]; - sTarget = sSplit[3]; - } - else if( sSplit.Length == 3)// merge info contains only file name - { - FileInfo fi = new FileInfo(currentFile.ChmFilePath); - string sPath = fi.DirectoryName; - - string sFile = sSplit[0]; - - if(sFile.Length > 0) - { - if(sFile[1] != ':') // no full path setting - { - sFile = Path.Combine(sPath, sFile); - } - } - - sFName = sFile; - sTarget = sSplit[2]; - } - - ArrayList arrToc = null; - if( (sFName.Length>0) && (sTarget.Length>0) ) - { - // if this link points into the current file - if( sFName.ToLower() == currentFile.ChmFilePath.ToLower() ) - { - if(sTarget.ToLower().IndexOf(".hhc") >= 0) - { - string sfCheck = sTarget; - - // remove prefixing ./ - while( (sfCheck[0]=='.') || (sfCheck[0]=='/') ) - { - sfCheck = sfCheck.Substring(1); - } - - if( currentFile.ContentsFile.ToLower() != sfCheck ) - { - arrToc = currentFile.ParseHHC( sTarget ); - - if( arrToc.Count > 0) - { - } - } - else - { - arrToc = currentFile.TOC; - } - - // target points to a complete TOC - int nCnt = 0; - - foreach(TOCItem chkItem in arrToc) - { - if(nCnt == 0) - { - curItem.AssociatedFile = currentFile; - curItem.Children = chkItem.Children; - curItem.ChmFile = currentFile.ChmFilePath; - curItem.ImageIndex = chkItem.ImageIndex; - curItem.Local = chkItem.Local; - curItem.MergeLink = chkItem.MergeLink; - curItem.Name = chkItem.Name; - curItem.TocMode = chkItem.TocMode; - curItem.TopicOffset = chkItem.TopicOffset; - - MarkChildrenAdded(chkItem.Children, curFile.MergLinks); - } - else - { - ArrayList checkList = null; - - if(curItem.Parent != null) - checkList = curItem.Parent.Children; - else - checkList = curFile.TOC; - - int nIdx = checkList.IndexOf(curItem); - if((nIdx+nCnt)>checkList.Count) - checkList.Add(chkItem); - else - checkList.Insert(nIdx+nCnt, chkItem); - - curFile.MergLinks.Add(chkItem); - MarkChildrenAdded(chkItem.Children, curFile.MergLinks); - } - - nCnt++; - } - } - else - { - - // target points to a single topic - TOCItem chkItem = currentFile.GetTOCItemByLocal(sTarget); - if(chkItem != null) - { - curItem.AssociatedFile = currentFile; - curItem.Children = chkItem.Children; - curItem.ChmFile = currentFile.ChmFilePath; - curItem.ImageIndex = chkItem.ImageIndex; - curItem.Local = chkItem.Local; - curItem.MergeLink = chkItem.MergeLink; - curItem.Name = chkItem.Name; - curItem.TocMode = chkItem.TocMode; - curItem.TopicOffset = chkItem.TopicOffset; - - curFile.MergLinks.Add(chkItem); - MarkChildrenAdded(chkItem.Children, curFile.MergLinks); - } - } - } - } - } - } - } - } - - /// - /// Adds sub-items of an TOC-entry to the merg-linked list. - /// This will mark this item as "added" during the extra merge run - /// of the HtmlHelpSystem class. - /// - /// TOCItem list - /// Arraylist which holds the merged-items - internal void MarkChildrenAdded(ArrayList tocs, ArrayList merged) - { - foreach(TOCItem curItem in tocs) - { - if(!merged.Contains(curItem)) - { - merged.Add(curItem); - - MarkChildrenAdded(curItem.Children, merged); - } - } - } - - /// - /// Removes merge-links from the toc of files which were not loaded - /// - internal void RemoveMergeLinks() - { - foreach(CHMFile curFile in _chmFiles) - { - if( curFile.MergLinks.Count > 0) - { - while(curFile.MergLinks.Count > 0) - { - TOCItem curItem = curFile.MergLinks[0] as TOCItem; - if(curItem.MergeLink.Length > 0) - curFile.RemoveTOCItem(curItem); - - curFile.MergLinks.RemoveAt(0); - } - } - } - } - - /// - /// Merges the information types and categories read by the CHMFile instance - /// into the system instance - /// - /// file instance - private void MergeFileInfoTypesCategories(CHMFile chmFile) - { - if(chmFile.HasInformationTypes) - { - for(int i=0; i - /// Removes the information types and categories read by the CHMFile instance - /// - /// file instance - private void RemoveFileInfoTypesCategories(CHMFile chmFile) - { - if(chmFile.HasInformationTypes) - { - for(int i=0; i - /// Removes a chm file from the internal file collection - /// - /// full file path of the chm file to remove - public void RemoveFile(string chmFile) - { - int nIdx = -1; - CHMFile removeInstance=null; - - foreach(CHMFile curFile in _chmFiles) - { - nIdx++; - - if( curFile.ChmFilePath.ToLower() == chmFile.ToLower() ) - { - removeInstance = curFile; - break; - } - } - - if(nIdx >= 0) - { - _toc.Clear(); // forces a rebuild of the merged toc - _index.Clear(); // force a rebuild of the merged index - - RemoveFileInfoTypesCategories(removeInstance); - _chmFiles.RemoveAt(nIdx); - } - } - - /// - /// Closes all files and destroys TOC/index - /// - public void CloseAllFiles() - { - for(int i=0; i < _chmFiles.Count; i++) - { - CHMFile curFile = _chmFiles[i] as CHMFile; - - _chmFiles.RemoveAt(i); - curFile.Dispose(); - i--; - } - - _chmFiles.Clear(); - _toc.Clear(); - _index.Clear(); - _informationTypes.Clear(); - _categories.Clear(); - } - - /// - /// Gets an array of loaded chm files. - /// - public CHMFile[] FileList - { - get - { - CHMFile[] ret = new CHMFile[ _chmFiles.Count ]; - for(int i=0;i<_chmFiles.Count;i++) - ret[i] = (CHMFile)_chmFiles[i]; - - return ret; - } - } - - /// - /// Returns true if the HtmlHelpSystem instance contains 1 or more information types - /// - public bool HasInformationTypes - { - get { return (_informationTypes.Count>0); } - } - - /// - /// Returns true if the HtmlHelpSystem instance contains 1 or more categories - /// - public bool HasCategories - { - get { return (_categories.Count>0); } - } - - /// - /// Gets an ArrayList of InformationType items - /// - public ArrayList InformationTypes - { - get { return _informationTypes; } - } - - /// - /// Gets an ArrayList of Category items - /// - public ArrayList Categories - { - get { return _categories; } - } - - /// - /// Gets the information type specified by its name - /// - /// name of the information type to receive - /// Returns the Instance for the name or null if not found - public InformationType GetInformationType(string name) - { - if(HasInformationTypes) - { - for(int i=0; i<_informationTypes.Count;i++) - { - InformationType iT = _informationTypes[i] as InformationType; - - if(iT.Name == name) - return iT; - } - } - - return null; - } - - /// - /// Gets the category specifiyd by its name - /// - /// name of the category - /// Returns the Instance for the name or null if not found - public Category GetCategory(string name) - { - if(HasCategories) - { - for(int i=0; i<_categories.Count;i++) - { - Category cat = _categories[i] as Category; - - if(cat.Name == name) - return cat; - } - } - - return null; - } - - /// - /// Gets the default topic - /// - public string DefaultTopic - { - get - { - if( _chmFiles.Count > 0 ) - { - foreach(CHMFile curFile in _chmFiles) - { - if( curFile.DefaultTopic.Length > 0) - { - return curFile.FormURL( curFile.DefaultTopic ); - } - } - } - - return "about:blank"; - } - } - - /// - /// Gets a merged table of contents of all opened chm files - /// - public TableOfContents TableOfContents - { - get - { - if( _chmFiles.Count > 0 ) - { - if( _toc.Count() <= 0) - { - // merge toc of files - foreach(CHMFile curFile in _chmFiles) - { - _toc.MergeToC( curFile.TOC ); - } - } - } - - return _toc; - } - } - - /// - /// Gets a merged index of all opened chm files - /// - public Index Index - { - get - { - if( _chmFiles.Count > 0 ) - { - if( (_index.Count(IndexType.KeywordLinks)+_index.Count(IndexType.AssiciativeLinks)) <= 0) - { - // merge index files - foreach(CHMFile curFile in _chmFiles) - { - _index.MergeIndex( curFile.IndexKLinks, IndexType.KeywordLinks); - _index.MergeIndex( curFile.IndexALinks, IndexType.AssiciativeLinks); - } - } - } - - return _index; - } - } - - /// - /// Gets a flag if the current instance offers a table of contents - /// - public bool HasTableOfContents - { - get - { - return (TableOfContents.Count() > 0); - } - } - - /// - /// Gets a flag if the current instance offers an index - /// - public bool HasIndex - { - get - { - return (HasALinks || HasKLinks); - } - } - - /// - /// Gets a flag if the index holds klinks - /// - public bool HasKLinks - { - get - { - return (_index.Count(IndexType.KeywordLinks) > 0); - } - } - - /// - /// Gets a flag if the index holds alinks - /// - public bool HasALinks - { - get - { - return (_index.Count(IndexType.AssiciativeLinks) > 0); - } - } - - /// - /// Gets a flag if the current instance supports fulltext searching - /// - public bool FullTextSearch - { - get - { - bool bRet = false; - - foreach(CHMFile curFile in _chmFiles) - { - bRet |= curFile.FullTextSearch; - } - - return bRet; - } - } - - /// - /// Performs a full-text search over the chm files - /// - /// words to search - /// true if partial word should be matched also - /// ( if this is true a search of 'support' will match 'supports', otherwise not ) - /// true if titles only - /// A DataTable containing the search hits - public DataTable PerformSearch(string words, bool partialMatches, bool titleOnly) - { - return PerformSearch(words, -1, partialMatches, titleOnly); - } - - /// - /// Performs a full-text search over the chm files - /// - /// words to search - /// maximal number of hits to return - /// true if partial word should be matched also - /// ( if this is true a search of 'support' will match 'supports', otherwise not ) - /// true if titles only - /// A DataTable containing the search hits - public DataTable PerformSearch(string words, int MaxResults, bool partialMatches, bool titleOnly) - { - if( ! FullTextSearch ) - return null; - - DataTable dtResult = null; - - int nCnt = 0; - - foreach(CHMFile curFile in _chmFiles) - { - if(nCnt == 0) - { - if(curFile.FullTextSearchEngine.CanSearch) - { - if(curFile.FullTextSearchEngine.Search(words, MaxResults, partialMatches, titleOnly)) - { - dtResult = curFile.FullTextSearchEngine.Hits; - dtResult.DefaultView.Sort = "Rating DESC"; - } - } - } - else - { - if(curFile.FullTextSearchEngine.CanSearch) - { - if(curFile.FullTextSearchEngine.Search(words, MaxResults, partialMatches, titleOnly)) - { - DataTable table = curFile.FullTextSearchEngine.Hits; - - // append rows from 2nd file - foreach(DataRow curRow in table.Rows) - { - dtResult.ImportRow( curRow ); - } - - dtResult.DefaultView.Sort = "Rating DESC"; - - // adjust max hits - if(MaxResults >= 0) - { - if(dtResult.DefaultView.Count > MaxResults) - { - for(int i=MaxResults-1; i 0) { - output.Append (GetChars (bytes, e)); - bytes.SetLength (0); - } - output.Append ((char) Int32.Parse (s.Substring (i + 2, 4), hexa)); - i += 5; - } else { - bytes.WriteByte ((byte) Int32.Parse (s.Substring (i + 1, 2), hexa)); - i += 2; - } - continue; - } - - if (bytes.Length > 0) { - output.Append (GetChars (bytes, e)); - bytes.SetLength (0); - } - - if (s [i] == '+') { - output.Append (' '); - } else { - output.Append (s [i]); - } - } - - if (bytes.Length > 0) { - output.Append (GetChars (bytes, e)); - } - - bytes = null; - return output.ToString (); - } - - public static string UrlDecode (byte [] bytes, Encoding e) - { - if (bytes == null) - return null; - - return UrlDecode (bytes, 0, bytes.Length, e); - } - - private static int GetInt (byte b) - { - char c = Char.ToUpper ((char) b); - if (c >= '0' && c <= '9') - return c - '0'; - - if (c < 'A' || c > 'F') - return 0; - - return (c - 'A' + 10); - } - - private static char GetChar (byte [] bytes, int offset, int length) - { - int value = 0; - int end = length + offset; - for (int i = offset; i < end; i++) - value = (value << 4) + GetInt (bytes [offset]); - - return (char) value; - } - - public static string UrlDecode (byte [] bytes, int offset, int count, Encoding e) - { - if (bytes == null || count == 0) - return null; - - if (bytes == null) - throw new ArgumentNullException ("bytes"); - - if (offset < 0 || offset > bytes.Length) - throw new ArgumentOutOfRangeException ("offset"); - - if (count < 0 || offset + count > bytes.Length) - throw new ArgumentOutOfRangeException ("count"); - - StringBuilder output = new StringBuilder (); - MemoryStream acc = new MemoryStream (); - - int end = count + offset; - for (int i = offset; i < end; i++) { - if (bytes [i] == '%' && i + 2 < count) { - if (bytes [i + 1] == (byte) 'u' && i + 5 < end) { - if (acc.Length > 0) { - output.Append (GetChars (acc, e)); - acc.SetLength (0); - } - output.Append (GetChar (bytes, offset + 2, 4)); - i += 5; - } else { - acc.WriteByte ((byte) GetChar (bytes, offset + 1, 2)); - i += 2; - } - continue; - } - - if (acc.Length > 0) { - output.Append (GetChars (acc, e)); - acc.SetLength (0); - } - - if (bytes [i] == '+') { - output.Append (' '); - } else { - output.Append ((char) bytes [i]); - } - } - - if (acc.Length > 0) { - output.Append (GetChars (acc, e)); - } - - acc = null; - return output.ToString (); - } - - public static byte [] UrlDecodeToBytes (byte [] bytes) - { - if (bytes == null) - return null; - - return UrlDecodeToBytes (bytes, 0, bytes.Length); - } - - public static byte [] UrlDecodeToBytes (string str) - { - return UrlDecodeToBytes (str, Encoding.UTF8); - } - - public static byte [] UrlDecodeToBytes (string str, Encoding e) - { - if (str == null) - return null; - - if (e == null) - throw new ArgumentNullException ("e"); - - return UrlDecodeToBytes (e.GetBytes (str)); - } - - public static byte [] UrlDecodeToBytes (byte [] bytes, int offset, int count) - { - if (bytes == null) - return null; - - int len = bytes.Length; - if (offset < 0 || offset >= len) - throw new ArgumentOutOfRangeException("offset"); - - if (count < 0 || offset > len - count) - throw new ArgumentOutOfRangeException("count"); - - MemoryStream result = new MemoryStream (); - int end = offset + count; - for (int i = offset; i < end; i++){ - char c = (char) bytes [i]; - if (c == '+') - c = ' '; - else if (c == '%' && i < end - 2) { - c = GetChar (bytes, i, 2); - i += 2; - } - result.WriteByte ((byte) c); - } - - return result.ToArray (); - } - - public static string UrlEncode(string str) - { - return UrlEncode(str, Encoding.UTF8); - } - - public static string UrlEncode (string s, Encoding Enc) - { - if (s == null) - return null; - - if (s == "") - return ""; - - byte [] bytes = Enc.GetBytes (s); - byte [] b =UrlEncodeToBytes (bytes, 0, bytes.Length); - return Encoding.ASCII.GetString (b,0,b.Length); - } - - public static string UrlEncode (byte [] bytes) - { - if (bytes == null) - return null; - - if (bytes.Length == 0) - return ""; - - byte []b=UrlEncodeToBytes(bytes, 0, bytes.Length); - return Encoding.ASCII.GetString (b,0,b.Length); - } - - public static string UrlEncode (byte [] bytes, int offset, int count) - { - if (bytes == null) - return null; - - if (bytes.Length == 0) - return ""; - - byte []b=UrlEncodeToBytes(bytes, offset, count); - return Encoding.ASCII.GetString (b,0,b.Length); - } - - public static byte [] UrlEncodeToBytes (string str) - { - return UrlEncodeToBytes (str, Encoding.UTF8); - } - - public static byte [] UrlEncodeToBytes (string str, Encoding e) - { - if (str == null) - return null; - - if (str == "") - return new byte [0]; - - byte [] bytes = e.GetBytes (str); - return UrlEncodeToBytes (bytes, 0, bytes.Length); - } - - public static byte [] UrlEncodeToBytes (byte [] bytes) - { - if (bytes == null) - return null; - - if (bytes.Length == 0) - return new byte [0]; - - return UrlEncodeToBytes (bytes, 0, bytes.Length); - } - - static char [] hexChars = "0123456789abcdef".ToCharArray (); - - public static byte [] UrlEncodeToBytes (byte [] bytes, int offset, int count) - { - if (bytes == null) - return null; - - int len = bytes.Length; - if (len == 0) - return new byte [0]; - - if (offset < 0 || offset >= len) - throw new ArgumentOutOfRangeException("offset"); - - if (count < 0 || count > len - offset) - throw new ArgumentOutOfRangeException("count"); - - MemoryStream result = new MemoryStream (); - int end = offset + count; - for (int i = offset; i < end; i++) { - char c = (char) bytes [i]; - if ((c == ' ') || (c < '0' && c != '-' && c != '.') || - (c < 'A' && c > '9') || - (c > 'Z' && c < 'a' && c != '_') || - (c > 'z')) { - result.WriteByte ((byte) '%'); - int idx = ((int) c) >> 4; - result.WriteByte ((byte) hexChars [idx]); - idx = ((int) c) & 0x0F; - result.WriteByte ((byte) hexChars [idx]); - } else { - result.WriteByte ((byte) c); - } - } - - return result.ToArray (); - } - - public static string UrlEncodeUnicode (string str) - { - if (str == null) - return null; - - StringBuilder result = new StringBuilder (); - int end = str.Length; - for (int i = 0; i < end; i++) { - int idx; - char c = str [i]; - if (c > 255) { - result.Append ("%u"); - idx = ((int) c) >> 24; - result.Append (hexChars [idx]); - idx = (((int) c) >> 16) & 0x0F; - result.Append (hexChars [idx]); - idx = (((int) c) >> 8) & 0x0F; - result.Append (hexChars [idx]); - idx = ((int) c) & 0x0F; - result.Append (hexChars [idx]); - continue; - } - - if ((c == ' ') || (c < '0' && c != '-' && c != '.') || - (c < 'A' && c > '9') || - (c > 'Z' && c < 'a' && c != '_') || - (c > 'z')) { - result.Append ('%'); - idx = ((int) c) >> 4; - result.Append (hexChars [idx]); - idx = ((int) c) & 0x0F; - result.Append (hexChars [idx]); - continue; - } - - result.Append (c); - } - - return result.ToString (); - } - - public static byte [] UrlEncodeUnicodeToBytes (string str) - { - if (str == null) - return null; - - if (str == "") - return new byte [0]; - - return Encoding.ASCII.GetBytes (UrlEncodeUnicode (str)); - } - - /// - /// Decodes an HTML-encoded string and returns the decoded string. - /// - /// The HTML string to decode. - /// The decoded text. - public static string HtmlDecode (string s) - { - if (s == null) - throw new ArgumentNullException ("s"); - - if (s.IndexOf ('&') == -1) - return s; - - bool insideEntity = false; // used to indicate that we are in a potential entity - string entity = String.Empty; - StringBuilder output = new StringBuilder (); - int len = s.Length; - - for (int i = 0; i < len; i++) { - char c = s [i]; - switch (c) { - case '&' : - output.Append (entity); - entity = "&"; - insideEntity = true; - break; - case ';' : - if (!insideEntity) { - output.Append (c); - break; - } - - entity += c; - int length = entity.Length; - if (length >= 2 && entity[1] == '#' && entity[2] != ';') - entity = ((char) Int32.Parse (entity.Substring (2, entity.Length - 3))).ToString(); - else if (length > 1 && Entities.ContainsKey (entity.Substring (1, entity.Length - 2))) - entity = Entities [entity.Substring (1, entity.Length - 2)].ToString (); - - output.Append (entity); - entity = String.Empty; - insideEntity = false; - break; - default : - if (insideEntity) - entity += c; - else - output.Append (c); - break; - } - } - output.Append (entity); - return output.ToString (); - } - - /// - /// Decodes an HTML-encoded string and sends the resulting output to a TextWriter output stream. - /// - /// The HTML string to decode - /// The TextWriter output stream containing the decoded string. - public static void HtmlDecode(string s, TextWriter output) - { - if (s != null) - output.Write (HtmlDecode (s)); - } - - /// - /// HTML-encodes a string and returns the encoded string. - /// - /// The text string to encode. - /// The HTML-encoded text. - public static string HtmlEncode (string s) - { - if (s == null) - return null; - - StringBuilder output = new StringBuilder (); - - foreach (char c in s) - switch (c) { - case '&' : - output.Append ("&"); - break; - case '>' : - output.Append (">"); - break; - case '<' : - output.Append ("<"); - break; - case '"' : - output.Append ("""); - break; - default: - if ((int) c > 128) { - output.Append ("&#"); - output.Append (((int) c).ToString ()); - output.Append (";"); - } - else - output.Append (c); - break; - } - return output.ToString (); - } - - /// - /// HTML-encodes a string and sends the resulting output to a TextWriter output stream. - /// - /// The string to encode. - /// The TextWriter output stream containing the encoded string. - public static void HtmlEncode(string s, TextWriter output) - { - if (s != null) - output.Write (HtmlEncode (s)); - } - -#if NET_1_1 - public string UrlPathEncode (string s) - { - if (s == null) - return null; - - int idx = s.IndexOf ("?"); - string s2 = null; - if (idx != -1) { - s2 = s.Substring (0, idx-1); - s2 = UrlEncode (s2) + s.Substring (idx); - } else { - s2 = UrlEncode (s); - } - - return s2; - } -#endif - #endregion // Methods - } -} diff --git a/irc/TechBot/CHMLibrary/Index.cs b/irc/TechBot/CHMLibrary/Index.cs deleted file mode 100644 index 76f73013f0d..00000000000 --- a/irc/TechBot/CHMLibrary/Index.cs +++ /dev/null @@ -1,322 +0,0 @@ -using System; -using System.Diagnostics; -using System.Collections; -using HtmlHelp.ChmDecoding; - -namespace HtmlHelp -{ - /// - /// Enumeration for specifying the index type - /// - public enum IndexType - { - /// - /// Keyword links should be used - /// - KeywordLinks = 0, - /// - /// Associative links should be used - /// - AssiciativeLinks = 1 - } - - /// - /// The class Index holds the (keyword links) KLinks and (associative links) ALinks of the htmlhelp - /// system. It implements methods for easy index-based searching. - /// - public class Index - { - private ArrayList _kLinks = new ArrayList(); - private ArrayList _aLinks = new ArrayList(); - - /// - /// Standard constructor - /// - public Index() - { - } - - /// - /// Constructor of the class - /// - /// arraylist with keyword links - /// arraylist with associative links - public Index(ArrayList kLinks, ArrayList aLinks) - { - _kLinks= kLinks; - _aLinks = aLinks; - } - - /// - /// Clears the current toc - /// - public void Clear() - { - if(_aLinks != null) - _aLinks.Clear(); - if(_kLinks != null) - _kLinks.Clear(); - } - - /// - /// Gets the number of index items for a specific type - /// - /// type of index - /// Returns the number of index items for a specific type - public int Count(IndexType typeOfIndex) - { - ArrayList _index = null; - - switch( typeOfIndex ) - { - case IndexType.AssiciativeLinks: _index = _aLinks; break; - case IndexType.KeywordLinks: _index = _kLinks; break; - } - - if(_index != null) - return _index.Count; - - return 0; - } - - /// - /// Gets the internal index list of keyword links - /// - public ArrayList KLinks - { - get - { - if(_kLinks==null) - _kLinks = new ArrayList(); - - return _kLinks; - } - } - - /// - /// Gets the internal index list of associative links - /// - public ArrayList ALinks - { - get - { - if(_aLinks==null) - _aLinks = new ArrayList(); - - return _aLinks; - } - } - - /// - /// Merges the the index list arrIndex into the current one - /// - /// indexlist which should be merged with the current one - /// type of index to merge - public void MergeIndex( ArrayList arrIndex, IndexType typeOfIndex ) - { - ArrayList _index = null; - - switch(typeOfIndex) - { - case IndexType.AssiciativeLinks: _index = _aLinks;break; - case IndexType.KeywordLinks: _index = _kLinks;break; - } - - foreach(IndexItem curItem in arrIndex) - { - //IndexItem searchItem = ContainsIndex(_index, curItem.KeyWordPath); - int insertIndex=0; - IndexItem searchItem = BinSearch(0, _index.Count-1, _index, curItem.KeyWordPath, false, false, ref insertIndex); - - if(searchItem != null) - { - // extend the keywords topics - foreach(IndexTopic curEntry in curItem.Topics) - { - searchItem.Topics.Add( curEntry ); - } - } - else - { - // add the item to the global collection - //_index.Add( curItem ); - - if(insertIndex > _index.Count) - _index.Add(curItem); - else - _index.Insert(insertIndex, curItem); - } - } - } - - /// - /// Searches an index entry using recursive binary search algo (divide and conquer). - /// - /// start index for searching - /// end index for searching - /// arraylist containing sorted IndexItem entries - /// keyword path to search - /// true if the keywordPath will only contain the keyword not the complete path - /// True if case should be ignored - /// out reference. will receive the index where the item with the - /// keywordPath should be inserted if not found (receives -1 if the item was found) - /// Returns an IndexItem instance if found, otherwise null - /// (use insertIndex for inserting the new item in a sorted order) - private IndexItem BinSearch(int nStart, int nEnd, ArrayList arrIndex, string keywordPath, - bool searchKeyword, bool caseInsensitive, ref int insertIndex) - { - if( arrIndex.Count <= 0 ) - { - insertIndex=0; - return null; - } - - if(caseInsensitive) - keywordPath = keywordPath.ToLower(); - - if( (nEnd - nStart) > 1) - { - int nCheck = nStart + (nEnd-nStart)/2; - - IndexItem iC = arrIndex[nCheck] as IndexItem; - - string sCompare = iC.KeyWordPath; - - if(searchKeyword) - sCompare = iC.KeyWord; - - if(caseInsensitive) - sCompare = sCompare.ToLower(); - - if( sCompare == keywordPath ) - { - insertIndex=-1; - return iC; - } - - if( keywordPath.CompareTo(sCompare) < 0 ) - { - return BinSearch(nStart, nCheck-1, arrIndex, keywordPath, searchKeyword, caseInsensitive, ref insertIndex); - } - - if( keywordPath.CompareTo(sCompare) > 0 ) - { - return BinSearch(nCheck+1, nEnd, arrIndex, keywordPath, searchKeyword, caseInsensitive, ref insertIndex); - } - } - else if(nEnd-nStart == 1) - { - IndexItem i1 = arrIndex[nStart] as IndexItem; - IndexItem i2 = arrIndex[nEnd] as IndexItem; - - string sCompare1 = i1.KeyWordPath; - - if(searchKeyword) - sCompare1 = i1.KeyWord; - - if(caseInsensitive) - sCompare1 = sCompare1.ToLower(); - - string sCompare2 = i2.KeyWordPath; - - if(searchKeyword) - sCompare2 = i2.KeyWord; - - if(caseInsensitive) - sCompare2 = sCompare2.ToLower(); - - if( sCompare1 == keywordPath) - { - insertIndex = -1; - return i1; - } - - if( sCompare2 == keywordPath) - { - insertIndex = -1; - return i2; - } - - if( sCompare1.CompareTo(keywordPath) > 0) - { - insertIndex = nStart; - return null; - } - else if( sCompare2.CompareTo(keywordPath) > 0) - { - insertIndex = nEnd; - return null; - } - else - { - insertIndex = nEnd+1; - } - } - - IndexItem itm = arrIndex[nEnd] as IndexItem; - - string sCompareI = itm.KeyWordPath; - - if(searchKeyword) - sCompareI = itm.KeyWord; - - if(caseInsensitive) - sCompareI = sCompareI.ToLower(); - - if( sCompareI.CompareTo(keywordPath) > 0) - { - insertIndex = nStart; - return null; - } - else if( sCompareI.CompareTo(keywordPath) < 0) - { - insertIndex = nEnd+1; - return null; - } - else - { - insertIndex = -1; - return arrIndex[nEnd] as IndexItem; - } - } - - /// - /// Checks if a keyword exists in a index collection - /// - /// index to search (arraylist of IndexItems) - /// keywordpath to search - /// Returns the found IndexItem, otherwise null - private IndexItem ContainsIndex(ArrayList arrIndex, string keywordPath) - { - foreach(IndexItem curItem in arrIndex) - { - if(curItem.KeyWordPath == keywordPath) - return curItem; - } - - return null; - } - - /// - /// Searches the alinks- or klinks-index for a specific keyword/associative - /// - /// keyword/associative to search - /// type of index to search - /// Returns an ArrayList which contains IndexTopic items or null if nothing was found - public IndexItem SearchIndex(string search, IndexType typeOfIndex) - { - ArrayList _index = null; - - switch( typeOfIndex ) - { - case IndexType.AssiciativeLinks: _index = _aLinks;break; - case IndexType.KeywordLinks: _index = _kLinks;break; - } - - int insertIdx=0; - IndexItem foundItem = BinSearch(0, _index.Count, _index, search, true, true, ref insertIdx); - - return foundItem; - } - } -} diff --git a/irc/TechBot/CHMLibrary/IndexItem.cs b/irc/TechBot/CHMLibrary/IndexItem.cs deleted file mode 100644 index a21415880cd..00000000000 --- a/irc/TechBot/CHMLibrary/IndexItem.cs +++ /dev/null @@ -1,396 +0,0 @@ -using System; -using System.IO; -using System.Text; -using System.Collections; - -using HtmlHelp.ChmDecoding; - -namespace HtmlHelp -{ - /// - /// The class IndexItem implements an help-index item - /// - public sealed class IndexItem : IComparable - { - /// - /// Internal member storing the keyword - /// - private string _keyWord = ""; - /// - /// Internal member storing all associated information type strings - /// - private ArrayList _infoTypeStrings = new ArrayList(); - /// - /// Internal member storing the flag if this is a see-also keyword - /// - private bool _isSeeAlso = false; - /// - /// Internal member storing the indent of the keyword - /// - private int _indent = 0; - /// - /// Internal member storing the last index of the keyword in the seperated list - /// - private int _charIndex = 0; - /// - /// Internal member storing the entry index - /// - private int _entryIndex = 0; - /// - /// Internal member storing an array of see-also values - /// - private string[] _seeAlso = new string[0]; - /// - /// Internal member storing an array of topic offsets - /// - private int[] _nTopics = new int[0]; - /// - /// Internal member storing the topics - /// - private ArrayList _Topics = null; - /// - /// Associated CHMFile instance - /// - private CHMFile _chmFile = null; - /// - /// Internal flag specifying the chm file path - /// - private string _chmFileName = ""; - - /// - /// Constructor of the class - /// - /// associated CHMFile instance - /// keyword - /// true if it is a see-also keyword - /// indent of the entry - /// char index of the last keyword in the separated list - /// index of the entry - /// string array with see-also values - /// integer array with topic offsets - internal IndexItem(CHMFile chmFile, string keyWord, bool isSeeAlso, int indent, int charIndex, int entryIndex, string[] seeAlsoValues, int[] topicOffsets) - { - _chmFile = chmFile; - _chmFileName = _chmFile.ChmFilePath; - _keyWord = keyWord; - _isSeeAlso = isSeeAlso; - _indent = indent; - _charIndex = charIndex; - _entryIndex = entryIndex; - _seeAlso = seeAlsoValues; - _nTopics = topicOffsets; - } - - /// - /// Standard constructor - /// - public IndexItem() - { - } - - #region Data dumping - /// - /// Dump the class data to a binary writer - /// - /// writer to write the data - /// true if the chm filename should be written - internal void Dump(ref BinaryWriter writer, bool writeFileName) - { - int i=0; - - writer.Write(_keyWord); - writer.Write(_isSeeAlso); - writer.Write(_indent); - - if(writeFileName) - writer.Write(_chmFileName); - - writer.Write(_infoTypeStrings.Count); - - for(i=0; i<_infoTypeStrings.Count; i++) - writer.Write( (_infoTypeStrings[i]).ToString() ); - - writer.Write(_seeAlso.Length); - - for(i=0; i<_seeAlso.Length; i++) - { - if(_seeAlso[i] == null) - writer.Write(""); - else - writer.Write( _seeAlso[i] ); - } - - writer.Write(Topics.Count); - - for(i=0; i - /// Dump the class data to a binary writer - /// - /// writer to write the data - internal void Dump(ref BinaryWriter writer) - { - Dump(ref writer, false); - } - - /// - /// Reads the object data from a dump store - /// - /// reader to read the data - /// filelist from helpsystem - internal bool ReadDump(ref BinaryReader reader, ArrayList filesList) - { - int i=0; - _keyWord = reader.ReadString(); - _isSeeAlso = reader.ReadBoolean(); - _indent = reader.ReadInt32(); - _chmFileName = reader.ReadString(); - - foreach(CHMFile curFile in filesList) - { - if(curFile.ChmFilePath == _chmFileName) - { - _chmFile = curFile; - break; - } - } - - if(_chmFile==null) - return false; - - int nCnt = reader.ReadInt32(); - - for(i=0; i - /// Reads the object data from a dump store - /// - /// reader to read the data - internal void ReadDump(ref BinaryReader reader) - { - int i=0; - _keyWord = reader.ReadString(); - _isSeeAlso = reader.ReadBoolean(); - _indent = reader.ReadInt32(); - - int nCnt = reader.ReadInt32(); - - for(i=0; i - /// Implements the compareto method which allows sorting. - /// - /// object to compare to - /// See IComparable.CompareTo() - public int CompareTo(object obj) - { - if( obj.GetType() == this.GetType() ) - { - IndexItem cmp = (IndexItem)obj; - - return this.KeyWordPath.CompareTo( cmp.KeyWordPath ); - } - - return 0; - } - - /// - /// Gets/Sets the associated CHMFile instance - /// - internal CHMFile ChmFile - { - get { return _chmFile; } - set { _chmFile = value; } - } - - /// - /// Gets the ArrayList which holds all information types/categories this item is associated - /// - internal ArrayList InfoTypeStrings - { - get { return _infoTypeStrings; } - } - - /// - /// Adds a see-also string to the index item and marks it as see also item - /// - /// see also string to add - internal void AddSeeAlso(string seeAlsoString) - { - string[] seeAlso = new string[ _seeAlso.Length +1 ]; - for(int i=0; i<_seeAlso.Length; i++) - seeAlso[i] = _seeAlso[i]; - - seeAlso[_seeAlso.Length] = seeAlsoString; - _seeAlso = seeAlso; - _isSeeAlso = true; - } - - /// - /// Gets/Sets the full keyword-path of this item ( ", " separated list) - /// - public string KeyWordPath - { - get { return _keyWord; } - set { _keyWord = value; } - } - - /// - /// Gets the keyword of this item - /// - public string KeyWord - { - get - { - return _keyWord.Substring(_charIndex, _keyWord.Length-_charIndex); - } - } - - /// - /// Gets the keyword of this item with prefixing indent spaces - /// - public string IndentKeyWord - { - get - { - string sKW = this.KeyWord; - StringBuilder sb = new StringBuilder("",this.Indent*3 + sKW.Length); - for(int i=0; i - /// Gets/Sets the see-also flag of this item - /// - public bool IsSeeAlso - { - get { return _isSeeAlso; } - set { _isSeeAlso = value; } - } - - /// - /// Gets/Sets the listbox indent for this item - /// - public int Indent - { - get { return _indent; } - set { _indent = value; } - } - - /// - /// Gets/Sets the character index of an indent keyword - /// - public int CharIndex - { - get { return _charIndex; } - set { _charIndex = value; } - } - - /// - /// Gets the see-also values of this item - /// - public string[] SeeAlso - { - get { return _seeAlso; } - } - - /// - /// Gets an array with the associated topics - /// - public ArrayList Topics - { - get - { - if( _Topics == null ) - { - if(IsSeeAlso) - { - _Topics = new ArrayList(); - } - else - { - if( (_chmFile != null) && (_chmFile.TopicsFile != null) ) - { - _Topics = new ArrayList(); - - for(int i=0; i<_nTopics.Length; i++) - { - IndexTopic newTopic = IndexTopic.FromTopicEntry((TopicEntry)_chmFile.TopicsFile.TopicTable[ _nTopics[i] ]); - newTopic.AssociatedFile = _chmFile; - _Topics.Add( newTopic ); - } - } - else - { - _Topics = new ArrayList(); - } - } - } - - return _Topics; - } - } - } -} diff --git a/irc/TechBot/CHMLibrary/IndexTopic.cs b/irc/TechBot/CHMLibrary/IndexTopic.cs deleted file mode 100644 index 07c8f66d022..00000000000 --- a/irc/TechBot/CHMLibrary/IndexTopic.cs +++ /dev/null @@ -1,216 +0,0 @@ -using System; -using System.IO; - -using HtmlHelp.ChmDecoding; - -namespace HtmlHelp -{ - /// - /// The class IndexTopic implements an entry for the IndexItem topics list. - /// - public sealed class IndexTopic - { - private DataMode _topicMode = DataMode.TextBased; - private string _title=""; - private string _local=""; - private string _compileFile = ""; - private string _chmPath = ""; - private int _topicOffset = -1; - private CHMFile _associatedFile = null; - - /// - /// Creates a new instance of the class based on an existing TopicEntry - /// - /// - internal static IndexTopic FromTopicEntry(TopicEntry entry) - { - return new IndexTopic(entry.EntryOffset, entry.ChmFile); - //return new IndexTopic( entry.Title, entry.Locale, entry.ChmFile.CompileFile, entry.ChmFile.ChmFilePath); - } - - /// - /// Creates a new instance of the class (binary extraction mode) - /// - /// offset of the topic entry - /// associated CHMFile instance - internal IndexTopic(int topicOffset, CHMFile associatedFile) - { - _topicMode = DataMode.Binary; - _topicOffset = topicOffset; - _associatedFile = associatedFile; - } - - /// - /// Constructor of the class - /// - /// topic title - /// topic local (content filename) - /// name of the chm file (location of topic) - /// path of the chm file - public IndexTopic(string Title, string local, string compilefile, string chmpath) - { - _topicMode = DataMode.TextBased; - _title = Title; - _local = local; - _compileFile = compilefile; - _chmPath = chmpath; - } - - #region Data dumping - /// - /// Dump the class data to a binary writer - /// - /// writer to write the data - internal void Dump(ref BinaryWriter writer) - { - writer.Write((int)_topicMode); - - if(_topicMode==DataMode.TextBased) - { - writer.Write(_title); - writer.Write(_local); - } - else - { - writer.Write(_topicOffset); - } - } - - /// - /// Reads the object data from a dump store - /// - /// reader to read the data - internal void ReadDump(ref BinaryReader reader) - { - _topicMode = (DataMode)reader.ReadInt32(); - - if(_topicMode==DataMode.TextBased) - { - _title = reader.ReadString(); - _local = reader.ReadString(); - } - else - { - _topicOffset = reader.ReadInt32(); - } - } - #endregion - - /// - /// Internally used to set the chm-finos when reading from dump store - /// - /// - /// - internal void SetChmInfo(string compilefile, string chmpath) - { - _compileFile = compilefile; - _chmPath = chmpath; - } - - /// - /// Gets/Sets the associated CHMFile instance - /// - internal CHMFile AssociatedFile - { - get { return _associatedFile; } - set { _associatedFile = value; } - } - - /// - /// Gets the topic title - /// - public string Title - { - get - { - if((_topicMode == DataMode.Binary )&&(_associatedFile!=null)) - { - if( _topicOffset >= 0) - { - TopicEntry te = (TopicEntry) (_associatedFile.TopicsFile[_topicOffset]); - if(te != null) - { - return te.Title; - } - } - } - - return _title; - } - } - - /// - /// Gets the local (content filename) - /// - public string Local - { - get - { - if((_topicMode == DataMode.Binary )&&(_associatedFile!=null)) - { - if( _topicOffset >= 0) - { - TopicEntry te = (TopicEntry) (_associatedFile.TopicsFile[_topicOffset]); - if(te != null) - { - return te.Locale; - } - } - } - - return _local; - } - } - - /// - /// Gets the compile file (location) - /// - public string CompileFile - { - get - { - if(_associatedFile != null) - return _associatedFile.CompileFile; - - return _compileFile; - } - } - - /// - /// Gets the chm file path - /// - public string ChmFilePath - { - get - { - if(_associatedFile != null) - return _associatedFile.ChmFilePath; - - return _chmPath; - } - } - - /// - /// Gets the url - /// - public string URL - { - get - { - string sL = Local; - - if(sL.Length<=0) - return "";//"about:blank"; - - if( (sL.ToLower().IndexOf("http://") >= 0) || - (sL.ToLower().IndexOf("https://") >= 0) || - (sL.ToLower().IndexOf("mailto:") >= 0) || - (sL.ToLower().IndexOf("ftp://") >= 0) || - (sL.ToLower().IndexOf("ms-its:") >= 0)) - return sL; - - return HtmlHelpSystem.UrlPrefix + ChmFilePath + "::/" + sL; - } - } - } -} diff --git a/irc/TechBot/CHMLibrary/InformationType.cs b/irc/TechBot/CHMLibrary/InformationType.cs deleted file mode 100644 index 7f23e5c4abc..00000000000 --- a/irc/TechBot/CHMLibrary/InformationType.cs +++ /dev/null @@ -1,146 +0,0 @@ -using System; -using System.IO; - -namespace HtmlHelp -{ - /// - /// Enumeration for specifying the mode of the information type - /// - public enum InformationTypeMode - { - /// - /// Inclusive information type. The user will be allowed to select from one or more information types. - /// - Inclusive = 0, - /// - /// Exclusive information type. The user will be allowed to choose only one information type within each category - /// - Exclusive = 1, - /// - /// Hidden information type. The user cannot see this information types (only for API calls). - /// - Hidden = 2 - } - - /// - /// The class InformationType implements a methods/properties for an information type. - /// - /// Note: Information types and categories allow users to filter help contents. - /// They are only supported if using sitemap TOC and/or sitemap Index. - public class InformationType - { - private string _name = ""; - private string _description = ""; - private InformationTypeMode _typeMode = InformationTypeMode.Inclusive; - private bool _isInCategory = false; - private int _referenceCount = 1; - - /// - /// Standard constructor - /// - /// the mode is set to InformationTypeMode.Inclusive by default - public InformationType() : this("","") - { - } - - /// - /// Standard constructor - /// - /// name of the information type - /// description - /// the mode is set to InformationTypeMode.Inclusive by default - public InformationType(string name, string description) : this(name, description, InformationTypeMode.Inclusive) - { - } - - /// - /// Standard constructor - /// - /// name of the information type - /// description - /// mode of the information type - public InformationType(string name, string description, InformationTypeMode mode) - { - _name = name; - _description = description; - _typeMode = mode; - } - - #region Data dumping - /// - /// Dump the class data to a binary writer - /// - /// writer to write the data - internal void Dump(ref BinaryWriter writer) - { - writer.Write( (int)_typeMode ); - writer.Write( _name ); - writer.Write( _description ); - } - - /// - /// Reads the object data from a dump store - /// - /// reader to read the data - internal void ReadDump(ref BinaryReader reader) - { - _typeMode = (InformationTypeMode)reader.ReadInt32(); - _name = reader.ReadString(); - _description = reader.ReadString(); - } - #endregion - - /// - /// Sets the flag if this information type is nested in at least one category - /// - /// true or false - internal void SetCategoryFlag(bool newValue) - { - _isInCategory = newValue; - } - - /// - /// Gets/Sets the reference count of this information type instance - /// - internal int ReferenceCount - { - get { return _referenceCount; } - set { _referenceCount = value; } - } - - /// - /// Gets true if this information type is nested in at least one category - /// - public bool IsInCategory - { - get { return _isInCategory; } - } - - /// - /// Gets/Sets the name of the information type - /// - public string Name - { - get { return _name; } - set { _name = value; } - } - - /// - /// Gets/Sets the description of the information type - /// - public string Description - { - get { return _description; } - set { _name = value; } - } - - /// - /// Gets/Sets the mode of the information type - /// - public InformationTypeMode Mode - { - get { return _typeMode; } - set { _typeMode = value; } - } - } -} diff --git a/irc/TechBot/CHMLibrary/Storage/CHMStream.cs b/irc/TechBot/CHMLibrary/Storage/CHMStream.cs deleted file mode 100644 index 8eab65942a4..00000000000 --- a/irc/TechBot/CHMLibrary/Storage/CHMStream.cs +++ /dev/null @@ -1,2842 +0,0 @@ -using System; -using System.Diagnostics; -using System.Text; -using System.Data; -using System.Text.RegularExpressions; -using System.Collections; -using System.Collections.Specialized; -using System.IO; -using System.Runtime.InteropServices; - -namespace CHMStream -{ - /// - /// Summary description for CHMFile. - /// - /// - public class CHMStream : IDisposable - { - public MemoryStream OpenStream(chmUnitInfo Info) - { - if (Info==null) - return null; - - MemoryStream st=new MemoryStream(); - this.ExtractFile(Info,st); - return st; - } - - public MemoryStream OpenStream(string FileName) - { - chmUnitInfo info=this.GetFileInfo(FileName); - if (info==null) - return null; - return OpenStream(info); - } - - private string m_CHMFileName; - public string CHMFileName - { - get - { - return m_CHMFileName; - } - } - - public CHMStream() - { - } - - public CHMStream(string CHMFileName) - { - OpenCHM(CHMFileName); - } - - public void OpenCHM(string CHMFileName) - { - m_CHMFileName=CHMFileName; - FileInfo fi=new FileInfo(m_CHMFileName); - Dir=fi.DirectoryName; - m_CHMName=fi.Name; - fi=null; - chm_open(m_CHMFileName); - } - - private bool m_bCHMLoaded=false; - public bool CHMLoaded - { - get - { - return m_bCHMLoaded; - } - } - - private string m_CHMName=""; - public string CHMName - { - get - { - return m_CHMName; - } - } - - private string Dir=""; - private string m_FileFind=""; - private string m_FileFindLastPart=""; - private chmUnitInfo m_FileInfo=null; - private int m_FileCount=0; - public void FindFile(chmUnitInfo Info, ref CHMStream.CHM_ENUMERATOR Status) - { - string LocalFile=Info.path; - LocalFile=LocalFile.Replace("/",@"\"); - if (!LocalFile.StartsWith(@"\")) - LocalFile=@"\"+LocalFile; - LocalFile=LocalFile.ToLower(); - - if (m_FileFind.Length<=LocalFile.Length) - { - if (LocalFile.IndexOf(m_FileFind)==LocalFile.Length-m_FileFind.Length) - { - Status=CHMStream.CHM_ENUMERATOR.CHM_ENUMERATOR_SUCCESS; - m_FileInfo=Info; - return; - } - } - Status=CHMStream.CHM_ENUMERATOR.CHM_ENUMERATOR_CONTINUE; - } - - public void FileCount(chmUnitInfo Info, ref CHMStream.CHM_ENUMERATOR Status) - { - m_FileCount++; - Status=CHMStream.CHM_ENUMERATOR.CHM_ENUMERATOR_CONTINUE; - } - - private ArrayList m_FileList=null; - private string m_strByExt=""; - public void FileList(chmUnitInfo Info, ref CHMStream.CHM_ENUMERATOR Status) - { - m_FileList.Add(Info.path); - Status=CHMStream.CHM_ENUMERATOR.CHM_ENUMERATOR_CONTINUE; - } - - public void FileListByExtension(chmUnitInfo Info, ref CHMStream.CHM_ENUMERATOR Status) - { - FileInfo fi=new FileInfo(Info.path); - if (fi.Extension.ToLower()==m_strByExt.ToLower()) - m_FileList.Add(Info.path); - Status=CHMStream.CHM_ENUMERATOR.CHM_ENUMERATOR_CONTINUE; - } - - public void FindFileIndex(chmUnitInfo Info, ref CHMStream.CHM_ENUMERATOR Status) - { - if (m_FileCount==m_FileFindIndex) - { - m_FileInfo=Info; - Status=CHMStream.CHM_ENUMERATOR.CHM_ENUMERATOR_SUCCESS; - } - else - { - m_FileCount++; - Status=CHMStream.CHM_ENUMERATOR.CHM_ENUMERATOR_CONTINUE; - } - } - - public int GetFileCount() - { - if (!m_bCHMLoaded) - return 0; - - m_FileCount=0; - this.CHMFileFoundEvent+=new CHMStream.CHMFileFound(FileCount); - this.chm_enumerate(CHM_ENUMERATE.CHM_ENUMERATE_ALL); - this.CHMFileFoundEvent-=new CHMStream.CHMFileFound(FileCount); - return m_FileCount; - } - - public ArrayList GetFileList() - { - if (!m_bCHMLoaded) - return null; - - m_FileList=null; - m_FileList=new ArrayList(1000); - this.CHMFileFoundEvent+=new CHMStream.CHMFileFound(FileList); - this.chm_enumerate(CHM_ENUMERATE.CHM_ENUMERATE_ALL); - this.CHMFileFoundEvent-=new CHMStream.CHMFileFound(FileList); - return m_FileList; - } - - public ArrayList GetFileListByExtenstion(string Ext) - { - if (!m_bCHMLoaded) - return null; - - m_FileList=null; - m_FileList=new ArrayList(1000); - m_strByExt=Ext; - this.CHMFileFoundEvent+=new CHMStream.CHMFileFound(FileListByExtension); - this.chm_enumerate(CHM_ENUMERATE.CHM_ENUMERATE_ALL); - this.CHMFileFoundEvent-=new CHMStream.CHMFileFound(FileListByExtension); - return m_FileList; - } - - public chmUnitInfo GetFileInfo(string FileName) - { - if (!m_bCHMLoaded) - return null; - - m_FileFind=FileName.ToLower().Replace("/",@"\"); - - // Remove all leading '..\' - do - { - if (m_FileFind.StartsWith(@"..\")) - m_FileFind=m_FileFind.Substring(3); - else - break; - } - while(true); - - if (!m_FileFind.StartsWith(@"\")) - m_FileFind=@"\"+m_FileFind; - - string []parts=m_FileFind.Split('\\'); - m_FileFindLastPart=@"\"+parts[parts.GetUpperBound(0)]; - - this.CHMFileFoundEvent+=new CHMStream.CHMFileFound(FindFile); - m_FileInfo=null; - this.chm_enumerate(CHM_ENUMERATE.CHM_ENUMERATE_ALL); - this.CHMFileFoundEvent-=new CHMStream.CHMFileFound(FindFile); - return m_FileInfo; - } - - private int m_FileFindIndex=0; - public chmUnitInfo GetFileInfo(int FileIndex) - { - if (!m_bCHMLoaded) - return null; - - m_FileFindIndex=FileIndex; - - this.CHMFileFoundEvent+=new CHMStream.CHMFileFound(FindFileIndex); - m_FileCount=0; - m_FileInfo=null; - this.chm_enumerate(CHM_ENUMERATE.CHM_ENUMERATE_ALL); - this.CHMFileFoundEvent-=new CHMStream.CHMFileFound(FindFileIndex); - return m_FileInfo; - } - - public chmUnitInfo GetFileInfoByExtension(string Ext) - { - this.CHMFileFoundEvent+=new CHMStream.CHMFileFound(FindFileByExtension); - m_FileInfo=null; - m_FileFind=Ext.ToLower(); - this.chm_enumerate(CHMStream.CHM_ENUMERATE.CHM_ENUMERATE_ALL); - this.CHMFileFoundEvent-=new CHMStream.CHMFileFound(FindFileByExtension); - return m_FileInfo; - } - - public bool ExtractFile(string FileName, System.IO.Stream st) - { - if (!m_bCHMLoaded) - return false; - - chmUnitInfo Info=GetFileInfo(FileName); - return ExtractFile(Info,st); - } - - public bool ExtractFile(chmUnitInfo Info, System.IO.Stream st) - { - if (!m_bCHMLoaded) - return false; - - if (Info==null) - return false; - else - { - chm_retrieve_object(Info,st,0,Info.length); - } - return true; - } - - public string ExtractTextFile(string FileName) - { - if (!m_bCHMLoaded) - return "CHM File not loaded"; - - chmUnitInfo Info=GetFileInfo(FileName); - return ExtractTextFile(Info); - } - - public string ExtractTextFile(chmUnitInfo Info) - { - if (!m_bCHMLoaded) - return "CHM File not loaded"; - - if (Info==null) - return ""; - - if (Info.path.Length>=2) - { - if (Info.path.Substring(0,2).CompareTo("/#")==0) - return ""; - if (Info.path.Substring(0,2).CompareTo("/$")==0) - return ""; - } - - MemoryStream st=new MemoryStream((int)Info.length); - this.chm_retrieve_object(Info,st,0,Info.length); - - if (st.Length==0) - return ""; - - string Text=""; - - ASCIIEncoding ascii=new ASCIIEncoding(); - Text=ascii.GetString(st.ToArray(),0,50); - - // UTF Decoding - if (Text.IndexOf("UTF-8")!=-1) - { - UTF8Encoding utf8 = new UTF8Encoding(); - Text=utf8.GetString(st.ToArray(),0,(int)st.Length); - } - else - Text=ascii.GetString(st.ToArray(),0,(int)st.Length); - - return Text; - } - - public void FindFileByExtension(chmUnitInfo Info, ref CHMStream.CHM_ENUMERATOR Status) - { - if ((Info.path.StartsWith("::")) || (Info.path.StartsWith("#")) ||(Info.path.StartsWith("$"))) - { - Status=CHMStream.CHM_ENUMERATOR.CHM_ENUMERATOR_CONTINUE; - return; - } - - FileInfo Fi=new FileInfo(Info.path); - if (Fi.Extension.ToLower()==m_FileFind) - { - Status=CHMStream.CHM_ENUMERATOR.CHM_ENUMERATOR_SUCCESS; - m_FileInfo=Info; - } - else - Status=CHMStream.CHM_ENUMERATOR.CHM_ENUMERATOR_CONTINUE; - } - - public bool GetCHMParts(string Url, ref string CHMFileName, ref string FileName, ref string Anchor) - { - Regex ParseURLRegEx= new Regex( @"ms-its:(?'CHMFile'.*)::(?'Topic'.*)", RegexOptions.IgnoreCase| RegexOptions.Singleline | RegexOptions.ExplicitCapture| RegexOptions.IgnorePatternWhitespace| RegexOptions.Compiled); - - // Parse URL - Get CHM Filename & Page Name - // Format 'ms-its:file name.chm::/topic.htm' - if (ParseURLRegEx.IsMatch(Url)) - { - Match m=ParseURLRegEx.Match(Url); - CHMFileName=m.Groups["CHMFile"].Value; - string Topic=m.Groups["Topic"].Value; - int idx=Topic.IndexOf("#"); - if (idx>-1) - { - FileName=Topic.Substring(0,idx); - Anchor=Topic.Substring(idx+1); - } - else - FileName=Topic; - return true; - } - return false; - } - - private string m_TempDir=""; - string ReplaceFileName(Match m) - { - string strReplace = m.ToString(); - - // Process string. - if (m.Groups["FileName"]==null) - return strReplace; - - string FileName=m.Groups["FileName"].Value; - string FileName2=FileName.Replace("/",@"\"); - int idx=FileName2.IndexOf("::"); - if (idx!=-1) - FileName2=FileName2.Substring(idx+2); - string []parts=FileName2.Split('\\'); - string NewName=@"file://"+m_TempDir+parts[parts.GetUpperBound(0)]; - - strReplace=strReplace.Replace(FileName,NewName); - return strReplace; - } - - public ArrayList GetFileList(ref string Text, string TempDir) - { - if (!m_bCHMLoaded) - return null; - - m_TempDir=TempDir; - - ArrayList FilesList=new ArrayList(); - - // Parse HTML for CCS, ima, etc - string regexContent=@"[\x2f a-zA-Z0-9\x5C\x2E\x28\x29\x23\x24\x25\x26\x27\x22\x21\x3F\x3E\x3D\x3C\x3B\x3A\x5B\x5D\x5E\x5F\x7D\x7C\x7B\x7E\x40\x2D\x2C\x2B\x2A]*\s*"; - string regexFileName=@"\s*=\s*[""|'](?'FileName'[^""^']*)[""|']\s*"; - - Regex ScriptRegex = new Regex(@"]*>.*", - RegexOptions.IgnoreCase - | RegexOptions.Multiline - | RegexOptions.Singleline - | RegexOptions.IgnorePatternWhitespace - | RegexOptions.Compiled); - - Regex XMLRegex = new Regex(@"<\?xml.*\?>", - RegexOptions.IgnoreCase - | RegexOptions.Multiline - | RegexOptions.Singleline - | RegexOptions.IgnorePatternWhitespace - | RegexOptions.Compiled); - - Regex XMLRegex2 = new Regex(@"]*>.*", - RegexOptions.IgnoreCase - | RegexOptions.Multiline - | RegexOptions.Singleline - | RegexOptions.IgnorePatternWhitespace - | RegexOptions.Compiled); - - Regex SRCRegex = new Regex( - @"src"+regexFileName, - RegexOptions.IgnoreCase - | RegexOptions.Multiline - | RegexOptions.Singleline - | RegexOptions.IgnorePatternWhitespace - | RegexOptions.Compiled); - - Regex StyleSheetRegex = new Regex( - @" 0; i--) - { - UInt32 curBlockIdx = (UInt32)(block-i); - - /* check if we most recently decompressed the previous block */ - if ((ulong)lzx_last_block != curBlockIdx) - { - if ((curBlockIdx % reset_blkcount)==0) - { - lzx_state.LZXreset(); - } - - _chm_get_cmpblock_bounds(st,curBlockIdx, ref cmpStart, ref cmpLen); - st.BaseStream.Seek((long)cmpStart,SeekOrigin.Begin); - if (lzx_state.LZXdecompress(st,OutBuffer, ref cmpLen, ref reset_table.block_len) != lzw.DECR_OK) - return (Int64)0; - } - lzx_last_block = (int)(curBlockIdx); - } - } - else - { - if ((block % reset_blkcount)==0) - { - lzx_state.LZXreset(); - } - } - - // decompress the block we actually want - if (_chm_get_cmpblock_bounds(st, block, ref cmpStart, ref cmpLen)==0) - return 0; - - st.BaseStream.Seek((long)cmpStart,SeekOrigin.Begin); - - if (lzx_state.LZXdecompress(st, OutBuffer, ref cmpLen,ref reset_table.block_len) != lzw.DECR_OK) - return (Int64)0; - - lzx_last_block = (int)block; - - // XXX: modify LZX routines to return the length of the data they - // * decompressed and return that instead, for an extra sanity check. - return reset_table.block_len; - } - - // grab a region from a compressed block - private ulong _chm_decompress_region(Stream buf, ulong start, ulong len) - { - ulong nBlock, nOffset; - ulong nLen; - ulong gotLen; - // byte [] ubuffer=null; - - if (len <= 0) - return (Int64)0; - - // figure out what we need to read - nBlock = start / reset_table.block_len; - nOffset = start % reset_table.block_len; - nLen = len; - if (nLen > (reset_table.block_len - nOffset)) - nLen = reset_table.block_len - nOffset; - - // data request not satisfied, so... start up the decompressor machine - if (lzx_state==null) - { - int window_size = ffs(this.window_size) - 1; - lzx_last_block = -1; - - lzx_state=new lzw(); - lzx_state.LZXinit(window_size); - } - - // decompress some data - MemoryStream ms=new MemoryStream((int)reset_table.block_len+6144); - gotLen = _chm_decompress_block(nBlock, ms); - if (gotLen < nLen) - nLen = gotLen; - - // memcpy(buf, ubuffer+nOffset, (unsigned int)nLen); - ms.Position=(long)nOffset; - for(ulong i=0;i= (ulong)ui.length) - return (Int64)0; - - // clip length - if (addr + (ulong)len > (ulong)ui.length) - len = (ulong)ui.length - (ulong)addr; - - // if the file is uncompressed, it's simple - if (ui.space == CHMStream.CHM_COMPRESSION.CHM_UNCOMPRESSED) - { - // read data - long FilePos=st.BaseStream.Position; - st.BaseStream.Seek((long)((long)data_offset + (long)ui.start + (long)addr),SeekOrigin.Begin); - // byte [] buffer=st.ReadBytes((int)len); - buf.Write(st.ReadBytes((int)len),0,(int) len); - st.BaseStream.Seek(FilePos,SeekOrigin.Begin); - return (ulong)len; - } - - // else if the file is compressed, it's a little trickier - else // ui->space == CHM_COMPRESSED - { - if (lzx_state!=null) - { - lzx_state.LZXteardown(); - lzx_state=null; - } - ulong swath=0, total=0; - do - { - if (!compression_enabled) - return total; - - // swill another mouthful - swath = _chm_decompress_region(buf, ui.start + addr, len); - - // if we didn't get any... - if (swath == 0) - { - Trace.Assert((total!=ui.length),"De-compress failed","Length Required = "+ui.length.ToString()+" Length returned = "+total.ToString()); - return total; - } - - // update stats - total += swath; - len -= swath; - addr += swath; - } while (len != 0); - lzx_state=null; - - Trace.Assert((len!=ui.length),"De-compress failed","Length Required = "+ui.length.ToString()+" Length returned = "+len.ToString()); - return len; - } - } - #endregion - - #region Enumerate functions - // Enumerate the objects in the .chm archive - // Use delegate to handle callback - - public delegate void CHMFileFound(chmUnitInfo Info, ref CHMStream.CHM_ENUMERATOR Status); - public event CHMFileFound CHMFileFoundEvent; - - public void OnFileFound(chmUnitInfo Info, ref CHMStream.CHM_ENUMERATOR Status) - { - if (CHMFileFoundEvent!=null) - CHMFileFoundEvent(Info,ref Status); - } - private int chm_enumerate(CHM_ENUMERATE what) - { - Int32 curPage; - - // buffer to hold whatever page we're looking at - chmPmglHeader header; - uint end=0; - uint cur=0; - - // the current ui - chmUnitInfo ui= new chmUnitInfo(); - CHMStream.CHM_ENUMERATE flag=CHMStream.CHM_ENUMERATE.None; - - // starting page - curPage = index_head; - - // until we have either returned or given up - while (curPage != -1) - { - st.BaseStream.Seek((long)((long)dir_offset + (long)(curPage*block_len)),SeekOrigin.Begin); - - // figure out start and end for this page - cur = (uint)st.BaseStream.Position; - - header=new chmPmglHeader(); - if (header.Read_pmgl_header(st)==0) - return 0; - - end = (uint)(st.BaseStream.Position + block_len - (header.free_space)- chmPmglHeader._CHM_PMGL_LEN); - - // loop over this page - while (st.BaseStream.Position < end) - { - if (header._chm_parse_PMGL_entry(st,ref ui)==0) - return 0; - - // check for DIRS - if (ui.length == 0 && ((what & CHM_ENUMERATE.CHM_ENUMERATE_DIRS)==0)) - continue; - - // check for FILES - if (ui.length != 0 && ((what & CHM_ENUMERATE.CHM_ENUMERATE_FILES)==0)) - continue; - - // check for NORMAL vs. META - if (ui.path[0] == '/') - { - // check for NORMAL vs. SPECIAL - if (ui.path.Length>2) - { - if (ui.path[1] == '#' || ui.path[1] == '$') - flag = CHMStream.CHM_ENUMERATE.CHM_ENUMERATE_SPECIAL; - else - flag = CHMStream.CHM_ENUMERATE.CHM_ENUMERATE_NORMAL; - } - else - flag = CHMStream.CHM_ENUMERATE.CHM_ENUMERATE_META; - if ((what & flag)==0) - continue; - } - - // call the enumerator - { - CHMStream.CHM_ENUMERATOR status = CHMStream.CHM_ENUMERATOR.CHM_ENUMERATOR_CONTINUE; - OnFileFound(ui,ref status); - - switch (status) - { - case CHMStream.CHM_ENUMERATOR.CHM_ENUMERATOR_FAILURE: - return 0; - - case CHMStream.CHM_ENUMERATOR.CHM_ENUMERATOR_CONTINUE: - break; - - case CHMStream.CHM_ENUMERATOR.CHM_ENUMERATOR_SUCCESS: - return 1; - - default: - break; - } - } - } - - // advance to next page - curPage = header.block_next; - } - - return 1; - } - #endregion - - #region IDisposable Members - - private bool disposed=false; - public void Dispose() - { - Dispose(true); - // This object will be cleaned up by the Dispose method. - // Therefore, you should call GC.SupressFinalize to - // take this object off the finalization queue - // and prevent finalization code for this object - // from executing a second time. - GC.SuppressFinalize(this); - } - - /// - /// Dispose(bool disposing) executes in two distinct scenarios. - /// If disposing equals true, the method has been called directly - /// or indirectly by a user's code. Managed and unmanaged resources - /// can be disposed. - /// If disposing equals false, the method has been called by the - /// runtime from inside the finalizer and you should not reference - /// other objects. Only unmanaged resources can be disposed. - /// - /// disposing flag - private void Dispose(bool disposing) - { - // Check to see if Dispose has already been called. - if(!this.disposed) - { - // If disposing equals true, dispose all managed - // and unmanaged resources. - if(disposing) - { - // Dispose managed resources. - } - } - disposed = true; - } - - #endregion - } - - #region Structures used by CHM Storage - public class BaseStructure - { - public bool CheckSig(string Sig1, char[] Sig2) - { - int i=0; - foreach(char ch in Sig1.ToCharArray()) - { - if (ch!=Sig2[i]) - return false; - i++; - } - return true; - } - - // skip a compressed dword - public void skip_cword(BinaryReader st) - { - byte b=0; - while ((b=st.ReadByte())>= 0x80); - } - - // skip the data from a PMGL entry - public void _chm_skip_PMGL_entry_data(BinaryReader st) - { - skip_cword(st); - skip_cword(st); - skip_cword(st); - } - - // parse a compressed dword - public UInt64 _chm_parse_cword(BinaryReader st) - { - UInt64 accum = 0; - byte temp=0; - while ((temp=st.ReadByte()) >= 0x80) - { - accum <<= 7; - accum += (ulong)(temp & 0x7f); - } - - return (accum << 7) + temp; - } - - // parse a utf-8 string into an ASCII char buffer - public int _chm_parse_UTF8(BinaryReader st, UInt64 count, ref string path) - { - UTF8Encoding utf8=new UTF8Encoding(); - path=utf8.GetString(st.ReadBytes((int)count),0,(int)count); - return 1; - } - } - - public class chmUnitInfo - { - public UInt64 start=0; - public UInt64 length=0; - public CHMStream.CHM_COMPRESSION space=CHMStream.CHM_COMPRESSION.CHM_UNCOMPRESSED; - public string path=""; - } - - // structure of ITSF headers - public class chmItsfHeader : BaseStructure - { - public const int _CHM_ITSF_V2_LEN=0x58; - public const int _CHM_ITSF_V3_LEN=0x60; - - public char[] signature=null; // 0 (ITSF) - public Int32 version=0; // 4 - public Int32 header_len=0; // 8 - public Int32 unknown_000c=0; // c - public UInt32 last_modified=0; // 10 - public UInt32 lang_id=0; // 14 - public Guid dir_uuid; // 18 - public Guid stream_uuid; // 28 - public UInt64 unknown_offset=0; // 38 - public UInt64 unknown_len=0; // 40 - public UInt64 dir_offset=0; // 48 - public UInt64 dir_len=0; // 50 - public UInt64 data_offset=0; // 58 (Not present before V3) - - public int Read_itsf_header(BinaryReader st) - { - signature=st.ReadChars(4); - if (CheckSig("ITSF",signature)==false) - return 0; - - version=st.ReadInt32(); - header_len=st.ReadInt32(); - unknown_000c=st.ReadInt32(); - last_modified=st.ReadUInt32(); - lang_id=st.ReadUInt32(); - dir_uuid=new Guid(st.ReadBytes(16)); - stream_uuid=new Guid(st.ReadBytes(16)); - unknown_offset=st.ReadUInt64(); - unknown_len=st.ReadUInt64(); - dir_offset=st.ReadUInt64(); - dir_len=st.ReadUInt64(); - - if (version==2) - { - if (header_len != chmItsfHeader._CHM_ITSF_V2_LEN) - return 0; - } - else if (version==3) - { - if (header_len != chmItsfHeader._CHM_ITSF_V3_LEN) - return 0; - } - else return 0; - - if (version==3) - data_offset=st.ReadUInt64(); - else - data_offset = dir_offset + dir_len; - - return 1; - } - } - - // structure of ITSP headers - public class chmItspHeader : BaseStructure - { - const int CHM_ITSP_V1_LEN=0x54; - - public char[] signature=null; // 0 (ITSP) - public Int32 version=0; - public Int32 header_len=0; - public Int32 unknown_000c=0; - public UInt32 block_len=0; - public Int32 blockidx_intvl=0; - public Int32 index_depth=0; - public Int32 index_root=0; - public Int32 index_head=0; - public Int32 unknown_0024=0; - public Int32 num_blocks=0; - public Int32 unknown_002c=0; - public UInt32 lang_id=0; - public Guid system_uuid; - public Guid unknown_0044; - - public int Read_itsp_header(BinaryReader st) - { - signature=st.ReadChars(4); // 0 (ITSP) - if (CheckSig("ITSP",signature)==false) - return 0; - - version=st.ReadInt32(); - header_len=st.ReadInt32(); - - if (header_len!=CHM_ITSP_V1_LEN) - return 0; - - unknown_000c=st.ReadInt32(); - block_len=st.ReadUInt32(); - blockidx_intvl=st.ReadInt32(); - index_depth=st.ReadInt32(); - index_root=st.ReadInt32(); - index_head=st.ReadInt32(); - unknown_0024=st.ReadInt32(); - num_blocks=st.ReadInt32(); - unknown_002c=st.ReadInt32(); - lang_id=st.ReadUInt32(); - system_uuid=new Guid(st.ReadBytes(16)); - unknown_0044=new Guid(st.ReadBytes(16)); - - return 1; - } - } - - public class chmPmglHeader : BaseStructure - { - public const int _CHM_PMGL_LEN=0x14; - public char[] signature=null; // 0 (PMGL) - public UInt32 free_space=0; // 4 - public UInt32 unknown_0008=0; // 8 - public Int32 block_prev=0; // c - public Int32 block_next=0; // 10 - - public int Read_pmgl_header(BinaryReader st) - { - signature=st.ReadChars(4); - if (CheckSig("PMGL",signature)==false) - return 0; - - free_space=st.ReadUInt32(); - unknown_0008=st.ReadUInt32(); - block_prev=st.ReadInt32(); - block_next=st.ReadInt32(); - return 1; - } - - // parse a PMGL entry into a chmUnitInfo struct; return 1 on success. - public int _chm_parse_PMGL_entry(BinaryReader st, ref chmUnitInfo ui) - { - UInt64 strLen; - - // parse str len - strLen = _chm_parse_cword(st); - - // parse path - if (_chm_parse_UTF8(st, strLen, ref ui.path)==0) - return 0; - - // parse info - ui.space = (CHMStream.CHM_COMPRESSION)_chm_parse_cword(st); - ui.start = _chm_parse_cword(st); - ui.length = _chm_parse_cword(st); - return 1; - } - - public chmUnitInfo FindObject(BinaryReader st, UInt32 block_len, string objPath) - { - UInt32 end = (UInt32)st.BaseStream.Position+ block_len - free_space - _CHM_PMGL_LEN; - - // now, scan progressively - chmUnitInfo FoundObject=new chmUnitInfo(); - - while (st.BaseStream.Position < end) - { - _chm_parse_PMGL_entry(st,ref FoundObject); - if (FoundObject.path.ToLower().CompareTo(objPath.ToLower())==0) - return FoundObject; - } - FoundObject=null; - - return null; - } - } - - public class chmPmgiHeader : BaseStructure - { - public const int _CHM_PMGI_LEN=0x8; - - public char[] signature=null; // 0 (PMGL) - public UInt32 free_space=0; // 4 - - public int Read_pmgi_header(BinaryReader st) - { - signature=st.ReadChars(4); - - if ((signature[0]!='P') || (signature[1]!='M') || (signature[2]!='G') || (signature[3]!='I')) - return 0; - - free_space=st.ReadUInt32(); - return 1; - } - - public Int32 _chm_find_in_PMGI(BinaryReader st, UInt32 block_len, string objPath) - { - int page=-1; - UInt64 strLen; - string buffer=""; - uint end = (uint)st.BaseStream.Position + block_len - free_space - _CHM_PMGI_LEN; - - // now, scan progressively - while (st.BaseStream.Position < end) - { - // grab the name - strLen = _chm_parse_cword(st); - buffer=""; - if (_chm_parse_UTF8(st, strLen, ref buffer)==0) - return -1; - - // check if it is the right name - if (buffer.ToLower().CompareTo(objPath.ToLower())>0) - return page; - - // load next value for path - page = (int)_chm_parse_cword(st); - } - return page; - } - } - - public class chmLzxcResetTable:BaseStructure - { - public UInt32 version=0; - public UInt32 block_count=0; - public UInt32 unknown=0; - public UInt32 table_offset=0; - public UInt64 uncompressed_len=0; - public UInt64 compressed_len=0; - public UInt64 block_len=0; - - public int Read_lzxc_reset_table(BinaryReader st) - { - version=st.ReadUInt32(); - block_count=st.ReadUInt32(); - unknown=st.ReadUInt32(); - table_offset=st.ReadUInt32(); - uncompressed_len=st.ReadUInt64(); - compressed_len=st.ReadUInt64(); - block_len=st.ReadUInt64(); - - // check structure - if (version != 2) - return 0; - else - return 1; - } - } - - // structure of LZXC control data block - public class chmLzxcControlData:BaseStructure - { - public const int _CHM_LZXC_MIN_LEN=0x18; - public const int _CHM_LZXC_V2_LEN=0x1c; - - public UInt32 size=0; // 0 - public char[] signature=null; // 4 (LZXC) - public UInt32 version=0; // 8 - public UInt32 resetInterval=0; // c - public UInt32 windowSize=0; // 10 - public UInt32 windowsPerReset=0; // 14 - public UInt32 unknown_18=0; // 18 - - public int Read_lzxc_control_data(BinaryReader st) - { - size=st.ReadUInt32(); - signature=st.ReadChars(4); - - if (CheckSig("LZXC",signature)==false) - return 0; - - version=st.ReadUInt32(); - resetInterval=st.ReadUInt32(); - windowSize=st.ReadUInt32(); - windowsPerReset=st.ReadUInt32(); - - if (size>=_CHM_LZXC_V2_LEN) - unknown_18=st.ReadUInt32(); - else - unknown_18 = 0; - - if (version == 2) - { - resetInterval *= 0x8000; - windowSize *= 0x8000; - } - if (windowSize == 0 || resetInterval == 0) - return 0; - - // for now, only support resetInterval a multiple of windowSize/2 - if (windowSize == 1) - return 0; - if ((resetInterval % (windowSize/2)) != 0) - return 0; - - return 1; - } - } - #endregion - - #region LZW Decoder - - internal class lzx_bits - { - public UInt32 bb=0; - public int bl=0; - } - - internal class lzw - { - public lzw() - { - } - - /* $Id: lzx.c,v 1.5 2002/10/09 01:16:33 jedwin Exp $ */ - /*************************************************************************** - * lzx.c - LZX decompression routines * - * ------------------- * - * * - * maintainer: Jed Wing * - * source: modified lzx.c from cabextract v0.5 * - * notes: This file was taken from cabextract v0.5, which was, * - * itself, a modified version of the lzx decompression code * - * from unlzx. * - * * - * platforms: In its current incarnation, this file has been tested on * - * two different Linux platforms (one, redhat-based, with a * - * 2.1.2 glibc and gcc 2.95.x, and the other, Debian, with * - * 2.2.4 glibc and both gcc 2.95.4 and gcc 3.0.2). Both were * - * Intel x86 compatible machines. * - ***************************************************************************/ - - /*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. Note that an exemption to this * - * license has been granted by Stuart Caie for the purposes of * - * distribution with CHMFile. This does not, to the best of my * - * knowledge, constitute a change in the license of this (the LZX) code * - * in general. * - * * - ***************************************************************************/ - - /* some constants defined by the LZX specification */ - private const int LZX_MIN_MATCH = 2; - private const int LZX_MAX_MATCH = 257; - private const int LZX_NUM_CHARS = 256; - private const int LZX_BLOCKTYPE_INVALID = 0; /* also blocktypes 4-7 invalid */ - private const int LZX_BLOCKTYPE_VERBATIM = 1; - private const int LZX_BLOCKTYPE_ALIGNED = 2; - private const int LZX_BLOCKTYPE_UNCOMPRESSED = 3; - private const int LZX_PRETREE_NUM_ELEMENTS = 20; - private const int LZX_ALIGNED_NUM_ELEMENTS = 8; /* aligned offset tree #elements */ - private const int LZX_NUM_PRIMARY_LENGTHS = 7; /* this one missing from spec! */ - private const int LZX_NUM_SECONDARY_LENGTHS = 249; /* length tree #elements */ - - /* LZX huffman defines: tweak tablebits as desired */ - private const int LZX_PRETREE_MAXSYMBOLS = LZX_PRETREE_NUM_ELEMENTS; - private const int LZX_PRETREE_TABLEBITS = 6; - private const int LZX_MAINTREE_MAXSYMBOLS = LZX_NUM_CHARS + 50*8; - private const int LZX_MAINTREE_TABLEBITS = 12; - private const int LZX_LENGTH_MAXSYMBOLS = LZX_NUM_SECONDARY_LENGTHS+1; - private const int LZX_LENGTH_TABLEBITS = 12; - private const int LZX_ALIGNED_MAXSYMBOLS = LZX_ALIGNED_NUM_ELEMENTS; - private const int LZX_ALIGNED_TABLEBITS = 7; - private const int LZX_LENTABLE_SAFETY = 64; /* we allow length table decoding overruns */ - - public const int DECR_OK = 0; - public const int DECR_DATAFORMAT = 1; - public const int DECR_ILLEGALDATA = 2; - public const int DECR_NOMEMORY = 3; - - private byte[] window; /* the actual decoding window */ - private ulong window_size; /* window size (32Kb through 2Mb) */ - private ulong actual_size; /* window size when it was first allocated */ - private ulong window_posn; /* current offset within the window */ - private ulong R0, R1, R2; /* for the LRU offset system */ - private UInt32 main_elements; /* number of main tree elements */ - private int header_read; /* have we started decoding at all yet? */ - private UInt32 block_type; /* type of this block */ - private ulong block_length; /* uncompressed length of this block */ - private ulong block_remaining; /* uncompressed bytes still left to decode */ - private ulong frames_read; /* the number of CFDATA blocks processed */ - private long intel_filesize; /* magic header value used for transform */ - private long intel_curpos; /* current offset in transform space */ - private int intel_started; /* have we seen any translatable data yet? */ - - - private uint [] PRETREE_table = new uint[(1<<(6)) + (((20))<<1)]; - private byte [] PRETREE_len = new byte [((20)) + (64)]; - - private uint [] MAINTREE_table= new uint[(1<<(12)) + (((256) + 50*8)<<1)]; - private byte [] MAINTREE_len = new byte [((256) + 50*8) + (64)]; - - private uint [] LENGTH_table= new uint[(1<<(12)) + (((249)+1)<<1)]; - private byte [] LENGTH_len = new byte [((249)+1) + (64)]; - - private uint [] ALIGNED_table= new uint[(1<<(7)) + (((8))<<1)]; - private byte [] ALIGNED_len = new byte [((8)) + (64)]; - private System.IO.BinaryReader BitSource=null; - private System.IO.Stream OutputStream=null; - - /* LZX decruncher */ - - /* Microsoft's LZX document and their implementation of the - * com.ms.util.cab Java package do not concur. - * - * In the LZX document, there is a table showing the correlation between - * window size and the number of position slots. It states that the 1MB - * window = 40 slots and the 2MB window = 42 slots. In the implementation, - * 1MB = 42 slots, 2MB = 50 slots. The actual calculation is 'find the - * first slot whose position base is equal to or more than the required - * window size'. This would explain why other tables in the document refer - * to 50 slots rather than 42. - * - * The constant NUM_PRIMARY_LENGTHS used in the decompression pseudocode - * is not defined in the specification. - * - * The LZX document does not state the uncompressed block has an - * uncompressed length field. Where does this length field come from, so - * we can know how large the block is? The implementation has it as the 24 - * bits following after the 3 blocktype bits, before the alignment - * padding. - * - * The LZX document states that aligned offset blocks have their aligned - * offset huffman tree AFTER the main and length trees. The implementation - * suggests that the aligned offset tree is BEFORE the main and length - * trees. - * - * The LZX document decoding algorithm states that, in an aligned offset - * block, if an extra_bits value is 1, 2 or 3, then that number of bits - * should be read and the result added to the match offset. This is - * correct for 1 and 2, but not 3, where just a huffman symbol (using the - * aligned tree) should be read. - * - * Regarding the E8 preprocessing, the LZX document states 'No translation - * may be performed on the last 6 bytes of the input block'. This is - * correct. However, the pseudocode provided checks for the *E8 leader* - * up to the last 6 bytes. If the leader appears between -10 and -7 bytes - * from the end, this would cause the next four bytes to be modified, at - * least one of which would be in the last 6 bytes, which is not allowed - * according to the spec. - * - * The specification states that the huffman trees must always contain at - * least one element. However, many CAB files contain blocks where the - * length tree is completely empty (because there are no matches), and - * this is expected to succeed. - */ - - /* LZX uses what it calls 'position slots' to represent match offsets. - * What this means is that a small 'position slot' number and a small - * offset from that slot are encoded instead of one large offset for - * every match. - * - position_base is an index to the position slot bases - * - extra_bits states how many bits of offset-from-base data is needed. - */ - private byte [] extra_bits = { - 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, 14, 14, - 15, 15, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, - 17, 17, 17 - }; - - private ulong [] position_base = { - 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, 32768, 49152, - 65536, 98304, 131072, 196608, 262144, 393216, 524288, 655360, 786432, 917504, 1048576, 1179648, 1310720, 1441792, 1572864, 1703936, - 1835008, 1966080, 2097152 - }; - - private UInt32 ReadUInt16() - { - UInt32 rc=0; - UInt32 Byte1=0; - UInt32 Byte2=0; - try - { - Byte1=BitSource.ReadByte(); - Byte2=BitSource.ReadByte(); - } - catch(Exception) - { - } - rc=(Byte2<<8)+Byte1; - return rc; - } - - public bool LZXinit(int WindowSize) - { - ulong wndsize = (ulong)(1 << WindowSize); - int i, posn_slots; - - /* LZX supports window sizes of 2^15 (32Kb) through 2^21 (2Mb) */ - /* if a previously allocated window is big enough, keep it */ - if (WindowSize< 15 || WindowSize> 21) return false; - - /* allocate state and associated window */ - window = new byte[wndsize]; - if (window==null) - { - return false; - } - - actual_size = wndsize; - window_size = wndsize; - - /* calculate required position slots */ - if (WindowSize == 20) posn_slots = 42; - else if (WindowSize== 21) posn_slots = 50; - else posn_slots = WindowSize << 1; - - /** alternatively **/ - /* posn_slots=i=0; while (i < wndsize) i += 1 << extra_bits[posn_slots++]; */ - - /* initialize other state */ - R0 = R1 = R2 = 1; - main_elements = (uint)(LZX_NUM_CHARS + (posn_slots << 3)); - header_read = 0; - frames_read = 0; - block_remaining = 0; - block_type = LZX_BLOCKTYPE_INVALID; - intel_curpos = 0; - intel_started = 0; - window_posn = 0; - - /* initialise tables to 0 (because deltas will be applied to them) */ - for (i = 0; i < LZX_MAINTREE_MAXSYMBOLS; i++) MAINTREE_len[i] = 0; - for (i = 0; i < LZX_LENGTH_MAXSYMBOLS; i++) LENGTH_len[i] = 0; - - return true; - } - - public void LZXteardown() - { - window=null; - } - - public int LZXreset() - { - R0 = R1 = R2 = 1; - header_read = 0; - frames_read = 0; - block_remaining = 0; - block_type = LZX_BLOCKTYPE_INVALID; - intel_curpos = 0; - intel_started = 0; - window_posn = 0; - - for (int i = 0; i < LZX_MAINTREE_MAXSYMBOLS + LZX_LENTABLE_SAFETY; i++) MAINTREE_len[i] = 0; - for (int i = 0; i < LZX_LENGTH_MAXSYMBOLS + LZX_LENTABLE_SAFETY; i++) LENGTH_len[i] = 0; - - return DECR_OK; - } - - - /* Bitstream reading macros: - * - * INIT_BITSTREAM should be used first to set up the system - * READ_BITS(var,n) takes N bits from the buffer and puts them in var - * - * ENSURE_BITS(n) ensures there are at least N bits in the bit buffer - * PEEK_BITS(n) extracts (without removing) N bits from the bit buffer - * REMOVE_BITS(n) removes N bits from the bit buffer - * - * These bit access routines work by using the area beyond the MSB and the - * LSB as a free source of zeroes. This avoids having to mask any bits. - * So we have to know the bit width of the bitbuffer variable. This is - * sizeof(ulong) * 8, also defined as ULONG_BITS - */ - - /* number of bits in ulong. Note: This must be at multiple of 16, and at - * least 32 for the bitbuffer code to work (ie, it must be able to ensure - * up to 17 bits - that's adding 16 bits when there's one bit left, or - * adding 32 bits when there are no bits left. The code should work fine - * for machines where ulong >= 32 bits. - */ - private int ULONG_BITS() - { - int rc=(System.Runtime.InteropServices.Marshal.SizeOf(typeof(System.UInt32))<<3); - return rc; - } - - /* make_decode_table(nsyms, nbits, length[], table[]) - * - * This function was coded by David Tritscher. It builds a fast huffman - * decoding table out of just a canonical huffman code lengths table. - * - * nsyms = total number of symbols in this huffman tree. - * nbits = any symbols with a code length of nbits or less can be decoded - * in one lookup of the table. - * length = A table to get code lengths from [0 to syms-1] - * table = The table to fill up with decoded symbols and pointers. - * - * Returns 0 for OK or 1 for error - */ - - private int make_decode_table(ulong nsyms, byte nbits, ref byte [] length, ref UInt32[] table) - { - ulong sym; - ulong leaf; - byte bit_num = 1; - ulong fill; - ulong pos = 0; /* the current position in the decode table */ - ulong table_mask = (ulong)(1 << nbits); - ulong bit_mask = table_mask >> 1; /* don't do 0 length codes */ - ulong next_symbol = bit_mask; /* base of allocation for long codes */ - - /* fill entries for codes short enough for a direct mapping */ - while (bit_num <= nbits) - { - for (sym = 0; sym < nsyms; sym++) - { - if (length[sym] == bit_num) - { - leaf = pos; - - if((pos += bit_mask) > table_mask) return 1; /* table overrun */ - - /* fill all possible lookups of this symbol with the symbol itself */ - fill = bit_mask; - while (fill-- > 0) table[leaf++] = (uint)sym; - } - } - bit_mask >>= 1; - bit_num++; - } - - /* if there are any codes longer than nbits */ - if (pos != table_mask) - { - /* clear the remainder of the table */ - for (sym = pos; sym < table_mask; sym++) table[sym] = 0; - - /* give ourselves room for codes to grow by up to 16 more bits */ - pos <<= 16; - table_mask <<= 16; - bit_mask = 1 << 15; - - while (bit_num <= 16) - { - for (sym = 0; sym < nsyms; sym++) - { - if (length[sym] == bit_num) - { - leaf = pos >> 16; - for (fill = 0; fill < (ulong)(bit_num - nbits); fill++) - { - /* if this path hasn't been taken yet, 'allocate' two entries */ - if (table[leaf] == 0) - { - table[(next_symbol << 1)] = 0; - table[(next_symbol << 1) + 1] = 0; - table[leaf] = (uint)next_symbol++; - } - /* follow the path and select either left or right for next bit */ - leaf = table[leaf] << 1; - if (((pos >> (byte)(15-fill)) & 1)==1) - leaf++; - } - table[leaf] = (uint)sym; - - if ((pos += bit_mask) > table_mask) - return 1; /* table overflow */ - } - } - bit_mask >>= 1; - bit_num++; - } - } - - /* full table? */ - if (pos == table_mask) - return 0; - - /* either erroneous table, or all elements are 0 - let's find out. */ - for (sym = 0; sym < nsyms; sym++) if (length[(uint)sym]!=0) - return 1; - - return 0; - } - - private int lzx_read_lens(byte []lens, ulong first, ulong last, ref lzx_bits lb) - { - ulong i,j, x,y; - int z; - - UInt32 bitbuf = lb.bb; - int bitsleft = lb.bl; - - UInt32 [] hufftbl=null; - - for (x = 0; x < 20; x++) - { - do - { - while (bitsleft < (4)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - y = (bitbuf >> (ULONG_BITS()- (4))); - bitbuf <<= 4; - bitsleft -= 4; - } - while (false); - PRETREE_len[x] = (byte)y; - } - if (make_decode_table( 20, 6, ref PRETREE_len, ref PRETREE_table)!=0) - return 2; - - for (x = first; x < last; ) - { - do - { - while (bitsleft < 16) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - hufftbl = PRETREE_table; - if ((i = hufftbl[((ulong)bitbuf >> (ULONG_BITS()- 6))]) >= 20) - { - j = (ulong)(1 << (byte)(ULONG_BITS()- ((6)))); - do - { - j >>= 1; - i <<= 1; - if ((bitbuf & j)!=0) - i|=1; - else - i|=0; - - if (j==0) - { - return (2); - } - } - while ((i = hufftbl[i]) >= 20); - } - z = (int)i; - j = PRETREE_len[z]; - bitbuf <<= (byte)j; - bitsleft -= (int)j; - } - while (false); - - if (z == 17) - { - do - { - while (bitsleft < (4)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - y = (bitbuf >> (ULONG_BITS()- (4))); - bitbuf <<= 4; - bitsleft -= 4; - } - while(false); - y += 4; - - while ((y--)!=0) - lens[x++] = 0; - } - else if (z == 18) - { - do - { - while (bitsleft < (5)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - (y) = (bitbuf >> (ULONG_BITS()- (5))); - bitbuf <<= 5; - bitsleft -= 5; - } - while (false); - - y += 20; - - while ((y--)!=0) - lens[x++] = 0; - } - else if (z == 19) - { - do - { - while (bitsleft < (1)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - y = (bitbuf >> (ULONG_BITS()- (1))); - bitbuf <<= 1; - bitsleft -= 1; - } - while(false); - y += 4; - do - { - while (bitsleft < (16)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - hufftbl = (PRETREE_table); - if ((i = hufftbl[(bitbuf >> (ULONG_BITS()- 6))]) >= 20) - { - j = (ulong)1 << (byte)(ULONG_BITS()- 6); - do - { - j >>= 1; - i <<= 1; - if ((bitbuf & j)==0) - i|=0; - else - i|=1; - if (j==0) - { - return (2); - } - } - while ((i = hufftbl[i]) >= 20); - } - z = (int)i; - j = PRETREE_len[z]; - - bitbuf <<= (byte)j; - bitsleft -= (int)j; - } - while(false); - z = lens[x] - z; - if (z < 0) - z += 17; - - while ((y--)!=0) - lens[x++] = (byte)z; - } - else - { - z = lens[x] - z; - if (z < 0) - z += 17; - lens[x++] = (byte)z; - } - } - lb.bb = bitbuf; - lb.bl = bitsleft; - return 0; - } - - public int LZXdecompress(System.IO.BinaryReader inpos, System.IO.Stream outpos, ref ulong inlen, ref ulong outlen) - { - BitSource=inpos; - OutputStream=outpos; - - long endinp = BitSource.BaseStream.Position+(long)inlen; - ulong runsrc, rundest; - UInt32 [] hufftbl; /* used in READ_HUFFSYM macro as chosen decoding table */ - - UInt32 bitbuf; - int bitsleft; - ulong match_offset, i,j,k; /* ijk used in READ_HUFFSYM macro */ - lzx_bits lb; /* used in READ_LENGTHS macro */ - lb=new lzx_bits(); - - int togo = (int)outlen, this_run, main_element, aligned_bits; - int match_length, length_footer, extra, verbatim_bits; - - bitsleft = 0; - bitbuf = 0; - - /* read header if necessary */ - if (header_read==0) - { - i = j = 0; - do - { - while (bitsleft < (1)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - k = (bitbuf >> (ULONG_BITS()- (1))); - bitbuf <<= 1; - bitsleft -= 1; - } - while(false); - - if (k!=0) - { - do - { - while (bitsleft < (16)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() -16 - bitsleft); - bitsleft += 16; - } - i = (bitbuf >> (ULONG_BITS()- (16))); - bitbuf <<= 16; - bitsleft -= 1; - } - while(false); - - do - { - while (bitsleft < (16)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - j = (bitbuf >> (ULONG_BITS()- (16))); - bitbuf <<= 16; - bitsleft -= 16; - } - while(false); - } - intel_filesize = (long)((i << 16) | j); - header_read = 1; - } - - /* main decoding loop */ - while (togo > 0) - { - if (block_remaining == 0) - { - if (block_type == (3)) - { - if ((block_length & 1)!=0) - BitSource.ReadByte(); - bitsleft = 0; - bitbuf = 0; - } - - do - { - while (bitsleft < (3)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - (block_type) = (uint)(bitbuf >> (ULONG_BITS()- (3))); - bitbuf <<= 3; - bitsleft -= 3; - } - while (false); - - do - { - while (bitsleft < (16)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - (i) = (bitbuf >> (ULONG_BITS()- (16))); - bitbuf <<= 16; - bitsleft -= 16; - } - while (false); - - do - { - while (bitsleft < (8)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - (j) = (bitbuf >> (ULONG_BITS()- (8))); - bitbuf <<= 8; - bitsleft -= 8; - } - while (false); - block_remaining = block_length = (i << 8) | j; - - switch (block_type) - { - case (LZX_BLOCKTYPE_ALIGNED): - for (i = 0; i < 8; i++) - { - do - { - while (bitsleft < (3)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - (j) = (bitbuf >> (ULONG_BITS()- (3))); - bitbuf <<= 3; - bitsleft -= 3; - } - while (false); - (ALIGNED_len)[i] = (byte)j; - } - if (make_decode_table( 8, 7, ref ALIGNED_len, ref ALIGNED_table)!=0) - { - return (2); - } - - do - { - lb.bb = bitbuf; - lb.bl = bitsleft; - if (lzx_read_lens(MAINTREE_len,0,256,ref lb)!=0) - { - return (2); - } - bitbuf = lb.bb; - bitsleft = lb.bl; - } - while (false); - do - { - lb.bb = bitbuf; - lb.bl = bitsleft; - if (lzx_read_lens(MAINTREE_len,256,main_elements,ref lb)!=0) - { - return (2); - } - bitbuf = lb.bb; - bitsleft = lb.bl; - } - while (false); - - if (make_decode_table( (256 + 50*8), 12, ref MAINTREE_len, ref MAINTREE_table)!=0) - { - return (2); - } - if (MAINTREE_len[0xE8] != 0) intel_started = 1; - - do - { - lb.bb = bitbuf; - lb.bl = bitsleft; - if (lzx_read_lens(LENGTH_len,0,249,ref lb)!=0) - { - return (2); - } - bitbuf = lb.bb; - bitsleft = lb.bl; - } - while (false); - if (make_decode_table( (249+1), 12, ref LENGTH_len, ref LENGTH_table)!=0) - { - return (2); - } - break; - - case (LZX_BLOCKTYPE_VERBATIM): - do - { - lb.bb = bitbuf; - lb.bl = bitsleft; - if (lzx_read_lens(MAINTREE_len,0,256,ref lb)!=0) - { - return (2); - } - bitbuf = lb.bb; - bitsleft = lb.bl; - } - while (false); - do - { - lb.bb = bitbuf; - lb.bl = bitsleft; - if (lzx_read_lens(MAINTREE_len,256,main_elements,ref lb)!=0) - { - return (2); - } - bitbuf = lb.bb; - bitsleft = lb.bl; - } - while (false); - - if (make_decode_table( (256 + 50*8), 12, ref MAINTREE_len, ref MAINTREE_table)!=0) - { - return (2); - } - if (MAINTREE_len[0xE8] != 0) intel_started = 1; - - do - { - lb.bb = bitbuf; - lb.bl = bitsleft; - if (lzx_read_lens(LENGTH_len,0,249,ref lb)!=0) - { - return (2); - } - bitbuf = lb.bb; - bitsleft = lb.bl; - } - while (false); - if (make_decode_table( (249+1), 12, ref LENGTH_len, ref LENGTH_table)!=0) - { - return (2); - } - break; - - case (LZX_BLOCKTYPE_UNCOMPRESSED): - intel_started = 1; - while (bitsleft < (16)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - bitsleft); - bitsleft += 16; - } - if (bitsleft > 16) - { - BitSource.BaseStream.Seek(-2,System.IO.SeekOrigin.Current); - } - R0 = (ulong)(BitSource.ReadByte()+(BitSource.ReadByte()<<8)+(BitSource.ReadByte()<<16)+(BitSource.ReadByte()<<24)); - R1 = (ulong)(BitSource.ReadByte()+(BitSource.ReadByte()<<8)+(BitSource.ReadByte()<<16)+(BitSource.ReadByte()<<24)); - R2 = (ulong)(BitSource.ReadByte()+(BitSource.ReadByte()<<8)+(BitSource.ReadByte()<<16)+(BitSource.ReadByte()<<24)); - break; - - default: - return (DECR_ILLEGALDATA); - } - } - - /* buffer exhaustion check */ - if (BitSource.BaseStream.Position > (long) endinp) - { - /* it's possible to have a file where the next run is less than - * 16 bits in size. In this case, the READ_HUFFSYM() macro used - * in building the tables will exhaust the buffer, so we should - * allow for this, but not allow those accidentally read bits to - * be used (so we check that there are at least 16 bits - * remaining - in this boundary case they aren't really part of - * the compressed data) - */ - if (BitSource.BaseStream.Position> (long)(endinp+2) || bitsleft < 16) - return DECR_ILLEGALDATA; - } - - while ((this_run = (int)block_remaining) > 0 && togo > 0) - { - if (this_run > togo) - this_run = togo; - - togo -= this_run; - block_remaining -= (ulong)this_run; - - /* apply 2^x-1 mask */ - window_posn &= window_size - 1; - - /* runs can't straddle the window wraparound */ - if ((window_posn + (ulong)this_run) > window_size) - return DECR_DATAFORMAT; - - switch (block_type) - { - case LZX_BLOCKTYPE_VERBATIM: - while (this_run > 0) - { - do - { - while (bitsleft < (16)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - hufftbl = MAINTREE_table; - if ((i = hufftbl[(bitbuf >> (ULONG_BITS()- 12))]) >= 256 + 50*8) - { - j = (ulong)(1 << (ULONG_BITS()- 12)); - do - { - j >>= 1; - i <<= 1; - if ((bitbuf & j)!=0) - i|=1; - else - i|=0; - if (j==0) - { - return (2); - } - } - while ((i = hufftbl[i]) >= (((256) + 50*8))); - } - j = MAINTREE_len[main_element = (int)i]; - bitbuf <<= (byte)j; - bitsleft -= (byte)j; - } - while (false); - - if (main_element < (256)) - { - window[window_posn++] = (byte)main_element; - this_run--; - } - else - { - main_element -= (256); - - match_length = main_element & (7); - if (match_length == (7)) - { - do - { - while (bitsleft < (16)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - hufftbl = (LENGTH_table); - if ((i = hufftbl[(bitbuf >> (ULONG_BITS()- 12))]) >= (((249)+1))) - { - j = (ulong)(1 << (ULONG_BITS()- ((12)))); - do - { - j >>= 1; - i <<= 1; - if ((bitbuf & j)!=0) - i|=1; - else - i|=0; - if (j==0) - { - return (2); - } - } - while ((i = hufftbl[i]) >= (((249)+1))); - } - j = LENGTH_len[(length_footer) = (int)i]; - bitbuf <<= (byte)j; - bitsleft -= (byte)j; - } - while (false); - - match_length += length_footer; - } - match_length += (2); - - match_offset = (ulong)(main_element >> 3); - - if (match_offset > 2) - { - if (match_offset != 3) - { - extra = extra_bits[match_offset]; - do - { - while (bitsleft < (extra)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - verbatim_bits = (int)(bitbuf >> (ULONG_BITS()- (extra))); - bitbuf <<= extra; - bitsleft -= extra; - } - while (false); - match_offset = position_base[match_offset] - 2 + (ulong)verbatim_bits; - } - else - { - match_offset = 1; - } - - R2 = R1; R1 = R0; R0 = match_offset; - } - else if (match_offset == 0) - { - match_offset = R0; - } - else if (match_offset == 1) - { - match_offset = R1; - R1 = R0; R0 = match_offset; - } - else - { - match_offset = R2; - R2 = R0; R0 = match_offset; - } - - rundest = window_posn; - // rundest= window+window_posn - runsrc = rundest - match_offset; - window_posn += (ulong)match_length; - this_run -= match_length; - - // runsrc < window - while ((runsrc<0) && (match_length-- > 0)) - { - window[rundest++]=window[runsrc+window_size]; - // *rundest++ = *(runsrc + window_size); - runsrc++; - } - - while (match_length-- > 0) - { - window[rundest++]=window[runsrc++]; - // *rundest++ = *runsrc++; - } - } - } - break; - - case LZX_BLOCKTYPE_ALIGNED: - while (this_run > 0) - { - do - { - while (bitsleft < (16)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - hufftbl = MAINTREE_table; - if ((i = hufftbl[(bitbuf >> (ULONG_BITS()- 12))]) >= (((256) + 50*8))) - { - j = (ulong)1 << (ULONG_BITS()- ((12))); - do - { - j >>= 1; - i <<= 1; - if ((bitbuf & j)!=0) - i|=1; - else - i|=0; - if (j==0) - { - return (2); - } - } - while ((i = hufftbl[i]) >= (((256) + 50*8))); - } - j = MAINTREE_len[(main_element) = (int)i]; - bitbuf <<= (int)j; - bitsleft -= (int)j; - } - while (false); - - if (main_element < (256)) - { - window[window_posn++] = (byte)main_element; - this_run--; - } - else - { - main_element -= (256); - match_length = main_element & (7); - if (match_length == (7)) - { - do - { - while (bitsleft < (16)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - hufftbl = LENGTH_table; - if ((i = hufftbl[(bitbuf >> (ULONG_BITS()- 12))]) >= (((249)+1))) - { - j = (ulong) 1 << (ULONG_BITS()- ((12))); - do - { - j >>= 1; - i <<= 1; - if ((bitbuf & j)!=0) - i|=1; - else - i|=0; - - if (j==0) - { - return (2); - } - } - while ((i = hufftbl[i]) >= (((249)+1))); - } - j = LENGTH_len[length_footer = (int)i]; - bitbuf <<= (int)j; - bitsleft -= (int)j; - } - while (false); - match_length += length_footer; - } - match_length += (2); - - match_offset = (ulong)(main_element >> 3); - - if (match_offset > 2) - { - extra = extra_bits[match_offset]; - match_offset = position_base[match_offset] - 2; - if (extra > 3) - { - extra -= 3; - do - { - while (bitsleft < (extra)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - verbatim_bits = (int)(bitbuf >> (ULONG_BITS()- (extra))); - bitbuf <<= extra; - bitsleft -= extra; - } - while (false); - match_offset += (ulong)(verbatim_bits << 3); - do - { - while (bitsleft < (16)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - hufftbl = (ALIGNED_table); - if ((i = hufftbl[(bitbuf >> (ULONG_BITS()- 7))]) >= 8) - { - j = (ulong)1 << (ULONG_BITS()- ((7))); - do - { - j >>= 1; - i <<= 1; - if ((bitbuf & j)!=0) - i|=1; - else - i|=0; - if (j==0) - { - return (2); - } - } - while ((i = hufftbl[i]) >= (((8)))); - } - - j = (ALIGNED_len)[(aligned_bits) = (int)i]; - bitbuf <<= (int)j; - bitsleft -= (int)j; - } - while (false); - match_offset += (ulong)aligned_bits; - } - else if (extra == 3) - { - do - { - while (bitsleft < (16)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - hufftbl = (ALIGNED_table); - if ((i = hufftbl[(bitbuf >> (ULONG_BITS()- 7))]) >= 8) - { - j = (ulong)1 << (ULONG_BITS()- ((7))); - do - { - j >>= 1; - i <<= 1; - if ((bitbuf & j)!=0) - i|=1; - else - i|=0; - if (j!=0) - { - return (2); - } - } - while ((i = hufftbl[i]) >= 8); - } - j = (ALIGNED_len)[(aligned_bits) = (int)i]; - bitbuf <<= (int)j; - bitsleft -= (int)j; - } - while (false); - match_offset += (ulong)aligned_bits; - } - else if (extra > 0) - { - do - { - while (bitsleft < (extra)) - { - bitbuf |= (UInt32)ReadUInt16() << (ULONG_BITS() - 16 - bitsleft); - bitsleft += 16; - } - (verbatim_bits) = (int)(bitbuf >> (int)(ULONG_BITS()- (extra))); - bitbuf <<= extra; - bitsleft -= extra; - } - while (false); - match_offset += (ulong)verbatim_bits; - } - else - { - match_offset = 1; - } - - R2 = R1; R1 = R0; R0 = match_offset; - } - else if (match_offset == 0) - { - match_offset = R0; - } - else if (match_offset == 1) - { - match_offset = R1; - R1 = R0; R0 = match_offset; - } - else - { - match_offset = R2; - R2 = R0; R0 = match_offset; - } - - rundest = window_posn; - runsrc = rundest - match_offset; - window_posn += (ulong)match_length; - this_run -= match_length; - - while ((runsrc<0) && (match_length-- > 0)) - { - // *rundest++ = *(runsrc + window_size); runsrc++; - window[rundest++]=window[runsrc + window_size]; - runsrc++; - } - - while (match_length-- > 0) - { - // *rundest++ = *runsrc++; - window[rundest++]=window[runsrc++]; - } - } - } - break; - - case LZX_BLOCKTYPE_UNCOMPRESSED: - if ((BitSource.BaseStream.Position + (long)this_run) > (long)endinp) - return (2); - - // memcpy(window + window_posn, inposCount, this_run); - for(i=0; i<(ulong)this_run;i++) - { - window[window_posn+i]=BitSource.ReadByte(); - } - window_posn += (ulong)this_run; - break; - - default: - return DECR_ILLEGALDATA; /* might as well */ - } - - } - } - - if (togo != 0) return DECR_ILLEGALDATA; - - // memcpy(outpos, window + ((!window_posn) ? window_size : window_posn) - outlen, (size_t) outlen); - ulong start=0; - if (window_posn==0) - start=(ulong)window_size; - else - start=(ulong)window_posn; - - start-=(ulong)outlen; - - long Pos=OutputStream.Position; - for(i=0;i<(ulong)outlen;i++) - { - OutputStream.WriteByte(window[start+i]); - } - OutputStream.Seek(Pos,System.IO.SeekOrigin.Begin); - - /* intel E8 decoding */ - if ((frames_read++ < 32768) && intel_filesize != 0) - { - if (outlen <= 6 || (intel_started==0)) - { - intel_curpos += (long)outlen; - } - else - { - // UBYTE *data = outpos; - long dataend = OutputStream.Position + (int)outlen - 10; - long curpos = intel_curpos; - long filesize = intel_filesize; - long abs_off, rel_off; - - intel_curpos = (long)curpos + (long)outlen; - - while (OutputStream.Position < dataend) - { - if (OutputStream.ReadByte() != 0xE8) - { - curpos++; - continue; - } - - abs_off = (long)(OutputStream.ReadByte() | (OutputStream.ReadByte() <<8) | (OutputStream.ReadByte() <<16) | (OutputStream.ReadByte() <<24)); - if (abs_off < filesize) - { - if (abs_off >= 0) - rel_off = (long)(abs_off - curpos); - else - rel_off = (long)abs_off + filesize; - OutputStream.WriteByte((byte)(rel_off & 0x000000ff)); - OutputStream.WriteByte((byte)((rel_off & 0x0000ff00)>>8)); - OutputStream.WriteByte((byte)((rel_off & 0x00ff0000)>>16)); - OutputStream.WriteByte((byte)((rel_off & 0xff000000)>>24)); - } - curpos += 5; - } - } - } - - return DECR_OK; - } - } - #endregion -} diff --git a/irc/TechBot/CHMLibrary/TOCItem.cs b/irc/TechBot/CHMLibrary/TOCItem.cs deleted file mode 100644 index 8f6b7f97909..00000000000 --- a/irc/TechBot/CHMLibrary/TOCItem.cs +++ /dev/null @@ -1,494 +0,0 @@ -using System; -using System.IO; -using System.Collections; -using System.Windows.Forms; - -using HtmlHelp.ChmDecoding; - -namespace HtmlHelp -{ - /// - /// The class TOCItem implements a toc-entry item - /// - public sealed class TOCItem - { - /// - /// Constant for standard folder (closed) image index (HH2 image list) - /// - public const int STD_FOLDER_HH2 = 4; - /// - /// Constant for standard folder (opened) image index (HH2 image list) - /// - public const int STD_FOLDER_OPEN_HH2 = 6; - /// - /// Constant for standard file image index (HH2 image list) - /// - public const int STD_FILE_HH2 = 16; - - /// - /// Constant for standard folder (closed) image index (HH1 image list) - /// - public const int STD_FOLDER_HH1 = 0; - /// - /// Constant for standard folder (opened) image index (HH1 image list) - /// - public const int STD_FOLDER_OPEN_HH1 = 1; - /// - /// Constant for standard file image index (HH1 image list) - /// - public const int STD_FILE_HH1 = 10; - - /// - /// Internal flag specifying the data extraction mode used for this item - /// - private DataMode _tocMode = DataMode.TextBased; - /// - /// Internal member storing the offset (only used in binary tocs) - /// - private int _offset = 0; - /// - /// Internal member storing the offset of the next item(only used in binary tocs) - /// - private int _offsetNext = 0; - /// - /// Internal member storing a merge link. - /// If the target file is in the merged files list of the CHM, - /// this item will be replaced with the target TOC or Topic, if not it will - /// be removed from TOC. - /// - private string _mergeLink = ""; - /// - /// Internal member storing the toc name - /// - private string _name = ""; - /// - /// Internal member storing the toc loca (content file) - /// - private string _local = ""; - /// - /// Internal member storing all associated information type strings - /// - private ArrayList _infoTypeStrings = new ArrayList(); - /// - /// Internal member storing the associated chm file - /// - private string _chmFile = ""; - /// - /// Internal member storing the image index - /// - private int _imageIndex = -1; - /// - /// Internal member storing the offset of the associated topic entry (for binary tocs) - /// - private int _topicOffset = -1; - /// - /// Internal member storing the toc children - /// - private ArrayList _children = new ArrayList(); - /// - /// Internal member storing the parameter collection - /// - private Hashtable _otherParams = new Hashtable(); - /// - /// Internal member storing the associated chmfile object - /// - private CHMFile _associatedFile = null; - /// - /// Parent item - /// - private TOCItem _parent=null; - - /// - /// Holds a pointer to the next item in the TOC - /// - public TOCItem Next=null; - - /// - /// Holds a pointer to the previous item in the TOC - /// - public TOCItem Prev=null; - - /// - /// Holds a pointer to the TreeNode where this TOC Item is used - /// - public System.Windows.Forms.TreeNode treeNode=null; - - /// - /// Constructor of the class used during text-based data extraction - /// - /// name of the item - /// local content file - /// image index - /// associated chm file - public TOCItem(string name, string local, int ImageIndex, string chmFile) - { - _tocMode = DataMode.TextBased; - _name = name; - _local = local; - _imageIndex = ImageIndex; - _chmFile = chmFile; - } - - /// - /// Constructor of the class used during binary data extraction - /// - /// offset of the associated topic entry - /// image index to use - /// associated chm file - public TOCItem(int topicOffset, int ImageIndex, CHMFile associatedFile) - { - _tocMode = DataMode.Binary; - _associatedFile = associatedFile; - _chmFile = associatedFile.ChmFilePath; - _topicOffset = topicOffset; - _imageIndex = ImageIndex; - } - - /// - /// Standard constructor - /// - public TOCItem() - { - } - - #region Data dumping - /// - /// Dump the class data to a binary writer - /// - /// writer to write the data - /// true if the chmfile name should be written - internal void Dump(ref BinaryWriter writer, bool writeFilename) - { - writer.Write((int)_tocMode); - writer.Write(_topicOffset); - writer.Write(_name); - - if((_tocMode == DataMode.TextBased)||(_topicOffset<0)) - { - writer.Write(_local); - } - - writer.Write(_imageIndex); - - writer.Write(_mergeLink); - - if(writeFilename) - writer.Write(_chmFile); - - writer.Write(_infoTypeStrings.Count); - - for(int i=0; i<_infoTypeStrings.Count; i++) - writer.Write( (_infoTypeStrings[i]).ToString() ); - - writer.Write(_children.Count); - - for(int i=0; i<_children.Count; i++) - { - TOCItem child = ((TOCItem)(_children[i])); - child.Dump(ref writer, writeFilename); - } - } - - /// - /// Dump the class data to a binary writer - /// - /// writer to write the data - internal void Dump(ref BinaryWriter writer) - { - Dump(ref writer, false); - } - - /// - /// Reads the object data from a dump store - /// - /// reader to read the data - /// true if the chmfile name should be read - internal void ReadDump(ref BinaryReader reader, bool readFilename) - { - int i=0; - _tocMode = (DataMode)reader.ReadInt32(); - _topicOffset = reader.ReadInt32(); - _name = reader.ReadString(); - - if((_tocMode == DataMode.TextBased)||(_topicOffset<0)) - { - _local = reader.ReadString(); - } - - _imageIndex = reader.ReadInt32(); - - _mergeLink = reader.ReadString(); - - if(readFilename) - _chmFile = reader.ReadString(); - - int nCnt = reader.ReadInt32(); - - for(i=0; i 0) - _associatedFile.MergLinks.Add(child); - } - } - - /// - /// Reads the object data from a dump store - /// - /// reader to read the data - internal void ReadDump(ref BinaryReader reader) - { - ReadDump(ref reader, false); - } - #endregion - - /// - /// Gets/Sets the data extraction mode with which this item was created. - /// - internal DataMode TocMode - { - get { return _tocMode; } - set { _tocMode = value; } - } - - /// - /// Gets/Sets the offset of the associated topic entry - /// - internal int TopicOffset - { - get { return _topicOffset; } - set { _topicOffset = value; } - } - - /// - /// Gets/Sets the associated CHMFile instance - /// - internal CHMFile AssociatedFile - { - get { return _associatedFile; } - set - { - _associatedFile = value; - } - } - - /// - /// Gets/Sets the offset of the item. - /// - /// Only used in binary tocs - internal int Offset - { - get { return _offset; } - set { _offset = value; } - } - - /// - /// Gets/Sets the offset of the next item. - /// - /// Only used in binary tocs - internal int OffsetNext - { - get { return _offsetNext; } - set { _offsetNext = value; } - } - - /// - /// Gets the ArrayList which holds all information types/categories this item is associated - /// - internal ArrayList InfoTypeStrings - { - get { return _infoTypeStrings; } - } - - /// - /// Gets/Sets the parent of this item - /// - public TOCItem Parent - { - get { return _parent; } - set { _parent = value; } - } - - /// - /// Gets/Sets the mergelink for this item. - /// You should not set the mergedlink by your own ! - /// This is only for loading merged CHMs. - /// - public string MergeLink - { - get { return _mergeLink; } - set { _mergeLink = value; } - } - - /// - /// Gets/Sets the name of the item - /// - public string Name - { - get - { - if(_mergeLink.Length > 0) - return ""; - - if(_name.Length <= 0) - { - if((_tocMode == DataMode.Binary )&&(_associatedFile!=null)) - { - if( _topicOffset >= 0) - { - TopicEntry te = (TopicEntry) (_associatedFile.TopicsFile[_topicOffset]); - if(te != null) - { - return te.Title; - } - } - } - } - - return _name; - } - set - { - _name = value; - } - } - - /// - /// Gets/Sets the local of the item - /// - public string Local - { - get - { - if(_mergeLink.Length > 0) - return ""; - - if(_local.Length <= 0) - { - if((_tocMode == DataMode.Binary )&&(_associatedFile!=null)) - { - if( _topicOffset >= 0) - { - TopicEntry te = (TopicEntry) (_associatedFile.TopicsFile[_topicOffset]); - if(te != null) - { - return te.Locale; - } - } - } - } - - return _local; - } - set { _local = value; } - } - - /// - /// Gets/Sets the chm file - /// - public string ChmFile - { - get - { - if(_associatedFile!=null) - return _associatedFile.ChmFilePath; - - return _chmFile; - } - set { _chmFile = value; } - } - - /// - /// Gets the url for the webbrowser for this file - /// - public string Url - { - get - { - string sL = Local; - - if( (sL.ToLower().IndexOf("http://") >= 0) || - (sL.ToLower().IndexOf("https://") >= 0) || - (sL.ToLower().IndexOf("mailto:") >= 0) || - (sL.ToLower().IndexOf("ftp://") >= 0) || - (sL.ToLower().IndexOf("ms-its:") >= 0)) - return sL; - - return HtmlHelpSystem.UrlPrefix + ChmFile + "::/" + sL; - } - } - - /// - /// Gets/Sets the image index of the item - /// - /// Set this to -1 for a default icon - public int ImageIndex - { - get - { - if( _imageIndex == -1) - { - int nFolderAdd = 0; - - if((_associatedFile != null) && (_associatedFile.ImageTypeFolder)) - { - // get the value which should be added, to display folders instead of books - if(HtmlHelpSystem.UseHH2TreePics) - nFolderAdd = 8; - else - nFolderAdd = 4; - } - - - if( _children.Count > 0) - return (HtmlHelpSystem.UseHH2TreePics ? (STD_FOLDER_HH2+nFolderAdd) : (STD_FOLDER_HH1+nFolderAdd)); - - return (HtmlHelpSystem.UseHH2TreePics ? STD_FILE_HH2 : STD_FILE_HH1); - } - return _imageIndex; - } - set { _imageIndex = value; } - } - - /// - /// Gets/Sets the children of this item. - /// - /// Each entry in the ArrayList is of type TOCItem - public ArrayList Children - { - get { return _children; } - set { _children = value; } - } - - /// - /// Gets the internal hashtable storing all params - /// - public Hashtable Params - { - get { return _otherParams; } - } - } -} diff --git a/irc/TechBot/CHMLibrary/TableOfContents.cs b/irc/TechBot/CHMLibrary/TableOfContents.cs deleted file mode 100644 index 68dfb050a6a..00000000000 --- a/irc/TechBot/CHMLibrary/TableOfContents.cs +++ /dev/null @@ -1,198 +0,0 @@ -using System; -using System.Diagnostics; -using System.Collections; -using HtmlHelp.ChmDecoding; - -namespace HtmlHelp -{ - /// - /// The class TableOfContents holds the TOC of the htmlhelp system class. - /// - public class TableOfContents - { - private ArrayList _toc = new ArrayList(); - - /// - /// Standard constructor - /// - public TableOfContents() - { - } - - /// - /// Constructor of the class - /// - /// - public TableOfContents(ArrayList toc) - { - _toc = toc; - } - - /// - /// Gets the internal stored table of contents - /// - public ArrayList TOC - { - get { return _toc; } - } - - /// - /// Clears the current toc - /// - public void Clear() - { - if(_toc!=null) - _toc.Clear(); - } - - /// - /// Gets the number of topics in the toc - /// - /// Returns the number of topics in the toc - public int Count() - { - if(_toc!=null) - return _toc.Count; - else - return 0; - } - - /// - /// Merges the arrToC list to the one in this instance - /// - /// the toc list which should be merged with the current one - internal void MergeToC( ArrayList arrToC ) - { - if(_toc==null) - _toc = new ArrayList(); - - MergeToC(_toc, arrToC, null); - } - - /// - /// Merges the arrToC list to the one in this instance (called if merged files - /// were found in a CHM) - /// - /// the toc list which should be merged with the current one - /// An arraylist of CHMFile instances. - internal void MergeToC( ArrayList arrToC, ArrayList openFiles ) - { - if(_toc==null) - _toc = new ArrayList(); - MergeToC(_toc, arrToC, openFiles); - } - - /// - /// Internal method for recursive toc merging - /// - /// level of global toc - /// level of local toc - /// An arraylist of CHMFile instances. - private void MergeToC( ArrayList globalLevel, ArrayList localLevel, ArrayList openFiles ) - { - foreach( TOCItem curItem in localLevel) - { - // if it is a part of the merged-links, we have to do nothing, - // because the method HtmlHelpSystem.RecalculateMergeLinks() has already - // placed this item at its correct position. - if(!IsMergedItem(curItem.Name, curItem.Local, openFiles)) - { - TOCItem globalItem = ContainsToC(globalLevel, curItem.Name); - if(globalItem == null) - { - // the global toc doesn't have a topic with this name - // so we need to add the complete toc node to the global toc - - globalLevel.Add( curItem ); - } - else - { - // the global toc contains the current topic - // advance to the next level - - if( (globalItem.Local.Length <= 0) && (curItem.Local.Length > 0) ) - { - // set the associated url - globalItem.Local = curItem.Local; - globalItem.ChmFile = curItem.ChmFile; - } - - MergeToC(globalItem.Children, curItem.Children); - } - } - } - } - - /// - /// Checks if the item is part of the merged-links - /// - /// name of the topic - /// local of the topic - /// An arraylist of CHMFile instances. - /// Returns true if this item is part of the merged-links - private bool IsMergedItem(string name, string local, ArrayList openFiles) - { - if(openFiles==null) - return false; - - foreach(CHMFile curFile in openFiles) - { - foreach(TOCItem curItem in curFile.MergLinks) - if( (curItem.Name == name) && (curItem.Local == local) ) - return true; - } - return false; - } - - /// - /// Checks if a topicname exists in a SINGLE toc level - /// - /// toc list - /// topic to search - /// Returns the topic item if found, otherwise null - private TOCItem ContainsToC(ArrayList arrToC, string Topic) - { - foreach(TOCItem curItem in arrToC) - { - if(curItem.Name == Topic) - return curItem; - } - - return null; - } - - /// - /// Searches the table of contents for a special topic - /// - /// topic to search - /// Returns an instance of TOCItem if found, otherwise null - public TOCItem SearchTopic(string topic) - { - return SearchTopic(topic, _toc); - } - - /// - /// Internal recursive tree search - /// - /// topic to search - /// tree level list to look in - /// Returns an instance of TOCItem if found, otherwise null - private TOCItem SearchTopic(string topic, ArrayList searchIn) - { - foreach(TOCItem curItem in searchIn) - { - if(curItem.Name.ToLower() == topic.ToLower() ) - return curItem; - - if(curItem.Children.Count>0) - { - TOCItem nf = SearchTopic(topic, curItem.Children); - if(nf != null) - return nf; - } - } - - return null; - } - } -} diff --git a/irc/TechBot/Compression/AssemblyInfo.cs b/irc/TechBot/Compression/AssemblyInfo.cs deleted file mode 100644 index dbacda112e8..00000000000 --- a/irc/TechBot/Compression/AssemblyInfo.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following -// attributes. -// -// change them to the information which is associated with the assembly -// you compile. - -[assembly: AssemblyTitle("")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has following format : -// -// Major.Minor.Build.Revision -// -// You can specify all values by your own or you can build default build and revision -// numbers with the '*' character (the default): - -[assembly: AssemblyVersion("1.0.*")] - -// The following attributes specify the key for the sign of your assembly. See the -// .NET Framework documentation for more information about signing. -// This is not required, if you don't want signing let these attributes like they're. -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] diff --git a/irc/TechBot/Compression/Checksums/Adler32.cs b/irc/TechBot/Compression/Checksums/Adler32.cs deleted file mode 100644 index 220dcbafa0c..00000000000 --- a/irc/TechBot/Compression/Checksums/Adler32.cs +++ /dev/null @@ -1,200 +0,0 @@ -// Adler32.cs - Computes Adler32 data checksum of a data stream -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; - -namespace ICSharpCode.SharpZipLib.Checksums -{ - - /// - /// Computes Adler32 checksum for a stream of data. An Adler32 - /// checksum is not as reliable as a CRC32 checksum, but a lot faster to - /// compute. - /// - /// The specification for Adler32 may be found in RFC 1950. - /// ZLIB Compressed Data Format Specification version 3.3) - /// - /// - /// From that document: - /// - /// "ADLER32 (Adler-32 checksum) - /// This contains a checksum value of the uncompressed data - /// (excluding any dictionary data) computed according to Adler-32 - /// algorithm. This algorithm is a 32-bit extension and improvement - /// of the Fletcher algorithm, used in the ITU-T X.224 / ISO 8073 - /// standard. - /// - /// Adler-32 is composed of two sums accumulated per byte: s1 is - /// the sum of all bytes, s2 is the sum of all s1 values. Both sums - /// are done modulo 65521. s1 is initialized to 1, s2 to zero. The - /// Adler-32 checksum is stored as s2*65536 + s1 in most- - /// significant-byte first (network) order." - /// - /// "8.2. The Adler-32 algorithm - /// - /// The Adler-32 algorithm is much faster than the CRC32 algorithm yet - /// still provides an extremely low probability of undetected errors. - /// - /// The modulo on unsigned long accumulators can be delayed for 5552 - /// bytes, so the modulo operation time is negligible. If the bytes - /// are a, b, c, the second sum is 3a + 2b + c + 3, and so is position - /// and order sensitive, unlike the first sum, which is just a - /// checksum. That 65521 is prime is important to avoid a possible - /// large class of two-byte errors that leave the check unchanged. - /// (The Fletcher checksum uses 255, which is not prime and which also - /// makes the Fletcher check insensitive to single byte changes 0 - - /// 255.) - /// - /// The sum s1 is initialized to 1 instead of zero to make the length - /// of the sequence part of s2, so that the length does not have to be - /// checked separately. (Any sequence of zeroes has a Fletcher - /// checksum of zero.)" - /// - /// - /// - public sealed class Adler32 : IChecksum - { - /// - /// largest prime smaller than 65536 - /// - readonly static uint BASE = 65521; - - uint checksum; - - /// - /// Returns the Adler32 data checksum computed so far. - /// - public long Value { - get { - return checksum; - } - } - - /// - /// Creates a new instance of the Adler32 class. - /// The checksum starts off with a value of 1. - /// - public Adler32() - { - Reset(); - } - - /// - /// Resets the Adler32 checksum to the initial value. - /// - public void Reset() - { - checksum = 1; //Initialize to 1 - } - - /// - /// Updates the checksum with the byte b. - /// - /// - /// the data value to add. The high byte of the int is ignored. - /// - public void Update(int bval) - { - //We could make a length 1 byte array and call update again, but I - //would rather not have that overhead - uint s1 = checksum & 0xFFFF; - uint s2 = checksum >> 16; - - s1 = (s1 + ((uint)bval & 0xFF)) % BASE; - s2 = (s1 + s2) % BASE; - - checksum = (s2 << 16) + s1; - } - - /// - /// Updates the checksum with the bytes taken from the array. - /// - /// - /// buffer an array of bytes - /// - public void Update(byte[] buffer) - { - Update(buffer, 0, buffer.Length); - } - - /// - /// Updates the checksum with the bytes taken from the array. - /// - /// - /// an array of bytes - /// - /// - /// the start of the data used for this update - /// - /// - /// the number of bytes to use for this update - /// - public void Update(byte[] buf, int off, int len) - { - if (buf == null) { - throw new ArgumentNullException("buf"); - } - - if (off < 0 || len < 0 || off + len > buf.Length) { - throw new ArgumentOutOfRangeException(); - } - - //(By Per Bothner) - uint s1 = checksum & 0xFFFF; - uint s2 = checksum >> 16; - - while (len > 0) { - // We can defer the modulo operation: - // s1 maximally grows from 65521 to 65521 + 255 * 3800 - // s2 maximally grows by 3800 * median(s1) = 2090079800 < 2^31 - int n = 3800; - if (n > len) { - n = len; - } - len -= n; - while (--n >= 0) { - s1 = s1 + (uint)(buf[off++] & 0xFF); - s2 = s2 + s1; - } - s1 %= BASE; - s2 %= BASE; - } - - checksum = (s2 << 16) | s1; - } - } -} diff --git a/irc/TechBot/Compression/Checksums/CRC32.cs b/irc/TechBot/Compression/Checksums/CRC32.cs deleted file mode 100644 index a78ad4c29f6..00000000000 --- a/irc/TechBot/Compression/Checksums/CRC32.cs +++ /dev/null @@ -1,211 +0,0 @@ -// CRC32.cs - Computes CRC32 data checksum of a data stream -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; - -namespace ICSharpCode.SharpZipLib.Checksums -{ - - /// - /// 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. - /// - public sealed class Crc32 : IChecksum - { - readonly static uint CrcSeed = 0xFFFFFFFF; - - readonly static uint[] CrcTable = new uint[] { - 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, - 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, - 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, - 0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, - 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, - 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, - 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, - 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, - 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, - 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC, 0x51DE003A, - 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, - 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, - 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, - 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, - 0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, - 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, - 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, - 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, - 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, - 0xFBD44C65, 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, - 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, - 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, - 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, 0xBE0B1010, - 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, - 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, - 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, - 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, - 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, - 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, - 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, - 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, - 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, - 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, - 0xA6BC5767, 0x3FB506DD, 0x48B2364B, 0xD80D2BDA, 0xAF0A1B4C, - 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, - 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, - 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, - 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, - 0x2CD99E8B, 0x5BDEAE1D, 0x9B64C2B0, 0xEC63F226, 0x756AA39C, - 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, - 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, - 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, - 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, - 0x18B74777, 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, - 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, 0xA00AE278, - 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, - 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, - 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, - 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, - 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, - 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, - 0x2D02EF8D - }; - - internal static uint ComputeCrc32(uint oldCrc, byte bval) - { - return (uint)(Crc32.CrcTable[(oldCrc ^ bval) & 0xFF] ^ (oldCrc >> 8)); - } - - /// - /// The crc data checksum so far. - /// - uint crc = 0; - - /// - /// Returns the CRC32 data checksum computed so far. - /// - public long Value { - get { - return (long)crc; - } - set { - crc = (uint)value; - } - } - - /// - /// Resets the CRC32 data checksum as if no update was ever called. - /// - public void Reset() - { - crc = 0; - } - - /// - /// Updates the checksum with the int bval. - /// - /// - /// the byte is taken as the lower 8 bits of bval - /// - public void Update(int bval) - { - crc ^= CrcSeed; - crc = CrcTable[(crc ^ bval) & 0xFF] ^ (crc >> 8); - crc ^= CrcSeed; - } - - /// - /// Updates the checksum with the bytes taken from the array. - /// - /// - /// buffer an array of bytes - /// - public void Update(byte[] buffer) - { - Update(buffer, 0, buffer.Length); - } - - /// - /// Adds the byte array to the data checksum. - /// - /// - /// the buffer which contains the data - /// - /// - /// the offset in the buffer where the data starts - /// - /// - /// the length of the data - /// - public void Update(byte[] buf, int off, int len) - { - if (buf == null) { - throw new ArgumentNullException("buf"); - } - - if (off < 0 || len < 0 || off + len > buf.Length) { - throw new ArgumentOutOfRangeException(); - } - - crc ^= CrcSeed; - - while (--len >= 0) { - crc = CrcTable[(crc ^ buf[off++]) & 0xFF] ^ (crc >> 8); - } - - crc ^= CrcSeed; - } - } -} diff --git a/irc/TechBot/Compression/Checksums/IChecksum.cs b/irc/TechBot/Compression/Checksums/IChecksum.cs deleted file mode 100644 index 98385b316ac..00000000000 --- a/irc/TechBot/Compression/Checksums/IChecksum.cs +++ /dev/null @@ -1,93 +0,0 @@ -// IChecksum.cs - Interface to compute a data checksum -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -namespace ICSharpCode.SharpZipLib.Checksums -{ - - /// - /// Interface to compute a data checksum used by checked input/output streams. - /// A data checksum can be updated by one byte or with a byte array. After each - /// update the value of the current checksum can be returned by calling - /// getValue. The complete checksum object can also be reset - /// so it can be used again with new data. - /// - public interface IChecksum - { - /// - /// Returns the data checksum computed so far. - /// - long Value - { - get; - } - - /// - /// Resets the data checksum as if no update was ever called. - /// - void Reset(); - - /// - /// Adds one byte to the data checksum. - /// - /// - /// the data value to add. The high byte of the int is ignored. - /// - void Update(int bval); - - /// - /// Updates the data checksum with the bytes taken from the array. - /// - /// - /// buffer an array of bytes - /// - void Update(byte[] buffer); - - /// - /// Adds the byte array to the data checksum. - /// - /// - /// the buffer which contains the data - /// - /// - /// the offset in the buffer where the data starts - /// - /// - /// the length of the data - /// - void Update(byte[] buf, int off, int len); - } -} diff --git a/irc/TechBot/Compression/Checksums/StrangeCRC.cs b/irc/TechBot/Compression/Checksums/StrangeCRC.cs deleted file mode 100644 index a2dc10fcf12..00000000000 --- a/irc/TechBot/Compression/Checksums/StrangeCRC.cs +++ /dev/null @@ -1,159 +0,0 @@ -// StrangeCRC.cs - computes a crc used in the bziplib ... I don't think that -// this is the 'standard' crc, please correct me, if I'm wrong -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; - -namespace ICSharpCode.SharpZipLib.Checksums -{ - - public class StrangeCRC : IChecksum - { - readonly static uint[] crc32Table = { - 0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, - 0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005, - 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, - 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, - 0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9, - 0x5f15adac, 0x5bd4b01b, 0x569796c2, 0x52568b75, - 0x6a1936c8, 0x6ed82b7f, 0x639b0da6, 0x675a1011, - 0x791d4014, 0x7ddc5da3, 0x709f7b7a, 0x745e66cd, - 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039, - 0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5, - 0xbe2b5b58, 0xbaea46ef, 0xb7a96036, 0xb3687d81, - 0xad2f2d84, 0xa9ee3033, 0xa4ad16ea, 0xa06c0b5d, - 0xd4326d90, 0xd0f37027, 0xddb056fe, 0xd9714b49, - 0xc7361b4c, 0xc3f706fb, 0xceb42022, 0xca753d95, - 0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1, - 0xe13ef6f4, 0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d, - 0x34867077, 0x30476dc0, 0x3d044b19, 0x39c556ae, - 0x278206ab, 0x23431b1c, 0x2e003dc5, 0x2ac12072, - 0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16, - 0x018aeb13, 0x054bf6a4, 0x0808d07d, 0x0cc9cdca, - 0x7897ab07, 0x7c56b6b0, 0x71159069, 0x75d48dde, - 0x6b93dddb, 0x6f52c06c, 0x6211e6b5, 0x66d0fb02, - 0x5e9f46bf, 0x5a5e5b08, 0x571d7dd1, 0x53dc6066, - 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba, - 0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, - 0xbfa1b04b, 0xbb60adfc, 0xb6238b25, 0xb2e29692, - 0x8aad2b2f, 0x8e6c3698, 0x832f1041, 0x87ee0df6, - 0x99a95df3, 0x9d684044, 0x902b669d, 0x94ea7b2a, - 0xe0b41de7, 0xe4750050, 0xe9362689, 0xedf73b3e, - 0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2, - 0xc6bcf05f, 0xc27dede8, 0xcf3ecb31, 0xcbffd686, - 0xd5b88683, 0xd1799b34, 0xdc3abded, 0xd8fba05a, - 0x690ce0ee, 0x6dcdfd59, 0x608edb80, 0x644fc637, - 0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb, - 0x4f040d56, 0x4bc510e1, 0x46863638, 0x42472b8f, - 0x5c007b8a, 0x58c1663d, 0x558240e4, 0x51435d53, - 0x251d3b9e, 0x21dc2629, 0x2c9f00f0, 0x285e1d47, - 0x36194d42, 0x32d850f5, 0x3f9b762c, 0x3b5a6b9b, - 0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff, - 0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623, - 0xf12f560e, 0xf5ee4bb9, 0xf8ad6d60, 0xfc6c70d7, - 0xe22b20d2, 0xe6ea3d65, 0xeba91bbc, 0xef68060b, - 0xd727bbb6, 0xd3e6a601, 0xdea580d8, 0xda649d6f, - 0xc423cd6a, 0xc0e2d0dd, 0xcda1f604, 0xc960ebb3, - 0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7, - 0xae3afba2, 0xaafbe615, 0xa7b8c0cc, 0xa379dd7b, - 0x9b3660c6, 0x9ff77d71, 0x92b45ba8, 0x9675461f, - 0x8832161a, 0x8cf30bad, 0x81b02d74, 0x857130c3, - 0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640, - 0x4e8ee645, 0x4a4ffbf2, 0x470cdd2b, 0x43cdc09c, - 0x7b827d21, 0x7f436096, 0x7200464f, 0x76c15bf8, - 0x68860bfd, 0x6c47164a, 0x61043093, 0x65c52d24, - 0x119b4be9, 0x155a565e, 0x18197087, 0x1cd86d30, - 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec, - 0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, - 0x2497d08d, 0x2056cd3a, 0x2d15ebe3, 0x29d4f654, - 0xc5a92679, 0xc1683bce, 0xcc2b1d17, 0xc8ea00a0, - 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb, 0xdbee767c, - 0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18, - 0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4, - 0x89b8fd09, 0x8d79e0be, 0x803ac667, 0x84fbdbd0, - 0x9abc8bd5, 0x9e7d9662, 0x933eb0bb, 0x97ffad0c, - 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668, - 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4 - }; - int globalCrc; - - public StrangeCRC() - { - Reset(); - } - - public void Reset() - { - globalCrc = -1; - } - - public long Value { - get { - return ~globalCrc; - } - } - - public void Update(int inCh) - { - int temp = (globalCrc >> 24) ^ inCh; - if (temp < 0) { - temp = 256 + temp; - } - globalCrc = (int)((globalCrc << 8) ^ crc32Table[temp]); - } - - public void Update(byte[] buf) - { - Update(buf, 0, buf.Length); - } - - public void Update(byte[] buf, int off, int len) - { - if (buf == null) { - throw new ArgumentNullException("buf"); - } - - if (off < 0 || len < 0 || off + len > buf.Length) { - throw new ArgumentOutOfRangeException(); - } - - for (int i = 0; i < len; ++i) { - Update(buf[off++]); - } - } - } -} diff --git a/irc/TechBot/Compression/Compression.cmbx b/irc/TechBot/Compression/Compression.cmbx deleted file mode 100644 index 28d8e0cd398..00000000000 --- a/irc/TechBot/Compression/Compression.cmbx +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/irc/TechBot/Compression/Compression.csproj b/irc/TechBot/Compression/Compression.csproj deleted file mode 100644 index 8e6fb7ef92e..00000000000 --- a/irc/TechBot/Compression/Compression.csproj +++ /dev/null @@ -1,65 +0,0 @@ - - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {E32307F1-623A-4E62-826F-56CDD4B23A54} - Library - Properties - Compression - Compression - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/irc/TechBot/Compression/Compression.prjx b/irc/TechBot/Compression/Compression.prjx deleted file mode 100644 index 95316d15b26..00000000000 --- a/irc/TechBot/Compression/Compression.prjx +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/irc/TechBot/Compression/Default.build b/irc/TechBot/Compression/Default.build deleted file mode 100644 index 5a229e272d6..00000000000 --- a/irc/TechBot/Compression/Default.build +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/irc/TechBot/Compression/Deflater.cs b/irc/TechBot/Compression/Deflater.cs deleted file mode 100644 index bb8d4cc3ca8..00000000000 --- a/irc/TechBot/Compression/Deflater.cs +++ /dev/null @@ -1,542 +0,0 @@ -// Deflater.cs -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; - -namespace ICSharpCode.SharpZipLib.Zip.Compression -{ - - /// - /// This is the Deflater class. The deflater class compresses input - /// with the deflate algorithm described in RFC 1951. It has several - /// compression levels and three different strategies described below. - /// - /// This class is not thread safe. This is inherent in the API, due - /// to the split of deflate and setInput. - /// - /// author of the original java version : Jochen Hoenicke - /// - public class Deflater - { - /// - /// The best and slowest compression level. This tries to find very - /// long and distant string repetitions. - /// - public static int BEST_COMPRESSION = 9; - - /// - /// The worst but fastest compression level. - /// - public static int BEST_SPEED = 1; - - /// - /// The default compression level. - /// - public static int DEFAULT_COMPRESSION = -1; - - /// - /// This level won't compress at all but output uncompressed blocks. - /// - public static int NO_COMPRESSION = 0; - - /// - /// The compression method. This is the only method supported so far. - /// There is no need to use this constant at all. - /// - public static int DEFLATED = 8; - - /* - * The Deflater can do the following state transitions: - * - * (1) -> INIT_STATE ----> INIT_FINISHING_STATE ---. - * / | (2) (5) | - * / v (5) | - * (3)| SETDICT_STATE ---> SETDICT_FINISHING_STATE |(3) - * \ | (3) | ,-------' - * | | | (3) / - * v v (5) v v - * (1) -> BUSY_STATE ----> FINISHING_STATE - * | (6) - * v - * FINISHED_STATE - * \_____________________________________/ - * | (7) - * v - * CLOSED_STATE - * - * (1) If we should produce a header we start in INIT_STATE, otherwise - * we start in BUSY_STATE. - * (2) A dictionary may be set only when we are in INIT_STATE, then - * we change the state as indicated. - * (3) Whether a dictionary is set or not, on the first call of deflate - * we change to BUSY_STATE. - * (4) -- intentionally left blank -- :) - * (5) FINISHING_STATE is entered, when flush() is called to indicate that - * there is no more INPUT. There are also states indicating, that - * the header wasn't written yet. - * (6) FINISHED_STATE is entered, when everything has been flushed to the - * internal pending output buffer. - * (7) At any time (7) - * - */ - - private static int IS_SETDICT = 0x01; - private static int IS_FLUSHING = 0x04; - private static int IS_FINISHING = 0x08; - - private static int INIT_STATE = 0x00; - private static int SETDICT_STATE = 0x01; - // private static int INIT_FINISHING_STATE = 0x08; - // private static int SETDICT_FINISHING_STATE = 0x09; - private static int BUSY_STATE = 0x10; - private static int FLUSHING_STATE = 0x14; - private static int FINISHING_STATE = 0x1c; - private static int FINISHED_STATE = 0x1e; - private static int CLOSED_STATE = 0x7f; - - /// - /// Compression level. - /// - private int level; - - /// - /// should we include a header. - /// - private bool noHeader; - - // /// - // /// Compression strategy. - // /// - // private int strategy; - - /// - /// The current state. - /// - private int state; - - /// - /// The total bytes of output written. - /// - private int totalOut; - - /// - /// The pending output. - /// - private DeflaterPending pending; - - /// - /// The deflater engine. - /// - private DeflaterEngine engine; - - /// - /// Creates a new deflater with default compression level. - /// - public Deflater() : this(DEFAULT_COMPRESSION, false) - { - - } - - /// - /// Creates a new deflater with given compression level. - /// - /// - /// the compression level, a value between NO_COMPRESSION - /// and BEST_COMPRESSION, or DEFAULT_COMPRESSION. - /// - /// if lvl is out of range. - public Deflater(int lvl) : this(lvl, false) - { - - } - - /// - /// Creates a new deflater with given compression level. - /// - /// - /// the compression level, a value between NO_COMPRESSION - /// and BEST_COMPRESSION. - /// - /// - /// true, if we should suppress the deflate header at the - /// beginning and the adler checksum at the end of the output. This is - /// useful for the GZIP format. - /// - /// if lvl is out of range. - public Deflater(int lvl, bool nowrap) - { - if (lvl == DEFAULT_COMPRESSION) { - lvl = 6; - } else if (lvl < NO_COMPRESSION || lvl > BEST_COMPRESSION) { - throw new ArgumentOutOfRangeException("lvl"); - } - - pending = new DeflaterPending(); - engine = new DeflaterEngine(pending); - this.noHeader = nowrap; - SetStrategy(DeflateStrategy.Default); - SetLevel(lvl); - Reset(); - } - - - /// - /// Resets the deflater. The deflater acts afterwards as if it was - /// just created with the same compression level and strategy as it - /// had before. - /// - public void Reset() - { - state = (noHeader ? BUSY_STATE : INIT_STATE); - totalOut = 0; - pending.Reset(); - engine.Reset(); - } - - /// - /// Gets the current adler checksum of the data that was processed so far. - /// - public int Adler { - get { - return engine.Adler; - } - } - - /// - /// Gets the number of input bytes processed so far. - /// - public int TotalIn { - get { - return engine.TotalIn; - } - } - - /// - /// Gets the number of output bytes so far. - /// - public int TotalOut { - get { - return totalOut; - } - } - - /// - /// Flushes the current input block. Further calls to deflate() will - /// produce enough output to inflate everything in the current input - /// block. This is not part of Sun's JDK so I have made it package - /// private. It is used by DeflaterOutputStream to implement - /// flush(). - /// - public void Flush() - { - state |= IS_FLUSHING; - } - - /// - /// Finishes the deflater with the current input block. It is an error - /// to give more input after this method was called. This method must - /// be called to force all bytes to be flushed. - /// - public void Finish() - { - state |= IS_FLUSHING | IS_FINISHING; - } - - /// - /// Returns true if the stream was finished and no more output bytes - /// are available. - /// - public bool IsFinished { - get { - return state == FINISHED_STATE && pending.IsFlushed; - } - } - - /// - /// Returns true, if the input buffer is empty. - /// You should then call setInput(). - /// NOTE: This method can also return true when the stream - /// was finished. - /// - public bool IsNeedingInput { - get { - return engine.NeedsInput(); - } - } - - /// - /// Sets the data which should be compressed next. This should be only - /// called when needsInput indicates that more input is needed. - /// If you call setInput when needsInput() returns false, the - /// previous input that is still pending will be thrown away. - /// The given byte array should not be changed, before needsInput() returns - /// true again. - /// This call is equivalent to setInput(input, 0, input.length). - /// - /// - /// the buffer containing the input data. - /// - /// - /// if the buffer was finished() or ended(). - /// - public void SetInput(byte[] input) - { - SetInput(input, 0, input.Length); - } - - /// - /// Sets the data which should be compressed next. This should be - /// only called when needsInput indicates that more input is needed. - /// The given byte array should not be changed, before needsInput() returns - /// true again. - /// - /// - /// the buffer containing the input data. - /// - /// - /// the start of the data. - /// - /// - /// the length of the data. - /// - /// - /// if the buffer was finished() or ended() or if previous input is still pending. - /// - public void SetInput(byte[] input, int off, int len) - { - if ((state & IS_FINISHING) != 0) { - throw new InvalidOperationException("finish()/end() already called"); - } - engine.SetInput(input, off, len); - } - - /// - /// Sets the compression level. There is no guarantee of the exact - /// position of the change, but if you call this when needsInput is - /// true the change of compression level will occur somewhere near - /// before the end of the so far given input. - /// - /// - /// the new compression level. - /// - public void SetLevel(int lvl) - { - if (lvl == DEFAULT_COMPRESSION) { - lvl = 6; - } else if (lvl < NO_COMPRESSION || lvl > BEST_COMPRESSION) { - throw new ArgumentOutOfRangeException("lvl"); - } - - if (level != lvl) { - level = lvl; - engine.SetLevel(lvl); - } - } - - /// - /// Sets the compression strategy. Strategy is one of - /// DEFAULT_STRATEGY, HUFFMAN_ONLY and FILTERED. For the exact - /// position where the strategy is changed, the same as for - /// setLevel() applies. - /// - /// - /// the new compression strategy. - /// - public void SetStrategy(DeflateStrategy stgy) - { - engine.Strategy = stgy; - } - - /// - /// Deflates the current input block to the given array. It returns - /// the number of bytes compressed, or 0 if either - /// needsInput() or finished() returns true or length is zero. - /// - /// - /// the buffer where to write the compressed data. - /// - public int Deflate(byte[] output) - { - return Deflate(output, 0, output.Length); - } - - /// - /// Deflates the current input block to the given array. It returns - /// the number of bytes compressed, or 0 if either - /// needsInput() or finished() returns true or length is zero. - /// - /// - /// the buffer where to write the compressed data. - /// - /// - /// the offset into the output array. - /// - /// - /// the maximum number of bytes that may be written. - /// - /// - /// if end() was called. - /// - /// - /// if offset and/or length don't match the array length. - /// - public int Deflate(byte[] output, int offset, int length) - { - int origLength = length; - - if (state == CLOSED_STATE) { - throw new InvalidOperationException("Deflater closed"); - } - - if (state < BUSY_STATE) { - /* output header */ - int header = (DEFLATED + - ((DeflaterConstants.MAX_WBITS - 8) << 4)) << 8; - int level_flags = (level - 1) >> 1; - if (level_flags < 0 || level_flags > 3) { - level_flags = 3; - } - header |= level_flags << 6; - if ((state & IS_SETDICT) != 0) { - /* Dictionary was set */ - header |= DeflaterConstants.PRESET_DICT; - } - header += 31 - (header % 31); - - - pending.WriteShortMSB(header); - if ((state & IS_SETDICT) != 0) { - int chksum = engine.Adler; - engine.ResetAdler(); - pending.WriteShortMSB(chksum >> 16); - pending.WriteShortMSB(chksum & 0xffff); - } - - state = BUSY_STATE | (state & (IS_FLUSHING | IS_FINISHING)); - } - - for (;;) { - int count = pending.Flush(output, offset, length); - offset += count; - totalOut += count; - length -= count; - - if (length == 0 || state == FINISHED_STATE) { - break; - } - - if (!engine.Deflate((state & IS_FLUSHING) != 0, (state & IS_FINISHING) != 0)) { - if (state == BUSY_STATE) { - /* We need more input now */ - return origLength - length; - } else if (state == FLUSHING_STATE) { - if (level != NO_COMPRESSION) { - /* We have to supply some lookahead. 8 bit lookahead - * are needed by the zlib inflater, and we must fill - * the next byte, so that all bits are flushed. - */ - int neededbits = 8 + ((-pending.BitCount) & 7); - while (neededbits > 0) { - /* write a static tree block consisting solely of - * an EOF: - */ - pending.WriteBits(2, 10); - neededbits -= 10; - } - } - state = BUSY_STATE; - } else if (state == FINISHING_STATE) { - pending.AlignToByte(); - /* We have completed the stream */ - if (!noHeader) { - int adler = engine.Adler; - pending.WriteShortMSB(adler >> 16); - pending.WriteShortMSB(adler & 0xffff); - } - state = FINISHED_STATE; - } - } - } - return origLength - length; - } - - /// - /// Sets the dictionary which should be used in the deflate process. - /// This call is equivalent to setDictionary(dict, 0, dict.Length). - /// - /// - /// the dictionary. - /// - /// - /// if setInput () or deflate () were already called or another dictionary was already set. - /// - public void SetDictionary(byte[] dict) - { - SetDictionary(dict, 0, dict.Length); - } - - /// - /// Sets the dictionary which should be used in the deflate process. - /// The dictionary should be a byte array containing strings that are - /// likely to occur in the data which should be compressed. The - /// dictionary is not stored in the compressed output, only a - /// checksum. To decompress the output you need to supply the same - /// dictionary again. - /// - /// - /// the dictionary. - /// - /// - /// an offset into the dictionary. - /// - /// - /// the length of the dictionary. - /// - /// - /// if setInput () or deflate () were already called or another dictionary was already set. - /// - public void SetDictionary(byte[] dict, int offset, int length) - { - if (state != INIT_STATE) { - throw new InvalidOperationException(); - } - - state = SETDICT_STATE; - engine.SetDictionary(dict, offset, length); - } - } -} diff --git a/irc/TechBot/Compression/DeflaterConstants.cs b/irc/TechBot/Compression/DeflaterConstants.cs deleted file mode 100644 index 8e2be6e21ca..00000000000 --- a/irc/TechBot/Compression/DeflaterConstants.cs +++ /dev/null @@ -1,85 +0,0 @@ -// DeflaterConstants.cs -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; - -namespace ICSharpCode.SharpZipLib.Zip.Compression -{ - - /// - /// This class contains constants used for the deflater. - /// - public class DeflaterConstants - { - public const bool DEBUGGING = false; - - public const int STORED_BLOCK = 0; - public const int STATIC_TREES = 1; - public const int DYN_TREES = 2; - public const int PRESET_DICT = 0x20; - - public const int DEFAULT_MEM_LEVEL = 8; - - public const int MAX_MATCH = 258; - public const int MIN_MATCH = 3; - - public const int MAX_WBITS = 15; - public const int WSIZE = 1 << MAX_WBITS; - public const int WMASK = WSIZE - 1; - - public const int HASH_BITS = DEFAULT_MEM_LEVEL + 7; - public const int HASH_SIZE = 1 << HASH_BITS; - public const int HASH_MASK = HASH_SIZE - 1; - public const int HASH_SHIFT = (HASH_BITS + MIN_MATCH - 1) / MIN_MATCH; - - public const int MIN_LOOKAHEAD = MAX_MATCH + MIN_MATCH + 1; - public const int MAX_DIST = WSIZE - MIN_LOOKAHEAD; - - public const int PENDING_BUF_SIZE = 1 << (DEFAULT_MEM_LEVEL + 8); - public static int MAX_BLOCK_SIZE = Math.Min(65535, PENDING_BUF_SIZE-5); - - public const int DEFLATE_STORED = 0; - public const int DEFLATE_FAST = 1; - public const int DEFLATE_SLOW = 2; - - public static int[] GOOD_LENGTH = { 0, 4, 4, 4, 4, 8, 8, 8, 32, 32 }; - public static int[] MAX_LAZY = { 0, 4, 5, 6, 4,16, 16, 32, 128, 258 }; - public static int[] NICE_LENGTH = { 0, 8,16,32,16,32,128,128, 258, 258 }; - public static int[] MAX_CHAIN = { 0, 4, 8,32,16,32,128,256,1024,4096 }; - public static int[] COMPR_FUNC = { 0, 1, 1, 1, 1, 2, 2, 2, 2, 2 }; - } -} diff --git a/irc/TechBot/Compression/DeflaterEngine.cs b/irc/TechBot/Compression/DeflaterEngine.cs deleted file mode 100644 index c543f850980..00000000000 --- a/irc/TechBot/Compression/DeflaterEngine.cs +++ /dev/null @@ -1,653 +0,0 @@ -// DeflaterEngine.cs -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; - -using ICSharpCode.SharpZipLib.Checksums; - -namespace ICSharpCode.SharpZipLib.Zip.Compression -{ - - public enum DeflateStrategy - { - // The default strategy. - Default = 0, - - // This strategy will only allow longer string repetitions. It is - // useful for random data with a small character set. - Filtered = 1, - - // This strategy will not look for string repetitions at all. It - // only encodes with Huffman trees (which means, that more common - // characters get a smaller encoding. - HuffmanOnly = 2 - } - - public class DeflaterEngine : DeflaterConstants - { - static int TOO_FAR = 4096; - - int ins_h; - // private byte[] buffer; - short[] head; - short[] prev; - - int matchStart, matchLen; - bool prevAvailable; - int blockStart; - int strstart, lookahead; - byte[] window; - - DeflateStrategy strategy; - int max_chain, max_lazy, niceLength, goodLength; - - /// - /// The current compression function. - /// - int comprFunc; - - /// - /// The input data for compression. - /// - byte[] inputBuf; - - /// - /// The total bytes of input read. - /// - int totalIn; - - /// - /// The offset into inputBuf, where input data starts. - /// - int inputOff; - - /// - /// The end offset of the input data. - /// - int inputEnd; - - DeflaterPending pending; - DeflaterHuffman huffman; - - /// - /// The adler checksum - /// - Adler32 adler; - - public DeflaterEngine(DeflaterPending pending) - { - this.pending = pending; - huffman = new DeflaterHuffman(pending); - adler = new Adler32(); - - window = new byte[2 * WSIZE]; - head = new short[HASH_SIZE]; - prev = new short[WSIZE]; - - /* We start at index 1, to avoid a implementation deficiency, that - * we cannot build a repeat pattern at index 0. - */ - blockStart = strstart = 1; - } - - public void Reset() - { - huffman.Reset(); - adler.Reset(); - blockStart = strstart = 1; - lookahead = 0; - totalIn = 0; - prevAvailable = false; - matchLen = MIN_MATCH - 1; - - for (int i = 0; i < HASH_SIZE; i++) { - head[i] = 0; - } - - for (int i = 0; i < WSIZE; i++) { - prev[i] = 0; - } - } - - public void ResetAdler() - { - adler.Reset(); - } - - public int Adler { - get { - return (int)adler.Value; - } - } - - public int TotalIn { - get { - return totalIn; - } - } - - public DeflateStrategy Strategy { - get { - return strategy; - } - set { - strategy = value; - } - } - - public void SetLevel(int lvl) - { - goodLength = DeflaterConstants.GOOD_LENGTH[lvl]; - max_lazy = DeflaterConstants.MAX_LAZY[lvl]; - niceLength = DeflaterConstants.NICE_LENGTH[lvl]; - max_chain = DeflaterConstants.MAX_CHAIN[lvl]; - - if (DeflaterConstants.COMPR_FUNC[lvl] != comprFunc) { - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("Change from "+comprFunc +" to " - // + DeflaterConstants.COMPR_FUNC[lvl]); - // } - switch (comprFunc) { - case DEFLATE_STORED: - if (strstart > blockStart) { - huffman.FlushStoredBlock(window, blockStart, - strstart - blockStart, false); - blockStart = strstart; - } - UpdateHash(); - break; - case DEFLATE_FAST: - if (strstart > blockStart) { - huffman.FlushBlock(window, blockStart, strstart - blockStart, - false); - blockStart = strstart; - } - break; - case DEFLATE_SLOW: - if (prevAvailable) { - huffman.TallyLit(window[strstart-1] & 0xff); - } - if (strstart > blockStart) { - huffman.FlushBlock(window, blockStart, strstart - blockStart, false); - blockStart = strstart; - } - prevAvailable = false; - matchLen = MIN_MATCH - 1; - break; - } - comprFunc = COMPR_FUNC[lvl]; - } - } - - void UpdateHash() - { - // if (DEBUGGING) { - // //Console.WriteLine("updateHash: "+strstart); - // } - ins_h = (window[strstart] << HASH_SHIFT) ^ window[strstart + 1]; - } - - int InsertString() - { - short match; - int hash = ((ins_h << HASH_SHIFT) ^ window[strstart + (MIN_MATCH -1)]) & HASH_MASK; - - // if (DEBUGGING) { - // if (hash != (((window[strstart] << (2*HASH_SHIFT)) ^ - // (window[strstart + 1] << HASH_SHIFT) ^ - // (window[strstart + 2])) & HASH_MASK)) { - // throw new Exception("hash inconsistent: "+hash+"/" - // +window[strstart]+"," - // +window[strstart+1]+"," - // +window[strstart+2]+","+HASH_SHIFT); - // } - // } - - prev[strstart & WMASK] = match = head[hash]; - head[hash] = (short)strstart; - ins_h = hash; - return match & 0xffff; - } - - void SlideWindow() - { - Array.Copy(window, WSIZE, window, 0, WSIZE); - matchStart -= WSIZE; - strstart -= WSIZE; - blockStart -= WSIZE; - - /* Slide the hash table (could be avoided with 32 bit values - * at the expense of memory usage). - */ - for (int i = 0; i < HASH_SIZE; ++i) { - int m = head[i] & 0xffff; - head[i] = (short)(m >= WSIZE ? (m - WSIZE) : 0); - } - - /* Slide the prev table. */ - for (int i = 0; i < WSIZE; i++) { - int m = prev[i] & 0xffff; - prev[i] = (short)(m >= WSIZE ? (m - WSIZE) : 0); - } - } - - public void FillWindow() - { - /* If the window is almost full and there is insufficient lookahead, - * move the upper half to the lower one to make room in the upper half. - */ - if (strstart >= WSIZE + MAX_DIST) { - SlideWindow(); - } - - /* If there is not enough lookahead, but still some input left, - * read in the input - */ - while (lookahead < DeflaterConstants.MIN_LOOKAHEAD && inputOff < inputEnd) { - int more = 2 * WSIZE - lookahead - strstart; - - if (more > inputEnd - inputOff) { - more = inputEnd - inputOff; - } - - System.Array.Copy(inputBuf, inputOff, window, strstart + lookahead, more); - adler.Update(inputBuf, inputOff, more); - - inputOff += more; - totalIn += more; - lookahead += more; - } - - if (lookahead >= MIN_MATCH) { - UpdateHash(); - } - } - - bool FindLongestMatch(int curMatch) - { - int chainLength = this.max_chain; - int niceLength = this.niceLength; - short[] prev = this.prev; - int scan = this.strstart; - int match; - int best_end = this.strstart + matchLen; - int best_len = Math.Max(matchLen, MIN_MATCH - 1); - - int limit = Math.Max(strstart - MAX_DIST, 0); - - int strend = strstart + MAX_MATCH - 1; - byte scan_end1 = window[best_end - 1]; - byte scan_end = window[best_end]; - - /* Do not waste too much time if we already have a good match: */ - if (best_len >= this.goodLength) { - chainLength >>= 2; - } - - /* Do not look for matches beyond the end of the input. This is necessary - * to make deflate deterministic. - */ - if (niceLength > lookahead) { - niceLength = lookahead; - } - - if (DeflaterConstants.DEBUGGING && strstart > 2 * WSIZE - MIN_LOOKAHEAD) { - throw new InvalidOperationException("need lookahead"); - } - - do { - if (DeflaterConstants.DEBUGGING && curMatch >= strstart) { - throw new InvalidOperationException("future match"); - } - if (window[curMatch + best_len] != scan_end || - window[curMatch + best_len - 1] != scan_end1 || - window[curMatch] != window[scan] || - window[curMatch + 1] != window[scan + 1]) { - continue; - } - - match = curMatch + 2; - scan += 2; - - /* We check for insufficient lookahead only every 8th comparison; - * the 256th check will be made at strstart+258. - */ - while (window[++scan] == window[++match] && - window[++scan] == window[++match] && - window[++scan] == window[++match] && - window[++scan] == window[++match] && - window[++scan] == window[++match] && - window[++scan] == window[++match] && - window[++scan] == window[++match] && - window[++scan] == window[++match] && scan < strend) ; - - if (scan > best_end) { - // if (DeflaterConstants.DEBUGGING && ins_h == 0) - // System.err.println("Found match: "+curMatch+"-"+(scan-strstart)); - matchStart = curMatch; - best_end = scan; - best_len = scan - strstart; - - if (best_len >= niceLength) { - break; - } - - scan_end1 = window[best_end - 1]; - scan_end = window[best_end]; - } - scan = strstart; - } while ((curMatch = (prev[curMatch & WMASK] & 0xffff)) > limit && --chainLength != 0); - - matchLen = Math.Min(best_len, lookahead); - return matchLen >= MIN_MATCH; - } - - public void SetDictionary(byte[] buffer, int offset, int length) - { - if (DeflaterConstants.DEBUGGING && strstart != 1) { - throw new InvalidOperationException("strstart not 1"); - } - adler.Update(buffer, offset, length); - if (length < MIN_MATCH) { - return; - } - if (length > MAX_DIST) { - offset += length - MAX_DIST; - length = MAX_DIST; - } - - System.Array.Copy(buffer, offset, window, strstart, length); - - UpdateHash(); - --length; - while (--length > 0) { - InsertString(); - strstart++; - } - strstart += 2; - blockStart = strstart; - } - - bool DeflateStored(bool flush, bool finish) - { - if (!flush && lookahead == 0) { - return false; - } - - strstart += lookahead; - lookahead = 0; - - int storedLen = strstart - blockStart; - - if ((storedLen >= DeflaterConstants.MAX_BLOCK_SIZE) || /* Block is full */ - (blockStart < WSIZE && storedLen >= MAX_DIST) || /* Block may move out of window */ - flush) { - bool lastBlock = finish; - if (storedLen > DeflaterConstants.MAX_BLOCK_SIZE) { - storedLen = DeflaterConstants.MAX_BLOCK_SIZE; - lastBlock = false; - } - - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("storedBlock["+storedLen+","+lastBlock+"]"); - // } - - huffman.FlushStoredBlock(window, blockStart, storedLen, lastBlock); - blockStart += storedLen; - return !lastBlock; - } - return true; - } - - private bool DeflateFast(bool flush, bool finish) - { - if (lookahead < MIN_LOOKAHEAD && !flush) { - return false; - } - - while (lookahead >= MIN_LOOKAHEAD || flush) { - if (lookahead == 0) { - /* We are flushing everything */ - huffman.FlushBlock(window, blockStart, strstart - blockStart, finish); - blockStart = strstart; - return false; - } - - if (strstart > 2 * WSIZE - MIN_LOOKAHEAD) { - /* slide window, as findLongestMatch need this. - * This should only happen when flushing and the window - * is almost full. - */ - SlideWindow(); - } - - int hashHead; - if (lookahead >= MIN_MATCH && - (hashHead = InsertString()) != 0 && - strategy != DeflateStrategy.HuffmanOnly && - strstart - hashHead <= MAX_DIST && - FindLongestMatch(hashHead)) { - /* longestMatch sets matchStart and matchLen */ - // if (DeflaterConstants.DEBUGGING) { - // for (int i = 0 ; i < matchLen; i++) { - // if (window[strstart+i] != window[matchStart + i]) { - // throw new Exception(); - // } - // } - // } - - // -jr- Hak hak hak this stops problems with fast/low compression and index out of range - if (huffman.TallyDist(strstart - matchStart, matchLen)) { - bool lastBlock = finish && lookahead == 0; - huffman.FlushBlock(window, blockStart, strstart - blockStart, lastBlock); - blockStart = strstart; - } - - lookahead -= matchLen; - if (matchLen <= max_lazy && lookahead >= MIN_MATCH) { - while (--matchLen > 0) { - ++strstart; - InsertString(); - } - ++strstart; - } else { - strstart += matchLen; - if (lookahead >= MIN_MATCH - 1) { - UpdateHash(); - } - } - matchLen = MIN_MATCH - 1; - continue; - } else { - /* No match found */ - huffman.TallyLit(window[strstart] & 0xff); - ++strstart; - --lookahead; - } - - if (huffman.IsFull()) { - bool lastBlock = finish && lookahead == 0; - huffman.FlushBlock(window, blockStart, strstart - blockStart, lastBlock); - blockStart = strstart; - return !lastBlock; - } - } - return true; - } - - bool DeflateSlow(bool flush, bool finish) - { - if (lookahead < MIN_LOOKAHEAD && !flush) { - return false; - } - - while (lookahead >= MIN_LOOKAHEAD || flush) { - if (lookahead == 0) { - if (prevAvailable) { - huffman.TallyLit(window[strstart-1] & 0xff); - } - prevAvailable = false; - - /* We are flushing everything */ - if (DeflaterConstants.DEBUGGING && !flush) { - throw new Exception("Not flushing, but no lookahead"); - } - huffman.FlushBlock(window, blockStart, strstart - blockStart, - finish); - blockStart = strstart; - return false; - } - - if (strstart >= 2 * WSIZE - MIN_LOOKAHEAD) { - /* slide window, as findLongestMatch need this. - * This should only happen when flushing and the window - * is almost full. - */ - SlideWindow(); - } - - int prevMatch = matchStart; - int prevLen = matchLen; - if (lookahead >= MIN_MATCH) { - int hashHead = InsertString(); - if (strategy != DeflateStrategy.HuffmanOnly && hashHead != 0 && strstart - hashHead <= MAX_DIST && FindLongestMatch(hashHead)) { - /* longestMatch sets matchStart and matchLen */ - - /* Discard match if too small and too far away */ - if (matchLen <= 5 && (strategy == DeflateStrategy.Filtered || (matchLen == MIN_MATCH && strstart - matchStart > TOO_FAR))) { - matchLen = MIN_MATCH - 1; - } - } - } - - /* previous match was better */ - if (prevLen >= MIN_MATCH && matchLen <= prevLen) { - // if (DeflaterConstants.DEBUGGING) { - // for (int i = 0 ; i < matchLen; i++) { - // if (window[strstart-1+i] != window[prevMatch + i]) - // throw new Exception(); - // } - // } - huffman.TallyDist(strstart - 1 - prevMatch, prevLen); - prevLen -= 2; - do { - strstart++; - lookahead--; - if (lookahead >= MIN_MATCH) { - InsertString(); - } - } while (--prevLen > 0); - strstart ++; - lookahead--; - prevAvailable = false; - matchLen = MIN_MATCH - 1; - } else { - if (prevAvailable) { - huffman.TallyLit(window[strstart-1] & 0xff); - } - prevAvailable = true; - strstart++; - lookahead--; - } - - if (huffman.IsFull()) { - int len = strstart - blockStart; - if (prevAvailable) { - len--; - } - bool lastBlock = (finish && lookahead == 0 && !prevAvailable); - huffman.FlushBlock(window, blockStart, len, lastBlock); - blockStart += len; - return !lastBlock; - } - } - return true; - } - - public bool Deflate(bool flush, bool finish) - { - bool progress; - do { - FillWindow(); - bool canFlush = flush && inputOff == inputEnd; - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("window: ["+blockStart+","+strstart+"," - // +lookahead+"], "+comprFunc+","+canFlush); - // } - switch (comprFunc) { - case DEFLATE_STORED: - progress = DeflateStored(canFlush, finish); - break; - case DEFLATE_FAST: - progress = DeflateFast(canFlush, finish); - break; - case DEFLATE_SLOW: - progress = DeflateSlow(canFlush, finish); - break; - default: - throw new InvalidOperationException("unknown comprFunc"); - } - } while (pending.IsFlushed && progress); /* repeat while we have no pending output and progress was made */ - return progress; - } - - public void SetInput(byte[] buf, int off, int len) - { - if (inputOff < inputEnd) { - throw new InvalidOperationException("Old input was not completely processed"); - } - - int end = off + len; - - /* We want to throw an ArrayIndexOutOfBoundsException early. The - * check is very tricky: it also handles integer wrap around. - */ - if (0 > off || off > end || end > buf.Length) { - throw new ArgumentOutOfRangeException(); - } - - inputBuf = buf; - inputOff = off; - inputEnd = end; - } - - public bool NeedsInput() - { - return inputEnd == inputOff; - } - } -} diff --git a/irc/TechBot/Compression/DeflaterHuffman.cs b/irc/TechBot/Compression/DeflaterHuffman.cs deleted file mode 100644 index 338d09ed242..00000000000 --- a/irc/TechBot/Compression/DeflaterHuffman.cs +++ /dev/null @@ -1,780 +0,0 @@ -// DeflaterHuffman.cs -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; - -namespace ICSharpCode.SharpZipLib.Zip.Compression -{ - - /// - /// This is the DeflaterHuffman class. - /// - /// This class is not thread safe. This is inherent in the API, due - /// to the split of deflate and setInput. - /// - /// author of the original java version : Jochen Hoenicke - /// - public class DeflaterHuffman - { - private static int BUFSIZE = 1 << (DeflaterConstants.DEFAULT_MEM_LEVEL + 6); - private static int LITERAL_NUM = 286; - private static int DIST_NUM = 30; - private static int BITLEN_NUM = 19; - private static int REP_3_6 = 16; - private static int REP_3_10 = 17; - private static int REP_11_138 = 18; - private static int EOF_SYMBOL = 256; - private static int[] BL_ORDER = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 }; - - private static byte[] bit4Reverse = { - 0, - 8, - 4, - 12, - 2, - 10, - 6, - 14, - 1, - 9, - 5, - 13, - 3, - 11, - 7, - 15 - }; - - public class Tree - { - public short[] freqs; - public byte[] length; - public int minNumCodes, numCodes; - - short[] codes; - int[] bl_counts; - int maxLength; - DeflaterHuffman dh; - - public Tree(DeflaterHuffman dh, int elems, int minCodes, int maxLength) - { - this.dh = dh; - this.minNumCodes = minCodes; - this.maxLength = maxLength; - freqs = new short[elems]; - bl_counts = new int[maxLength]; - } - - public void Reset() - { - for (int i = 0; i < freqs.Length; i++) { - freqs[i] = 0; - } - codes = null; - length = null; - } - - public void WriteSymbol(int code) - { - // if (DeflaterConstants.DEBUGGING) { - // freqs[code]--; - // // Console.Write("writeSymbol("+freqs.length+","+code+"): "); - // } - dh.pending.WriteBits(codes[code] & 0xffff, length[code]); - } - - public void CheckEmpty() - { - bool empty = true; - for (int i = 0; i < freqs.Length; i++) { - if (freqs[i] != 0) { - //Console.WriteLine("freqs["+i+"] == "+freqs[i]); - empty = false; - } - } - if (!empty) { - throw new Exception(); - } - //Console.WriteLine("checkEmpty suceeded!"); - } - - public void SetStaticCodes(short[] stCodes, byte[] stLength) - { - codes = stCodes; - length = stLength; - } - - public void BuildCodes() - { - int numSymbols = freqs.Length; - int[] nextCode = new int[maxLength]; - int code = 0; - codes = new short[freqs.Length]; - - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("buildCodes: "+freqs.Length); - // } - - for (int bits = 0; bits < maxLength; bits++) { - nextCode[bits] = code; - code += bl_counts[bits] << (15 - bits); - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("bits: "+(bits+1)+" count: "+bl_counts[bits] - // +" nextCode: "+code); // HACK : Integer.toHexString( - // } - } - if (DeflaterConstants.DEBUGGING && code != 65536) { - throw new Exception("Inconsistent bl_counts!"); - } - - for (int i=0; i < numCodes; i++) { - int bits = length[i]; - if (bits > 0) { - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("codes["+i+"] = rev(" + nextCode[bits-1]+")," // HACK : Integer.toHexString( - // +bits); - // } - codes[i] = BitReverse(nextCode[bits-1]); - nextCode[bits-1] += 1 << (16 - bits); - } - } - } - - void BuildLength(int[] childs) - { - this.length = new byte [freqs.Length]; - int numNodes = childs.Length / 2; - int numLeafs = (numNodes + 1) / 2; - int overflow = 0; - - for (int i = 0; i < maxLength; i++) { - bl_counts[i] = 0; - } - - /* First calculate optimal bit lengths */ - int[] lengths = new int[numNodes]; - lengths[numNodes-1] = 0; - - for (int i = numNodes - 1; i >= 0; i--) { - if (childs[2*i+1] != -1) { - int bitLength = lengths[i] + 1; - if (bitLength > maxLength) { - bitLength = maxLength; - overflow++; - } - lengths[childs[2*i]] = lengths[childs[2*i+1]] = bitLength; - } else { - /* A leaf node */ - int bitLength = lengths[i]; - bl_counts[bitLength - 1]++; - this.length[childs[2*i]] = (byte) lengths[i]; - } - } - - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("Tree "+freqs.Length+" lengths:"); - // for (int i=0; i < numLeafs; i++) { - // //Console.WriteLine("Node "+childs[2*i]+" freq: "+freqs[childs[2*i]] - // + " len: "+length[childs[2*i]]); - // } - // } - - if (overflow == 0) { - return; - } - - int incrBitLen = maxLength - 1; - do { - /* Find the first bit length which could increase: */ - while (bl_counts[--incrBitLen] == 0) - ; - - /* Move this node one down and remove a corresponding - * amount of overflow nodes. - */ - do { - bl_counts[incrBitLen]--; - bl_counts[++incrBitLen]++; - overflow -= 1 << (maxLength - 1 - incrBitLen); - } while (overflow > 0 && incrBitLen < maxLength - 1); - } while (overflow > 0); - - /* We may have overshot above. Move some nodes from maxLength to - * maxLength-1 in that case. - */ - bl_counts[maxLength-1] += overflow; - bl_counts[maxLength-2] -= overflow; - - /* Now recompute all bit lengths, scanning in increasing - * frequency. It is simpler to reconstruct all lengths instead of - * fixing only the wrong ones. This idea is taken from 'ar' - * written by Haruhiko Okumura. - * - * The nodes were inserted with decreasing frequency into the childs - * array. - */ - int nodePtr = 2 * numLeafs; - for (int bits = maxLength; bits != 0; bits--) { - int n = bl_counts[bits-1]; - while (n > 0) { - int childPtr = 2*childs[nodePtr++]; - if (childs[childPtr + 1] == -1) { - /* We found another leaf */ - length[childs[childPtr]] = (byte) bits; - n--; - } - } - } - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("*** After overflow elimination. ***"); - // for (int i=0; i < numLeafs; i++) { - // //Console.WriteLine("Node "+childs[2*i]+" freq: "+freqs[childs[2*i]] - // + " len: "+length[childs[2*i]]); - // } - // } - } - - public void BuildTree() - { - int numSymbols = freqs.Length; - - /* heap is a priority queue, sorted by frequency, least frequent - * nodes first. The heap is a binary tree, with the property, that - * the parent node is smaller than both child nodes. This assures - * that the smallest node is the first parent. - * - * The binary tree is encoded in an array: 0 is root node and - * the nodes 2*n+1, 2*n+2 are the child nodes of node n. - */ - int[] heap = new int[numSymbols]; - int heapLen = 0; - int maxCode = 0; - for (int n = 0; n < numSymbols; n++) { - int freq = freqs[n]; - if (freq != 0) { - /* Insert n into heap */ - int pos = heapLen++; - int ppos; - while (pos > 0 && freqs[heap[ppos = (pos - 1) / 2]] > freq) { - heap[pos] = heap[ppos]; - pos = ppos; - } - heap[pos] = n; - - maxCode = n; - } - } - - /* We could encode a single literal with 0 bits but then we - * don't see the literals. Therefore we force at least two - * literals to avoid this case. We don't care about order in - * this case, both literals get a 1 bit code. - */ - while (heapLen < 2) { - int node = maxCode < 2 ? ++maxCode : 0; - heap[heapLen++] = node; - } - - numCodes = Math.Max(maxCode + 1, minNumCodes); - - int numLeafs = heapLen; - int[] childs = new int[4*heapLen - 2]; - int[] values = new int[2*heapLen - 1]; - int numNodes = numLeafs; - for (int i = 0; i < heapLen; i++) { - int node = heap[i]; - childs[2*i] = node; - childs[2*i+1] = -1; - values[i] = freqs[node] << 8; - heap[i] = i; - } - - /* Construct the Huffman tree by repeatedly combining the least two - * frequent nodes. - */ - do { - int first = heap[0]; - int last = heap[--heapLen]; - - /* Propagate the hole to the leafs of the heap */ - int ppos = 0; - int path = 1; - - while (path < heapLen) { - if (path + 1 < heapLen && values[heap[path]] > values[heap[path+1]]) { - path++; - } - - heap[ppos] = heap[path]; - ppos = path; - path = path * 2 + 1; - } - - /* Now propagate the last element down along path. Normally - * it shouldn't go too deep. - */ - int lastVal = values[last]; - while ((path = ppos) > 0 && values[heap[ppos = (path - 1)/2]] > lastVal) { - heap[path] = heap[ppos]; - } - heap[path] = last; - - - int second = heap[0]; - - /* Create a new node father of first and second */ - last = numNodes++; - childs[2*last] = first; - childs[2*last+1] = second; - int mindepth = Math.Min(values[first] & 0xff, values[second] & 0xff); - values[last] = lastVal = values[first] + values[second] - mindepth + 1; - - /* Again, propagate the hole to the leafs */ - ppos = 0; - path = 1; - - while (path < heapLen) { - if (path + 1 < heapLen && values[heap[path]] > values[heap[path+1]]) { - path++; - } - - heap[ppos] = heap[path]; - ppos = path; - path = ppos * 2 + 1; - } - - /* Now propagate the new element down along path */ - while ((path = ppos) > 0 && values[heap[ppos = (path - 1)/2]] > lastVal) { - heap[path] = heap[ppos]; - } - heap[path] = last; - } while (heapLen > 1); - - if (heap[0] != childs.Length / 2 - 1) { - throw new Exception("Weird!"); - } - BuildLength(childs); - } - - public int GetEncodedLength() - { - int len = 0; - for (int i = 0; i < freqs.Length; i++) { - len += freqs[i] * length[i]; - } - return len; - } - - public void CalcBLFreq(Tree blTree) - { - int max_count; /* max repeat count */ - int min_count; /* min repeat count */ - int count; /* repeat count of the current code */ - int curlen = -1; /* length of current code */ - - int i = 0; - while (i < numCodes) { - count = 1; - int nextlen = length[i]; - if (nextlen == 0) { - max_count = 138; - min_count = 3; - } else { - max_count = 6; - min_count = 3; - if (curlen != nextlen) { - blTree.freqs[nextlen]++; - count = 0; - } - } - curlen = nextlen; - i++; - - while (i < numCodes && curlen == length[i]) { - i++; - if (++count >= max_count) { - break; - } - } - - if (count < min_count) { - blTree.freqs[curlen] += (short)count; - } else if (curlen != 0) { - blTree.freqs[REP_3_6]++; - } else if (count <= 10) { - blTree.freqs[REP_3_10]++; - } else { - blTree.freqs[REP_11_138]++; - } - } - } - - public void WriteTree(Tree blTree) - { - int max_count; /* max repeat count */ - int min_count; /* min repeat count */ - int count; /* repeat count of the current code */ - int curlen = -1; /* length of current code */ - - int i = 0; - while (i < numCodes) { - count = 1; - int nextlen = length[i]; - if (nextlen == 0) { - max_count = 138; - min_count = 3; - } else { - max_count = 6; - min_count = 3; - if (curlen != nextlen) { - blTree.WriteSymbol(nextlen); - count = 0; - } - } - curlen = nextlen; - i++; - - while (i < numCodes && curlen == length[i]) { - i++; - if (++count >= max_count) { - break; - } - } - - if (count < min_count) { - while (count-- > 0) { - blTree.WriteSymbol(curlen); - } - } else if (curlen != 0) { - blTree.WriteSymbol(REP_3_6); - dh.pending.WriteBits(count - 3, 2); - } else if (count <= 10) { - blTree.WriteSymbol(REP_3_10); - dh.pending.WriteBits(count - 3, 3); - } else { - blTree.WriteSymbol(REP_11_138); - dh.pending.WriteBits(count - 11, 7); - } - } - } - } - - public DeflaterPending pending; - private Tree literalTree, distTree, blTree; - - private short[] d_buf; - private byte[] l_buf; - private int last_lit; - private int extra_bits; - - private static short[] staticLCodes; - private static byte[] staticLLength; - private static short[] staticDCodes; - private static byte[] staticDLength; - - /// - /// Reverse the bits of a 16 bit value. - /// - public static short BitReverse(int value) - { - return (short) (bit4Reverse[value & 0xF] << 12 | - bit4Reverse[(value >> 4) & 0xF] << 8 | - bit4Reverse[(value >> 8) & 0xF] << 4 | - bit4Reverse[value >> 12]); - } - - - static DeflaterHuffman() - { - /* See RFC 1951 3.2.6 */ - /* Literal codes */ - staticLCodes = new short[LITERAL_NUM]; - staticLLength = new byte[LITERAL_NUM]; - int i = 0; - while (i < 144) { - staticLCodes[i] = BitReverse((0x030 + i) << 8); - staticLLength[i++] = 8; - } - while (i < 256) { - staticLCodes[i] = BitReverse((0x190 - 144 + i) << 7); - staticLLength[i++] = 9; - } - while (i < 280) { - staticLCodes[i] = BitReverse((0x000 - 256 + i) << 9); - staticLLength[i++] = 7; - } - while (i < LITERAL_NUM) { - staticLCodes[i] = BitReverse((0x0c0 - 280 + i) << 8); - staticLLength[i++] = 8; - } - - /* Distant codes */ - staticDCodes = new short[DIST_NUM]; - staticDLength = new byte[DIST_NUM]; - for (i = 0; i < DIST_NUM; i++) { - staticDCodes[i] = BitReverse(i << 11); - staticDLength[i] = 5; - } - } - - public DeflaterHuffman(DeflaterPending pending) - { - this.pending = pending; - - literalTree = new Tree(this, LITERAL_NUM, 257, 15); - distTree = new Tree(this, DIST_NUM, 1, 15); - blTree = new Tree(this, BITLEN_NUM, 4, 7); - - d_buf = new short[BUFSIZE]; - l_buf = new byte [BUFSIZE]; - } - - public void Reset() - { - last_lit = 0; - extra_bits = 0; - literalTree.Reset(); - distTree.Reset(); - blTree.Reset(); - } - - int Lcode(int len) - { - if (len == 255) { - return 285; - } - - int code = 257; - while (len >= 8) { - code += 4; - len >>= 1; - } - return code + len; - } - - int Dcode(int distance) - { - int code = 0; - while (distance >= 4) { - code += 2; - distance >>= 1; - } - return code + distance; - } - - public void SendAllTrees(int blTreeCodes) - { - blTree.BuildCodes(); - literalTree.BuildCodes(); - distTree.BuildCodes(); - pending.WriteBits(literalTree.numCodes - 257, 5); - pending.WriteBits(distTree.numCodes - 1, 5); - pending.WriteBits(blTreeCodes - 4, 4); - for (int rank = 0; rank < blTreeCodes; rank++) { - pending.WriteBits(blTree.length[BL_ORDER[rank]], 3); - } - literalTree.WriteTree(blTree); - distTree.WriteTree(blTree); - // if (DeflaterConstants.DEBUGGING) { - // blTree.CheckEmpty(); - // } - } - - public void CompressBlock() - { - for (int i = 0; i < last_lit; i++) { - int litlen = l_buf[i] & 0xff; - int dist = d_buf[i]; - if (dist-- != 0) { - // if (DeflaterConstants.DEBUGGING) { - // Console.Write("["+(dist+1)+","+(litlen+3)+"]: "); - // } - - int lc = Lcode(litlen); - literalTree.WriteSymbol(lc); - - int bits = (lc - 261) / 4; - if (bits > 0 && bits <= 5) { - pending.WriteBits(litlen & ((1 << bits) - 1), bits); - } - - int dc = Dcode(dist); - distTree.WriteSymbol(dc); - - bits = dc / 2 - 1; - if (bits > 0) { - pending.WriteBits(dist & ((1 << bits) - 1), bits); - } - } else { - // if (DeflaterConstants.DEBUGGING) { - // if (litlen > 32 && litlen < 127) { - // Console.Write("("+(char)litlen+"): "); - // } else { - // Console.Write("{"+litlen+"}: "); - // } - // } - literalTree.WriteSymbol(litlen); - } - } - // if (DeflaterConstants.DEBUGGING) { - // Console.Write("EOF: "); - // } - literalTree.WriteSymbol(EOF_SYMBOL); - // if (DeflaterConstants.DEBUGGING) { - // literalTree.CheckEmpty(); - // distTree.CheckEmpty(); - // } - } - - public void FlushStoredBlock(byte[] stored, int storedOffset, int storedLength, bool lastBlock) - { - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("Flushing stored block "+ storedLength); - // } - pending.WriteBits((DeflaterConstants.STORED_BLOCK << 1) + (lastBlock ? 1 : 0), 3); - pending.AlignToByte(); - pending.WriteShort(storedLength); - pending.WriteShort(~storedLength); - pending.WriteBlock(stored, storedOffset, storedLength); - Reset(); - } - - public void FlushBlock(byte[] stored, int storedOffset, int storedLength, bool lastBlock) - { - literalTree.freqs[EOF_SYMBOL]++; - - /* Build trees */ - literalTree.BuildTree(); - distTree.BuildTree(); - - /* Calculate bitlen frequency */ - literalTree.CalcBLFreq(blTree); - distTree.CalcBLFreq(blTree); - - /* Build bitlen tree */ - blTree.BuildTree(); - - int blTreeCodes = 4; - for (int i = 18; i > blTreeCodes; i--) { - if (blTree.length[BL_ORDER[i]] > 0) { - blTreeCodes = i+1; - } - } - int opt_len = 14 + blTreeCodes * 3 + blTree.GetEncodedLength() + - literalTree.GetEncodedLength() + distTree.GetEncodedLength() + - extra_bits; - - int static_len = extra_bits; - for (int i = 0; i < LITERAL_NUM; i++) { - static_len += literalTree.freqs[i] * staticLLength[i]; - } - for (int i = 0; i < DIST_NUM; i++) { - static_len += distTree.freqs[i] * staticDLength[i]; - } - if (opt_len >= static_len) { - /* Force static trees */ - opt_len = static_len; - } - - if (storedOffset >= 0 && storedLength+4 < opt_len >> 3) { - /* Store Block */ - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("Storing, since " + storedLength + " < " + opt_len - // + " <= " + static_len); - // } - FlushStoredBlock(stored, storedOffset, storedLength, lastBlock); - } else if (opt_len == static_len) { - /* Encode with static tree */ - pending.WriteBits((DeflaterConstants.STATIC_TREES << 1) + (lastBlock ? 1 : 0), 3); - literalTree.SetStaticCodes(staticLCodes, staticLLength); - distTree.SetStaticCodes(staticDCodes, staticDLength); - CompressBlock(); - Reset(); - } else { - /* Encode with dynamic tree */ - pending.WriteBits((DeflaterConstants.DYN_TREES << 1) + (lastBlock ? 1 : 0), 3); - SendAllTrees(blTreeCodes); - CompressBlock(); - Reset(); - } - } - - public bool IsFull() - { -// return last_lit + 16 >= BUFSIZE; // HACK: This was == 'last_lit == BUFSIZE', but errors occured with DeflateFast - return last_lit >= BUFSIZE; // -jr- This is the correct form! - } - - public bool TallyLit(int lit) - { - // if (DeflaterConstants.DEBUGGING) { - // if (lit > 32 && lit < 127) { - // //Console.WriteLine("("+(char)lit+")"); - // } else { - // //Console.WriteLine("{"+lit+"}"); - // } - // } - d_buf[last_lit] = 0; - l_buf[last_lit++] = (byte)lit; - literalTree.freqs[lit]++; - return IsFull(); - } - - public bool TallyDist(int dist, int len) - { - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("["+dist+","+len+"]"); - // } - - d_buf[last_lit] = (short)dist; - l_buf[last_lit++] = (byte)(len - 3); - - int lc = Lcode(len - 3); - literalTree.freqs[lc]++; - if (lc >= 265 && lc < 285) { - extra_bits += (lc - 261) / 4; - } - - int dc = Dcode(dist - 1); - distTree.freqs[dc]++; - if (dc >= 4) { - extra_bits += dc / 2 - 1; - } - return IsFull(); - } - } -} diff --git a/irc/TechBot/Compression/DeflaterPending.cs b/irc/TechBot/Compression/DeflaterPending.cs deleted file mode 100644 index 8144ff35e61..00000000000 --- a/irc/TechBot/Compression/DeflaterPending.cs +++ /dev/null @@ -1,52 +0,0 @@ -// DeflaterPending.cs -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -namespace ICSharpCode.SharpZipLib.Zip.Compression -{ - - /// - /// This class stores the pending output of the Deflater. - /// - /// author of the original java version : Jochen Hoenicke - /// - public class DeflaterPending : PendingBuffer - { - public DeflaterPending() : base(DeflaterConstants.PENDING_BUF_SIZE) - { - } - } -} diff --git a/irc/TechBot/Compression/Inflater.cs b/irc/TechBot/Compression/Inflater.cs deleted file mode 100644 index b915c8ffe7d..00000000000 --- a/irc/TechBot/Compression/Inflater.cs +++ /dev/null @@ -1,782 +0,0 @@ -// Inflater.cs -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; - -using ICSharpCode.SharpZipLib.Checksums; -using ICSharpCode.SharpZipLib.Zip.Compression.Streams; - -namespace ICSharpCode.SharpZipLib.Zip.Compression -{ - - /// - /// Inflater is used to decompress data that has been compressed according - /// to the "deflate" standard described in rfc1950. - /// - /// The usage is as following. First you have to set some input with - /// setInput(), then inflate() it. If inflate doesn't - /// inflate any bytes there may be three reasons: - ///
          - ///
        • needsInput() returns true because the input buffer is empty. - /// You have to provide more input with setInput(). - /// NOTE: needsInput() also returns true when, the stream is finished. - ///
        • - ///
        • needsDictionary() returns true, you have to provide a preset - /// dictionary with setDictionary().
        • - ///
        • finished() returns true, the inflater has finished.
        • - ///
        - /// Once the first output byte is produced, a dictionary will not be - /// needed at a later stage. - /// - /// author of the original java version : John Leuner, Jochen Hoenicke - ///
        - public class Inflater - { - /// - /// Copy lengths for literal codes 257..285 - /// - private static int[] CPLENS = { - 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 - }; - - /// - /// Extra bits for literal codes 257..285 - /// - private static int[] CPLEXT = { - 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 - }; - - /// - /// Copy offsets for distance codes 0..29 - /// - private static int[] CPDIST = { - 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 - }; - - /// - /// Extra bits for distance codes - /// - private static int[] CPDEXT = { - 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 - }; - - /// - /// This are the state in which the inflater can be. - /// - private const int DECODE_HEADER = 0; - private const int DECODE_DICT = 1; - private const int DECODE_BLOCKS = 2; - private const int DECODE_STORED_LEN1 = 3; - private const int DECODE_STORED_LEN2 = 4; - private const int DECODE_STORED = 5; - private const int DECODE_DYN_HEADER = 6; - private const int DECODE_HUFFMAN = 7; - private const int DECODE_HUFFMAN_LENBITS = 8; - private const int DECODE_HUFFMAN_DIST = 9; - private const int DECODE_HUFFMAN_DISTBITS = 10; - private const int DECODE_CHKSUM = 11; - private const int FINISHED = 12; - - /// - /// This variable contains the current state. - /// - private int mode; - - /// - /// The adler checksum of the dictionary or of the decompressed - /// stream, as it is written in the header resp. footer of the - /// compressed stream. - /// Only valid if mode is DECODE_DICT or DECODE_CHKSUM. - /// - private int readAdler; - - /// - /// The number of bits needed to complete the current state. This - /// is valid, if mode is DECODE_DICT, DECODE_CHKSUM, - /// DECODE_HUFFMAN_LENBITS or DECODE_HUFFMAN_DISTBITS. - /// - private int neededBits; - private int repLength, repDist; - private int uncomprLen; - - /// - /// True, if the last block flag was set in the last block of the - /// inflated stream. This means that the stream ends after the - /// current block. - /// - private bool isLastBlock; - - /// - /// The total number of inflated bytes. - /// - private int totalOut; - - /// - /// The total number of bytes set with setInput(). This is not the - /// value returned by getTotalIn(), since this also includes the - /// unprocessed input. - /// - private int totalIn; - - /// - /// This variable stores the nowrap flag that was given to the constructor. - /// True means, that the inflated stream doesn't contain a header nor the - /// checksum in the footer. - /// - private bool nowrap; - - private StreamManipulator input; - private OutputWindow outputWindow; - private InflaterDynHeader dynHeader; - private InflaterHuffmanTree litlenTree, distTree; - private Adler32 adler; - - /// - /// Creates a new inflater. - /// - public Inflater() : this(false) - { - } - - /// - /// Creates a new inflater. - /// - /// - /// true if no header and checksum field appears in the - /// stream. This is used for GZIPed input. For compatibility with - /// Sun JDK you should provide one byte of input more than needed in - /// this case. - /// - public Inflater(bool nowrap) - { - this.nowrap = nowrap; - this.adler = new Adler32(); - input = new StreamManipulator(); - outputWindow = new OutputWindow(); - mode = nowrap ? DECODE_BLOCKS : DECODE_HEADER; - } - - /// - /// Resets the inflater so that a new stream can be decompressed. All - /// pending input and output will be discarded. - /// - public void Reset() - { - mode = nowrap ? DECODE_BLOCKS : DECODE_HEADER; - totalIn = totalOut = 0; - input.Reset(); - outputWindow.Reset(); - dynHeader = null; - litlenTree = null; - distTree = null; - isLastBlock = false; - adler.Reset(); - } - - /// - /// Decodes the deflate header. - /// - /// - /// false if more input is needed. - /// - /// - /// if header is invalid. - /// - private bool DecodeHeader() - { - int header = input.PeekBits(16); - if (header < 0) { - return false; - } - input.DropBits(16); - /* The header is written in "wrong" byte order */ - header = ((header << 8) | (header >> 8)) & 0xffff; - if (header % 31 != 0) { - throw new FormatException("Header checksum illegal"); - } - - if ((header & 0x0f00) != (Deflater.DEFLATED << 8)) { - throw new FormatException("Compression Method unknown"); - } - - /* Maximum size of the backwards window in bits. - * We currently ignore this, but we could use it to make the - * inflater window more space efficient. On the other hand the - * full window (15 bits) is needed most times, anyway. - int max_wbits = ((header & 0x7000) >> 12) + 8; - */ - - if ((header & 0x0020) == 0) { // Dictionary flag? - mode = DECODE_BLOCKS; - } else { - mode = DECODE_DICT; - neededBits = 32; - } - return true; - } - - /// - /// Decodes the dictionary checksum after the deflate header. - /// - /// - /// false if more input is needed. - /// - private bool DecodeDict() - { - while (neededBits > 0) { - int dictByte = input.PeekBits(8); - if (dictByte < 0) { - return false; - } - input.DropBits(8); - readAdler = (readAdler << 8) | dictByte; - neededBits -= 8; - } - return false; - } - - /// - /// Decodes the huffman encoded symbols in the input stream. - /// - /// - /// false if more input is needed, true if output window is - /// full or the current block ends. - /// - /// - /// if deflated stream is invalid. - /// - private bool DecodeHuffman() - { - int free = outputWindow.GetFreeSpace(); - while (free >= 258) { - int symbol; - switch (mode) { - case DECODE_HUFFMAN: - /* This is the inner loop so it is optimized a bit */ - while (((symbol = litlenTree.GetSymbol(input)) & ~0xff) == 0) { - outputWindow.Write(symbol); - if (--free < 258) { - return true; - } - } - if (symbol < 257) { - if (symbol < 0) { - return false; - } else { - /* symbol == 256: end of block */ - distTree = null; - litlenTree = null; - mode = DECODE_BLOCKS; - return true; - } - } - - try { - repLength = CPLENS[symbol - 257]; - neededBits = CPLEXT[symbol - 257]; - } catch (Exception) { - throw new FormatException("Illegal rep length code"); - } - goto case DECODE_HUFFMAN_LENBITS;/* fall through */ - case DECODE_HUFFMAN_LENBITS: - if (neededBits > 0) { - mode = DECODE_HUFFMAN_LENBITS; - int i = input.PeekBits(neededBits); - if (i < 0) { - return false; - } - input.DropBits(neededBits); - repLength += i; - } - mode = DECODE_HUFFMAN_DIST; - goto case DECODE_HUFFMAN_DIST;/* fall through */ - case DECODE_HUFFMAN_DIST: - symbol = distTree.GetSymbol(input); - if (symbol < 0) { - return false; - } - try { - repDist = CPDIST[symbol]; - neededBits = CPDEXT[symbol]; - } catch (Exception) { - throw new FormatException("Illegal rep dist code"); - } - - goto case DECODE_HUFFMAN_DISTBITS;/* fall through */ - case DECODE_HUFFMAN_DISTBITS: - if (neededBits > 0) { - mode = DECODE_HUFFMAN_DISTBITS; - int i = input.PeekBits(neededBits); - if (i < 0) { - return false; - } - input.DropBits(neededBits); - repDist += i; - } - outputWindow.Repeat(repLength, repDist); - free -= repLength; - mode = DECODE_HUFFMAN; - break; - default: - throw new FormatException(); - } - } - return true; - } - - /// - /// Decodes the adler checksum after the deflate stream. - /// - /// - /// false if more input is needed. - /// - /// - /// DataFormatException, if checksum doesn't match. - /// - private bool DecodeChksum() - { - while (neededBits > 0) { - int chkByte = input.PeekBits(8); - if (chkByte < 0) { - return false; - } - input.DropBits(8); - readAdler = (readAdler << 8) | chkByte; - neededBits -= 8; - } - if ((int) adler.Value != readAdler) { - throw new FormatException("Adler chksum doesn't match: " + (int)adler.Value + " vs. " + readAdler); - } - mode = FINISHED; - return false; - } - - /// - /// Decodes the deflated stream. - /// - /// - /// false if more input is needed, or if finished. - /// - /// - /// DataFormatException, if deflated stream is invalid. - /// - private bool Decode() - { - switch (mode) { - case DECODE_HEADER: - return DecodeHeader(); - case DECODE_DICT: - return DecodeDict(); - case DECODE_CHKSUM: - return DecodeChksum(); - - case DECODE_BLOCKS: - if (isLastBlock) { - if (nowrap) { - mode = FINISHED; - return false; - } else { - input.SkipToByteBoundary(); - neededBits = 32; - mode = DECODE_CHKSUM; - return true; - } - } - - int type = input.PeekBits(3); - if (type < 0) { - return false; - } - input.DropBits(3); - - if ((type & 1) != 0) { - isLastBlock = true; - } - switch (type >> 1){ - case DeflaterConstants.STORED_BLOCK: - input.SkipToByteBoundary(); - mode = DECODE_STORED_LEN1; - break; - case DeflaterConstants.STATIC_TREES: - litlenTree = InflaterHuffmanTree.defLitLenTree; - distTree = InflaterHuffmanTree.defDistTree; - mode = DECODE_HUFFMAN; - break; - case DeflaterConstants.DYN_TREES: - dynHeader = new InflaterDynHeader(); - mode = DECODE_DYN_HEADER; - break; - default: - throw new FormatException("Unknown block type "+type); - } - return true; - - case DECODE_STORED_LEN1: - { - if ((uncomprLen = input.PeekBits(16)) < 0) { - return false; - } - input.DropBits(16); - mode = DECODE_STORED_LEN2; - } - goto case DECODE_STORED_LEN2; /* fall through */ - case DECODE_STORED_LEN2: - { - int nlen = input.PeekBits(16); - if (nlen < 0) { - return false; - } - input.DropBits(16); - if (nlen != (uncomprLen ^ 0xffff)) { - throw new FormatException("broken uncompressed block"); - } - mode = DECODE_STORED; - } - goto case DECODE_STORED;/* fall through */ - case DECODE_STORED: - { - int more = outputWindow.CopyStored(input, uncomprLen); - uncomprLen -= more; - if (uncomprLen == 0) { - mode = DECODE_BLOCKS; - return true; - } - return !input.IsNeedingInput; - } - - case DECODE_DYN_HEADER: - if (!dynHeader.Decode(input)) { - return false; - } - - litlenTree = dynHeader.BuildLitLenTree(); - distTree = dynHeader.BuildDistTree(); - mode = DECODE_HUFFMAN; - goto case DECODE_HUFFMAN; /* fall through */ - case DECODE_HUFFMAN: - case DECODE_HUFFMAN_LENBITS: - case DECODE_HUFFMAN_DIST: - case DECODE_HUFFMAN_DISTBITS: - return DecodeHuffman(); - case FINISHED: - return false; - default: - throw new FormatException(); - } - } - - /// - /// Sets the preset dictionary. This should only be called, if - /// needsDictionary() returns true and it should set the same - /// dictionary, that was used for deflating. The getAdler() - /// function returns the checksum of the dictionary needed. - /// - /// - /// the dictionary. - /// - /// - /// if no dictionary is needed. - /// - /// - /// if the dictionary checksum is wrong. - /// - public void SetDictionary(byte[] buffer) - { - SetDictionary(buffer, 0, buffer.Length); - } - - /// - /// Sets the preset dictionary. This should only be called, if - /// needsDictionary() returns true and it should set the same - /// dictionary, that was used for deflating. The getAdler() - /// function returns the checksum of the dictionary needed. - /// - /// - /// the dictionary. - /// - /// - /// the offset into buffer where the dictionary starts. - /// - /// - /// the length of the dictionary. - /// - /// - /// if no dictionary is needed. - /// - /// - /// if the dictionary checksum is wrong. - /// - /// - /// if the off and/or len are wrong. - /// - public void SetDictionary(byte[] buffer, int off, int len) - { - if (!IsNeedingDictionary) { - throw new InvalidOperationException(); - } - - adler.Update(buffer, off, len); - if ((int)adler.Value != readAdler) { - throw new ArgumentException("Wrong adler checksum"); - } - adler.Reset(); - outputWindow.CopyDict(buffer, off, len); - mode = DECODE_BLOCKS; - } - - /// - /// Sets the input. This should only be called, if needsInput() - /// returns true. - /// - /// - /// the input. - /// - /// - /// if no input is needed. - /// - public void SetInput(byte[] buf) - { - SetInput(buf, 0, buf.Length); - } - - /// - /// Sets the input. This should only be called, if needsInput() - /// returns true. - /// - /// - /// the input. - /// - /// - /// the offset into buffer where the input starts. - /// - /// - /// the length of the input. - /// - /// - /// if no input is needed. - /// - /// - /// if the off and/or len are wrong. - /// - public void SetInput(byte[] buf, int off, int len) - { - input.SetInput(buf, off, len); - totalIn += len; - } - - /// - /// Inflates the compressed stream to the output buffer. If this - /// returns 0, you should check, whether needsDictionary(), - /// needsInput() or finished() returns true, to determine why no - /// further output is produced. - /// - /// - /// the output buffer. - /// - /// - /// the number of bytes written to the buffer, 0 if no further - /// output can be produced. - /// - /// - /// if buf has length 0. - /// - /// - /// if deflated stream is invalid. - /// - public int Inflate(byte[] buf) - { - return Inflate(buf, 0, buf.Length); - } - - /// - /// Inflates the compressed stream to the output buffer. If this - /// returns 0, you should check, whether needsDictionary(), - /// needsInput() or finished() returns true, to determine why no - /// further output is produced. - /// - /// - /// the output buffer. - /// - /// - /// the offset into buffer where the output should start. - /// - /// - /// the maximum length of the output. - /// - /// - /// the number of bytes written to the buffer, 0 if no further output can be produced. - /// - /// - /// if len is <= 0. - /// - /// - /// if the off and/or len are wrong. - /// - /// - /// if deflated stream is invalid. - /// - public int Inflate(byte[] buf, int off, int len) - { - if (len < 0) { - throw new ArgumentOutOfRangeException("len < 0"); - } - // Special case: len may be zero - if (len == 0) { - if (IsFinished == false) {// -jr- 08-Nov-2003 INFLATE_BUG fix.. - Decode(); - } - return 0; - } - /* // Check for correct buff, off, len triple - if (off < 0 || off + len >= buf.Length) { - throw new ArgumentException("off/len outside buf bounds"); - }*/ - int count = 0; - int more; - do { - if (mode != DECODE_CHKSUM) { - /* Don't give away any output, if we are waiting for the - * checksum in the input stream. - * - * With this trick we have always: - * needsInput() and not finished() - * implies more output can be produced. - */ - more = outputWindow.CopyOutput(buf, off, len); - adler.Update(buf, off, more); - off += more; - count += more; - totalOut += more; - len -= more; - if (len == 0) { - return count; - } - } - } while (Decode() || (outputWindow.GetAvailable() > 0 && mode != DECODE_CHKSUM)); - return count; - } - - /// - /// Returns true, if the input buffer is empty. - /// You should then call setInput(). - /// NOTE: This method also returns true when the stream is finished. - /// - public bool IsNeedingInput { - get { - return input.IsNeedingInput; - } - } - - /// - /// Returns true, if a preset dictionary is needed to inflate the input. - /// - public bool IsNeedingDictionary { - get { - return mode == DECODE_DICT && neededBits == 0; - } - } - - /// - /// Returns true, if the inflater has finished. This means, that no - /// input is needed and no output can be produced. - /// - public bool IsFinished { - get { - return mode == FINISHED && outputWindow.GetAvailable() == 0; - } - } - - /// - /// Gets the adler checksum. This is either the checksum of all - /// uncompressed bytes returned by inflate(), or if needsDictionary() - /// returns true (and thus no output was yet produced) this is the - /// adler checksum of the expected dictionary. - /// - /// - /// the adler checksum. - /// - public int Adler { - get { - return IsNeedingDictionary ? readAdler : (int) adler.Value; - } - } - - /// - /// Gets the total number of output bytes returned by inflate(). - /// - /// - /// the total number of output bytes. - /// - public int TotalOut { - get { - return totalOut; - } - } - - /// - /// Gets the total number of processed compressed input bytes. - /// - /// - /// the total number of bytes of processed input bytes. - /// - public int TotalIn { - get { - return totalIn - RemainingInput; - } - } - - /// - /// Gets the number of unprocessed input. Useful, if the end of the - /// stream is reached and you want to further process the bytes after - /// the deflate stream. - /// - /// - /// the number of bytes of the input which were not processed. - /// - public int RemainingInput { - get { - return input.AvailableBytes; - } - } - } -} diff --git a/irc/TechBot/Compression/InflaterDynHeader.cs b/irc/TechBot/Compression/InflaterDynHeader.cs deleted file mode 100644 index 653c7847cea..00000000000 --- a/irc/TechBot/Compression/InflaterDynHeader.cs +++ /dev/null @@ -1,207 +0,0 @@ -// InflaterDynHeader.cs -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; - -using ICSharpCode.SharpZipLib.Zip.Compression.Streams; - -namespace ICSharpCode.SharpZipLib.Zip.Compression -{ - - class InflaterDynHeader - { - const int LNUM = 0; - const int DNUM = 1; - const int BLNUM = 2; - const int BLLENS = 3; - const int LENS = 4; - const int REPS = 5; - - static readonly int[] repMin = { 3, 3, 11 }; - static readonly int[] repBits = { 2, 3, 7 }; - - byte[] blLens; - byte[] litdistLens; - - InflaterHuffmanTree blTree; - - int mode; - int lnum, dnum, blnum, num; - int repSymbol; - byte lastLen; - int ptr; - - static readonly int[] BL_ORDER = - { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 }; - - public InflaterDynHeader() - { - } - - public bool Decode(StreamManipulator input) - { - decode_loop: - for (;;) { - switch (mode) { - case LNUM: - lnum = input.PeekBits(5); - if (lnum < 0) { - return false; - } - lnum += 257; - input.DropBits(5); - // System.err.println("LNUM: "+lnum); - mode = DNUM; - goto case DNUM; // fall through - case DNUM: - dnum = input.PeekBits(5); - if (dnum < 0) { - return false; - } - dnum++; - input.DropBits(5); - // System.err.println("DNUM: "+dnum); - num = lnum+dnum; - litdistLens = new byte[num]; - mode = BLNUM; - goto case BLNUM; // fall through - case BLNUM: - blnum = input.PeekBits(4); - if (blnum < 0) { - return false; - } - blnum += 4; - input.DropBits(4); - blLens = new byte[19]; - ptr = 0; - // System.err.println("BLNUM: "+blnum); - mode = BLLENS; - goto case BLLENS; // fall through - case BLLENS: - while (ptr < blnum) { - int len = input.PeekBits(3); - if (len < 0) { - return false; - } - input.DropBits(3); - // System.err.println("blLens["+BL_ORDER[ptr]+"]: "+len); - blLens[BL_ORDER[ptr]] = (byte) len; - ptr++; - } - blTree = new InflaterHuffmanTree(blLens); - blLens = null; - ptr = 0; - mode = LENS; - goto case LENS; // fall through - case LENS: - { - int symbol; - while (((symbol = blTree.GetSymbol(input)) & ~15) == 0) { - /* Normal case: symbol in [0..15] */ - - // System.err.println("litdistLens["+ptr+"]: "+symbol); - litdistLens[ptr++] = lastLen = (byte)symbol; - - if (ptr == num) { - /* Finished */ - return true; - } - } - - /* need more input ? */ - if (symbol < 0) { - return false; - } - - /* otherwise repeat code */ - if (symbol >= 17) { - /* repeat zero */ - // System.err.println("repeating zero"); - lastLen = 0; - } else { - if (ptr == 0) { - throw new Exception(); - } - } - repSymbol = symbol-16; - } - mode = REPS; - goto case REPS; // fall through - case REPS: - { - int bits = repBits[repSymbol]; - int count = input.PeekBits(bits); - if (count < 0) { - return false; - } - input.DropBits(bits); - count += repMin[repSymbol]; - // System.err.println("litdistLens repeated: "+count); - - if (ptr + count > num) { - throw new Exception(); - } - while (count-- > 0) { - litdistLens[ptr++] = lastLen; - } - - if (ptr == num) { - /* Finished */ - return true; - } - } - mode = LENS; - goto decode_loop; - } - } - } - - public InflaterHuffmanTree BuildLitLenTree() - { - byte[] litlenLens = new byte[lnum]; - Array.Copy(litdistLens, 0, litlenLens, 0, lnum); - return new InflaterHuffmanTree(litlenLens); - } - - public InflaterHuffmanTree BuildDistTree() - { - byte[] distLens = new byte[dnum]; - Array.Copy(litdistLens, lnum, distLens, 0, dnum); - return new InflaterHuffmanTree(distLens); - } - } -} diff --git a/irc/TechBot/Compression/InflaterHuffmanTree.cs b/irc/TechBot/Compression/InflaterHuffmanTree.cs deleted file mode 100644 index 02beb60a34c..00000000000 --- a/irc/TechBot/Compression/InflaterHuffmanTree.cs +++ /dev/null @@ -1,213 +0,0 @@ -// InflaterHuffmanTree.cs -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; - -using ICSharpCode.SharpZipLib.Zip.Compression.Streams; - -namespace ICSharpCode.SharpZipLib.Zip.Compression -{ - - public class InflaterHuffmanTree - { - private static int MAX_BITLEN = 15; - private short[] tree; - - public static InflaterHuffmanTree defLitLenTree, defDistTree; - - static InflaterHuffmanTree() - { - try { - byte[] codeLengths = new byte[288]; - int i = 0; - while (i < 144) { - codeLengths[i++] = 8; - } - while (i < 256) { - codeLengths[i++] = 9; - } - while (i < 280) { - codeLengths[i++] = 7; - } - while (i < 288) { - codeLengths[i++] = 8; - } - defLitLenTree = new InflaterHuffmanTree(codeLengths); - - codeLengths = new byte[32]; - i = 0; - while (i < 32) { - codeLengths[i++] = 5; - } - defDistTree = new InflaterHuffmanTree(codeLengths); - } catch (Exception) { - throw new ApplicationException("InflaterHuffmanTree: static tree length illegal"); - } - } - - /// - /// Constructs a Huffman tree from the array of code lengths. - /// - /// - /// the array of code lengths - /// - public InflaterHuffmanTree(byte[] codeLengths) - { - BuildTree(codeLengths); - } - - private void BuildTree(byte[] codeLengths) - { - int[] blCount = new int[MAX_BITLEN + 1]; - int[] nextCode = new int[MAX_BITLEN + 1]; - - for (int i = 0; i < codeLengths.Length; i++) { - int bits = codeLengths[i]; - if (bits > 0) { - blCount[bits]++; - } - } - - int code = 0; - int treeSize = 512; - for (int bits = 1; bits <= MAX_BITLEN; bits++) { - nextCode[bits] = code; - code += blCount[bits] << (16 - bits); - if (bits >= 10) { - /* We need an extra table for bit lengths >= 10. */ - int start = nextCode[bits] & 0x1ff80; - int end = code & 0x1ff80; - treeSize += (end - start) >> (16 - bits); - } - } -/* -jr comment this out! doesnt work for dynamic trees and pkzip 2.04g - if (code != 65536) - { - throw new Exception("Code lengths don't add up properly."); - } -*/ - /* Now create and fill the extra tables from longest to shortest - * bit len. This way the sub trees will be aligned. - */ - tree = new short[treeSize]; - int treePtr = 512; - for (int bits = MAX_BITLEN; bits >= 10; bits--) { - int end = code & 0x1ff80; - code -= blCount[bits] << (16 - bits); - int start = code & 0x1ff80; - for (int i = start; i < end; i += 1 << 7) { - tree[DeflaterHuffman.BitReverse(i)] = (short) ((-treePtr << 4) | bits); - treePtr += 1 << (bits-9); - } - } - - for (int i = 0; i < codeLengths.Length; i++) { - int bits = codeLengths[i]; - if (bits == 0) { - continue; - } - code = nextCode[bits]; - int revcode = DeflaterHuffman.BitReverse(code); - if (bits <= 9) { - do { - tree[revcode] = (short) ((i << 4) | bits); - revcode += 1 << bits; - } while (revcode < 512); - } else { - int subTree = tree[revcode & 511]; - int treeLen = 1 << (subTree & 15); - subTree = -(subTree >> 4); - do { - tree[subTree | (revcode >> 9)] = (short) ((i << 4) | bits); - revcode += 1 << bits; - } while (revcode < treeLen); - } - nextCode[bits] = code + (1 << (16 - bits)); - } - - } - - /// - /// Reads the next symbol from input. The symbol is encoded using the - /// huffman tree. - /// - /// - /// input the input source. - /// - /// - /// the next symbol, or -1 if not enough input is available. - /// - public int GetSymbol(StreamManipulator input) - { - int lookahead, symbol; - if ((lookahead = input.PeekBits(9)) >= 0) { - if ((symbol = tree[lookahead]) >= 0) { - input.DropBits(symbol & 15); - return symbol >> 4; - } - int subtree = -(symbol >> 4); - int bitlen = symbol & 15; - if ((lookahead = input.PeekBits(bitlen)) >= 0) { - symbol = tree[subtree | (lookahead >> 9)]; - input.DropBits(symbol & 15); - return symbol >> 4; - } else { - int bits = input.AvailableBits; - lookahead = input.PeekBits(bits); - symbol = tree[subtree | (lookahead >> 9)]; - if ((symbol & 15) <= bits) { - input.DropBits(symbol & 15); - return symbol >> 4; - } else { - return -1; - } - } - } else { - int bits = input.AvailableBits; - lookahead = input.PeekBits(bits); - symbol = tree[lookahead]; - if (symbol >= 0 && (symbol & 15) <= bits) { - input.DropBits(symbol & 15); - return symbol >> 4; - } else { - return -1; - } - } - } - } -} - diff --git a/irc/TechBot/Compression/PendingBuffer.cs b/irc/TechBot/Compression/PendingBuffer.cs deleted file mode 100644 index e0bc96b9192..00000000000 --- a/irc/TechBot/Compression/PendingBuffer.cs +++ /dev/null @@ -1,210 +0,0 @@ -// PendingBuffer.cs -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; - -namespace ICSharpCode.SharpZipLib.Zip.Compression -{ - - /// - /// This class is general purpose class for writing data to a buffer. - /// - /// It allows you to write bits as well as bytes - /// Based on DeflaterPending.java - /// - /// author of the original java version : Jochen Hoenicke - /// - public class PendingBuffer - { - protected byte[] buf; - int start; - int end; - - uint bits; - int bitCount; - - public PendingBuffer() : this( 4096 ) - { - - } - - public PendingBuffer(int bufsize) - { - buf = new byte[bufsize]; - } - - public void Reset() - { - start = end = bitCount = 0; - } - - public void WriteByte(int b) - { - if (DeflaterConstants.DEBUGGING && start != 0) { - throw new Exception(); - } - buf[end++] = (byte) b; - } - - public void WriteShort(int s) - { - if (DeflaterConstants.DEBUGGING && start != 0) { - throw new Exception(); - } - buf[end++] = (byte) s; - buf[end++] = (byte) (s >> 8); - } - - public void WriteInt(int s) - { - if (DeflaterConstants.DEBUGGING && start != 0) { - throw new Exception(); - } - buf[end++] = (byte) s; - buf[end++] = (byte) (s >> 8); - buf[end++] = (byte) (s >> 16); - buf[end++] = (byte) (s >> 24); - } - - public void WriteBlock(byte[] block, int offset, int len) - { - if (DeflaterConstants.DEBUGGING && start != 0) { - throw new Exception(); - } - System.Array.Copy(block, offset, buf, end, len); - end += len; - } - - public int BitCount { - get { - return bitCount; - } - } - - public void AlignToByte() - { - if (DeflaterConstants.DEBUGGING && start != 0) { - throw new Exception(); - } - if (bitCount > 0) { - buf[end++] = (byte) bits; - if (bitCount > 8) { - buf[end++] = (byte) (bits >> 8); - } - } - bits = 0; - bitCount = 0; - } - - public void WriteBits(int b, int count) - { - if (DeflaterConstants.DEBUGGING && start != 0) { - throw new Exception(); - } - // if (DeflaterConstants.DEBUGGING) { - // //Console.WriteLine("writeBits("+b+","+count+")"); - // } - bits |= (uint)(b << bitCount); - bitCount += count; - if (bitCount >= 16) { - buf[end++] = (byte) bits; - buf[end++] = (byte) (bits >> 8); - bits >>= 16; - bitCount -= 16; - } - } - - public void WriteShortMSB(int s) - { - if (DeflaterConstants.DEBUGGING && start != 0) { - throw new Exception(); - } - buf[end++] = (byte) (s >> 8); - buf[end++] = (byte) s; - } - - public bool IsFlushed { - get { - return end == 0; - } - } - - /// - /// Flushes the pending buffer into the given output array. If the - /// output array is to small, only a partial flush is done. - /// - /// - /// the output array; - /// - /// - /// the offset into output array; - /// - /// - /// length the maximum number of bytes to store; - /// - /// - /// IndexOutOfBoundsException if offset or length are invalid. - /// - public int Flush(byte[] output, int offset, int length) - { - if (bitCount >= 8) { - buf[end++] = (byte) bits; - bits >>= 8; - bitCount -= 8; - } - if (length > end - start) { - length = end - start; - System.Array.Copy(buf, start, output, offset, length); - start = 0; - end = 0; - } else { - System.Array.Copy(buf, start, output, offset, length); - start += length; - } - return length; - } - - public byte[] ToByteArray() - { - byte[] ret = new byte[end - start]; - System.Array.Copy(buf, start, ret, 0, ret.Length); - start = 0; - end = 0; - return ret; - } - } -} diff --git a/irc/TechBot/Compression/Streams/DeflaterOutputStream.cs b/irc/TechBot/Compression/Streams/DeflaterOutputStream.cs deleted file mode 100644 index dd8c658e843..00000000000 --- a/irc/TechBot/Compression/Streams/DeflaterOutputStream.cs +++ /dev/null @@ -1,379 +0,0 @@ -// DeflaterOutputStream.cs -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; -using System.IO; -using ICSharpCode.SharpZipLib.Checksums; -using ICSharpCode.SharpZipLib.Zip.Compression; - -namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams -{ - - /// - /// This is a special FilterOutputStream deflating the bytes that are - /// written through it. It uses the Deflater for deflating. - /// - /// authors of the original java version : Tom Tromey, Jochen Hoenicke - /// - public class DeflaterOutputStream : Stream - { - /// - /// This buffer is used temporarily to retrieve the bytes from the - /// deflater and write them to the underlying output stream. - /// - protected byte[] buf; - - /// - /// The deflater which is used to deflate the stream. - /// - protected Deflater def; - - /// - /// base stream the deflater depends on. - /// - protected Stream baseOutputStream; - - /// - /// I needed to implement the abstract member. - /// - public override bool CanRead { - get { - return baseOutputStream.CanRead; - } - } - - /// - /// I needed to implement the abstract member. - /// - public override bool CanSeek { - get { - return false; -// return baseOutputStream.CanSeek; - } - } - - /// - /// I needed to implement the abstract member. - /// - public override bool CanWrite { - get { - return baseOutputStream.CanWrite; - } - } - - /// - /// I needed to implement the abstract member. - /// - public override long Length { - get { - return baseOutputStream.Length; - } - } - - /// - /// I needed to implement the abstract member. - /// - public override long Position { - get { - return baseOutputStream.Position; - } - set { - baseOutputStream.Position = value; - } - } - - /// - /// I needed to implement the abstract member. - /// - public override long Seek(long offset, SeekOrigin origin) - { - throw new NotSupportedException("Seek not supported"); // -jr- 01-Dec-2003 -// return baseOutputStream.Seek(offset, origin); - } - - /// - /// I needed to implement the abstract member. - /// - public override void SetLength(long val) - { - baseOutputStream.SetLength(val); - } - - /// - /// I needed to implement the abstract member. - /// - public override int ReadByte() - { - return baseOutputStream.ReadByte(); - } - - /// - /// I needed to implement the abstract member. - /// - public override int Read(byte[] b, int off, int len) - { - return baseOutputStream.Read(b, off, len); - } - // -jr- 01-Dec-2003 - public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) - { - throw new NotSupportedException("Asynch read not currently supported"); - } - - // -jr- 01-Dec-2003 - public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) - { - throw new NotSupportedException("Asynch write not currently supported"); - } - - /// - /// Deflates everything in the def's input buffers. This will call - /// def.deflate() until all bytes from the input buffers - /// are processed. - /// - protected void Deflate() - { - while (!def.IsNeedingInput) { - int len = def.Deflate(buf, 0, buf.Length); - - // System.err.println("DOS deflated " + len + " baseOutputStream of " + buf.length); - if (len <= 0) { - break; - } - baseOutputStream.Write(buf, 0, len); - } - - if (!def.IsNeedingInput) { - throw new ApplicationException("Can't deflate all input?"); - } - } - - /// - /// Creates a new DeflaterOutputStream with a default Deflater and default buffer size. - /// - /// - /// the output stream where deflated output should be written. - /// - public DeflaterOutputStream(Stream baseOutputStream) : this(baseOutputStream, new Deflater(), 512) - { - } - - /// - /// Creates a new DeflaterOutputStream with the given Deflater and - /// default buffer size. - /// - /// - /// the output stream where deflated output should be written. - /// - /// - /// the underlying deflater. - /// - public DeflaterOutputStream(Stream baseOutputStream, Deflater defl) :this(baseOutputStream, defl, 512) - { - } - - /// - /// Creates a new DeflaterOutputStream with the given Deflater and - /// buffer size. - /// - /// - /// the output stream where deflated output should be written. - /// - /// - /// the underlying deflater. - /// - /// - /// the buffer size. - /// - /// - /// if bufsize isn't positive. - /// - public DeflaterOutputStream(Stream baseOutputStream, Deflater defl, int bufsize) - { - this.baseOutputStream = baseOutputStream; - if (bufsize <= 0) { - throw new InvalidOperationException("bufsize <= 0"); - } - buf = new byte[bufsize]; - def = defl; - } - - /// - /// Flushes the stream by calling flush() on the deflater and then - /// on the underlying stream. This ensures that all bytes are - /// flushed. - /// - public override void Flush() - { - def.Flush(); - Deflate(); - baseOutputStream.Flush(); - } - - /// - /// Finishes the stream by calling finish() on the deflater. - /// - public virtual void Finish() - { - def.Finish(); - while (!def.IsFinished) { - int len = def.Deflate(buf, 0, buf.Length); - if (len <= 0) { - break; - } - - // kidnthrain encryption alteration - if (this.Password != null) { - // plain data has been deflated. Now encrypt result - this.EncryptBlock(buf, 0, len); - } - - baseOutputStream.Write(buf, 0, len); - } - if (!def.IsFinished) { - throw new ApplicationException("Can't deflate all input?"); - } - baseOutputStream.Flush(); - } - - /// - /// Calls finish () and closes the stream. - /// - public override void Close() - { - Finish(); - baseOutputStream.Close(); - } - - /// - /// Writes a single byte to the compressed output stream. - /// - /// - /// the byte value. - /// - public override void WriteByte(byte bval) - { - byte[] b = new byte[1]; - b[0] = (byte) bval; - Write(b, 0, 1); - } - - /// - /// Writes a len bytes from an array to the compressed stream. - /// - /// - /// the byte array. - /// - /// - /// the offset into the byte array where to start. - /// - /// - /// the number of bytes to write. - /// - public override void Write(byte[] buf, int off, int len) - { - // System.err.println("DOS with off " + off + " and len " + len); - def.SetInput(buf, off, len); - Deflate(); - } - - #region Encryption - string password = null; - uint[] keys = null; - - public string Password { - get { - return password; - } - set { - password = value; - } - } - - - //The beauty of xor-ing bits is that - //plain ^ key = enc - //and enc ^ key = plain - //accordingly, this is the exact same as the decrypt byte - //function in InflaterInputStream - protected byte EncryptByte() - { - uint temp = ((keys[2] & 0xFFFF) | 2); - return (byte)((temp * (temp ^ 1)) >> 8); - } - - - /// - /// Takes a buffer of data and uses the keys - /// that have been previously initialized from a - /// password and then updated via a random encryption header - /// to encrypt that data - /// - protected void EncryptBlock(byte[] buf, int off, int len) - { - for (int i = off; i < off + len; ++i) { - byte oldbyte = buf[i]; - buf[i] ^= EncryptByte(); - UpdateKeys(oldbyte); - } - } - - /// - /// Initializes our encryption keys using a given password - /// - protected void InitializePassword(string password) { - keys = new uint[] { - 0x12345678, - 0x23456789, - 0x34567890 - }; - - for (int i = 0; i < password.Length; ++i) { - UpdateKeys((byte)password[i]); - } - } - - protected void UpdateKeys(byte ch) - { - keys[0] = Crc32.ComputeCrc32(keys[0], ch); - keys[1] = keys[1] + (byte)keys[0]; - keys[1] = keys[1] * 134775813 + 1; - keys[2] = Crc32.ComputeCrc32(keys[2], (byte)(keys[1] >> 24)); - } - #endregion - } -} diff --git a/irc/TechBot/Compression/Streams/InflaterInputStream.cs b/irc/TechBot/Compression/Streams/InflaterInputStream.cs deleted file mode 100644 index 9317e5e185d..00000000000 --- a/irc/TechBot/Compression/Streams/InflaterInputStream.cs +++ /dev/null @@ -1,386 +0,0 @@ -// InflaterInputStream.cs -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; -using System.IO; - -using ICSharpCode.SharpZipLib.Zip.Compression; -using ICSharpCode.SharpZipLib.Checksums; - -namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams -{ - - /// - /// This filter stream is used to decompress data compressed baseInputStream the "deflate" - /// format. The "deflate" format is described baseInputStream RFC 1951. - /// - /// This stream may form the basis for other decompression filters, such - /// as the GzipInputStream. - /// - /// author of the original java version : John Leuner - /// - public class InflaterInputStream : Stream - { - //Variables - - /// - /// Decompressor for this filter - /// - protected Inflater inf; - - /// - /// Byte array used as a buffer - /// - protected byte[] buf; - - /// - /// Size of buffer - /// - protected int len; - - //We just use this if we are decoding one byte at a time with the read() call - private byte[] onebytebuffer = new byte[1]; - - /// - /// base stream the inflater depends on. - /// - protected Stream baseInputStream; - - protected long csize; - - /// - /// I needed to implement the abstract member. - /// - public override bool CanRead { - get { - return baseInputStream.CanRead; - } - } - - /// - /// I needed to implement the abstract member. - /// - public override bool CanSeek { - get { - return false; - // return baseInputStream.CanSeek; - } - } - - /// - /// I needed to implement the abstract member. - /// - public override bool CanWrite { - get { - return baseInputStream.CanWrite; - } - } - - /// - /// I needed to implement the abstract member. - /// - public override long Length { - get { - return len; - } - } - - /// - /// I needed to implement the abstract member. - /// - public override long Position { - get { - return baseInputStream.Position; - } - set { - baseInputStream.Position = value; - } - } - - /// - /// Flushes the baseInputStream - /// - public override void Flush() - { - baseInputStream.Flush(); - } - - /// - /// I needed to implement the abstract member. - /// - public override long Seek(long offset, SeekOrigin origin) - { - throw new NotSupportedException("Seek not supported"); // -jr- 01-Dec-2003 - } - - /// - /// I needed to implement the abstract member. - /// - public override void SetLength(long val) - { - baseInputStream.SetLength(val); - } - - /// - /// I needed to implement the abstract member. - /// - public override void Write(byte[] array, int offset, int count) - { - baseInputStream.Write(array, offset, count); - } - - /// - /// I needed to implement the abstract member. - /// - public override void WriteByte(byte val) - { - baseInputStream.WriteByte(val); - } - - // -jr- 01-Dec-2003 This may be flawed for some base streams? Depends on implementation of BeginWrite - public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) - { - throw new NotSupportedException("Asynch write not currently supported"); - } - - //Constructors - - /// - /// Create an InflaterInputStream with the default decompresseor - /// and a default buffer size. - /// - /// - /// the InputStream to read bytes from - /// - public InflaterInputStream(Stream baseInputStream) : this(baseInputStream, new Inflater(), 4096) - { - - } - - /// - /// Create an InflaterInputStream with the specified decompresseor - /// and a default buffer size. - /// - /// - /// the InputStream to read bytes from - /// - /// - /// the decompressor used to decompress data read from baseInputStream - /// - public InflaterInputStream(Stream baseInputStream, Inflater inf) : this(baseInputStream, inf, 4096) - { - } - - /// - /// Create an InflaterInputStream with the specified decompresseor - /// and a specified buffer size. - /// - /// - /// the InputStream to read bytes from - /// - /// - /// the decompressor used to decompress data read from baseInputStream - /// - /// - /// size of the buffer to use - /// - public InflaterInputStream(Stream baseInputStream, Inflater inf, int size) - { - this.baseInputStream = baseInputStream; - this.inf = inf; - try { - this.len = (int)baseInputStream.Length; - } catch (Exception) { - // the stream may not support .Length - this.len = 0; - } - - if (size <= 0) { - throw new ArgumentOutOfRangeException("size <= 0"); - } - - buf = new byte[size]; //Create the buffer - } - - //Methods - - /// - /// Returns 0 once the end of the stream (EOF) has been reached. - /// Otherwise returns 1. - /// - public virtual int Available { - get { - return inf.IsFinished ? 0 : 1; - } - } - - /// - /// Closes the input stream - /// - public override void Close() - { - baseInputStream.Close(); - } - - /// - /// Fills the buffer with more data to decompress. - /// - protected void Fill() - { - len = baseInputStream.Read(buf, 0, buf.Length); - // decrypting crypted data - if (cryptbuffer != null) { - DecryptBlock(buf, 0, System.Math.Min((int)(csize - inf.TotalIn), buf.Length)); - } - - if (len <= 0) { - throw new ApplicationException("Deflated stream ends early."); - } - inf.SetInput(buf, 0, len); - } - - /// - /// Reads one byte of decompressed data. - /// - /// The byte is baseInputStream the lower 8 bits of the int. - /// - public override int ReadByte() - { - int nread = Read(onebytebuffer, 0, 1); //read one byte - if (nread > 0) { - return onebytebuffer[0] & 0xff; - } - return -1; // ok - } - - /// - /// Decompresses data into the byte array - /// - /// - /// the array to read and decompress data into - /// - /// - /// the offset indicating where the data should be placed - /// - /// - /// the number of bytes to decompress - /// - public override int Read(byte[] b, int off, int len) - { - for (;;) { - int count; - try { - count = inf.Inflate(b, off, len); - } catch (Exception e) { - throw new ZipException(e.ToString()); - } - - if (count > 0) { - return count; - } - - if (inf.IsNeedingDictionary) { - throw new ZipException("Need a dictionary"); - } else if (inf.IsFinished) { - return 0; - } else if (inf.IsNeedingInput) { - Fill(); - } else { - throw new InvalidOperationException("Don't know what to do"); - } - } - } - - /// - /// Skip specified number of bytes of uncompressed data - /// - /// - /// number of bytes to skip - /// - public long Skip(long n) - { - if (n < 0) { - throw new ArgumentOutOfRangeException("n"); - } - int len = 2048; - if (n < len) { - len = (int) n; - } - byte[] tmp = new byte[len]; - return (long)baseInputStream.Read(tmp, 0, tmp.Length); - } - - #region Encryption stuff - protected byte[] cryptbuffer = null; - - uint[] keys = null; - protected byte DecryptByte() - { - uint temp = ((keys[2] & 0xFFFF) | 2); - return (byte)((temp * (temp ^ 1)) >> 8); - } - - protected void DecryptBlock(byte[] buf, int off, int len) - { - for (int i = off; i < off + len; ++i) { - buf[i] ^= DecryptByte(); - UpdateKeys(buf[i]); - } - } - - protected void InitializePassword(string password) - { - keys = new uint[] { - 0x12345678, - 0x23456789, - 0x34567890 - }; - for (int i = 0; i < password.Length; ++i) { - UpdateKeys((byte)password[i]); - } - } - - protected void UpdateKeys(byte ch) - { - keys[0] = Crc32.ComputeCrc32(keys[0], ch); - keys[1] = keys[1] + (byte)keys[0]; - keys[1] = keys[1] * 134775813 + 1; - keys[2] = Crc32.ComputeCrc32(keys[2], (byte)(keys[1] >> 24)); - } - #endregion - } -} diff --git a/irc/TechBot/Compression/Streams/OutputWindow.cs b/irc/TechBot/Compression/Streams/OutputWindow.cs deleted file mode 100644 index 426c1f752d3..00000000000 --- a/irc/TechBot/Compression/Streams/OutputWindow.cs +++ /dev/null @@ -1,176 +0,0 @@ -// OutputWindow.cs -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; - -namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams -{ - - /// - /// Contains the output from the Inflation process. - /// We need to have a window so that we can refer backwards into the output stream - /// to repeat stuff. - /// - /// author of the original java version : John Leuner - /// - public class OutputWindow - { - private static int WINDOW_SIZE = 1 << 15; - private static int WINDOW_MASK = WINDOW_SIZE - 1; - - private byte[] window = new byte[WINDOW_SIZE]; //The window is 2^15 bytes - private int windowEnd = 0; - private int windowFilled = 0; - - public void Write(int abyte) - { - if (windowFilled++ == WINDOW_SIZE) { - throw new InvalidOperationException("Window full"); - } - window[windowEnd++] = (byte) abyte; - windowEnd &= WINDOW_MASK; - } - - - private void SlowRepeat(int repStart, int len, int dist) - { - while (len-- > 0) { - window[windowEnd++] = window[repStart++]; - windowEnd &= WINDOW_MASK; - repStart &= WINDOW_MASK; - } - } - - public void Repeat(int len, int dist) - { - if ((windowFilled += len) > WINDOW_SIZE) { - throw new InvalidOperationException("Window full"); - } - - int rep_start = (windowEnd - dist) & WINDOW_MASK; - int border = WINDOW_SIZE - len; - if (rep_start <= border && windowEnd < border) { - if (len <= dist) { - System.Array.Copy(window, rep_start, window, windowEnd, len); - windowEnd += len; - } else { - /* We have to copy manually, since the repeat pattern overlaps. - */ - while (len-- > 0) { - window[windowEnd++] = window[rep_start++]; - } - } - } else { - SlowRepeat(rep_start, len, dist); - } - } - - public int CopyStored(StreamManipulator input, int len) - { - len = Math.Min(Math.Min(len, WINDOW_SIZE - windowFilled), input.AvailableBytes); - int copied; - - int tailLen = WINDOW_SIZE - windowEnd; - if (len > tailLen) { - copied = input.CopyBytes(window, windowEnd, tailLen); - if (copied == tailLen) { - copied += input.CopyBytes(window, 0, len - tailLen); - } - } else { - copied = input.CopyBytes(window, windowEnd, len); - } - - windowEnd = (windowEnd + copied) & WINDOW_MASK; - windowFilled += copied; - return copied; - } - - public void CopyDict(byte[] dict, int offset, int len) - { - if (windowFilled > 0) { - throw new InvalidOperationException(); - } - - if (len > WINDOW_SIZE) { - offset += len - WINDOW_SIZE; - len = WINDOW_SIZE; - } - System.Array.Copy(dict, offset, window, 0, len); - windowEnd = len & WINDOW_MASK; - } - - public int GetFreeSpace() - { - return WINDOW_SIZE - windowFilled; - } - - public int GetAvailable() - { - return windowFilled; - } - - public int CopyOutput(byte[] output, int offset, int len) - { - int copy_end = windowEnd; - if (len > windowFilled) { - len = windowFilled; - } else { - copy_end = (windowEnd - windowFilled + len) & WINDOW_MASK; - } - - int copied = len; - int tailLen = len - copy_end; - - if (tailLen > 0) { - System.Array.Copy(window, WINDOW_SIZE - tailLen, output, offset, tailLen); - offset += tailLen; - len = copy_end; - } - System.Array.Copy(window, copy_end - len, output, offset, len); - windowFilled -= copied; - if (windowFilled < 0) { - throw new InvalidOperationException(); - } - return copied; - } - - public void Reset() - { - windowFilled = windowEnd = 0; - } - } -} diff --git a/irc/TechBot/Compression/Streams/StreamManipulator.cs b/irc/TechBot/Compression/Streams/StreamManipulator.cs deleted file mode 100644 index 35f98cc4f76..00000000000 --- a/irc/TechBot/Compression/Streams/StreamManipulator.cs +++ /dev/null @@ -1,245 +0,0 @@ -// StreamManipulator.cs -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; - -namespace ICSharpCode.SharpZipLib.Zip.Compression.Streams -{ - - /// - /// This class allows us to retrieve a specified amount of bits from - /// the input buffer, as well as copy big byte blocks. - /// - /// It uses an int buffer to store up to 31 bits for direct - /// manipulation. This guarantees that we can get at least 16 bits, - /// but we only need at most 15, so this is all safe. - /// - /// There are some optimizations in this class, for example, you must - /// never peek more then 8 bits more than needed, and you must first - /// peek bits before you may drop them. This is not a general purpose - /// class but optimized for the behaviour of the Inflater. - /// - /// authors of the original java version : John Leuner, Jochen Hoenicke - /// - public class StreamManipulator - { - private byte[] window; - private int window_start = 0; - private int window_end = 0; - - private uint buffer = 0; - private int bits_in_buffer = 0; - - /// - /// Get the next n bits but don't increase input pointer. n must be - /// less or equal 16 and if you if this call succeeds, you must drop - /// at least n-8 bits in the next call. - /// - /// - /// the value of the bits, or -1 if not enough bits available. */ - /// - public int PeekBits(int n) - { - if (bits_in_buffer < n) { - if (window_start == window_end) { - return -1; // ok - } - buffer |= (uint)((window[window_start++] & 0xff | - (window[window_start++] & 0xff) << 8) << bits_in_buffer); - bits_in_buffer += 16; - } - return (int)(buffer & ((1 << n) - 1)); - } - - /// - /// Drops the next n bits from the input. You should have called peekBits - /// with a bigger or equal n before, to make sure that enough bits are in - /// the bit buffer. - /// - public void DropBits(int n) - { - buffer >>= n; - bits_in_buffer -= n; - } - - /// - /// Gets the next n bits and increases input pointer. This is equivalent - /// to peekBits followed by dropBits, except for correct error handling. - /// - /// - /// the value of the bits, or -1 if not enough bits available. - /// - public int GetBits(int n) - { - int bits = PeekBits(n); - if (bits >= 0) { - DropBits(n); - } - return bits; - } - - /// - /// Gets the number of bits available in the bit buffer. This must be - /// only called when a previous peekBits() returned -1. - /// - /// - /// the number of bits available. - /// - public int AvailableBits { - get { - return bits_in_buffer; - } - } - - /// - /// Gets the number of bytes available. - /// - /// - /// the number of bytes available. - /// - public int AvailableBytes { - get { - return window_end - window_start + (bits_in_buffer >> 3); - } - } - - /// - /// Skips to the next byte boundary. - /// - public void SkipToByteBoundary() - { - buffer >>= (bits_in_buffer & 7); - bits_in_buffer &= ~7; - } - - public bool IsNeedingInput { - get { - return window_start == window_end; - } - } - - /// - /// Copies length bytes from input buffer to output buffer starting - /// at output[offset]. You have to make sure, that the buffer is - /// byte aligned. If not enough bytes are available, copies fewer - /// bytes. - /// - /// - /// the buffer. - /// - /// - /// the offset in the buffer. - /// - /// - /// the length to copy, 0 is allowed. - /// - /// - /// the number of bytes copied, 0 if no byte is available. - /// - public int CopyBytes(byte[] output, int offset, int length) - { - if (length < 0) { - throw new ArgumentOutOfRangeException("length negative"); - } - if ((bits_in_buffer & 7) != 0) { - /* bits_in_buffer may only be 0 or 8 */ - throw new InvalidOperationException("Bit buffer is not aligned!"); - } - - int count = 0; - while (bits_in_buffer > 0 && length > 0) { - output[offset++] = (byte) buffer; - buffer >>= 8; - bits_in_buffer -= 8; - length--; - count++; - } - if (length == 0) { - return count; - } - - int avail = window_end - window_start; - if (length > avail) { - length = avail; - } - System.Array.Copy(window, window_start, output, offset, length); - window_start += length; - - if (((window_start - window_end) & 1) != 0) { - /* We always want an even number of bytes in input, see peekBits */ - buffer = (uint)(window[window_start++] & 0xff); - bits_in_buffer = 8; - } - return count + length; - } - - public StreamManipulator() - { - } - - public void Reset() - { - buffer = (uint)(window_start = window_end = bits_in_buffer = 0); - } - - public void SetInput(byte[] buf, int off, int len) - { - if (window_start < window_end) { - throw new InvalidOperationException("Old input was not completely processed"); - } - - int end = off + len; - - /* We want to throw an ArrayIndexOutOfBoundsException early. The - * check is very tricky: it also handles integer wrap around. - */ - if (0 > off || off > end || end > buf.Length) { - throw new ArgumentOutOfRangeException(); - } - - if ((len & 1) != 0) { - /* We always want an even number of bytes in input, see peekBits */ - buffer |= (uint)((buf[off++] & 0xff) << bits_in_buffer); - bits_in_buffer += 8; - } - - window = buf; - window_start = off; - window_end = end; - } - } -} diff --git a/irc/TechBot/Compression/ZipException.cs b/irc/TechBot/Compression/ZipException.cs deleted file mode 100644 index b342592569a..00000000000 --- a/irc/TechBot/Compression/ZipException.cs +++ /dev/null @@ -1,62 +0,0 @@ -// ZipException.cs -// Copyright (C) 2001 Mike Krueger -// -// This file was translated from java, it was part of the GNU Classpath -// Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// -// Linking this library statically or dynamically with other modules is -// making a combined work based on this library. Thus, the terms and -// conditions of the GNU General Public License cover the whole -// combination. -// -// As a special exception, the copyright holders of this library give you -// permission to link this library with independent modules to produce an -// executable, regardless of the license terms of these independent -// modules, and to copy and distribute the resulting executable under -// terms of your choice, provided that you also meet, for each linked -// independent module, the terms and conditions of the license of that -// module. An independent module is a module which is not derived from -// or based on this library. If you modify this library, you may extend -// this exception to your version of the library, but you are not -// obligated to do so. If you do not wish to do so, delete this -// exception statement from your version. - -using System; - -namespace ICSharpCode.SharpZipLib -{ - - /// - /// Is thrown during the creation or input of a zip file. - /// - public class ZipException : Exception - { - /// - /// Initializes a new instance of the ZipException class with default properties. - /// - public ZipException() - { - } - - /// - /// Initializes a new instance of the ZipException class with a specified error message. - /// - public ZipException(string msg) : base(msg) - { - } - } -} diff --git a/irc/TechBot/Resources/hresult.xml b/irc/TechBot/Resources/hresult.xml deleted file mode 100644 index 68e5bdc55e2..00000000000 --- a/irc/TechBot/Resources/hresult.xml +++ /dev/null @@ -1,1088 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/irc/TechBot/Resources/ntstatus.xml b/irc/TechBot/Resources/ntstatus.xml deleted file mode 100644 index 2e99a3bd13d..00000000000 --- a/irc/TechBot/Resources/ntstatus.xml +++ /dev/null @@ -1,1111 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/irc/TechBot/Resources/winerror.xml b/irc/TechBot/Resources/winerror.xml deleted file mode 100644 index 237ced972bb..00000000000 --- a/irc/TechBot/Resources/winerror.xml +++ /dev/null @@ -1,1839 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/irc/TechBot/Resources/wm.xml b/irc/TechBot/Resources/wm.xml deleted file mode 100644 index 86994eae728..00000000000 --- a/irc/TechBot/Resources/wm.xml +++ /dev/null @@ -1,321 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/irc/TechBot/TechBot.Commands.Common/Base/BugCommand.cs b/irc/TechBot/TechBot.Commands.Common/Base/BugCommand.cs deleted file mode 100644 index d6563d6867f..00000000000 --- a/irc/TechBot/TechBot.Commands.Common/Base/BugCommand.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; - -using TechBot.Library; - -namespace TechBot.Commands.Common -{ - public abstract class BugCommand : Command - { -// private string m_BugID = null; - - public BugCommand() - { - } - - public string BugID - { - get { return Parameters; } - set { Parameters = value; } - } - - public override void ExecuteCommand() - { - if (string.IsNullOrEmpty(BugID)) - { - Say("Please provide a valid bug number."); - } - else - { - try - { - Say(BugUrl, Int32.Parse(BugID)); - } - catch (Exception) - { - Say("{0} is not a valid bug number.", BugID); - } - } - } - - protected abstract string BugUrl { get; } - } -} diff --git a/irc/TechBot/TechBot.Commands.Common/ErrorCommand.cs b/irc/TechBot/TechBot.Commands.Common/ErrorCommand.cs deleted file mode 100644 index bb1980b032e..00000000000 --- a/irc/TechBot/TechBot.Commands.Common/ErrorCommand.cs +++ /dev/null @@ -1,180 +0,0 @@ -using System; -using System.Xml; -using System.Collections; - -using TechBot.Library; - -namespace TechBot.Commands.Common -{ - [Command("error", Help = "!error ")] - public class ErrorCommand : Command - { - private NtStatusCommand ntStatus; - private WinErrorCommand winerror; - private HResultCommand hresult; - - public ErrorCommand() - { - this.ntStatus = new NtStatusCommand(); - this.winerror = new WinErrorCommand(); - this.hresult = new HResultCommand(); - } - - private static int GetSeverity(long error) - { - return (int)((error >> 30) & 0x3); - } - - private static bool IsCustomer(long error) - { - return (error & 0x20000000) != 0; - } - - private static bool IsReserved(long error) - { - return (error & 0x10000000) != 0; - } - - private static int GetFacility(long error) - { - return (int)((error >> 16) & 0xFFF); - } - - private static short GetCode(long error) - { - return (short)((error >> 0) & 0xFFFF); - } - - private static string FormatSeverity(long error) - { - int severity = GetSeverity(error); - switch (severity) - { - case 0: return "SUCCESS"; - case 1: return "INFORMATIONAL"; - case 2: return "WARNING"; - case 3: return "ERROR"; - } - return null; - } - - private static string FormatFacility(long error) - { - int facility = GetFacility(error); - return facility.ToString(); - } - - private static string FormatCode(long error) - { - int code = GetCode(error); - return code.ToString(); - } - - public override void ExecuteCommand() - { - if (Parameters.Equals(String.Empty)) - { - Say("Please provide an Error Code."); - return; - } - - string errorText = Parameters; - - retry: - NumberParser np = new NumberParser(); - long error = np.Parse(errorText); - if (np.Error) - { - Say("{0} is not a valid Error Code.", Parameters); - return; - } - - ArrayList descriptions = new ArrayList(); - - // Error is out of bounds - if ((ulong)error > uint.MaxValue) - { - // Do nothing - } - // Error is outside of the range [0, 65535]: it cannot be a plain Win32 error code - else if ((ulong)error > ushort.MaxValue) - { - // Customer bit is set: custom error code - if (IsCustomer(error)) - { - string description = String.Format("[custom, severity {0}, facility {1}, code {2}]", - FormatSeverity(error), - FormatFacility(error), - FormatCode(error)); - descriptions.Add(description); - } - // Reserved bit is set: HRESULT_FROM_NT(ntstatus) - else if (IsReserved(error)) - { - int status = (int)(error & 0xCFFFFFFF); - string description = ntStatus.GetNtstatusDescription(status); - - if (description == null) - description = status.ToString("X"); - - description = String.Format("HRESULT_FROM_NT({0})", description); - descriptions.Add(description); - } - // Win32 facility: HRESULT_FROM_WIN32(winerror) - else if (GetFacility(error) == 7) - { - // Must be an error code - if (GetSeverity(error) == 2) - { - short err = GetCode(error); - string description = winerror.GetWinerrorDescription(err); - - if (description == null) - description = err.ToString("D"); - - description = String.Format("HRESULT_FROM_WIN32({0})", description); - descriptions.Add(description); - } - } - } - - string winerrorDescription = winerror.GetWinerrorDescription(error); - string ntstatusDescription = ntStatus.GetNtstatusDescription(error); - string hresultDescription = hresult.GetHresultDescription(error); - - if (winerrorDescription != null) - descriptions.Add(winerrorDescription); - if (ntstatusDescription != null) - descriptions.Add(ntstatusDescription); - if (hresultDescription != null) - descriptions.Add(hresultDescription); - - if (descriptions.Count == 0) - { - // Last chance heuristics: attempt to parse a 8-digit decimal as hexadecimal - if (errorText.Length == 8) - { - errorText = "0x" + errorText; - goto retry; - } - - Say("I don't know about Error Code {0}.", - Parameters); - } - else if (descriptions.Count == 1) - { - string description = (string)descriptions[0]; - Say("{0} is {1}.", - Parameters, - description); - } - else - { - Say("{0} could be:", Parameters); - - foreach (string description in descriptions) - Say("\t{0}", description); - } - } - } -} diff --git a/irc/TechBot/TechBot.Commands.Common/HResultCommand.cs b/irc/TechBot/TechBot.Commands.Common/HResultCommand.cs deleted file mode 100644 index fd42239ba43..00000000000 --- a/irc/TechBot/TechBot.Commands.Common/HResultCommand.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using System.Xml; - -using TechBot.Library; - -namespace TechBot.Commands.Common -{ - [Command("hresult", Help = "!hresult ")] - public class HResultCommand : XmlLookupCommand - { - public HResultCommand() - { - } - - public override string XmlFile - { - get { return Settings.Default.HResultXml; } - } - - public override void ExecuteCommand() - { - if (string.IsNullOrEmpty(Text)) - { - Say("Please provide a valid HRESULT value."); - } - else - { - NumberParser np = new NumberParser(); - long hresult = np.Parse(Text); - if (np.Error) - { - Say("{0} is not a valid HRESULT value.", Text); - return; - } - - string description = GetHresultDescription(hresult); - if (description != null) - { - Say("{0} is {1}.", - Text, - description); - } - else - { - Say("I don't know about HRESULT {0}.", Text); - } - } - } - - public string GetHresultDescription(long hresult) - { - XmlElement root = base.m_XmlDocument.DocumentElement; - XmlNode node = root.SelectSingleNode(String.Format("Hresult[@value='{0}']", - hresult.ToString("X8"))); - if (node != null) - { - XmlAttribute text = node.Attributes["text"]; - if (text == null) - throw new Exception("Node has no text attribute."); - return text.Value; - } - else - return null; - } - } -} diff --git a/irc/TechBot/TechBot.Commands.Common/NtStatusCommand.cs b/irc/TechBot/TechBot.Commands.Common/NtStatusCommand.cs deleted file mode 100644 index 96120e48bf3..00000000000 --- a/irc/TechBot/TechBot.Commands.Common/NtStatusCommand.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using System.Xml; - -using TechBot.Library; - -namespace TechBot.Commands.Common -{ - [Command("ntstatus", Help = "!ntstatus ")] - public class NtStatusCommand : XmlLookupCommand - { - public NtStatusCommand() - { - } - - public override string XmlFile - { - get { return Settings.Default.NtStatusXml; } - } - - public override void ExecuteCommand() - { - if (string.IsNullOrEmpty(Text)) - { - Say("Please provide a valid NTSTATUS value."); - } - else - { - NumberParser np = new NumberParser(); - long ntstatus = np.Parse(Text); - if (np.Error) - { - Say("{0} is not a valid NTSTATUS value.", Text); - return; - } - - string description = GetNtstatusDescription(ntstatus); - if (description != null) - { - Say("{0} is {1}.", - Text, - description); - } - else - { - Say("I don't know about NTSTATUS {0}.", Text); - } - } - } - - public string GetNtstatusDescription(long ntstatus) - { - XmlElement root = base.m_XmlDocument.DocumentElement; - XmlNode node = root.SelectSingleNode(String.Format("Ntstatus[@value='{0}']", - ntstatus.ToString("X8"))); - if (node != null) - { - XmlAttribute text = node.Attributes["text"]; - if (text == null) - throw new Exception("Node has no text attribute."); - return text.Value; - } - else - return null; - } - } -} diff --git a/irc/TechBot/TechBot.Commands.Common/Properties/AssemblyInfo.cs b/irc/TechBot/TechBot.Commands.Common/Properties/AssemblyInfo.cs deleted file mode 100644 index 72c565a8582..00000000000 --- a/irc/TechBot/TechBot.Commands.Common/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("TechBot.Commands.Common")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Sand")] -[assembly: AssemblyProduct("TechBot.Commands.Common")] -[assembly: AssemblyCopyright("Copyright © Sand 2008")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("5d39d6f8-37fb-423b-ba88-1d5d8e5a1317")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/irc/TechBot/TechBot.Commands.Common/ReactOSBugUrl.cs b/irc/TechBot/TechBot.Commands.Common/ReactOSBugUrl.cs deleted file mode 100644 index 3d94d6ba839..00000000000 --- a/irc/TechBot/TechBot.Commands.Common/ReactOSBugUrl.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -using TechBot.Library; - -namespace TechBot.Commands.Common -{ - [Command("rosbug", Help = "!rosbug ", Description = "Will give you a link to the reqested ReactOS bug")] - class ReactOSBugUrl : BugCommand - { - public ReactOSBugUrl() - { - } - - protected override string BugUrl - { - get { return "http://www.reactos.org/bugzilla/show_bug.cgi?id={0}"; } - } - } -} diff --git a/irc/TechBot/TechBot.Commands.Common/SambaBugUrl.cs b/irc/TechBot/TechBot.Commands.Common/SambaBugUrl.cs deleted file mode 100644 index 6c3767720de..00000000000 --- a/irc/TechBot/TechBot.Commands.Common/SambaBugUrl.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -using TechBot.Library; - -namespace TechBot.Commands.Common -{ - [Command("sambabug", Help = "!sambabug ", Description = "Will give you a link to the reqested Samba bug")] - class SambaBugUrl : BugCommand - { - public SambaBugUrl() - { - } - - protected override string BugUrl - { - get { return "https://bugzilla.samba.org/show_bug.cgi?id={0}"; } - } - } -} diff --git a/irc/TechBot/TechBot.Commands.Common/Settings.Designer.cs b/irc/TechBot/TechBot.Commands.Common/Settings.Designer.cs deleted file mode 100644 index d05b1de36c9..00000000000 --- a/irc/TechBot/TechBot.Commands.Common/Settings.Designer.cs +++ /dev/null @@ -1,71 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.1433 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace TechBot.Commands.Common { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("C:\\Ros\\current\\irc\\TechBot\\Resources\\ntstatus.xml")] - public string NtStatusXml { - get { - return ((string)(this["NtStatusXml"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("C:\\Ros\\current\\irc\\TechBot\\Resources\\winerror.xml")] - public string WinErrorXml { - get { - return ((string)(this["WinErrorXml"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("C:\\Ros\\current\\irc\\TechBot\\Resources\\hresult.xml")] - public string HResultXml { - get { - return ((string)(this["HResultXml"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("C:\\Ros\\current\\irc\\TechBot\\Resources\\wm.xml")] - public string WMXml { - get { - return ((string)(this["WMXml"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("svn://svn.reactos.org/reactos/trunk")] - public string SVNRoot { - get { - return ((string)(this["SVNRoot"])); - } - } - } -} diff --git a/irc/TechBot/TechBot.Commands.Common/Settings.cs b/irc/TechBot/TechBot.Commands.Common/Settings.cs deleted file mode 100644 index 45a94a87392..00000000000 --- a/irc/TechBot/TechBot.Commands.Common/Settings.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace TechBot.Commands.Common { - - - // This class allows you to handle specific events on the settings class: - // The SettingChanging event is raised before a setting's value is changed. - // The PropertyChanged event is raised after a setting's value is changed. - // The SettingsLoaded event is raised after the setting values are loaded. - // The SettingsSaving event is raised before the setting values are saved. - internal sealed partial class Settings { - - public Settings() { - // // To add event handlers for saving and changing settings, uncomment the lines below: - // - // this.SettingChanging += this.SettingChangingEventHandler; - // - // this.SettingsSaving += this.SettingsSavingEventHandler; - // - } - - private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) { - // Add code to handle the SettingChangingEvent event here. - } - - private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) { - // Add code to handle the SettingsSaving event here. - } - } -} diff --git a/irc/TechBot/TechBot.Commands.Common/Settings.settings b/irc/TechBot/TechBot.Commands.Common/Settings.settings deleted file mode 100644 index 4ee296b8e5a..00000000000 --- a/irc/TechBot/TechBot.Commands.Common/Settings.settings +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - C:\Ros\current\irc\TechBot\Resources\ntstatus.xml - - - C:\Ros\current\irc\TechBot\Resources\winerror.xml - - - C:\Ros\current\irc\TechBot\Resources\hresult.xml - - - C:\Ros\current\irc\TechBot\Resources\wm.xml - - - svn://svn.reactos.org/reactos/trunk - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.Commands.Common/SvnCommand.cs b/irc/TechBot/TechBot.Commands.Common/SvnCommand.cs deleted file mode 100644 index 9604761132a..00000000000 --- a/irc/TechBot/TechBot.Commands.Common/SvnCommand.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; - -using TechBot.Library; - -namespace TechBot.Commands.Common -{ - [Command("svn", Help = "!svn" , Description="Where the ROS SVN repository is located")] - public class SvnCommand : Command - { - private string m_SvnRoot; - - public SvnCommand() - { - m_SvnRoot = Settings.Default.SVNRoot; - } - - public override void ExecuteCommand() - { - Say("svn co {0}", m_SvnRoot); - } - } -} diff --git a/irc/TechBot/TechBot.Commands.Common/TechBot.Commands.Common.csproj b/irc/TechBot/TechBot.Commands.Common/TechBot.Commands.Common.csproj deleted file mode 100644 index 589f42a206a..00000000000 --- a/irc/TechBot/TechBot.Commands.Common/TechBot.Commands.Common.csproj +++ /dev/null @@ -1,75 +0,0 @@ - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {041B5F06-BF97-4981-B024-3A7B6DD9F6AE} - Library - Properties - TechBot.Commands.Common - TechBot.Commands.Common - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - Settings.settings - True - True - - - - - - - - - {1114F34D-F388-4F38-AE27-C0EE1B10B777} - TechBot.Library - - - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.Commands.Common/WMCommand.cs b/irc/TechBot/TechBot.Commands.Common/WMCommand.cs deleted file mode 100644 index 2b79f4ed7ef..00000000000 --- a/irc/TechBot/TechBot.Commands.Common/WMCommand.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System; -using System.Xml; - -using TechBot.Library; - -namespace TechBot.Commands.Common -{ - [Command("wm" , Help = "!wm or !wm ")] - public class WMCommand : XmlCommand - { - public WMCommand() - { - } - - public override string XmlFile - { - get { return Settings.Default.WMXml; } - } - - [CommandParameter("wm", "The windows message to check" , DefaultParameter = true)] - public string WMText - { - get { return Parameters; } - set { Parameters = value; } - } - - public override void ExecuteCommand() - { - if (string.IsNullOrEmpty(WMText)) - { - Say("Please provide a valid window message value or name."); - - } - else - { - NumberParser np = new NumberParser(); - long wm = np.Parse(WMText); - string output; - if (np.Error) - { - // Assume "!wm " form. - output = GetWmNumber(WMText); - } - else - { - output = GetWmDescription(wm); - } - - if (output != null) - { - Say("{0} is {1}.", - WMText, - output); - } - else - { - Say("I don't know about window message {0}.", WMText); - } - } - } - - private string GetWmDescription(long wm) - { - XmlElement root = base.m_XmlDocument.DocumentElement; - XmlNode node = root.SelectSingleNode(String.Format("WindowMessage[@value='{0}']", - wm)); - if (node != null) - { - XmlAttribute text = node.Attributes["text"]; - if (text == null) - throw new Exception("Node has no text attribute."); - return text.Value; - } - else - return null; - } - - private string GetWmNumber(string wmName) - { - XmlElement root = base.m_XmlDocument.DocumentElement; - XmlNode node = root.SelectSingleNode(String.Format("WindowMessage[@text='{0}']", - wmName)); - if (node != null) - { - XmlAttribute value = node.Attributes["value"]; - if (value == null) - throw new Exception("Node has no value attribute."); - return value.Value; - } - else - return null; - } - } -} diff --git a/irc/TechBot/TechBot.Commands.Common/WineBugUrl.cs b/irc/TechBot/TechBot.Commands.Common/WineBugUrl.cs deleted file mode 100644 index e87a0c30b3e..00000000000 --- a/irc/TechBot/TechBot.Commands.Common/WineBugUrl.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -using TechBot.Library; - -namespace TechBot.Commands.Common -{ - [Command("winebug", Help = "!winebug " , Description="Will give you a link to the reqested Wine bug")] - class WineBugUrl : BugCommand - { - public WineBugUrl() - { - } - - protected override string BugUrl - { - get { return "http://bugs.winehq.org/show_bug.cgi?id={0}"; } - } - } -} diff --git a/irc/TechBot/TechBot.Commands.Common/WinerrorCommand.cs b/irc/TechBot/TechBot.Commands.Common/WinerrorCommand.cs deleted file mode 100644 index 950f37bd61b..00000000000 --- a/irc/TechBot/TechBot.Commands.Common/WinerrorCommand.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using System.Xml; - -using TechBot.Library; - -namespace TechBot.Commands.Common -{ - [Command("winerror", Help = "!winerror ")] - public class WinErrorCommand : XmlLookupCommand - { - public WinErrorCommand() - { - } - - public override string XmlFile - { - get { return Settings.Default.WinErrorXml; } - } - - public override void ExecuteCommand() - { - if (string.IsNullOrEmpty(Text)) - { - Say("Please provide a valid System Error Code value."); - } - else - { - NumberParser np = new NumberParser(); - long winerror = np.Parse(Text); - if (np.Error) - { - Say("{0} is not a valid System Error Code value.", Text); - return; - } - - string description = GetWinerrorDescription(winerror); - if (description != null) - { - Say("{0} is {1}.", - Text, - description); - } - else - { - Say("I don't know about System Error Code {0}.", Text); - } - } - } - - public string GetWinerrorDescription(long winerror) - { - XmlElement root = base.m_XmlDocument.DocumentElement; - XmlNode node = root.SelectSingleNode(String.Format("Winerror[@value='{0}']", - winerror.ToString())); - if (node != null) - { - XmlAttribute text = node.Attributes["text"]; - if (text == null) - throw new Exception("Node has no text attribute."); - return text.Value; - } - else - return null; - } - } -} diff --git a/irc/TechBot/TechBot.Commands.Common/app.config b/irc/TechBot/TechBot.Commands.Common/app.config deleted file mode 100644 index 479a2cdc49d..00000000000 --- a/irc/TechBot/TechBot.Commands.Common/app.config +++ /dev/null @@ -1,27 +0,0 @@ - - - - -
        - - - - - - C:\Ros\current\irc\TechBot\Resources\ntstatus.xml - - - C:\Ros\current\irc\TechBot\Resources\winerror.xml - - - C:\Ros\current\irc\TechBot\Resources\hresult.xml - - - C:\Ros\current\irc\TechBot\Resources\wm.xml - - - svn://svn.reactos.org/reactos/trunk - - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.Commands.MSDN/ApiCommand.cs b/irc/TechBot/TechBot.Commands.MSDN/ApiCommand.cs deleted file mode 100644 index a165f6aa68d..00000000000 --- a/irc/TechBot/TechBot.Commands.MSDN/ApiCommand.cs +++ /dev/null @@ -1,309 +0,0 @@ -using System; -using System.IO; -using System.Data; -using System.Text.RegularExpressions; - -using HtmlHelp; -using HtmlHelp.ChmDecoding; - -using TechBot.Library; - -namespace TechBot.Commands.MSDN -{ - [Command("api", Help = "!api ")] - public class ApiCommand : Command - { - private bool IsVerbose = false; - - private HtmlHelpSystem chm; - - public ApiCommand() - { - LoadCHM(); - } - - [CommandParameter("api", "The API name")] - public string API - { - get { return Parameters; } - set { Parameters = value; } - } - - private void WriteIfVerbose(string message) - { - if (IsVerbose) - Say(message); - } - - private void LoadCHM() - { - string CHMFilename = Path.Combine(Settings.Default.ChmPath, Settings.Default.MainChm); - chm = new HtmlHelpSystem(); - chm.OpenFile(CHMFilename, null); - - Console.WriteLine(String.Format("Loaded main CHM: {0}", - Path.GetFileName(CHMFilename))); - foreach (string filename in Directory.GetFiles(Settings.Default.ChmPath)) - { - if (!Path.GetExtension(filename).ToLower().Equals(".chm")) - continue; - if (Path.GetFileName(filename).ToLower().Equals(Settings.Default.MainChm)) - continue; - - Console.WriteLine(String.Format("Loading CHM: {0}", - Path.GetFileName(filename))); - try - { - chm.MergeFile(filename); - } - catch (Exception ex) - { - Console.WriteLine(String.Format("Could not load CHM: {0}. Exception {1}", - Path.GetFileName(filename), - ex)); - } - } - Console.WriteLine(String.Format("Loaded {0} CHMs", - chm.FileList.Length)); - } - - public override void ExecuteCommand() - { - if (Name.Trim().Equals(String.Empty)) - { - Say("Please give me a keyword."); - } - else - { - Search(Name); - } - } - - private bool SearchIndex( - string keyword) - { - if (chm.HasIndex) - { - IndexItem item = chm.Index.SearchIndex(keyword, - IndexType.KeywordLinks); - if (item != null && item.Topics.Count > 0) - { - WriteIfVerbose(String.Format("Keyword {0} found in index", - item.KeyWord)); - IndexTopic indexTopic = item.Topics[0] as IndexTopic; - return DisplayResult( keyword, - indexTopic); - } - else - { - WriteIfVerbose(String.Format("Keyword {0} not found in index", - keyword)); - return false; - } - } - else - return false; - } - - private void SearchFullText(string keyword) - { - string sort = "Rating ASC"; - WriteIfVerbose(String.Format("Searching fulltext database for {0}", - keyword)); - - bool partialMatches = false; - bool titlesOnly = true; - int maxResults = 100; - DataTable results = chm.PerformSearch(keyword, - maxResults, - partialMatches, - titlesOnly); - WriteIfVerbose(String.Format("results.Rows.Count = {0}", - results != null ? - results.Rows.Count.ToString() : "(none)")); - if (results != null && results.Rows.Count > 0) - { - results.DefaultView.Sort = sort; - if (!DisplayResult(keyword, - results)) - { - Say("No result"); - } - } - else - { - Say("No result"); - } - } - - private void Search(string keyword) - { - if (!SearchIndex(keyword)) - SearchFullText(keyword); - } - - private bool DisplayResult(string keyword, - IndexTopic indexTopic) - { - keyword = keyword.Trim().ToLower(); - string url = indexTopic.URL; - WriteIfVerbose(String.Format("URL from index search {0}", - url)); - string prototype = ExtractPrototype(url); - if (prototype == null || prototype.Trim().Equals(String.Empty)) - return false; - string formattedPrototype = FormatPrototype(prototype); - Say(formattedPrototype); - return true; - } - - private bool DisplayResult(string keyword, - DataTable results) - { - keyword = keyword.Trim().ToLower(); - for (int i = 0; i < results.DefaultView.Count; i++) - { - DataRowView row = results.DefaultView[i]; - string title = row["Title"].ToString(); - WriteIfVerbose(String.Format("Examining {0}", title)); - if (title.Trim().ToLower().Equals(keyword)) - { - string location = row["Location"].ToString(); - string rating = row["Rating"].ToString(); - string url = row["Url"].ToString(); - string prototype = ExtractPrototype(url); - if (prototype == null || prototype.Trim().Equals(String.Empty)) - continue; - string formattedPrototype = FormatPrototype(prototype); - Say(formattedPrototype); - return true; - } - } - return false; - } - - private void DisplayNoResult(MessageContext context, - string keyword) - { - TechBot.ServiceOutput.WriteLine(context, - String.Format("I don't know about keyword {0}", - keyword)); - } - - private string ReplaceComments(string s) - { - return Regex.Replace(s, "//(.+)\r\n", ""); - } - - private string ReplaceLineEndings(string s) - { - return Regex.Replace(s, "(\r\n)+", " "); - } - - private string ReplaceSpaces(string s) - { - return Regex.Replace(s, @" +", " "); - } - - private string ReplaceSpacesBeforeLeftParenthesis(string s) - { - return Regex.Replace(s, @"\( ", @"("); - } - - private string ReplaceSpacesBeforeRightParenthesis(string s) - { - return Regex.Replace(s, @" \)", @")"); - } - - private string ReplaceSemicolon(string s) - { - return Regex.Replace(s, @";", @""); - } - - private string FormatPrototype(string prototype) - { - string s = ReplaceComments(prototype); - s = ReplaceLineEndings(s); - s = ReplaceSpaces(s); - s = ReplaceSpacesBeforeLeftParenthesis(s); - s = ReplaceSpacesBeforeRightParenthesis(s); - s = ReplaceSemicolon(s); - return s; - } - - private string ExtractPrototype(string url) - { - string page = GetPage(url); - Match match = Regex.Match(page, - "
        (.+)
        ", - RegexOptions.Multiline | - RegexOptions.Singleline); - if (match.Groups.Count > 1) - { - string prototype = match.Groups[1].ToString(); - return StripHtml(StripAfterSlashPre(prototype)); - } - - return ""; - } - - private string StripAfterSlashPre(string html) - { - int index = html.IndexOf(""); - if (index != -1) - { - return html.Substring(0, index); - } - else - return html; - } - - private string StripHtml(string html) - { - return Regex.Replace(html, @"<(.|\n)*?>", String.Empty); - } - - private string GetPage(string url) - { - string CHMFileName = ""; - string topicName = ""; - string anchor = ""; - CHMStream.CHMStream baseStream; - if (!chm.BaseStream.GetCHMParts(url, ref CHMFileName, ref topicName, ref anchor)) - { - baseStream = chm.BaseStream; - CHMFileName = baseStream.CHMFileName; - topicName = url; - anchor = ""; - } - else - { - baseStream = GetBaseStreamFromCHMFileName(CHMFileName); - } - - if ((topicName == "") || (CHMFileName == "") || (baseStream == null)) - { - return ""; - } - - return baseStream.ExtractTextFile(topicName); - } - - private CHMStream.CHMStream GetBaseStreamFromCHMFileName(string CHMFileName) - { - foreach (CHMFile file in chm.FileList) - { - WriteIfVerbose(String.Format("Compare: {0} <> {1}", - file.ChmFilePath, - CHMFileName)); - if (file.ChmFilePath.ToLower().Equals(CHMFileName.ToLower())) - { - return file.BaseStream; - } - } - WriteIfVerbose(String.Format("Could not find loaded CHM file in list: {0}", - CHMFileName)); - return null; - } - } -} diff --git a/irc/TechBot/TechBot.Commands.MSDN/Properties/AssemblyInfo.cs b/irc/TechBot/TechBot.Commands.MSDN/Properties/AssemblyInfo.cs deleted file mode 100644 index 44bdf804a8b..00000000000 --- a/irc/TechBot/TechBot.Commands.MSDN/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("TechBot.Commands.MSDN")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Sand")] -[assembly: AssemblyProduct("TechBot.Commands.MSDN")] -[assembly: AssemblyCopyright("Copyright © Sand 2008")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("8a6332ce-82e3-4fbd-a799-8f4b8d025955")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/irc/TechBot/TechBot.Commands.MSDN/Settings.Designer.cs b/irc/TechBot/TechBot.Commands.MSDN/Settings.Designer.cs deleted file mode 100644 index 634aeefe0c7..00000000000 --- a/irc/TechBot/TechBot.Commands.MSDN/Settings.Designer.cs +++ /dev/null @@ -1,50 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.1433 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace TechBot.Commands.MSDN { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("C:\\IRC\\TechBot\\CHM")] - public string ChmPath { - get { - return ((string)(this["ChmPath"])); - } - set { - this["ChmPath"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("kmarch.chm")] - public string MainChm { - get { - return ((string)(this["MainChm"])); - } - set { - this["MainChm"] = value; - } - } - } -} diff --git a/irc/TechBot/TechBot.Commands.MSDN/Settings.settings b/irc/TechBot/TechBot.Commands.MSDN/Settings.settings deleted file mode 100644 index d13c49f8e2a..00000000000 --- a/irc/TechBot/TechBot.Commands.MSDN/Settings.settings +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - C:\IRC\TechBot\CHM - - - kmarch.chm - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.Commands.MSDN/TechBot.Commands.MSDN.csproj b/irc/TechBot/TechBot.Commands.MSDN/TechBot.Commands.MSDN.csproj deleted file mode 100644 index 636ac87d58f..00000000000 --- a/irc/TechBot/TechBot.Commands.MSDN/TechBot.Commands.MSDN.csproj +++ /dev/null @@ -1,69 +0,0 @@ - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {ADBF1ED6-A586-4707-BD59-4CD53448D0FE} - Library - Properties - TechBot.Commands.MSDN - TechBot.Commands.MSDN - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - True - True - Settings.settings - - - - - {72E5CCA1-6318-4D62-964D-CB23A5C743B5} - CHMLibrary - - - {1114F34D-F388-4F38-AE27-C0EE1B10B777} - TechBot.Library - - - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.Commands.MSDN/TechBot.Commands.MSDN.csproj.user b/irc/TechBot/TechBot.Commands.MSDN/TechBot.Commands.MSDN.csproj.user deleted file mode 100644 index a1d742b1c46..00000000000 --- a/irc/TechBot/TechBot.Commands.MSDN/TechBot.Commands.MSDN.csproj.user +++ /dev/null @@ -1,5 +0,0 @@ - - - ProjectFiles - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.Commands.MSDN/app.config b/irc/TechBot/TechBot.Commands.MSDN/app.config deleted file mode 100644 index 83f087c3399..00000000000 --- a/irc/TechBot/TechBot.Commands.MSDN/app.config +++ /dev/null @@ -1,18 +0,0 @@ - - - - -
        - - - - - - C:\IRC\TechBot\CHM - - - kmarch.chm - - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.Console/App.config b/irc/TechBot/TechBot.Console/App.config deleted file mode 100644 index dfa480f3d3c..00000000000 --- a/irc/TechBot/TechBot.Console/App.config +++ /dev/null @@ -1,27 +0,0 @@ - - - - -
        - - - - - - irc.eu.freenode.net - - - rbuildbottest2 - - - RBuildBot2 - - - qwerty - - - 6667 - - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.Console/AssemblyInfo.cs b/irc/TechBot/TechBot.Console/AssemblyInfo.cs deleted file mode 100644 index dbacda112e8..00000000000 --- a/irc/TechBot/TechBot.Console/AssemblyInfo.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following -// attributes. -// -// change them to the information which is associated with the assembly -// you compile. - -[assembly: AssemblyTitle("")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has following format : -// -// Major.Minor.Build.Revision -// -// You can specify all values by your own or you can build default build and revision -// numbers with the '*' character (the default): - -[assembly: AssemblyVersion("1.0.*")] - -// The following attributes specify the key for the sign of your assembly. See the -// .NET Framework documentation for more information about signing. -// This is not required, if you don't want signing let these attributes like they're. -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] diff --git a/irc/TechBot/TechBot.Console/ConsoleTechBotService.cs b/irc/TechBot/TechBot.Console/ConsoleTechBotService.cs deleted file mode 100644 index d3543131aa7..00000000000 --- a/irc/TechBot/TechBot.Console/ConsoleTechBotService.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -using TechBot.Library; - -namespace TechBot.Console -{ - public class ConsoleServiceOutput : IServiceOutput - { - public void WriteLine(MessageContext context, - string message) - { - System.Console.WriteLine(message); - } - } - - public class ConsoleTechBotService : TechBotService - { - public ConsoleTechBotService() - : base(new ConsoleServiceOutput()) - { - System.Console.WriteLine("TechBot running console service..."); - } - - public override void Run() - { - //Call the base class - base.Run(); - - while (true) - { - InjectMessage(System.Console.ReadLine()); - } - } - } -} diff --git a/irc/TechBot/TechBot.Console/Default.build b/irc/TechBot/TechBot.Console/Default.build deleted file mode 100644 index 706547f170b..00000000000 --- a/irc/TechBot/TechBot.Console/Default.build +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/irc/TechBot/TechBot.Console/Main.cs b/irc/TechBot/TechBot.Console/Main.cs deleted file mode 100644 index eec2855e95b..00000000000 --- a/irc/TechBot/TechBot.Console/Main.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Configuration; -using TechBot.Library; - -namespace TechBot.Console -{ - class MainClass - { - public static void Main(string[] args) - { - TechBotService m_TechBot = null; - - if (args.Length > 0 && args[0].ToLower().Equals("irc")) - { - m_TechBot = new IrcTechBotService(Settings.Default.IRCServerHostName, - Settings.Default.IRCServerHostPort, - Settings.Default.IRCChannelNames, - Settings.Default.IRCBotName, - Settings.Default.IRCBotPassword); - } - else - { - m_TechBot = new ConsoleTechBotService(); - } - - m_TechBot.Run(); - } - } -} \ No newline at end of file diff --git a/irc/TechBot/TechBot.Console/Properties/.gitignore b/irc/TechBot/TechBot.Console/Properties/.gitignore deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/irc/TechBot/TechBot.Console/Settings.Designer.cs b/irc/TechBot/TechBot.Console/Settings.Designer.cs deleted file mode 100644 index 4f05450c12f..00000000000 --- a/irc/TechBot/TechBot.Console/Settings.Designer.cs +++ /dev/null @@ -1,86 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.1433 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace TechBot.Console { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("irc.eu.freenode.net")] - public string IRCServerHostName { - get { - return ((string)(this["IRCServerHostName"])); - } - set { - this["IRCServerHostName"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("rbuildbottest2")] - public string IRCChannelNames { - get { - return ((string)(this["IRCChannelNames"])); - } - set { - this["IRCChannelNames"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("RBuildBot2")] - public string IRCBotName { - get { - return ((string)(this["IRCBotName"])); - } - set { - this["IRCBotName"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("qwerty")] - public string IRCBotPassword { - get { - return ((string)(this["IRCBotPassword"])); - } - set { - this["IRCBotPassword"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("6667")] - public int IRCServerHostPort { - get { - return ((int)(this["IRCServerHostPort"])); - } - set { - this["IRCServerHostPort"] = value; - } - } - } -} diff --git a/irc/TechBot/TechBot.Console/Settings.settings b/irc/TechBot/TechBot.Console/Settings.settings deleted file mode 100644 index ba8340928b0..00000000000 --- a/irc/TechBot/TechBot.Console/Settings.settings +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - irc.eu.freenode.net - - - rbuildbottest2 - - - RBuildBot2 - - - qwerty - - - 6667 - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.Console/TechBot.Console.cmbx b/irc/TechBot/TechBot.Console/TechBot.Console.cmbx deleted file mode 100644 index 0e37e7626b7..00000000000 --- a/irc/TechBot/TechBot.Console/TechBot.Console.cmbx +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.Console/TechBot.Console.csproj b/irc/TechBot/TechBot.Console/TechBot.Console.csproj deleted file mode 100644 index a7be83244f4..00000000000 --- a/irc/TechBot/TechBot.Console/TechBot.Console.csproj +++ /dev/null @@ -1,80 +0,0 @@ - - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {44258BA2-FFCB-4463-9CED-6DE5CC5CEBD4} - Exe - Properties - TechBot.Console - TechBot.Console - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - True - True - Settings.settings - - - - - - - - {041B5F06-BF97-4981-B024-3A7B6DD9F6AE} - TechBot.Commands.Common - - - {D676FEDE-62DD-4B4D-94C6-308598E827F9} - TechBot.Commands.RBuild - - - {D2A57931-DF04-4BC3-BD11-75DF4F3B0A88} - TechBot.IRCLibrary - - - {1114F34D-F388-4F38-AE27-C0EE1B10B777} - TechBot.Library - - - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.Console/TechBot.Console.prjx b/irc/TechBot/TechBot.Console/TechBot.Console.prjx deleted file mode 100644 index 6a08d66c7be..00000000000 --- a/irc/TechBot/TechBot.Console/TechBot.Console.prjx +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.IRCLibrary/AssemblyInfo.cs b/irc/TechBot/TechBot.IRCLibrary/AssemblyInfo.cs deleted file mode 100644 index dbacda112e8..00000000000 --- a/irc/TechBot/TechBot.IRCLibrary/AssemblyInfo.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following -// attributes. -// -// change them to the information which is associated with the assembly -// you compile. - -[assembly: AssemblyTitle("")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has following format : -// -// Major.Minor.Build.Revision -// -// You can specify all values by your own or you can build default build and revision -// numbers with the '*' character (the default): - -[assembly: AssemblyVersion("1.0.*")] - -// The following attributes specify the key for the sign of your assembly. See the -// .NET Framework documentation for more information about signing. -// This is not required, if you don't want signing let these attributes like they're. -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] diff --git a/irc/TechBot/TechBot.IRCLibrary/Default.build b/irc/TechBot/TechBot.IRCLibrary/Default.build deleted file mode 100644 index 1c468dd5fd0..00000000000 --- a/irc/TechBot/TechBot.IRCLibrary/Default.build +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/irc/TechBot/TechBot.IRCLibrary/IRC.cs b/irc/TechBot/TechBot.IRCLibrary/IRC.cs deleted file mode 100644 index ca85f08fd7b..00000000000 --- a/irc/TechBot/TechBot.IRCLibrary/IRC.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; - -namespace TechBot.IRCLibrary -{ - /// - /// IRC constants and helper methods. - /// - public class IRC - { - #region IRC commands - - public const string JOIN = "JOIN"; - public const string NICK = "NICK"; - public const string PART = "PART"; - public const string PING = "PING"; - public const string PONG = "PONG"; - public const string PRIVMSG = "PRIVMSG"; - public const string USER = "USER"; - public const string PASS = "PASS"; - public const string GHOST = "NICKSERV GHOST"; - public const string NOTICE = "NOTICE"; - - public const string RPL_NAMREPLY = "353"; - public const string RPL_ENDOFNAMES = "366"; - public const string ERR_NICKNAMEINUSE = "433"; - - #endregion - - } -} diff --git a/irc/TechBot/TechBot.IRCLibrary/IrcChannel.cs b/irc/TechBot/TechBot.IRCLibrary/IrcChannel.cs deleted file mode 100644 index 0c16e59b0bd..00000000000 --- a/irc/TechBot/TechBot.IRCLibrary/IrcChannel.cs +++ /dev/null @@ -1,137 +0,0 @@ -/* - Channels names are strings (beginning with a '&' or '#' character) of - length up to 200 characters. Apart from the the requirement that the - first character being either '&' or '#'; the only restriction on a - channel name is that it may not contain any spaces (' '), a control G - (^G or ASCII 7), or a comma (',' which is used as a list item - separator by the protocol). - */ -using System; -using System.Collections; - -namespace TechBot.IRCLibrary -{ - /// - /// IRC channel type. - /// - public enum IrcChannelType - { - Public, - Private, - Secret - } - - - - /// - /// IRC channel. - /// - public class IrcChannel - { - #region Private fields - - private IrcClient owner; - private string name; - private IrcChannelType type = IrcChannelType.Public; - private ArrayList users = new ArrayList(); - - #endregion - - #region Public properties - - /// - /// Owner of this channel. - /// - public IrcClient Owner - { - get - { - return owner; - } - } - - /// - /// Name of channel (no leading #). - /// - public string Name - { - get - { - return name; - } - } - - /// - /// Type of channel. - /// - public IrcChannelType Type - { - get - { - return type; - } - } - - /// - /// Users in this channel. - /// - public ArrayList Users - { - get - { - return users; - } - } - - #endregion - - /// - /// Constructor. - /// - /// Owner of this channel. - /// Name of channel. - public IrcChannel(IrcClient owner, string name) - { - if (owner == null) - { - throw new ArgumentNullException("owner", "Owner cannot be null."); - } - if (name == null) - { - throw new ArgumentNullException("name", "Name cannot be null."); - } - this.owner = owner; - this.name = name; - } - - /// - /// Locate a user. - /// - /// Nickname of user (no decorations). - /// User or null if not found. - public IrcUser LocateUser(string nickname) - { - foreach (IrcUser user in Users) - { - /* FIXME: There are special cases for nickname comparison */ - if (nickname.ToLower().Equals(user.Nickname.ToLower())) - { - return user; - } - } - return null; - } - - /// - /// Talk to the channel. - /// - /// Text to send to the channel. - public void Talk(string text) - { - owner.SendMessage(new IrcMessage(IRC.PRIVMSG, - String.Format("#{0} :{1}", - name, - text))); - } - } -} diff --git a/irc/TechBot/TechBot.IRCLibrary/IrcClient.cs b/irc/TechBot/TechBot.IRCLibrary/IrcClient.cs deleted file mode 100644 index 361071507ce..00000000000 --- a/irc/TechBot/TechBot.IRCLibrary/IrcClient.cs +++ /dev/null @@ -1,794 +0,0 @@ -using System; -using System.IO; -using System.Text; -using System.Collections; -using System.Net.Sockets; - -namespace TechBot.IRCLibrary -{ - /// - /// Delegate that delivers an IRC message. - /// - public delegate void MessageReceivedHandler(IrcMessage message); - - /// - /// Delegate that notifies if the user database for a channel has changed. - /// - public delegate void ChannelUserDatabaseChangedHandler(IrcChannel channel); - - public delegate void OnConnectHandler (); - public delegate void OnDisconnectHandler(); - public delegate void OnConnectionLostHandler(); - - /// - /// An IRC client. - /// - public class IrcClient - { - /// - /// Monitor when an IRC command is received. - /// - private class IrcCommandEventRegistration - { - /// - /// IRC command to monitor. - /// - private string command; - public string Command - { - get - { - return command; - } - } - - /// - /// Handler to call when command is received. - /// - private MessageReceivedHandler handler; - public MessageReceivedHandler Handler - { - get - { - return handler; - } - } - - /// - /// Constructor. - /// - /// IRC command to monitor. - /// Handler to call when command is received. - public IrcCommandEventRegistration(string command, - MessageReceivedHandler handler) - { - this.command = command; - this.handler = handler; - } - } - - - - /// - /// A buffer to store lines of text. - /// - private class LineBuffer - { - /// - /// Full lines of text in buffer. - /// - private ArrayList strings; - - /// - /// Part of the last line of text in buffer. - /// - private string left = ""; - - /// - /// Standard constructor. - /// - public LineBuffer() - { - strings = new ArrayList(); - } - - /// - /// Return true if there is a complete line in the buffer or false if there is not. - /// - public bool DataAvailable - { - get - { - return (strings.Count > 0); - } - } - - /// - /// Return next complete line in buffer or null if none exists. - /// - /// Next complete line in buffer or null if none exists. - public string Read() - { - if (DataAvailable) - { - string line = strings[0] as string; - strings.RemoveAt(0); - return line; - } - else - { - return null; - } - } - - /// - /// Write a string to buffer splitting it into lines. - /// - /// - public void Write(string data) - { - data = left + data; - left = ""; - string[] sa = data.Split(new char[] { '\n' }); - if (sa.Length <= 0) - { - left = data; - return; - } - else - { - left = ""; - } - for (int i = 0; i < sa.Length; i++) - { - if (i < sa.Length - 1) - { - /* This is a complete line. Remove any \r characters at the end of the line. */ - string line = sa[i].TrimEnd(new char[] { '\r', '\n'}); - /* Silently ignore empty lines */ - if (!line.Equals(String.Empty)) - { - strings.Add(line); - } - } - else - { - /* This may be a partial line. */ - left = sa[i]; - } - } - } - } - - - /// - /// State for asynchronous reads. - /// - private class StateObject - { - /// - /// Network stream where data is read from. - /// - public NetworkStream Stream; - - /// - /// Buffer where data is put. - /// - public byte[] Buffer; - - /// - /// Constructor. - /// - /// Network stream where data is read from. - /// Buffer where data is put. - public StateObject(NetworkStream stream, byte[] buffer) - { - this.Stream = stream; - this.Buffer = buffer; - } - } - - - #region Private fields - private bool firstPingReceived = false; - private bool awaitingGhostDeath = false; - private System.Text.Encoding encoding = System.Text.Encoding.UTF8; - private TcpClient tcpClient; - private NetworkStream networkStream; - private bool connected = false; - private LineBuffer messageStream; - private ArrayList ircCommandEventRegistrations = new ArrayList(); - private ArrayList channels = new ArrayList(); - private string reqNickname; - private string curNickname; - private string password; - #endregion - - #region Public events - - public event MessageReceivedHandler MessageReceived; - - public event ChannelUserDatabaseChangedHandler ChannelUserDatabaseChanged; - - public event OnConnectHandler OnConnect; - public event OnConnectionLostHandler OnConnectionLost; - public event OnDisconnectHandler OnDisconnect; - - #endregion - - #region Public properties - - /// - /// Encoding used. - /// - public System.Text.Encoding Encoding - { - get - { - return encoding; - } - set - { - encoding = value; - } - } - - /// - /// List of joined channels. - /// - public ArrayList Channels - { - get - { - return channels; - } - } - - /// - /// Nickname for the bot. - /// - public string Nickname - { - get - { - return curNickname; - } - } - #endregion - - #region Private methods - - /// - /// Signal MessageReceived event. - /// - /// Message that was received. - private void OnMessageReceived(IrcMessage message) - { - foreach (IrcCommandEventRegistration icre in ircCommandEventRegistrations) - { - if (message.Command.ToLower().Equals(icre.Command.ToLower())) - { - icre.Handler(message); - } - } - if (MessageReceived != null) - { - MessageReceived(message); - } - } - - /// - /// Signal ChannelUserDatabaseChanged event. - /// - /// Message that was received. - private void OnChannelUserDatabaseChanged(IrcChannel channel) - { - if (ChannelUserDatabaseChanged != null) - { - ChannelUserDatabaseChanged(channel); - } - } - - /// - /// Start an asynchronous read. - /// - private void Receive() - { - if ((networkStream != null) && (networkStream.CanRead)) - { - byte[] buffer = new byte[1024]; - networkStream.BeginRead(buffer, 0, buffer.Length, - new AsyncCallback(ReadComplete), - new StateObject(networkStream, buffer)); - } - else - { - throw new Exception("Socket is closed."); - } - } - - /// - /// Asynchronous read has completed. - /// - /// IAsyncResult object. - private void ReadComplete(IAsyncResult ar) - { - try - { - StateObject stateObject = (StateObject)ar.AsyncState; - if (stateObject.Stream.CanRead) - { - int bytesReceived = stateObject.Stream.EndRead(ar); - if (bytesReceived > 0) - { - messageStream.Write(Encoding.GetString(stateObject.Buffer, 0, bytesReceived)); - while (messageStream.DataAvailable) - { - OnMessageReceived(new IrcMessage(messageStream.Read())); - } - } - } - - Receive(); - } - catch (SocketException) - { - if (OnConnectionLost != null) - OnConnectionLost(); - } - catch (IOException) - { - if (OnConnectionLost != null) - OnConnectionLost(); - } - catch (Exception) - { - if (OnConnectionLost != null) - OnConnectionLost(); - } - } - - /// - /// Locate channel. - /// - /// Channel name. - /// Channel or null if none was found. - private IrcChannel LocateChannel(string name) - { - foreach (IrcChannel channel in Channels) - { - if (name.ToLower().Equals(channel.Name.ToLower())) - { - return channel; - } - } - return null; - } - - /// - /// Send a PONG message when a PING message is received. - /// - /// Received IRC message. - private void PingMessageReceived(IrcMessage message) - { - SendMessage(new IrcMessage(IRC.PONG, message.Parameters)); - firstPingReceived = true; - } - - /// - /// Send a PONG message when a PING message is received. - /// - /// Received IRC message. - private void NoticeMessageReceived(IrcMessage message) - { - if (awaitingGhostDeath) - { - string str = string.Format("{0} has been ghosted", reqNickname); - if (message.Parameters.Contains(str)) - { - ChangeNick(reqNickname); - SubmitPassword(password); - awaitingGhostDeath = false; - } - } - } - - /// - /// Process RPL_NAMREPLY message. - /// - /// Received IRC message. - private void RPL_NAMREPLYMessageReceived(IrcMessage message) - { - try - { - // :Oslo2.NO.EU.undernet.org 353 E101 = #E101 :E101 KongFu_uK @Exception - /* "( "=" / "*" / "@" ) - :[ "@" / "+" ] *( " " [ "@" / "+" ] ) - - "@" is used for secret channels, "*" for private - channels, and "=" for others (public channels). */ - if (message.Parameters == null) - { - System.Diagnostics.Debug.WriteLine(String.Format("Message has no parameters.")); - return; - } - string[] parameters = message.Parameters.Split(new char[] { ' '}); - if (parameters.Length < 5) - { - System.Diagnostics.Debug.WriteLine(String.Format("{0} is two few parameters.", parameters.Length)); - return; - } - IrcChannelType type; - switch (parameters[1]) - { - case "=": - type = IrcChannelType.Public; - break; - case "*": - type = IrcChannelType.Private; - break; - case "@": - type = IrcChannelType.Secret; - break; - default: - type = IrcChannelType.Public; - break; - } - IrcChannel channel = LocateChannel(parameters[2].Substring(1)); - if (channel == null) - { - System.Diagnostics.Debug.WriteLine(String.Format("Channel not found '{0}'.", - parameters[2].Substring(1))); - return; - } - string nickname = parameters[3]; - if (nickname[0] != ':') - { - System.Diagnostics.Debug.WriteLine(String.Format("String should start with : and not {0}.", nickname[0])); - return; - } - /* Skip : */ - IrcUser user = channel.LocateUser(nickname.Substring(1)); - if (user == null) - { - user = new IrcUser(this, - nickname.Substring(1)); - channel.Users.Add(user); - } - for (int i = 4; i < parameters.Length; i++) - { - nickname = parameters[i]; - user = channel.LocateUser(nickname); - if (user == null) - { - user = new IrcUser(this, - nickname); - channel.Users.Add(user); - } - } - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine(String.Format("Ex. {0}", ex)); - } - } - - /// - /// Process RPL_ENDOFNAMES message. - /// - /// Received IRC message. - private void RPL_ENDOFNAMESMessageReceived(IrcMessage message) - { - try - { - /* :End of NAMES list */ - if (message.Parameters == null) - { - System.Diagnostics.Debug.WriteLine(String.Format("Message has no parameters.")); - return; - } - - string[] parameters = message.Parameters.Split(new char[] { ' ' }); - IrcChannel channel = LocateChannel(parameters[1].Substring(1)); - if (channel == null) - { - System.Diagnostics.Debug.WriteLine(String.Format("Channel not found '{0}'.", - parameters[0].Substring(1))); - return; - } - - OnChannelUserDatabaseChanged(channel); - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine(String.Format("Ex. {0}", ex)); - } - } - - /// - /// Process ERR_NICKNAMEINUSE message. - /// - /// Received IRC message. - private void ERR_NICKNAMEINUSEMessageReceived(IrcMessage message) - { - try - { - if (message.Parameters == null) - { - System.Diagnostics.Debug.WriteLine(String.Format("Message has no parameters.")); - return; - } - - /* Connect with a different name */ - string[] parameters = message.Parameters.Split(new char[] { ' ' }); - string nickname = parameters[1]; - ChangeNick(nickname + "__"); - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine(String.Format("Ex. {0}", ex)); - } - } - - #endregion - - /// - /// Connect to the specified IRC server on the specified port. - /// - /// Address of IRC server. - /// Port of IRC server. - public void Connect(string server, int port) - { - if (connected) - { - throw new AlreadyConnectedException(); - } - else - { - messageStream = new LineBuffer(); - tcpClient = new TcpClient(); - tcpClient.Connect(server, port); - tcpClient.NoDelay = true; - tcpClient.LingerState = new LingerOption(false, 0); - networkStream = tcpClient.GetStream(); - connected = networkStream.CanRead && networkStream.CanWrite; - if (!connected) - { - throw new Exception("Cannot read and write from socket."); - } - /* Install PING message handler */ - MonitorCommand(IRC.PING, new MessageReceivedHandler(PingMessageReceived)); - /* Install NOTICE message handler */ - MonitorCommand(IRC.NOTICE, new MessageReceivedHandler(NoticeMessageReceived)); - /* Install RPL_NAMREPLY message handler */ - MonitorCommand(IRC.RPL_NAMREPLY, new MessageReceivedHandler(RPL_NAMREPLYMessageReceived)); - /* Install RPL_ENDOFNAMES message handler */ - MonitorCommand(IRC.RPL_ENDOFNAMES, new MessageReceivedHandler(RPL_ENDOFNAMESMessageReceived)); - /* Install ERR_NICKNAMEINUSE message handler */ - MonitorCommand(IRC.ERR_NICKNAMEINUSE, new MessageReceivedHandler(ERR_NICKNAMEINUSEMessageReceived)); - /* Start receiving data */ - Receive(); - } - } - - /// - /// Disconnect from IRC server. - /// - public void Diconnect() - { - if (!connected) - { - throw new NotConnectedException(); - } - else - { - connected = false; - tcpClient.Close(); - tcpClient = null; - - if (OnDisconnect != null) - OnDisconnect(); - } - } - - /// - /// Send an IRC message. - /// - /// The message to be sent. - public void SendMessage(IrcMessage message) - { - try - { - if (!connected) - { - throw new NotConnectedException(); - } - - /* Serialize sending messages */ - lock (typeof(IrcClient)) - { - NetworkStream networkStream = tcpClient.GetStream(); - byte[] bytes = Encoding.GetBytes(message.Line); - networkStream.Write(bytes, 0, bytes.Length); - networkStream.Flush(); - } - } - catch (SocketException) - { - if (OnConnectionLost != null) - OnConnectionLost(); - } - catch (IOException) - { - if (OnConnectionLost != null) - OnConnectionLost(); - } - catch (Exception) - { - if (OnConnectionLost != null) - OnConnectionLost(); - } - } - - /// - /// Monitor when a message with an IRC command is received. - /// - /// IRC command to monitor. - /// Handler to call when command is received. - public void MonitorCommand(string command, MessageReceivedHandler handler) - { - if (command == null) - { - throw new ArgumentNullException("command", "Command cannot be null."); - } - if (handler == null) - { - throw new ArgumentNullException("handler", "Handler cannot be null."); - } - ircCommandEventRegistrations.Add(new IrcCommandEventRegistration(command, handler)); - } - - /// - /// Talk to the channel. - /// - /// Nickname of user to talk to. - /// Text to send to the channel. - public void TalkTo(string nickname, string text) - { - } - - /// - /// Change nickname. - /// - /// New nickname. - public void ChangeNick(string nickname) - { - if (nickname == null) - throw new ArgumentNullException("nickname", "Nickname cannot be null."); - - Console.WriteLine("Changing nick to {0}\n", nickname); - curNickname = nickname; - - /* NICK [ ] */ - SendMessage(new IrcMessage(IRC.NICK, nickname)); - } - - /// - /// Ghost nickname. - /// - /// Nickname. - public void GhostNick(string nickname, - string password) - { - if (nickname == null) - throw new ArgumentNullException("nickname", "Nickname cannot be null."); - - if (password == null) - throw new ArgumentNullException("password", "Password cannot be null."); - - awaitingGhostDeath = true; - - /* GHOST */ - SendMessage(new IrcMessage(IRC.GHOST, nickname + " " + password)); - } - - /// - /// Submit password to identify user. - /// - /// Password of registered nick. - private void SubmitPassword(string password) - { - if (password == null) - throw new ArgumentNullException("password", "Password cannot be null."); - - this.password = password; - - /* PASS */ - SendMessage(new IrcMessage(IRC.PASS, password)); - } - - /// - /// Register. - /// - /// New nickname. - /// Password. Can be null. - /// Real name. Can be null. - public void Register(string nickname, - string password, - string realname) - { - if (nickname == null) - throw new ArgumentNullException("nickname", "Nickname cannot be null."); - reqNickname = nickname; - firstPingReceived = false; - if (password != null) - { - SubmitPassword(password); - } - ChangeNick(nickname); - /* OLD: USER */ - /* NEW: USER */ - SendMessage(new IrcMessage(IRC.USER, String.Format("{0} 0 * :{1}", - nickname, realname != null ? realname : "Anonymous"))); - - /* Wait for PING for up til 10 seconds */ - int timer = 0; - while (!firstPingReceived && timer < 200) - { - System.Threading.Thread.Sleep(50); - timer++; - } - } - - /// - /// Join an IRC channel. - /// - /// Name of channel (without leading #). - /// New channel. - public IrcChannel JoinChannel(string name) - { - IrcChannel channel = new IrcChannel(this, name); - channels.Add(channel); - /* JOIN ( *( "," ) [ *( "," ) ] ) / "0" */ - SendMessage(new IrcMessage(IRC.JOIN, String.Format("#{0}", name))); - return channel; - } - - /// - /// Part an IRC channel. - /// - /// IRC channel. If null, the user parts from all channels. - /// Part message. Can be null. - public void PartChannel(IrcChannel channel, string message) - { - /* PART *( "," ) [ ] */ - if (channel != null) - { - SendMessage(new IrcMessage(IRC.PART, String.Format("#{0}{1}", - channel.Name, message != null ? String.Format(" :{0}", message) : ""))); - channels.Remove(channel); - } - else - { - string channelList = null; - foreach (IrcChannel myChannel in Channels) - { - if (channelList == null) - { - channelList = ""; - } - else - { - channelList += ","; - } - channelList += myChannel.Name; - } - if (channelList != null) - { - SendMessage(new IrcMessage(IRC.PART, String.Format("#{0}{1}", - channelList, message != null ? String.Format(" :{0}", message) : ""))); - Channels.Clear(); - } - } - } - } -} diff --git a/irc/TechBot/TechBot.IRCLibrary/IrcException.cs b/irc/TechBot/TechBot.IRCLibrary/IrcException.cs deleted file mode 100644 index a96b688ad82..00000000000 --- a/irc/TechBot/TechBot.IRCLibrary/IrcException.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; - -namespace TechBot.IRCLibrary -{ - /// - /// Base class for all IRC exceptions. - /// - public class IrcException : Exception - { - public IrcException() : base() - { - } - - public IrcException(string message) : base(message) - { - } - - public IrcException(string message, Exception innerException) : base(message, innerException) - { - } - } - - /// - /// Thrown when there is no connection to an IRC server. - /// - public class NotConnectedException : IrcException - { - } - - /// - /// Thrown when there is an attempt to connect to an IRC server and there is already a connection. - /// - public class AlreadyConnectedException : IrcException - { - } - - /// - /// Thrown when there is attempted to parse a malformed or invalid IRC message. - /// - public class MalformedMessageException : IrcException - { - public MalformedMessageException(string message) : base(message) - { - } - - public MalformedMessageException(string message, Exception innerException) : base(message, innerException) - { - } - } -} diff --git a/irc/TechBot/TechBot.IRCLibrary/IrcMessage.cs b/irc/TechBot/TechBot.IRCLibrary/IrcMessage.cs deleted file mode 100644 index f74ea806be4..00000000000 --- a/irc/TechBot/TechBot.IRCLibrary/IrcMessage.cs +++ /dev/null @@ -1,503 +0,0 @@ -using System; - -namespace TechBot.IRCLibrary -{ - /* - ::= [':' ] - ::= | [ '!' ] [ '@' ] - ::= { } | - ::= ' ' { ' ' } - ::= [ ':' | ] - - ::= - ::= - - ::= CR LF - - NOTES: - - 1) is consists only of SPACE character(s) (0x20). - Specially notice that TABULATION, and all other control - characters are considered NON-WHITE-SPACE. - - 2) After extracting the parameter list, all parameters are equal, - whether matched by or . is just - a syntactic trick to allow SPACE within parameter. - - 3) The fact that CR and LF cannot appear in parameter strings is - just artifact of the message framing. This might change later. - - 4) The NUL character is not special in message framing, and - basically could end up inside a parameter, but as it would - cause extra complexities in normal C string handling. Therefore - NUL is not allowed within messages. - - 5) The last parameter may be an empty string. - - 6) Use of the extended prefix (['!' ] ['@' ]) must - not be used in server to server communications and is only - intended for server to client messages in order to provide - clients with more useful information about who a message is - from without the need for additional queries. - */ - /* - NOTICE AUTH :*** Looking up your hostname - NOTICE AUTH :*** Checking Ident - NOTICE AUTH :*** Found your hostname - NOTICE AUTH :*** No ident response - */ - - /// - /// IRC message. - /// - public class IrcMessage - { - #region Private fields - private string line; - private string prefix; - private string prefixServername; - private string prefixNickname; - private string prefixUser; - private string prefixHost; - private string command; - private string parameters; - #endregion - - /// - /// Line of text that is to be parsed as an IRC message. - /// - public string Line - { - get - { - return line; - } - } - - /// - /// Does the message have a prefix? - /// - public bool HasPrefix - { - get - { - return prefix != null; - } - } - - /// - /// Prefix or null if none exists. - /// - public string Prefix - { - get - { - return prefix; - } - } - - /// - /// Servername part of prefix or null if no prefix or servername exists. - /// - public string PrefixServername - { - get - { - return prefixServername; - } - } - - /// - /// Nickname part of prefix or null if no prefix or nick exists. - /// - public string PrefixNickname - { - get - { - return prefixNickname; - } - } - - /// - /// User part of (extended) prefix or null if no (extended) prefix exists. - /// - public string PrefixUser - { - get - { - return prefixUser; - } - } - - /// - /// Host part of (extended) prefix or null if no (extended) prefix exists. - /// - public string PrefixHost - { - get - { - return prefixHost; - } - } - - /// - /// Command part of message. - /// - public string Command - { - get - { - return command; - } - } - - /// - /// Is command numeric? - /// - public bool IsCommandNumeric - { - get - { - if (command == null || command.Length != 3) - { - return false; - } - try - { - Int32.Parse(command); - return true; - } - catch (Exception) - { - return false; - } - } - } - - /// - /// Command part of message as text. - /// - public string CommandText - { - get - { - return command; - } - } - - /// - /// Command part of message as a number. - /// - /// Thrown if IsCommandNumeric returns false. - public int CommandNumber - { - get - { - if (IsCommandNumeric) - { - return Int32.Parse(command); - } - else - { - throw new InvalidOperationException(); - } - } - } - - /// - /// Parameters part of message. - /// - public string Parameters - { - get - { - return parameters; - } - } - - /// - /// Constructor. - /// - /// Line of text that is to be parsed as an IRC message. - public IrcMessage(string line) - { - /* - * ::= [':' ] - * ::= | [ '!' ] [ '@' ] - * :Oslo1.NO.EU.undernet.org 461 MYNICK USER :Not enough parameters - */ - try - { - this.line = line; - int i = 0; - - #region Prefix - if (line[i].Equals(':')) - { - i++; - prefix = ""; - /* This message has a prefix */ - string s = ""; - while (i < line.Length && line[i] != ' ' && line[i] != '!' && line[i] != '@') - { - s += line[i++]; - } - if (IsValidIrcNickname(s)) - { - prefixNickname = s; - prefix += prefixNickname; - if (line[i] == '!') - { - /* This message has an extended prefix */ - i++; - s = ""; - while (i < line.Length && line[i] != ' ' && line[i] != '@') - { - s += line[i]; - i++; - } - prefixUser = s; - prefix += "!" + prefixUser; - } - if (line[i] == '@') - { - /* This message has a host prefix */ - s = ""; - do - { - s += line[++i]; - } - while (i < line.Length && line[i] != ' '); - prefixHost = s; - prefix += "@" + prefixHost; - } - } - else /* Assume it is a servername */ - { - prefixServername = s; - prefix += prefixServername; - } - - /* Skip spaces */ - while (i < line.Length && line[i] == ' ') - { - i++; - } - } - else - { - prefix = null; - } - #endregion - - #region Command - if (Char.IsDigit(line[i])) - { - if (!Char.IsDigit(line, i + 1) || !Char.IsDigit(line, i + 2)) - { - throw new Exception(); - } - command = String.Format("{0}{1}{2}", line[i++], line[i++], line[i++]); - } - else - { - command = ""; - while (i < line.Length && Char.IsLetter(line[i])) - { - command += line[i]; - i++; - } - } - #endregion - - #region Parameters - while (true) - { - /* Skip spaces */ - while (i < line.Length && line[i] == ' ') - { - i++; - } - if (i < line.Length && line[i].Equals(':')) - { - i++; - - /* Trailing */ - while (i < line.Length && line[i] != ' ' && line[i] != '\r' && line[i] != '\n' && line[i] != 0) - { - if (parameters == null) - { - parameters = ""; - } - parameters += line[i]; - i++; - } - } - else - { - /* Middle */ - while (i < line.Length && line[i] != '\r' && line[i] != '\n' && line[i] != 0) - { - if (parameters == null) - { - parameters = ""; - } - parameters += line[i]; - i++; - } - } - if (i >= line.Length) - { - break; - } - } - #endregion - } - catch (Exception ex) - { - throw new MalformedMessageException("The message is malformed.", ex); - } - } - - /// - /// Constructor. - /// - /// - /// - /// - /// - /// - /// - public IrcMessage(string prefixServername, - string prefixNickname, - string prefixUser, - string prefixHost, - string command, - string parameters) - { - throw new NotImplementedException(); - } - - /// - /// Constructor. - /// - /// IRC command. - /// IRC command parameters. May be null if there are no parameters. - public IrcMessage(string command, - string parameters) - { - if (command == null || !IsValidIrcCommand(command)) - { - throw new ArgumentException("Command is not a valid IRC command.", "command"); - } - /* An IRC message must not be longer than 512 characters (including terminating CRLF) */ - int parametersLength = (parameters != null) ? 1 + parameters.Length : 0; - if (command.Length + parametersLength > 510) - { - throw new MalformedMessageException("IRC message cannot be longer than 512 characters."); - } - this.command = command; - this.parameters = parameters; - if (parameters != null) - { - this.line = String.Format("{0} {1}\r\n", command, parameters); - } - else - { - this.line = String.Format("{0}\r\n", command); - } - } - - /// - /// Returns wether a string of text is a valid IRC command. - /// - /// The IRC command. - /// True, if command is a valid IRC command, false if not. - private static bool IsValidIrcCommand(string command) - { - foreach (char c in command) - { - if (!Char.IsLetter(c) && !Char.IsWhiteSpace(c)) - { - return false; - } - } - return true; - } - - private const string IrcSpecial = @"-[]\`^{}"; - private const string IrcSpecialNonSpecs = @"_|"; - - /// - /// Returns wether a character is an IRC special character. - /// - /// Character to test. - /// True if the character is an IRC special character, false if not. - private static bool IsSpecial(char c) - { - foreach (char validCharacter in IrcSpecial) - { - if (c.Equals(validCharacter)) - { - return true; - } - } - foreach (char validCharacter in IrcSpecialNonSpecs) - { - if (c.Equals(validCharacter)) - { - return true; - } - } - return false; - } - - /// - /// Returns wether a string of text is a valid IRC nickname. - /// - /// The IRC nickname. - /// True, if nickname is a valid IRC nickname, false if not. - private static bool IsValidIrcNickname(string nickname) - { - /* - * ::= { | | } - * ::= 'a' ... 'z' | 'A' ... 'Z' - * ::= '0' ... '9' - * ::= '-' | '[' | ']' | '\' | '`' | '^' | '{' | '}' - */ - /* An IRC nicknmame must be 1 - 9 characters in length. We don't care so much if it is larger */ - if ((nickname.Length < 1) || (nickname.Length > 30)) - { - return false; - } - /* First character must be a letter. */ - if (!Char.IsLetter(nickname[0])) - { - return false; - } - /* Check the other valid characters for validity. */ - foreach (char c in nickname) - { - if (!Char.IsLetter(c) && !Char.IsDigit(c) && !IsSpecial(c)) - { - return false; - } - } - return true; - } - - /// - /// Write contents to a string. - /// - /// Contents as a string. - public override string ToString() - { - return String.Format("Line({0})Prefix({1})Command({2})Parameters({3})", - line, prefix != null ? prefix : "(null)", - command != null ? command : "(null)", - parameters != null ? parameters : "(null)"); - } - } -} diff --git a/irc/TechBot/TechBot.IRCLibrary/IrcUser.cs b/irc/TechBot/TechBot.IRCLibrary/IrcUser.cs deleted file mode 100644 index 30f0a94db40..00000000000 --- a/irc/TechBot/TechBot.IRCLibrary/IrcUser.cs +++ /dev/null @@ -1,132 +0,0 @@ -using System; - -namespace TechBot.IRCLibrary -{ - /// - /// IRC user. - /// - public class IrcUser - { - #region Private fields - - private IrcClient owner; - private string nickname; - private string decoratedNickname; - - #endregion - - #region Public properties - - /// - /// Owner of this channel. - /// - public IrcClient Owner - { - get - { - return owner; - } - } - - /// - /// Nickname of user. - /// - public string Nickname - { - get - { - return nickname; - } - } - - /// - /// Decorated nickname of user. - /// - public string DecoratedNickname - { - get - { - return decoratedNickname; - } - } - - /// - /// Wether user is channel operator. - /// - public bool Operator - { - get - { - return decoratedNickname.StartsWith("@"); - } - } - - /// - /// Wether user has voice. - /// - public bool Voice - { - get - { - return decoratedNickname.StartsWith("+"); - } - } - - #endregion - - /// - /// Constructor. - /// - /// Owner of this channel. - /// Nickname (possibly decorated) of user. - public IrcUser(IrcClient owner, - string nickname) - { - if (owner == null) - { - throw new ArgumentNullException("owner", "Owner cannot be null."); - } - this.owner = owner; - this.decoratedNickname = nickname.Trim(); - this.nickname = StripDecoration(decoratedNickname); - } - - /// - /// Talk to the user. - /// - /// Text to send to the user. - public void Talk(string text) - { - if (text == null) - { - throw new ArgumentNullException("text", "Text cannot be null."); - } - - owner.SendMessage(new IrcMessage(IRC.PRIVMSG, - String.Format("{0} :{1}", - nickname, - text))); - } - - /// - /// Strip docoration of nickname. - /// - /// Possible decorated nickname. - /// Undecorated nickname. - public static string StripDecoration(string decoratedNickname) - { - if (decoratedNickname.StartsWith("@")) - { - return decoratedNickname.Substring(1); - } - else if (decoratedNickname.StartsWith("+")) - { - return decoratedNickname.Substring(1); - } - else - { - return decoratedNickname; - } - } - } -} diff --git a/irc/TechBot/TechBot.IRCLibrary/Properties/.gitignore b/irc/TechBot/TechBot.IRCLibrary/Properties/.gitignore deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/irc/TechBot/TechBot.IRCLibrary/TechBot.IRCLibrary.cmbx b/irc/TechBot/TechBot.IRCLibrary/TechBot.IRCLibrary.cmbx deleted file mode 100644 index 67b1e6077d5..00000000000 --- a/irc/TechBot/TechBot.IRCLibrary/TechBot.IRCLibrary.cmbx +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.IRCLibrary/TechBot.IRCLibrary.csproj b/irc/TechBot/TechBot.IRCLibrary/TechBot.IRCLibrary.csproj deleted file mode 100644 index 02647ee5cde..00000000000 --- a/irc/TechBot/TechBot.IRCLibrary/TechBot.IRCLibrary.csproj +++ /dev/null @@ -1,59 +0,0 @@ - - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {D2A57931-DF04-4BC3-BD11-75DF4F3B0A88} - Library - Properties - TechBot.IRCLibrary - TechBot.IRCLibrary - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.IRCLibrary/TechBot.IRCLibrary.prjx b/irc/TechBot/TechBot.IRCLibrary/TechBot.IRCLibrary.prjx deleted file mode 100644 index 457a420241d..00000000000 --- a/irc/TechBot/TechBot.IRCLibrary/TechBot.IRCLibrary.prjx +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.IRCLibrary/app.config b/irc/TechBot/TechBot.IRCLibrary/app.config deleted file mode 100644 index b4e2a174a9f..00000000000 --- a/irc/TechBot/TechBot.IRCLibrary/app.config +++ /dev/null @@ -1,15 +0,0 @@ - - - - -
        - - - - - - ! - - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.Library/Attributes/CommandAttribute.cs b/irc/TechBot/TechBot.Library/Attributes/CommandAttribute.cs deleted file mode 100644 index a16ee780d7c..00000000000 --- a/irc/TechBot/TechBot.Library/Attributes/CommandAttribute.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace TechBot.Library -{ - public class CommandAttribute : Attribute - { - private string m_Name = null; - private string m_Help = "No help for this command is available"; - private string m_Desc = "No description for this command is available"; - - public CommandAttribute(string name) - { - m_Name = name; - } - - public string Name - { - get { return m_Name; } - } - - public string Help - { - get { return m_Help; } - set { m_Help = value; } - } - - public string Description - { - get { return m_Desc; } - set { m_Desc = value; } - } - } -} diff --git a/irc/TechBot/TechBot.Library/Attributes/CommandParameterAliasAttribute.cs b/irc/TechBot/TechBot.Library/Attributes/CommandParameterAliasAttribute.cs deleted file mode 100644 index 05dc10da4bd..00000000000 --- a/irc/TechBot/TechBot.Library/Attributes/CommandParameterAliasAttribute.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; - -namespace TechBot.Library -{ - /// - /// This class implements an alias attribute to work in conjunction - /// with the CommandLineSwitchAttribute - /// attribute. If the CommandLineSwitchAttribute exists, then this attribute - /// defines an alias for it. - /// - [AttributeUsage( AttributeTargets.Property )] - public class CommandParameterAliasAttribute : Attribute - { - #region Private Variables - protected string m_Alias = ""; - #endregion - - #region Public Properties - public string Alias - { - get { return m_Alias; } - } - - #endregion - - #region Constructors - public CommandParameterAliasAttribute(string alias) - { - m_Alias = alias; - } - #endregion - } - -} diff --git a/irc/TechBot/TechBot.Library/Attributes/CommandParameterAttribute.cs b/irc/TechBot/TechBot.Library/Attributes/CommandParameterAttribute.cs deleted file mode 100644 index f996c73dc6c..00000000000 --- a/irc/TechBot/TechBot.Library/Attributes/CommandParameterAttribute.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; - -namespace TechBot.Library -{ - /// Implements a basic command-line switch by taking the - /// switching name and the associated description. - /// Only currently is implemented for properties, so all - /// auto-switching variables should have a get/set method supplied. - [AttributeUsage( AttributeTargets.Property )] - public class CommandParameterAttribute : Attribute - { - #region Private Variables - private string m_name = ""; - private string m_description = ""; - private bool m_Required = true; - private bool m_Default = false; - #endregion - - #region Public Properties - /// Accessor for retrieving the switch-name for an associated - /// property. - public string Name { get { return m_name; } } - - /// Accessor for retrieving the description for a switch of - /// an associated property. - public string Description { get { return m_description; } } - - public bool Required { get { return m_Required; } } - - public bool DefaultParameter - { - get { return m_Default; } - set { m_Default = value; } - } - - #endregion - - #region Constructors - - /// - /// Attribute constructor. - /// - public CommandParameterAttribute(string name, string description) - { - m_name = name; - m_description = description; - } - #endregion - } -} diff --git a/irc/TechBot/TechBot.Library/Collections/CommandBuilderCollection.cs b/irc/TechBot/TechBot.Library/Collections/CommandBuilderCollection.cs deleted file mode 100644 index 6cb4a814ca1..00000000000 --- a/irc/TechBot/TechBot.Library/Collections/CommandBuilderCollection.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace TechBot.Library -{ - public class CommandBuilderCollection : List - { - public CommandBuilder Find(string name) - { - foreach (CommandBuilder command in this) - { - if (command.Name == name) - return command; - } - - return null; - } - } -} diff --git a/irc/TechBot/TechBot.Library/Commands/Base/Command.cs b/irc/TechBot/TechBot.Library/Commands/Base/Command.cs deleted file mode 100644 index 040d870d833..00000000000 --- a/irc/TechBot/TechBot.Library/Commands/Base/Command.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System; -using System.Text.RegularExpressions; - -namespace TechBot.Library -{ - public abstract class Command - { - protected TechBotService m_TechBotService = null; - protected MessageContext m_Context = null; - protected string m_Params = null; - - public TechBotService TechBot - { - get { return m_TechBotService; } - set { m_TechBotService = value; } - } - - public MessageContext Context - { - get { return m_Context; } - set { m_Context = value; } - } - - public virtual bool AnswerInPublic - { - get { return true; } - } - - public string Name - { - get - { - CommandAttribute commandAttribute = (CommandAttribute) - Attribute.GetCustomAttribute(GetType(), typeof(CommandAttribute)); - - return commandAttribute.Name; - } - } - - public string Parameters - { - get { return m_Params; } - set { m_Params = value; } - } - - protected virtual void Say() - { - TechBot.ServiceOutput.WriteLine(Context, string.Empty); - } - - protected virtual void Say(string message) - { - TechBot.ServiceOutput.WriteLine(Context, message); - } - - protected virtual void Say(string format , params object[] args) - { - TechBot.ServiceOutput.WriteLine(Context, String.Format(format, args)); - } - - public void Run() - { - if (Context is ChannelMessageContext) - { - if (AnswerInPublic) - { - ExecuteCommand(); - } - else - { - Say("Sorry, I only respond '{0}' in private , PM me!", Name); - } - } - else - { - ExecuteCommand(); - } - } - - public abstract void ExecuteCommand(); - - public virtual void Initialize() - { - } - - public virtual void DeInitialize() - { - } - } -} diff --git a/irc/TechBot/TechBot.Library/Commands/Base/XmlCommand.cs b/irc/TechBot/TechBot.Library/Commands/Base/XmlCommand.cs deleted file mode 100644 index 673e796eb50..00000000000 --- a/irc/TechBot/TechBot.Library/Commands/Base/XmlCommand.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Xml; -using System.Collections.Generic; -using System.Text; - -namespace TechBot.Library -{ - public abstract class XmlCommand : Command - { - protected XmlDocument m_XmlDocument; - - public XmlCommand() - { - m_XmlDocument = new XmlDocument(); - m_XmlDocument.Load(XmlFile); - } - - public abstract string XmlFile { get; } - - public XmlDocument XmlDocument - { - get { return m_XmlDocument; } - } - } -} \ No newline at end of file diff --git a/irc/TechBot/TechBot.Library/Commands/Base/XmlLookupCommand.cs b/irc/TechBot/TechBot.Library/Commands/Base/XmlLookupCommand.cs deleted file mode 100644 index 20c8bfcfbcc..00000000000 --- a/irc/TechBot/TechBot.Library/Commands/Base/XmlLookupCommand.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace TechBot.Library -{ - public abstract class XmlLookupCommand : XmlCommand - { - public virtual string Text - { - get { return Parameters; } - set { Parameters = value; } - } - } -} diff --git a/irc/TechBot/TechBot.Library/Commands/HelpCommand.cs b/irc/TechBot/TechBot.Library/Commands/HelpCommand.cs deleted file mode 100644 index 7c7fb34cddf..00000000000 --- a/irc/TechBot/TechBot.Library/Commands/HelpCommand.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using System.Reflection; -using System.Collections; - -namespace TechBot.Library -{ - [Command("help", Help = "!help or !help -name:[CommandName]", Description = "Shows this help , type 'help -name:[CommandName]'")] - public class HelpCommand : Command - { - public HelpCommand() - { - } - - public override bool AnswerInPublic - { - get { return false; } - } - - [CommandParameter("Name", "The command name to show help")] - public string CommandName - { - get { return Parameters; } - set { Parameters = value; } - } - - public override void ExecuteCommand() - { - if (string.IsNullOrEmpty(CommandName)) - { - Say("I support the following commands:"); - - foreach (CommandBuilder command in TechBot.Commands) - { - Say("{0}{1} - {2}", - Settings.Default.CommandPrefix, - command.Name, - command.Description); - } - } - else - { - CommandBuilder cmdBuilder = TechBot.Commands.Find(CommandName); - - if (cmdBuilder == null) - { - Say("Command '{0}' is not recognized. Type '!help' to show all available commands", CommandName); - } - else - { - Say("Command '{0}' help:", CommandName); - Say(); - Say(cmdBuilder.Description); - Say(); - Say(cmdBuilder.Help); - Say(); - Say("Parameters :"); - Say(); - - PropertyInfo[] propertyInfoArray = cmdBuilder.Type.GetProperties(BindingFlags.Public | BindingFlags.Instance); - foreach (PropertyInfo propertyInfo in propertyInfoArray) - { - CommandParameterAttribute[] commandAttributes = (CommandParameterAttribute[]) - Attribute.GetCustomAttributes(propertyInfo, typeof(CommandParameterAttribute)); - - foreach (CommandParameterAttribute parameter in commandAttributes) - { - Say("\t-{0}: [{1}]", - parameter.Name, - parameter.Description); - } - } - - Say(); - } - } - } - } -} diff --git a/irc/TechBot/TechBot.Library/Factory/CommandBuilder.cs b/irc/TechBot/TechBot.Library/Factory/CommandBuilder.cs deleted file mode 100644 index 6a459670a4c..00000000000 --- a/irc/TechBot/TechBot.Library/Factory/CommandBuilder.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Reflection; -using System.Collections.Generic; -using System.Text; - -namespace TechBot.Library -{ - public class CommandBuilder - { - private Type m_CommandType; - private string m_CommandName; - private string m_CommandHelp; - private string m_CommandDesc; - - public CommandBuilder(Type commandType) - { - m_CommandType = commandType; - - CommandAttribute commandAttribute = (CommandAttribute) - Attribute.GetCustomAttribute(commandType, typeof(CommandAttribute)); - - m_CommandName = commandAttribute.Name; - m_CommandHelp = commandAttribute.Help; - m_CommandDesc = commandAttribute.Description; - } - - public string Name - { - get { return m_CommandName; } - } - - public string Help - { - get { return m_CommandHelp; } - } - - public string Description - { - get { return m_CommandDesc; } - } - - public Type Type - { - get { return m_CommandType; } - } - - public Command CreateCommand() - { - return (Command)Type.Assembly.CreateInstance(Type.FullName, true); - } - } -} diff --git a/irc/TechBot/TechBot.Library/Factory/CommandFactory.cs b/irc/TechBot/TechBot.Library/Factory/CommandFactory.cs deleted file mode 100644 index 100bd2bdcf4..00000000000 --- a/irc/TechBot/TechBot.Library/Factory/CommandFactory.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.IO; -using System.Collections; -using System.Collections.Generic; -using System.ComponentModel; -using System.Reflection; - -namespace TechBot.Library -{ - public class CommandFactory - { - private static CommandBuilderCollection m_Commands = new CommandBuilderCollection(); - - private CommandFactory() - { - } - - public static void LoadPlugins() - { - //get the file names of the dll files in the current directory. - foreach (string fileName in Directory.GetFiles(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "*.dll")) - { - LoadPluginsFromDLLFile(fileName); - } - } - - private static void LoadPluginsFromDLLFile(string sFile) - { - Assembly assPlugin = Assembly.LoadFile(sFile); - - Console.WriteLine("Loading plugins from : {0}", assPlugin.Location); - - if (assPlugin != null) - { - foreach (Type pluginType in assPlugin.GetTypes()) - { - if (pluginType.IsSubclassOf(typeof(Command))) - { - if (pluginType.IsAbstract == false) - { - CommandBuilder cmdBuilder = new CommandBuilder(pluginType); - - Console.WriteLine("{0}:{1}", - cmdBuilder.Name, - cmdBuilder.Description); - - //Add it to the list. - Commands.Add(new CommandBuilder(pluginType)); - } - } - } - } - } - - public static CommandBuilderCollection Commands - { - get { return m_Commands; } - } - } -} diff --git a/irc/TechBot/TechBot.Library/MessageContext.cs b/irc/TechBot/TechBot.Library/MessageContext.cs deleted file mode 100644 index 1d9677c8462..00000000000 --- a/irc/TechBot/TechBot.Library/MessageContext.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; -using TechBot.IRCLibrary; - -namespace TechBot.Library -{ - public abstract class MessageContext - { - } - - public class ChannelMessageContext : MessageContext - { - private IrcChannel m_IrcChannel; - - public IrcChannel Channel - { - get { return m_IrcChannel; } - } - - public ChannelMessageContext(IrcChannel channel) - { - m_IrcChannel = channel; - } - } - - public class UserMessageContext : MessageContext - { - private IrcUser m_IrcUser; - - public IrcUser User - { - get { return m_IrcUser; } - } - - public UserMessageContext(IrcUser user) - { - m_IrcUser = user; - } - } -} diff --git a/irc/TechBot/TechBot.Library/NumberParser.cs b/irc/TechBot/TechBot.Library/NumberParser.cs deleted file mode 100644 index 232ed0be1f2..00000000000 --- a/irc/TechBot/TechBot.Library/NumberParser.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Globalization; - -namespace TechBot.Library -{ - public class NumberParser - { - public bool Error = false; - - private const string SpecialHexCharacters = "ABCDEF"; - - private static bool IsSpecialHexCharacter(char ch) - { - foreach (char specialChar in SpecialHexCharacters) - { - if (ch.ToString().ToUpper() == specialChar.ToString()) - return true; - } - return false; - } - - private static bool HasSpecialHexCharacters(string s) - { - foreach (char ch in s) - { - if (IsSpecialHexCharacter(ch)) - return true; - } - return false; - } - - public long Parse(string s) - { - try - { - Error = false; - bool useHex = false; - if (s.StartsWith("0x", StringComparison.InvariantCultureIgnoreCase)) - { - s = s.Substring(2); - useHex = true; - } - if (HasSpecialHexCharacters(s)) - useHex = true; - if (useHex) - return Int64.Parse(s, - NumberStyles.HexNumber); - else - return Int64.Parse(s); - } - catch (FormatException) - { - Error = true; - } - catch (OverflowException) - { - Error = true; - } - return -1; - } - } -} diff --git a/irc/TechBot/TechBot.Library/Properties/.gitignore b/irc/TechBot/TechBot.Library/Properties/.gitignore deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/irc/TechBot/TechBot.Library/Properties/AssemblyInfo.cs b/irc/TechBot/TechBot.Library/Properties/AssemblyInfo.cs deleted file mode 100644 index af4e2756b62..00000000000 --- a/irc/TechBot/TechBot.Library/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following -// attributes. -// -// change them to the information which is associated with the assembly -// you compile. - -[assembly: AssemblyTitle("")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has following format : -// -// Major.Minor.Build.Revision -// -// You can specify all values by your own or you can build default build and revision -// numbers with the '*' character (the default): - -[assembly: AssemblyVersion("1.0.*")] - -// The following attributes specify the key for the sign of your assembly. See the -// .NET Framework documentation for more information about signing. -// This is not required, if you don't want signing let these attributes like they're. -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] diff --git a/irc/TechBot/TechBot.Library/ServiceOutput.cs b/irc/TechBot/TechBot.Library/ServiceOutput.cs deleted file mode 100644 index d73a93e62ea..00000000000 --- a/irc/TechBot/TechBot.Library/ServiceOutput.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace TechBot.Library -{ - public interface IServiceOutput - { - void WriteLine(MessageContext context, string message); - } -} diff --git a/irc/TechBot/TechBot.Library/Settings.Designer.cs b/irc/TechBot/TechBot.Library/Settings.Designer.cs deleted file mode 100644 index 1a4445e28b2..00000000000 --- a/irc/TechBot/TechBot.Library/Settings.Designer.cs +++ /dev/null @@ -1,80 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.1433 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace TechBot.Library { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("C:\\Ros\\current\\irc\\TechBot\\Resources\\ntstatus.xml")] - public string NtStatusXml { - get { - return ((string)(this["NtStatusXml"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("C:\\Ros\\current\\irc\\TechBot\\Resources\\winerror.xml")] - public string WinErrorXml { - get { - return ((string)(this["WinErrorXml"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("C:\\Ros\\current\\irc\\TechBot\\Resources\\hresult.xml")] - public string HResultXml { - get { - return ((string)(this["HResultXml"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("C:\\Ros\\current\\irc\\TechBot\\Resources\\wm.xml")] - public string WMXml { - get { - return ((string)(this["WMXml"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("svn://svn.reactos.org/reactos/trunk")] - public string SVNRoot { - get { - return ((string)(this["SVNRoot"])); - } - } - - [global::System.Configuration.ApplicationScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("!")] - public string CommandPrefix { - get { - return ((string)(this["CommandPrefix"])); - } - } - } -} diff --git a/irc/TechBot/TechBot.Library/Settings.cs b/irc/TechBot/TechBot.Library/Settings.cs deleted file mode 100644 index e1543b0e887..00000000000 --- a/irc/TechBot/TechBot.Library/Settings.cs +++ /dev/null @@ -1,28 +0,0 @@ -namespace TechBot.Library { - - - // This class allows you to handle specific events on the settings class: - // The SettingChanging event is raised before a setting's value is changed. - // The PropertyChanged event is raised after a setting's value is changed. - // The SettingsLoaded event is raised after the setting values are loaded. - // The SettingsSaving event is raised before the setting values are saved. - internal sealed partial class Settings { - - public Settings() { - // // To add event handlers for saving and changing settings, uncomment the lines below: - // - // this.SettingChanging += this.SettingChangingEventHandler; - // - // this.SettingsSaving += this.SettingsSavingEventHandler; - // - } - - private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) { - // Add code to handle the SettingChangingEvent event here. - } - - private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) { - // Add code to handle the SettingsSaving event here. - } - } -} diff --git a/irc/TechBot/TechBot.Library/Settings.settings b/irc/TechBot/TechBot.Library/Settings.settings deleted file mode 100644 index 2673cc50cb1..00000000000 --- a/irc/TechBot/TechBot.Library/Settings.settings +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - C:\Ros\current\irc\TechBot\Resources\ntstatus.xml - - - C:\Ros\current\irc\TechBot\Resources\winerror.xml - - - C:\Ros\current\irc\TechBot\Resources\hresult.xml - - - C:\Ros\current\irc\TechBot\Resources\wm.xml - - - svn://svn.reactos.org/reactos/trunk - - - ! - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.Library/TechBot.Library.csproj b/irc/TechBot/TechBot.Library/TechBot.Library.csproj deleted file mode 100644 index 59505743bf2..00000000000 --- a/irc/TechBot/TechBot.Library/TechBot.Library.csproj +++ /dev/null @@ -1,83 +0,0 @@ - - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {1114F34D-F388-4F38-AE27-C0EE1B10B777} - Library - Properties - TechBot.Library - TechBot.Library - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - True - True - Settings.settings - - - - - - - - - - - - {D2A57931-DF04-4BC3-BD11-75DF4F3B0A88} - TechBot.IRCLibrary - - - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.Library/TechBotIrcService.cs b/irc/TechBot/TechBot.Library/TechBotIrcService.cs deleted file mode 100644 index 2a51374d330..00000000000 --- a/irc/TechBot/TechBot.Library/TechBotIrcService.cs +++ /dev/null @@ -1,312 +0,0 @@ -using System; -using System.Text; -using System.Collections; -using System.Threading; - -using TechBot.IRCLibrary; - -namespace TechBot.Library -{ - public class IrcServiceOutput : IServiceOutput - { - public void WriteLine(MessageContext context, - string message) - { - if (context is ChannelMessageContext) - { - Thread.Sleep (500); - ChannelMessageContext channelContext = context as ChannelMessageContext; - channelContext.Channel.Talk(message); - } - else if (context is UserMessageContext) - { - UserMessageContext userContext = context as UserMessageContext; - userContext.User.Talk(message); - } - else - { - throw new InvalidOperationException(String.Format("Unhandled message context '{0}'", - context.GetType())); - } - } - } - - public class IrcTechBotService : TechBotService - { - private int port; - private string hostname; - private string channelnames; - private string botname; - private string password; - private IrcClient m_IrcClient; - private ArrayList channels = new ArrayList(); - private bool isStopped = false; - - public IrcTechBotService(string hostname, - int port, - string channelnames, - string botname, - string password) - : base (new IrcServiceOutput()) - { - this.hostname = hostname; - this.port = port; - this.channelnames = channelnames; - this.botname = botname; - if (password == null || password.Trim() == "") - this.password = null; - else - this.password = password; - } - - public override void Run() - { - //Call the base class - base.Run(); - - m_IrcClient = new IrcClient(); - m_IrcClient.Encoding = Encoding.GetEncoding("iso-8859-1"); - m_IrcClient.OnConnect += new OnConnectHandler(m_IrcClient_OnConnect); - m_IrcClient.OnConnectionLost += new OnConnectionLostHandler(m_IrcClient_OnConnectionLost); - m_IrcClient.OnDisconnect += new OnDisconnectHandler(m_IrcClient_OnDisconnect); - m_IrcClient.MessageReceived += new MessageReceivedHandler(client_MessageReceived); - m_IrcClient.ChannelUserDatabaseChanged += new ChannelUserDatabaseChangedHandler(client_ChannelUserDatabaseChanged); - - Connect(); - } - - void m_IrcClient_OnConnect() - { - Console.WriteLine("Connected..."); - } - - private void Connect() - { - Console.WriteLine("Connecting to {0} port {1}", - hostname, - port); - m_IrcClient.Connect(hostname, port); - - m_IrcClient.Register(botname, password, null); - Console.WriteLine("Registered as {0}...", m_IrcClient.Nickname); - - /* Did we get the nick we wanted? */ - if (m_IrcClient.Nickname != botname) - { - /* there must have been an existing one, kill it */ - m_IrcClient.GhostNick(botname, password);; - } - - JoinChannels(); - - while (!isStopped) - { - Thread.Sleep(1000); - } - - PartChannels(); - m_IrcClient.Diconnect(); - } - - void m_IrcClient_OnDisconnect() - { - Console.WriteLine("Disconnected..."); - } - - void m_IrcClient_OnConnectionLost() - { - //Dispose old connection - Disconnect(); - - //Sleep for 1 minute - Thread.Sleep(1000 * 60); - - //Try to reconnect - Connect(); - } - - private void Disconnect() - { - try - { - m_IrcClient.Diconnect(); - } - catch (Exception) - { - // - } - } - - public void Stop() - { - isStopped = true; - } - - private void JoinChannels() - { - foreach (string channelname in channelnames.Split(new char[] { ';' })) - { - IrcChannel channel = m_IrcClient.JoinChannel(channelname); - channels.Add(channel); - System.Console.WriteLine(String.Format("Joined channel #{0}...", - channel.Name)); - } - } - - private void PartChannels() - { - foreach (IrcChannel channel in channels) - { - m_IrcClient.PartChannel(channel, "Caught in the bitstream..."); - System.Console.WriteLine(String.Format("Parted channel #{0}...", - channel.Name)); - } - } - - private string GetMessageSource(MessageContext context) - { - if (context is ChannelMessageContext) - { - ChannelMessageContext channelContext = context as ChannelMessageContext; - return String.Format("#{0}", - channelContext.Channel.Name); - } - else if (context is UserMessageContext) - { - UserMessageContext userContext = context as UserMessageContext; - return userContext.User.Nickname; - } - else - { - throw new InvalidOperationException(String.Format("Unhandled message context '{0}'", - context.GetType())); - } - } - - private void ExtractMessage(string parameters, - out string message) - { - int startIndex = parameters.IndexOf(':'); - if (startIndex != -1) - { - message = parameters.Substring(startIndex + 1); - } - else - { - message = parameters; - } - } - - private bool GetChannelName(IrcMessage message, - out string channelName) - { - if (message.Parameters == null || !message.Parameters.StartsWith("#")) - { - channelName = null; - return false; - } - - int index = message.Parameters.IndexOf(' '); - if (index == -1) - index = message.Parameters.Length; - else - index = index - 1; - channelName = message.Parameters.Substring(1, index); - return true; - } - - private bool GetTargetNickname(IrcMessage message, - out string nickname) - { - if (message.Parameters == null) - { - nickname = null; - return false; - } - - int index = message.Parameters.IndexOf(' '); - if (index == -1) - index = message.Parameters.Length; - nickname = message.Parameters.Substring(0, index); - Console.WriteLine("nickname: " + nickname); - return true; - } - - private bool ShouldAcceptMessage(IrcMessage message, - out MessageContext context) - { - if (message.Command.ToUpper().Equals("PRIVMSG")) - { - string channelName; - string nickname; - if (GetChannelName(message, - out channelName)) - { - foreach (IrcChannel channel in channels) - { - if (String.Compare(channel.Name, channelName, true) == 0) - { - context = new ChannelMessageContext(channel); - return true; - } - } - } - else if (GetTargetNickname(message, - out nickname)) - { - IrcUser targetUser = new IrcUser(m_IrcClient, - nickname); - if (String.Compare(targetUser.Nickname, botname, true) == 0) - { - IrcUser sourceUser = new IrcUser(m_IrcClient, - message.PrefixNickname); - context = new UserMessageContext(sourceUser); - return true; - } - } - } - context = null; - return false; - } - - private void client_MessageReceived(IrcMessage message) - { - try - { - if (message.Command != null && - message.Parameters != null) - { - string injectMessage; - ExtractMessage(message.Parameters, - out injectMessage); - MessageContext context; - if (ShouldAcceptMessage(message, - out context)) - { - Console.WriteLine(String.Format("Injecting: {0} from {1}", - injectMessage, - GetMessageSource(context))); - InjectMessage(context, - injectMessage); - } - else - { - Console.WriteLine("Received: " + message.Line); - } - } - else - { - Console.WriteLine("Received: " + message.Line); - } - } - catch (Exception ex) - { - Console.WriteLine(String.Format("Exception: {0}", ex)); - } - } - - private void client_ChannelUserDatabaseChanged(IrcChannel channel) - { - } - } -} diff --git a/irc/TechBot/TechBot.Library/TechBotService.cs b/irc/TechBot/TechBot.Library/TechBotService.cs deleted file mode 100644 index 025ff46d8ed..00000000000 --- a/irc/TechBot/TechBot.Library/TechBotService.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.IO; -using System.Data; -using System.Threading; - -using TechBot.IRCLibrary; - -namespace TechBot.Library -{ - public abstract class TechBotService - { - protected IServiceOutput m_ServiceOutput; - - public TechBotService(IServiceOutput serviceOutput) - { - m_ServiceOutput = serviceOutput; - } - - public virtual void Run() - { - CommandFactory.LoadPlugins(); - } - - public IServiceOutput ServiceOutput - { - get { return m_ServiceOutput; } - } - - public CommandBuilderCollection Commands - { - get { return CommandFactory.Commands; } - } - - public void InjectMessage(MessageContext context, string message) - { - ParseCommandMessage(context, - message); - } - - private bool IsCommandMessage(string message) - { - return message.StartsWith(Settings.Default.CommandPrefix); - } - - public void InjectMessage(string message) - { - ParseCommandMessage(null, message); - } - - public void ParseCommandMessage(MessageContext context, - string message) - { - if (!IsCommandMessage(message)) - return; - - message = message.Substring(1).Trim(); - int index = message.IndexOf(' '); - string commandName; - string commandParams = ""; - if (index != -1) - { - commandName = message.Substring(0, index).Trim(); - commandParams = message.Substring(index).Trim(); - } - else - commandName = message.Trim(); - - foreach (CommandBuilder command in Commands) - { - if (command.Name == commandName) - { - //Create a new instance of the required command type - Command cmd = command.CreateCommand(); - - cmd.TechBot = this; - cmd.Context = context; - cmd.Parameters = commandParams; - - try - { - cmd.Initialize(); - cmd.Run(); - cmd.DeInitialize(); - } - catch (Exception e) - { - ServiceOutput.WriteLine(context, string.Format("Uops! Just crashed with exception '{0}' at {1}", - e.Message, - e.Source)); - - ServiceOutput.WriteLine(context, e.StackTrace); - } - - return; - } - } - } - } -} diff --git a/irc/TechBot/TechBot.Library/app.config b/irc/TechBot/TechBot.Library/app.config deleted file mode 100644 index cc2cba5b4ee..00000000000 --- a/irc/TechBot/TechBot.Library/app.config +++ /dev/null @@ -1,30 +0,0 @@ - - - - -
        - - - - - - C:\Ros\current\irc\TechBot\Resources\ntstatus.xml - - - C:\Ros\current\irc\TechBot\Resources\winerror.xml - - - C:\Ros\current\irc\TechBot\Resources\hresult.xml - - - C:\Ros\current\irc\TechBot\Resources\wm.xml - - - svn://svn.reactos.org/reactos/trunk - - - ! - - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot.sln b/irc/TechBot/TechBot.sln deleted file mode 100644 index 3c794500893..00000000000 --- a/irc/TechBot/TechBot.sln +++ /dev/null @@ -1,62 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechBot", "TechBot\TechBot.csproj", "{106F437D-424B-4758-A69C-862D08D26F3D}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Compression", "Compression\Compression.csproj", "{E32307F1-623A-4E62-826F-56CDD4B23A54}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CHMLibrary", "CHMLibrary\CHMLibrary.csproj", "{72E5CCA1-6318-4D62-964D-CB23A5C743B5}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechBot.Console", "TechBot.Console\TechBot.Console.csproj", "{44258BA2-FFCB-4463-9CED-6DE5CC5CEBD4}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechBot.IRCLibrary", "TechBot.IRCLibrary\TechBot.IRCLibrary.csproj", "{D2A57931-DF04-4BC3-BD11-75DF4F3B0A88}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechBot.Library", "TechBot.Library\TechBot.Library.csproj", "{1114F34D-F388-4F38-AE27-C0EE1B10B777}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechBot.Commands.Common", "TechBot.Commands.Common\TechBot.Commands.Common.csproj", "{041B5F06-BF97-4981-B024-3A7B6DD9F6AE}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TechBot.Commands.MSDN", "TechBot.Commands.MSDN\TechBot.Commands.MSDN.csproj", "{ADBF1ED6-A586-4707-BD59-4CD53448D0FE}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {106F437D-424B-4758-A69C-862D08D26F3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {106F437D-424B-4758-A69C-862D08D26F3D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {106F437D-424B-4758-A69C-862D08D26F3D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {106F437D-424B-4758-A69C-862D08D26F3D}.Release|Any CPU.Build.0 = Release|Any CPU - {E32307F1-623A-4E62-826F-56CDD4B23A54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E32307F1-623A-4E62-826F-56CDD4B23A54}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E32307F1-623A-4E62-826F-56CDD4B23A54}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E32307F1-623A-4E62-826F-56CDD4B23A54}.Release|Any CPU.Build.0 = Release|Any CPU - {72E5CCA1-6318-4D62-964D-CB23A5C743B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {72E5CCA1-6318-4D62-964D-CB23A5C743B5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {72E5CCA1-6318-4D62-964D-CB23A5C743B5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {72E5CCA1-6318-4D62-964D-CB23A5C743B5}.Release|Any CPU.Build.0 = Release|Any CPU - {44258BA2-FFCB-4463-9CED-6DE5CC5CEBD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {44258BA2-FFCB-4463-9CED-6DE5CC5CEBD4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {44258BA2-FFCB-4463-9CED-6DE5CC5CEBD4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {44258BA2-FFCB-4463-9CED-6DE5CC5CEBD4}.Release|Any CPU.Build.0 = Release|Any CPU - {D2A57931-DF04-4BC3-BD11-75DF4F3B0A88}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D2A57931-DF04-4BC3-BD11-75DF4F3B0A88}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D2A57931-DF04-4BC3-BD11-75DF4F3B0A88}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D2A57931-DF04-4BC3-BD11-75DF4F3B0A88}.Release|Any CPU.Build.0 = Release|Any CPU - {1114F34D-F388-4F38-AE27-C0EE1B10B777}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1114F34D-F388-4F38-AE27-C0EE1B10B777}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1114F34D-F388-4F38-AE27-C0EE1B10B777}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1114F34D-F388-4F38-AE27-C0EE1B10B777}.Release|Any CPU.Build.0 = Release|Any CPU - {041B5F06-BF97-4981-B024-3A7B6DD9F6AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {041B5F06-BF97-4981-B024-3A7B6DD9F6AE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {041B5F06-BF97-4981-B024-3A7B6DD9F6AE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {041B5F06-BF97-4981-B024-3A7B6DD9F6AE}.Release|Any CPU.Build.0 = Release|Any CPU - {ADBF1ED6-A586-4707-BD59-4CD53448D0FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {ADBF1ED6-A586-4707-BD59-4CD53448D0FE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {ADBF1ED6-A586-4707-BD59-4CD53448D0FE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {ADBF1ED6-A586-4707-BD59-4CD53448D0FE}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/irc/TechBot/TechBot/App.config b/irc/TechBot/TechBot/App.config deleted file mode 100644 index 652f7444d66..00000000000 --- a/irc/TechBot/TechBot/App.config +++ /dev/null @@ -1,44 +0,0 @@ - - - - -
        - - - - - - - - - - - - - - - - - - - - - - - irc.eu.freenode.net - - - rbuildbottest - - - RBuildBot - - - qwerty - - - 6667 - - - - diff --git a/irc/TechBot/TechBot/AssemblyInfo.cs b/irc/TechBot/TechBot/AssemblyInfo.cs deleted file mode 100644 index dbacda112e8..00000000000 --- a/irc/TechBot/TechBot/AssemblyInfo.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following -// attributes. -// -// change them to the information which is associated with the assembly -// you compile. - -[assembly: AssemblyTitle("")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has following format : -// -// Major.Minor.Build.Revision -// -// You can specify all values by your own or you can build default build and revision -// numbers with the '*' character (the default): - -[assembly: AssemblyVersion("1.0.*")] - -// The following attributes specify the key for the sign of your assembly. See the -// .NET Framework documentation for more information about signing. -// This is not required, if you don't want signing let these attributes like they're. -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] diff --git a/irc/TechBot/TechBot/Default.build b/irc/TechBot/TechBot/Default.build deleted file mode 100644 index 8d0f4bb4de7..00000000000 --- a/irc/TechBot/TechBot/Default.build +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/irc/TechBot/TechBot/ProjectInstaller.cs b/irc/TechBot/TechBot/ProjectInstaller.cs deleted file mode 100644 index 0dc2b152a6e..00000000000 --- a/irc/TechBot/TechBot/ProjectInstaller.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.ComponentModel; -using System.ServiceProcess; -using System.Configuration.Install; -using System.Collections.Generic; -using System.Text; - -namespace TechBot -{ - [RunInstaller(true)] - public class ProjectInstaller : Installer - { - public ProjectInstaller() - { - ServiceProcessInstaller spi = null; - ServiceInstaller si = null; - - spi = new ServiceProcessInstaller(); - spi.Account = ServiceAccount.LocalSystem; - - si = new ServiceInstaller(); - si.ServiceName = "TechBot"; - si.StartType = ServiceStartMode.Automatic; - - Installers.AddRange(new Installer[] { spi, si }); - } - } -} diff --git a/irc/TechBot/TechBot/Properties/.gitignore b/irc/TechBot/TechBot/Properties/.gitignore deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/irc/TechBot/TechBot/ServiceThread.cs b/irc/TechBot/TechBot/ServiceThread.cs deleted file mode 100644 index 411d0f94f98..00000000000 --- a/irc/TechBot/TechBot/ServiceThread.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Configuration; -using System.Diagnostics; -using TechBot.Library; - -namespace TechBot -{ - public class ServiceThread - { - private EventLog m_EventLog; - - public ServiceThread(EventLog eventLog) - { - m_EventLog = eventLog; - } - - public void Run() - { - System.Console.WriteLine("TechBot irc service..."); - - IrcTechBotService ircService = new IrcTechBotService( - Settings.Default.IRCServerHostName, - Settings.Default.IRCServerHostPort, - Settings.Default.IRCChannelNames, - Settings.Default.IRCBotName, - Settings.Default.IRCBotPassword); - - ircService.Run(); - } - - public void Start() - { - try - { - Run(); - } - catch (Exception ex) - { - m_EventLog.WriteEntry(String.Format("Ex. {0}", ex)); - } - } - } -} diff --git a/irc/TechBot/TechBot/Settings.Designer.cs b/irc/TechBot/TechBot/Settings.Designer.cs deleted file mode 100644 index 87ae5985bc2..00000000000 --- a/irc/TechBot/TechBot/Settings.Designer.cs +++ /dev/null @@ -1,86 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.1433 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace TechBot { - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default { - get { - return defaultInstance; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("irc.eu.freenode.net")] - public string IRCServerHostName { - get { - return ((string)(this["IRCServerHostName"])); - } - set { - this["IRCServerHostName"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("rbuildbottest")] - public string IRCChannelNames { - get { - return ((string)(this["IRCChannelNames"])); - } - set { - this["IRCChannelNames"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("RBuildBot")] - public string IRCBotName { - get { - return ((string)(this["IRCBotName"])); - } - set { - this["IRCBotName"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("qwerty")] - public string IRCBotPassword { - get { - return ((string)(this["IRCBotPassword"])); - } - set { - this["IRCBotPassword"] = value; - } - } - - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("6667")] - public int IRCServerHostPort { - get { - return ((int)(this["IRCServerHostPort"])); - } - set { - this["IRCServerHostPort"] = value; - } - } - } -} diff --git a/irc/TechBot/TechBot/Settings.settings b/irc/TechBot/TechBot/Settings.settings deleted file mode 100644 index cd1160b7e7f..00000000000 --- a/irc/TechBot/TechBot/Settings.settings +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - irc.eu.freenode.net - - - rbuildbottest - - - RBuildBot - - - qwerty - - - 6667 - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot/TechBot.csproj b/irc/TechBot/TechBot/TechBot.csproj deleted file mode 100644 index b5b42911efa..00000000000 --- a/irc/TechBot/TechBot/TechBot.csproj +++ /dev/null @@ -1,82 +0,0 @@ - - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {106F437D-424B-4758-A69C-862D08D26F3D} - Exe - Properties - TechBot - TechBot - TechBot.TechBotService - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - - Component - - - - Settings.settings - True - True - - - Component - - - - - - - - - - - - {D2A57931-DF04-4BC3-BD11-75DF4F3B0A88} - TechBot.IRCLibrary - - - {1114F34D-F388-4F38-AE27-C0EE1B10B777} - TechBot.Library - - - - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot/TechBot.prjx b/irc/TechBot/TechBot/TechBot.prjx deleted file mode 100644 index 7af6ca126aa..00000000000 --- a/irc/TechBot/TechBot/TechBot.prjx +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/irc/TechBot/TechBot/TechBotService.cs b/irc/TechBot/TechBot/TechBotService.cs deleted file mode 100644 index 61c1e0f5cd1..00000000000 --- a/irc/TechBot/TechBot/TechBotService.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System; -using System.Threading; -using System.Collections; -using System.ComponentModel; -using System.Data; -using System.Diagnostics; -using System.ServiceProcess; -using System.Configuration.Install; - -namespace TechBot -{ - public class TechBotService : ServiceBase - { - private Thread thread; - private ServiceThread threadWorker; - - public TechBotService() - { - InitializeComponents(); - } - - private void InitializeComponents() - { - this.ServiceName = "TechBot"; - } - - /// - /// This method starts the service. - /// - public static void Main() - { - System.ServiceProcess.ServiceBase.Run(new System.ServiceProcess.ServiceBase[] { - new TechBotService() // To run more than one service you have to add them here - }); - } - - /// - /// Clean up any resources being used. - /// - protected override void Dispose(bool disposing) - { - base.Dispose(disposing); - } - - /// - /// Start this service. - /// - protected override void OnStart(string[] args) - { - try - { - threadWorker = new ServiceThread(EventLog); - thread = new Thread(new ThreadStart(threadWorker.Start)); - thread.Start(); - EventLog.WriteEntry(String.Format("TechBot service is running.")); - } - catch (Exception ex) - { - EventLog.WriteEntry(String.Format("Ex. {0}", ex)); - } - } - - /// - /// Stop this service. - /// - protected override void OnStop() - { - try - { - thread.Abort(); - thread.Join(); - thread = null; - threadWorker = null; - EventLog.WriteEntry(String.Format("TechBot service is stopped.")); - } - catch (Exception ex) - { - EventLog.WriteEntry(String.Format("Ex. {0}", ex)); - } - } - } -}