[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] [windows-installer.pingus] 19 new revisions pushed by addre
From: |
pingus |
Subject: |
[Pingus-CVS] [windows-installer.pingus] 19 new revisions pushed by address@hidden on 2011-10-20 00:52 GMT |
Date: |
Thu, 20 Oct 2011 00:54:30 +0000 |
19 new revisions:
Revision: 1fe512cca1fc
Author: David Philippi <address@hidden>
Date: Thu Apr 15 13:50:08 2004
Log: add new windows installer
http://code.google.com/p/pingus/source/detail?r=1fe512cca1fc&repo=windows-installer
Revision: 960718fb73a0
Author: David Philippi <address@hidden>
Date: Thu Apr 15 14:36:33 2004
Log: remove unrequired files
http://code.google.com/p/pingus/source/detail?r=960718fb73a0&repo=windows-installer
Revision: 4f26142530c2
Author: David Philippi <address@hidden>
Date: Fri Apr 16 12:25:47 2004
Log: add patch and ran dos2unix
http://code.google.com/p/pingus/source/detail?r=4f26142530c2&repo=windows-installer
Revision: fa392afde534
Author: David Philippi <address@hidden>
Date: Fri Apr 16 14:21:06 2004
Log: unix2dos
http://code.google.com/p/pingus/source/detail?r=fa392afde534&repo=windows-installer
Revision: d06a0440285d
Author: David Philippi <address@hidden>
Date: Sun Apr 18 13:54:42 2004
Log: display space on drive, better error handling
http://code.google.com/p/pingus/source/detail?r=d06a0440285d&repo=windows-installer
Revision: 7d9b738b40c9
Author: David Philippi <address@hidden>
Date: Thu Dec 30 16:34:22 2004
Log: updated mail address
http://code.google.com/p/pingus/source/detail?r=7d9b738b40c9&repo=windows-installer
Revision: aa142c1d49e4
Author: Jason Green <address@hidden>
Date: Mon Dec 5 09:00:26 2005
Log: Set SVN end of line style on everything to native....
http://code.google.com/p/pingus/source/detail?r=aa142c1d49e4&repo=windows-installer
Revision: 2040f317ec20
Author: Ingo Ruhnke <address@hidden>
Date: Sat Feb 11 06:32:52 2006
Log: Started Pingus-SDL branch
http://code.google.com/p/pingus/source/detail?r=2040f317ec20&repo=windows-installer
Revision: 0afc1f04bbb6
Author: Jimmy Salmon <address@hidden>
Date: Sun Aug 19 14:20:27 2007
Log: Added nsis installer
http://code.google.com/p/pingus/source/detail?r=0afc1f04bbb6&repo=windows-installer
Revision: e6d7b0105ff5
Author: Jimmy Salmon <address@hidden>
Date: Sun Aug 19 14:34:51 2007
Log: Removed old installer, don't include contrib dir
http://code.google.com/p/pingus/source/detail?r=e6d7b0105ff5&repo=windows-installer
Revision: f3f4bd009b38
Author: Jimmy Salmon <address@hidden>
Date: Sun Aug 19 14:41:10 2007
Log: Remove more files from installer
http://code.google.com/p/pingus/source/detail?r=f3f4bd009b38&repo=windows-installer
Revision: 960aa95405bc
Author: Ingo Ruhnke <address@hidden>
Date: Thu Aug 23 11:42:59 2007
Log: - moved level_comment_tool/ and windows_installer/ to trunk
http://code.google.com/p/pingus/source/detail?r=960aa95405bc&repo=windows-installer
Revision: ff339b90e926
Author: Jimmy Salmon <address@hidden>
Date: Fri Aug 24 19:40:38 2007
Log: Updated for new location
http://code.google.com/p/pingus/source/detail?r=ff339b90e926&repo=windows-installer
Revision: 3399f9cabe2f
Author: Jimmy Salmon <address@hidden>
Date: Fri Sep 21 21:38:03 2007
Log: Updated for 0.7.1
http://code.google.com/p/pingus/source/detail?r=3399f9cabe2f&repo=windows-installer
Revision: 7ca89d02bea1
Author: Jimmy Salmon <address@hidden>
Date: Sun Sep 23 07:59:28 2007
Log: Don't need lib dir
http://code.google.com/p/pingus/source/detail?r=7ca89d02bea1&repo=windows-installer
Revision: 14c5781edd99
Author: Jimmy Salmon <address@hidden>
Date: Mon Sep 24 19:54:08 2007
Log: Added pingus.exe.config
http://code.google.com/p/pingus/source/detail?r=14c5781edd99&repo=windows-installer
Revision: 367829415509
Author: Jimmy Salmon <address@hidden>
Date: Sun Oct 28 22:32:53 2007
Log: Prepare for 0.7.2
http://code.google.com/p/pingus/source/detail?r=367829415509&repo=windows-installer
Revision: aed6563547ee
Author: Jimmy Salmon <address@hidden>
Date: Sun Oct 28 23:17:45 2007
Log: Add to Add/Remove Programs
http://code.google.com/p/pingus/source/detail?r=aed6563547ee&repo=windows-installer
Revision: 1e653b54d568
Author: Jimmy Salmon <address@hidden>
Date: Sun Oct 28 23:36:57 2007
Log: Fix removing shortcuts from start menu in Vista
http://code.google.com/p/pingus/source/detail?r=1e653b54d568&repo=windows-installer
==============================================================================
Revision: 1fe512cca1fc
Author: David Philippi <address@hidden>
Date: Thu Apr 15 13:50:08 2004
Log: add new windows installer
http://code.google.com/p/pingus/source/detail?r=1fe512cca1fc&repo=windows-installer
Added:
/installer.exe
/readme.txt
/run.png
/source.zip
/src/BlueZip/BlueHead.h
/src/BlueZip/BlueZip.cpp
/src/BlueZip/BlueZip.h
/src/BlueZip/CRC.cpp
/src/BlueZip/CompHead.h
/src/BlueZip/DefTree.cpp
/src/BlueZip/Deflate.cpp
/src/BlueZip/Errors.h
/src/BlueZip/FileIO.cpp
/src/BlueZip/FileIO.h
/src/BlueZip/General.cpp
/src/BlueZip/General.h
/src/BlueZip/Inflate.cpp
/src/BlueZip/Inflate.h
/src/BlueZip/License.txt
/src/BlueZip/ReadZip.cpp
/src/BlueZip/Store.cpp
/src/BlueZip/Structs.cpp
/src/BlueZip/Structs.h
/src/BlueZip/Trees.cpp
/src/BlueZip/WriteZip.cpp
/src/BlueZip/fList.cpp
/src/BlueZip/fList.h
/src/BlueZip/zList.cpp
/src/BlueZip/zList.h
/src/Debug/Installer.res
/src/FileCode.cpp
/src/FileCode.h
/src/Header.h
/src/Installer.dsp
/src/Installer.dsw
/src/Installer.rc
/src/Parameters.h
/src/Pingus-Installer.manifest
/src/Release/Installer.res
/src/Setup.ico
/src/ShellCode.cpp
/src/ShellCode.h
/src/StartCode.cpp
/src/resource.h
/start.png
=======================================
--- /dev/null
+++ /installer.exe Thu Apr 15 13:50:08 2004
Binary file, no diff available.
=======================================
--- /dev/null
+++ /readme.txt Thu Apr 15 13:50:08 2004
@@ -0,0 +1,13 @@
+This is the Pingus Windows Installer
+
+The installer, when built in release mode, can be concatenated with a zip
that you use to install and executed. The command line for doing this in
DOS is:
+
+copy /b installer.exe + pingus.zip Pingus-Setup.exe
+
+Its not too badly written so it should be possible to tweak the code as
required. The additional overhead of the installer is 20.5Kb
+
+The things the installer does not do:
+ Cancel an active install
+ Allow you to uninstall Pingus
+
+Written by Neil Mitchell, address@hidden for help if required,
or the Pingus mailing list.
=======================================
--- /dev/null
+++ /run.png Thu Apr 15 13:50:08 2004
Binary file, no diff available.
=======================================
--- /dev/null
+++ /source.zip Thu Apr 15 13:50:08 2004
Binary file, no diff available.
=======================================
--- /dev/null
+++ /src/BlueZip/BlueHead.h Thu Apr 15 13:50:08 2004
@@ -0,0 +1,70 @@
+#define WIN32_MEAN_AND_LEAN
+#include <windows.h>
+
+#ifdef _DEBUG
+# define Assert(a) if (!(a)) _asm int 3;
+# define AssertD(a)if (!(a)) _asm int 3; //use if it has to create extra
data to Assert on
+#else
+# define Assert(a) __assume(a); //Microsoft specific, speed up programs
+# define AssertD(a) //nothing
+#endif
+
+#if defined(_DEBUG) && defined(ERR_BREAK)
+# define ErrMsg(a) _asm int 3;
+#else
+# define ErrMsg(a) //nothing
+#endif
+
+//to remove Compression define NO_COMPRESSION
+#define NO_COMPRESSION
+
+//Make good programming practice
+#ifndef PLAY_NICELY
+#define malloc MALLOC_IS_OLD
+#define free FREE_IS_OLD
+#define strdup STRDUP_IS_OLD
+#define BOOL BOOL_IS_FOR_CRAP_C_COMPILERS_ONLY
+#endif //!PLAY_NICELY
+
+typedef unsigned char u8;
+typedef unsigned short u16;
+typedef unsigned long u32;
+typedef unsigned int uint;
+
+// Macros for reading shorts and longs from an array of bytes
+u16 inline stream16(char* b, int i)
+{
+ return *((u16*) &b[i]);
+}
+
+u32 inline stream32(char* b, int i)
+{
+ return *((u32*) &b[i]);
+}
+
+class datLocal;
+class datCentral;
+class datEnd;
+
+#include "General.h"
+#include "FileIO.h"
+#include "Structs.h"
+
+
+class BlueZip;
+class zList;
+class fList;
+
+#include "BlueZip.h"
+#include "zList.h"
+#include "fList.h"
+
+//From CRC
+void CRC(const u8* buf, uint len);
+void InitCRC();
+u32 GetCRC();
+
+
+//From Store.cpp
+void ReadStore(File In, File Out, zList* z);
+void WriteStore(File In, File Out, zList* z);
=======================================
--- /dev/null
+++ /src/BlueZip/BlueZip.cpp Thu Apr 15 13:50:08 2004
@@ -0,0 +1,105 @@
+#include "BlueHead.h"
+
+BlueZip::BlueZip(LPCTSTR FileName)
+{
+ this->FileName = CopyString(FileName);
+
+ //Initialise for a blank file name
+ Files = NULL;
+ Comment = NULL;
+ data.lComment = 0;
+
+#ifndef NO_COMPRESSION
+ Pending = NULL;
+#endif
+}
+
+BlueZip::~BlueZip()
+{
+ delete[] FileName;
+ if (Comment) delete[] Comment;
+
+ while (Files != NULL)
+ {
+ zList* z = Files;
+ Files = Files->next;
+ delete z;
+ }
+
+#ifndef NO_COMPRESSION
+ while (Pending != NULL)
+ {
+ fList* f = Pending;
+ Pending = Pending->next;
+ delete f;
+ }
+#endif
+}
+
+#ifndef NO_COMPRESSION
+
+void BlueZip::AddFile(LPCTSTR FileName)
+{
+ Pending = new fList(FileName, Pending);
+}
+
+void BlueZip::WriteEnd(File f)
+{
+ //Handle mutliple disks correctly (i.e. don't)
+ data.DiskNo = 0;
+ data.DiskOne = 0;
+ data.DiskNum = data.Count;
+
+ long l = sigEnd;
+ FileWrite(f, &l, 4);
+ data.Write(f);
+ if (data.lComment)
+ FileWrite(f, Comment, data.lComment);
+}
+
+#endif //!NO_COMPRESSION
+
+
+void BlueZip::ReadEnd(File f)
+{
+ data.Read(f);
+
+ if (data.lComment)
+ {
+ Comment = new char[data.lComment];
+ FileRead(f, Comment, data.lComment);
+ }
+}
+
+bool BlueZip::GetFile(zList* z, LPCTSTR FileName)
+{
+ //First open the ZIP file for reading
+ File Orig = FileOpenRead(this->FileName);
+ if (!FileValid(Orig))
+ {
+ ErrMsg("Failed to open the reading file");
+ return false;
+ }
+
+ File Out = FileOpenWrite(FileName);
+ if (!FileValid(Out))
+ {
+ ErrMsg("Failed to open the output file");
+ return false;
+ }
+
+ //Perform CRC checks yourself
+ InitCRC();
+ SeekBeg(Orig, z->data.Offset + FilePosDelta);
+ ReadStore(Orig, Out, z);
+
+ if (z->data.CRC != GetCRC())
+ {
+ ErrMsg("Failed on the CRC");
+ return false;
+ }
+
+ FileClose(Orig);
+ FileClose(Out);
+ return true;
+}
=======================================
--- /dev/null
+++ /src/BlueZip/BlueZip.h Thu Apr 15 13:50:08 2004
@@ -0,0 +1,38 @@
+
+class __declspec(dllexport) BlueZip
+{
+private:
+ datEnd data; // The end header
+ char* Comment; // Actual comment
+
+ int FilePosDelta; // The value added to begin seeks to compenstate for
SFX headers
+
+ LPTSTR FileName;
+
+ //Used by ReadFile
+ bool ScanZip(File f);
+ void ReadEnd(File f);
+
+#ifndef NO_COMPRESSION
+ fList* Pending; // List of names to add
+ void WriteEnd(File f);
+
+ //fList** PendingNext; - Implement this to add in order
+#endif
+
+public:
+ zList* Files; // A point to the first file in the ZIP
+
+
+ BlueZip(LPCTSTR FileName);
+ ~BlueZip();
+
+ bool Read(); //Load the file into memory
+
+#ifndef NO_COMPRESSION
+ bool Write(bool Store = false); //Write the file back out
+ void AddFile(LPCTSTR FileName);
+#endif
+
+ bool GetFile(zList* z, LPCTSTR FileName);
+};
=======================================
--- /dev/null
+++ /src/BlueZip/CRC.cpp Thu Apr 15 13:50:08 2004
@@ -0,0 +1,111 @@
+#include "BlueHead.h"
+//Create a CRC value for a buffer
+
+//First define the table
+const u32 CrcTable[256] =
+{
+ 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
+ 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
+ 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
+ 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
+ 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
+ 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
+ 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
+ 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
+ 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
+ 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
+ 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
+ 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
+ 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
+ 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
+ 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
+ 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
+ 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
+ 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
+ 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
+ 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
+ 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
+ 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
+ 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
+ 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
+ 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
+ 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
+ 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
+ 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
+ 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
+ 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
+ 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
+ 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
+ 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
+ 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
+ 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
+ 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
+ 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
+ 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
+ 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
+ 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
+ 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
+ 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
+ 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
+ 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
+ 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
+ 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
+ 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
+ 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
+ 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
+ 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
+ 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
+ 0x2d02ef8dL
+};
+
+
+//One atomic operation
+#define DO1(buf) CRC32(*buf++)
+#define DO2(buf) DO1(buf); DO1(buf)
+#define DO4(buf) DO2(buf); DO2(buf)
+#define DO8(buf) DO4(buf); DO4(buf)
+
+
+//Local variable holding the CRC value:
+u32 CrcRegister;
+
+void inline CRC32(u8 b)
+{
+ CrcRegister = CrcTable[((int)CrcRegister ^ b) & 0xff] ^ (CrcRegister >>
8);
+}
+
+void InitCRC()
+{
+ //Do the inversion at this stage, save the odd clock cycle
+ CrcRegister = 0xffffffffL;
+}
+
+u32 GetCRC()
+{
+ //Check code is compatible with ZIP code, may vary based on word size
+ Assert((CrcRegister ^ 0xffffffffL) == ~CrcRegister);
+ return ~CrcRegister;
+}
+
+void CRC(const u8* buf, uint len)
+{
+//crc - the shift register
+//buf - the buffer containing the data
+//len - the length of the buffer
+
+// Run a set of bytes through the crc shift register. If buf is a NULL
+// pointer, then initialize the crc shift register contents instead.
+// Return the current crc in either case.
+ if (buf == NULL) return;
+
+ //unroll the loops
+ for (; len >= 8; len -= 8)
+ {
+ //Will be expanded to 8 different calls
+ DO8(buf);
+ }
+ for (; len /* >= 1 */; len--)
+ {
+ DO1(buf);
+ }
+}
=======================================
--- /dev/null
+++ /src/BlueZip/CompHead.h Thu Apr 15 13:50:08 2004
@@ -0,0 +1,44 @@
+#include "BlueHead.h"
+
+#define error(a) _asm int 3
+
+
+
+const uint MinMatch = 3;
+const uint MaxMatch = 258;
+/* The minimum and maximum match lengths */
+
+const uint WSize = 0x8000;
+/* Maximum window size = 32K. If you are really short of memory, compile
+ * with a smaller WSIZE but this reduces the compression ratio for files
+ * of size > WSIZE. WSIZE must be a power of two in the current
implementation.
+ */
+
+const uint MinLookahead = (MaxMatch + MinMatch + 1);
+/* Minimum amount of lookahead, except at the end of the input file.
+ * See deflate.c for comments about the MIN_MATCH+1.
+ */
+
+const uint MaxDist = (WSize - MinLookahead);
+/* In order to simplify the code, particularly on 16 bit machines, match
+ * distances are limited to MAX_DIST instead of WSIZE.
+ */
+
+/* Public globals */
+
+
+void flush_outbuf(char *, unsigned *);
+uint ReadBuf(char *buf, unsigned size);
+
+
+
+ /* in deflate.c */
+void LmInit();
+u32 Deflate();
+
+ /* in trees.c */
+void ct_init (int *);
+bool ct_tally (int, int);
+u32 flush_block (char far *, u32, int);
+void bi_init (char *, unsigned int, int);
+
=======================================
--- /dev/null
+++ /src/BlueZip/DefTree.cpp Thu Apr 15 13:50:08 2004
@@ -0,0 +1,44 @@
+#include "CompHead.h"
+
+#ifndef NO_COMPRESSION
+
+#ifdef _DEBUG
+ extern u32 isize; /* byte length of input file, for debug
only */
+#endif
+
+File ifile; /* file to compress */
+File zfile; /* output zip file */
+
+void SetupDeftree(File In, File Out, int my_level)
+{
+ ifile = In;
+ zfile = Out;
+}
+
+
+uint ReadBuf(char* buf, uint size)
+{
+ //IN assertion: size >= 2 (for end-of-line translation)
+
+ //Do not do end of line translation, who cares (use TextPad!)
+ const uint len = FileReadBuf(ifile, buf, size);
+ if (len != 0)
+ CRC((u8*) buf, len);
+
+#ifdef _DEBUG
+ isize += (u32) len;
+#endif
+ return len;
+}
+
+void flush_outbuf(char* buf, uint* size)
+{
+ if (*size != 0) {
+ FileWrite(zfile, buf, *size);
+ }
+ *size = 0;
+}
+
+
+
+#endif //!NO_COMPRESSION
=======================================
--- /dev/null
+++ /src/BlueZip/Deflate.cpp Thu Apr 15 13:50:08 2004
@@ -0,0 +1,539 @@
+#include "CompHead.h"
+
+//exclude from some builds
+#ifndef NO_COMPRESSION
+
+
+//PUBLIC SECTION
+#ifdef _DEBUG
+unsigned long isize;
+#endif
+//END PUBLIC SECTION
+
+
+
+//INIT SECTION
+char FileOutbuf[1024]; // output buffer for compression to file
+//END
+
+
+
+const uint HashBits = 15; // Number of bits used to hash strings
+
+const uint HashSize (1 << HashBits);
+const uint HashMask = HashSize - 1;
+const uint WMask = (WSize - 1);
+// HASH_SIZE and WSIZE must be powers of two
+
+const uint NIL = 0;
+// Tail of hash chains
+
+const uint TooFar = 4096;
+// Matches of length 3 are discarded if their distance exceeds TOO_FAR
+
+//
===========================================================================
+// Local data used by the "longest match" routines.
+
+typedef u16 Pos;
+typedef uint IPos;
+// A Pos is an index in the character window. We use short instead of int
to
+// save space in the various tables. IPos is used only for parameter
passing.
+
+u8 Window[2 * WSize];
+// Sliding window. Input bytes are read into the second half of the window,
+// and move to the first half later to keep a dictionary of at least WSIZE
+// bytes. With this organization, matches are limited to a distance of
+// WSIZE-MAX_MATCH bytes, but this ensures that IO is always
+// performed with a length multiple of the block size. Also, it limits
+// the window size to 64K, which is quite useful on MSDOS.
+
+Pos Prev[WSize];
+// Link to older string with same hash index. To limit the size of this
+// array to 64K, this link is maintained only for the last 32K strings.
+// An index in this array is thus a window index modulo 32K.
+
+Pos Head[HashSize];
+// Heads of the hash chains or NIL. If your compiler thinks that
+// HASH_SIZE is a dynamic value, recompile with -DDYN_ALLOC.
+
+
+const u32 WindowSize = 2 * WSize;
+// The size of the window
+
+long BlockStart;
+// window position at the beginning of the current output block. Gets
+// negative when the window is moved backwards.
+
+uint InsH; // hash index of string to be inserted
+
+const uint HShift = ((HashBits + MinMatch - 1) / MinMatch);
+// Number of bits by which ins_h and del_h must be shifted at each
+// input step. It must be such that after MIN_MATCH steps, the oldest
+// byte no longer takes part in the hash key, that is:
+// H_SHIFT * MIN_MATCH >= HASH_BITS
+
+uint PrevLength;
+// Length of the best match at previous step. Matches not greater than this
+// are discarded. This is used in the lazy match evaluation.
+
+uint StrStart; // start of string to insert
+uint MatchStart; // start of matching string
+bool EOFile; // flag set at end of input file
+uint LookAhead; // number of valid bytes ahead in window
+
+//Parameters for compression mode
+
+const uint MaxChainLength = 4096;
+// To speed up deflation, hash chains are never searched beyond this
length.
+// A higher limit improves compression ratio but degrades the speed.
+
+const uint MaxLazyMatch = 258;
+// Attempt to find a better match only when the current match is strictly
+// smaller than this value. This mechanism is used only for compression
+// levels >= 4.
+
+const uint GoodMatch = 32;
+// Use a faster search when the previous match is longer than this
+
+int NiceMatch; // Stop searching when current match exceeds this
+
+
+const int Equal = 0;
+/* result of memcmp for equal strings */
+
+/*
===========================================================================
+ * Prototypes for local functions.
+ */
+
+void FillWindow();
+int LongestMatch(IPos CurMatch);
+
+#ifdef _DEBUG
+void CheckMatch(IPos Start, IPos Match, int Length);
+#endif
+
+/*
===========================================================================
+ * Update a hash value with the given input byte
+ * IN assertion: all calls to to UPDATE_HASH are made with consecutive
+ * input characters, so that a running hash key can be computed from the
+ * previous key instead of complete recalculation each time.
+ */
+
+void inline UpdateHash(u8 b)
+{
+ InsH = ((InsH << HShift) ^ b) & HashMask;
+}
+
+/*
===========================================================================
+ * Insert string s in the dictionary and set match_head to the previous
head
+ * of the hash chain (the most recent string with same hash key). Return
+ * the previous length of the hash chain.
+ * IN assertion: all calls to to INSERT_STRING are made with consecutive
+ * input characters and the first MIN_MATCH bytes of s are valid
+ * (except for the last MIN_MATCH-1 bytes of the input file).
+ */
+
+IPos inline InsertString(IPos HashHead) //StrStart is the other value
+{
+ UpdateHash(Window[StrStart + (MinMatch - 1)]);
+ IPos i = Head[InsH];
+ Prev[StrStart & WMask] = i;
+ Head[InsH] = StrStart;
+ return i;
+}
+
+
+/*
===========================================================================
+ * Initialize the "longest match" routines for a new file
+ *
+ * IN assertion: window_size is > 0 if the input file is already read or
+ * mmap'ed in the window[] array, 0 otherwise. In the first case,
+ * window_size is sufficient to contain the whole input file plus
+ * MIN_LOOKAHEAD bytes (to avoid referencing memory beyond the end
+ * of window[] when looking for matches towards the end).
+ */
+void LmInit()
+{
+ // Initialize the hash table (avoiding 64K overflow for 16 bit systems).
+ // prev[] will be initialized on the fly.
+ Head[HashSize-1] = NIL;
+ memset((char*) Head, NIL, (uint) (HashSize - 1) * sizeof(*Head));
+
+ // Set the default configuration parameters:
+ //Do not try to find matches longer than the maximum
+ NiceMatch = MaxMatch;
+
+ StrStart = 0;
+ BlockStart = 0;
+
+ // Read 64K in one step, double the window size
+ LookAhead = ReadBuf((char*) Window, WSize * 2);
+
+ EOFile = (LookAhead == 0);
+ if (EOFile) return;
+
+ // Make sure that we always have enough lookahead. This is important
+ // if input comes from a device such as a tty.
+ if (LookAhead < MinLookahead)
+ FillWindow();
+
+ InsH = 0;
+
+ uint j;
+ for (j = 0; j < MinMatch - 1; j++)
+ UpdateHash(Window[j]);
+ // If lookahead < MIN_MATCH, ins_h is garbage, but this is
+ // not important since only literal bytes will be emitted.
+}
+
+//
===========================================================================
+// Set match_start to the longest match starting at the given string and
+// return its length. Matches shorter or equal to prev_length are
discarded,
+// in which case the result is equal to prev_length and match_start is
+// garbage.
+// IN assertions: cur_match is the head of the hash chain for the current
+// string (strstart) and its distance is <= MAX_DIST, and prev_length >=
1
+
+int LongestMatch(IPos CurMatch)
+{
+ uint ChainLength = MaxChainLength; // max hash chain length
+ u8* Scan = Window + StrStart; // current string
+ u8* Match; //
matched string
+ int Len; //
length of current match
+ int BestLen = PrevLength; // best match length so
far
+
+ IPos Limit = StrStart > (IPos)MaxDist ? StrStart - (IPos)MaxDist : NIL;
+ // Stop when cur_match becomes <= limit. To simplify the code,
+ // we prevent matches with the string of window index 0.
+
+
+ u8* StrEnd = Window + StrStart + MaxMatch;
+ u8 ScanEnd1 = Scan[BestLen - 1];
+ u8 ScanEnd = Scan[BestLen];
+
+ /* Do not waste too much time if we already have a good match: */
+ if (PrevLength >= GoodMatch)
+ {
+ ChainLength >>= 2;
+ }
+
+ Assert(StrStart <= WindowSize - MinLookahead);//, "insufficient
lookahead");
+
+ do
+ {
+ Assert(CurMatch < StrStart);//, "no future");
+ Match = Window + CurMatch;
+
+ /* Skip to next match if the match length cannot increase
+ * or if the match length is less than 2:
+ */
+
+ if (Match[BestLen] != ScanEnd ||
+ Match[BestLen - 1] != ScanEnd1 ||
+ *Match != Scan[0] ||
+ *++Match != Scan[1])
+ continue;
+
+ // The check at best_len-1 can be removed because it will be made
+ // again later. (This heuristic is not always a win.)
+ // It is not necessary to compare scan[2] and match[2] since they
+ // are always equal when the other bytes match, given that
+ // the hash keys are equal and that HASH_BITS >= 8.
+ Scan += 2;
+ Match++;
+
+ /* We check for insufficient lookahead only every 8th comparison;
+ * the 256th check will be made at strstart+258.
+ */
+ do {
+ } while ((*++Scan == *++Match) && (*++Scan == *++Match) &&
+ (*++Scan == *++Match) && (*++Scan == *++Match)
&&
+ (*++Scan == *++Match) && (*++Scan == *++Match)
&&
+ (*++Scan == *++Match) && (*++Scan == *++Match)
&&
+ Scan < StrEnd);
+
+ Assert(Scan <= Window + (uint)(WindowSize-1));//, "wild scan");
+
+ Len = MaxMatch - (int)(StrEnd - Scan);
+ Scan = StrEnd - MaxMatch;
+
+ if (Len > BestLen) {
+ MatchStart = CurMatch;
+ BestLen = Len;
+ if (Len >= NiceMatch) break;
+
+ ScanEnd1 = Scan[BestLen - 1];
+ ScanEnd = Scan[BestLen];
+ }
+ } while ((CurMatch = Prev[CurMatch & WMask]) > Limit
+ && --ChainLength != 0);
+
+ return BestLen;
+}
+
+
+#ifdef _DEBUG
+/*
===========================================================================
+ * Check that the match at match_start is indeed a match.
+ */
+void CheckMatch(IPos Start, IPos Match, int Len)
+{
+ // check that the match is indeed a match
+ if (memcmp((char*) Window + Match,
+ (char*) Window + Start, Len) != Equal)
+ {
+ error("invalid match");
+ }
+}
+#else
+# define CheckMatch(Start, Match, Len)
+#endif
+
+/*
===========================================================================
+ * Fill the window when the lookahead becomes insufficient.
+ * Updates strstart and lookahead, and sets eofile if end of input file.
+ *
+ * IN assertion: lookahead < MIN_LOOKAHEAD && strstart + lookahead > 0
+ * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD
+ * At least one byte has been read, or eofile is set; file reads are
+ * performed for at least two bytes (required for the translate_eol
option).
+ */
+void FillWindow()
+{
+ uint n, m;
+ uint More; // Amount of free space at the end of the window.
+
+ do
+ {
+ More = (unsigned)(WindowSize - (u32)LookAhead - (u32)StrStart);
+
+ // 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 (More == (unsigned)EOF)
+ {
+ //Occurs for files one byte long
+ More--;
+ }
+ else if (StrStart >= WSize + MaxDist)
+ {
+ // By the IN assertion, the window is not empty so we can't
confuse
+ // more == 0 with more == 64K on a 16 bit machine.
+ memcpy((char*) Window, (char*) Window + WSize, (uint) WSize);
+ MatchStart -= WSize;
+ StrStart -= WSize; // we now have strstart >= MAX_DIST:
+
+ BlockStart -= (long) WSize;
+
+ //Neil Optimisation, HASH_SIZE == WSIZE
+ //:. only do one loop, with two operations in it
+
+ //This must be true, if not use the original ZIP code
+ Assert(HashSize == WSize);
+
+
+ for (n = 0; n < HashSize; n++)
+ {
+ m = Head[n];
+ //NB: Do NOT use MAX as More is uint :. always
> 0
+ Head[n] = (Pos) (m >= WSize ? m-WSize : NIL);
+
+ //Dependant on WSIZE
+ m = Prev[n];
+ Prev[n] = (Pos)(m >= WSize ? m-WSize : NIL);
+ // If n is not on any hash chain, prev[n] is
garbage but
+ // its value will never be used.
+ }
+ More += WSize;
+ }
+ if (EOFile) return;
+
+ /* If there was no sliding:
+ * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD -
1 &&
+ * more == window_size - lookahead - strstart
+ * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
+ * => more >= window_size - 2*WSIZE + 2
+ * In the MMAP or BIG_MEM case (not yet supported in gzip),
+ * window_size == input_size + MIN_LOOKAHEAD &&
+ * strstart + lookahead <= input_size => more >= MIN_LOOKAHEAD.
+ * Otherwise, window_size == 2*WSIZE so more >= 2.
+ * If there was sliding, more >= WSIZE. So in all cases, more >= 2.
+ */
+ Assert(More >= 2); //more < 2
+
+ n = ReadBuf((char*) Window + StrStart + LookAhead, More);
+ EOFile = (n == 0);
+ LookAhead += n;
+
+ } while ((LookAhead < MinLookahead) && !EOFile);
+}
+
+/*
===========================================================================
+ * Flush the current block, with given end-of-file flag.
+ * IN assertion: strstart is set to the end of the current match.
+ */
+
+inline u32 DoFlushBlock(bool eof)
+{
+ return flush_block(BlockStart >= 0L ?
(char*)&Window[(unsigned)BlockStart] : \
+ (char*)NULL, (long)StrStart - BlockStart, eof);
+}
+
+
+/*
===========================================================================
+ * Same as above, but achieves better compression. We use a lazy
+ * evaluation for matches: a match is finally adopted only if there is
+ * no better match at the next window position.
+ */
+u32 Deflate()
+{
+
+ IPos HashHead = NIL; // head of hash chain
+ IPos PrevMatch; // previous
match
+ bool Flush; // set
if current block must be flushed
+ bool MatchAvailable = false; // set if previous match exists
+ uint MatchLength = MinMatch - 1; // length of best match
+
+#ifdef _DEBUG
+ extern u32 isize; // byte length of input file, for debug only
+#endif
+
+ // Process the input block.
+ while (LookAhead != 0)
+ {
+ // Insert the string window[strstart .. strstart+2] in the
+ // dictionary, and set hash_head to the head of the hash chain:
+ if (LookAhead >= MinMatch)
+ HashHead = InsertString(HashHead);
+
+ // Find the longest match, discarding those <= prev_length.
+ PrevLength = MatchLength;
+ PrevMatch = MatchStart;
+ MatchLength = MinMatch - 1;
+
+ if ((HashHead != NIL) &&
+ (PrevLength < MaxLazyMatch) &&
+ (StrStart - HashHead <= MaxDist))
+ {
+ // To simplify the code, we prevent matches with the string
+ // of window index 0 (in particular we have to avoid a match
+ // of the string with itself at the start of the input file).
+
+ // Do not look for matches beyond the end of the input.
+ // This is necessary to make deflate deterministic.
+ if ((uint) NiceMatch > LookAhead)
+ NiceMatch = (int) LookAhead;
+
+ MatchLength = LongestMatch(HashHead);
+ // LongestMatch() sets match_start
+ if (MatchLength > LookAhead)
+ MatchLength = LookAhead;
+
+ // Ignore a length 3 match if it is too distant:
+ if ((MatchLength == MinMatch) && (StrStart - MatchStart >
TooFar))
+ {
+ // If prev_match is also MIN_MATCH, match_start is garbage
+ // but we will ignore the current match anyway.
+ MatchLength = MinMatch - 1;
+ }
+ }
+ // If there was a match at the previous step and the current
+ // match is not better, output the previous match:
+ if ((PrevLength >= MinMatch) && (MatchLength <= PrevLength))
+ {
+ uint MaxInsert = StrStart + LookAhead - MinMatch;
+ CheckMatch(StrStart - 1, PrevMatch, PrevLength);
+
+ Flush = ct_tally(StrStart - 1 - PrevMatch, PrevLength -
MinMatch);
+
+ // Insert in hash table all strings up to the end of the match.
+ // strstart-1 and strstart are already inserted.
+ LookAhead -= PrevLength - 1;
+ PrevLength -= 2;
+ do
+ {
+ if (++StrStart <= MaxInsert)
+ {
+ HashHead = InsertString(HashHead);
+ // strstart never exceeds WSIZE-MAX_MATCH, so there are
+ // always MIN_MATCH bytes ahead.
+ }
+ }
+ while (--PrevLength != 0);
+
+ StrStart++;
+ MatchAvailable = false;
+ MatchLength = MinMatch - 1;
+
+ if (Flush)
+ {
+ DoFlushBlock(false);
+ BlockStart = StrStart;
+ }
+
+ }
+ else if (MatchAvailable)
+ {
+ // If there was no match at the previous position, output a
+ // single literal. If there was a match but the current match
+ // is longer, truncate the previous match to a single literal.
+ if (ct_tally (0, Window[StrStart-1]))
+ {
+ DoFlushBlock(false);
+ BlockStart = StrStart;
+ }
+ StrStart++;
+ LookAhead--;
+ }
+ else
+ {
+ /* There is no previous match to compare with, wait for
+ * the next step to decide.
+ */
+ MatchAvailable = true;
+ StrStart++;
+ LookAhead--;
+ }
+ AssertD((StrStart <= isize) && (LookAhead <= isize));//, "a bit
too far");
+
+ // Make sure that we always have enough lookahead, except
+ // at the end of the input file. We need MAX_MATCH bytes
+ // for the next match, plus MIN_MATCH bytes to insert the
+ // string following the next match.
+ if (LookAhead < MinLookahead)
+ FillWindow();
+ }
+
+ if (MatchAvailable)
+ ct_tally (0, Window[StrStart-1]);
+
+ return DoFlushBlock(true); // eof
+}
+
+
+
+
+
+
+
+//NEIL SPECIFIC
+
+
+u32 filecompress(int* cmpr_method)
+{
+
+ /* Set the defaults for file compression. */
+ //zfile = zipfile; handled in SetupDefTree
+
+#ifdef _DEBUG
+ isize = 0;
+#endif
+
+ /* Initialize deflate's internals and execute file compression. */
+ bi_init(FileOutbuf, sizeof(FileOutbuf), true);
+ ct_init(cmpr_method);
+ LmInit();
+ return Deflate();
+}
+
+#endif //!NO_COMPRESSION
=======================================
--- /dev/null
+++ /src/BlueZip/Errors.h Thu Apr 15 13:50:08 2004
@@ -0,0 +1,4 @@
+//Error messages, with descriptive text
+//Can be turned off with the command
+//Can either send the text, or 0xffffffff
+
=======================================
--- /dev/null
+++ /src/BlueZip/FileIO.cpp Thu Apr 15 13:50:08 2004
@@ -0,0 +1,141 @@
+#include "BlueHead.h"
+
+File FileOpenRead(LPCTSTR s)
+{
+ return CreateFile(s, GENERIC_READ,
+ FILE_SHARE_READ, NULL, OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL, NULL);
+}
+
+File FileOpenWrite(LPCTSTR s)
+{
+ return CreateFile(s, GENERIC_WRITE,
+ FILE_SHARE_READ, NULL, CREATE_NEW,
+ FILE_ATTRIBUTE_NORMAL, NULL);
+}
+
+void FileRead(File f, void* buf, DWORD size)
+{
+ DWORD d;
+ ReadFile(f, buf, size, &d, NULL);
+ Assert(size == d);
+}
+
+int FileReadBuf(File f, void* buf, DWORD size)
+{
+ DWORD d;
+ ReadFile(f, buf, size, &d, NULL);
+ return d;
+}
+
+void FileWrite(File f, const void* buf, DWORD size)
+{
+ DWORD d;
+ WriteFile(f, buf, size, &d, NULL);
+ Assert(size == d);
+}
+
+
+bool FileValid(File f)
+{
+ return (f != File_Invalid);
+}
+
+void FileClose(File f)
+{
+#ifdef _DEBUG
+ if (!CloseHandle(f)) _asm int 3;
+#else
+ CloseHandle(f);
+#endif
+}
+
+
+bool FileReplace(LPCTSTR To, LPCTSTR From)
+{
+ //First remove the existing file
+ DeleteFile(To);
+ //Then copy it accross
+ return (MoveFile(From, To) != FALSE);
+}
+
+File FileOpenTemp(LPTSTR s)
+{
+ char Buffer[MAX_PATH];
+
+ if ((GetTempPath(MAX_PATH, Buffer) == 0) ||
+ (GetTempFileName(Buffer, "ZIP", 0, s) == 0))
+ return File_Invalid;
+
+ return CreateFile(s, GENERIC_WRITE,
+ FILE_SHARE_READ, NULL, CREATE_ALWAYS, //Create Always, not
Create New
+ FILE_ATTRIBUTE_NORMAL, NULL);;
+}
+
+
+//return TRUE for success, FALSE for failure
+//fseek returns 0 for success
+
+void inline _p_Seek(File f, long offset, DWORD origin)
+{
+#ifdef _DEBUG
+ if (SetFilePointer(f, offset, NULL, origin) == 0xFFFFFFFF) _asm int 3;
+#else
+ SetFilePointer(f, offset, NULL, origin);
+#endif
+}
+
+void SeekBeg(File f, long offset)
+{_p_Seek(f, offset, FILE_BEGIN);}
+
+void SeekCur(File f, long offset)
+{_p_Seek(f, offset, FILE_CURRENT);}
+
+void SeekEnd(File f, long offset)
+{_p_Seek(f, offset, FILE_END);}
+
+
+int FilePos(File f)
+{
+ DWORD d = SetFilePointer(f, 0, NULL, FILE_CURRENT);
+ Assert(d != 0xFFFFFFFF);
+ return d;
+}
+
+int FileLen(File f)
+{
+ return GetFileSize(f, NULL);
+}
+
+void FileGetDate(File f, datCentral* data)
+{
+ FILETIME ft;
+#ifdef _DEBUG
+ if (!GetFileTime(f, NULL, NULL, &ft)) _asm int 3;
+ if (!FileTimeToDosDateTime(&ft, &data->Date, &data->Time)) _asm int 3;
+#else
+ GetFileTime(f, &ft, NULL, NULL);
+ FileTimeToDosDateTime(&ft, &data->Date, &data->Time);
+#endif
+}
+
+#define A_RONLY 0x01
+#define A_HIDDEN 0x02
+#define A_SYSTEM 0x04
+#define A_LABEL 0x08
+#define A_DIR 0x10
+#define A_ARCHIVE 0x20
+
+u32 FileGetAttrib(File f, LPCTSTR FileName)
+{
+ DWORD Attr = GetFileAttributes(FileName);
+ Assert(Attr != 0xFFFFFFFF);
+
+ return(
+ (Attr & FILE_ATTRIBUTE_READONLY ? A_RONLY :0) |
+ (Attr & FILE_ATTRIBUTE_HIDDEN ? A_HIDDEN :0) |
+ (Attr & FILE_ATTRIBUTE_SYSTEM ? A_SYSTEM :0) |
+ (Attr & FILE_ATTRIBUTE_DIRECTORY ? A_DIR :0) |
+ (Attr & FILE_ATTRIBUTE_ARCHIVE ? A_ARCHIVE :0));
+}
+
=======================================
--- /dev/null
+++ /src/BlueZip/FileIO.h Thu Apr 15 13:50:08 2004
@@ -0,0 +1,27 @@
+
+//Use Windows (reliable) file IO routines
+#define File HANDLE
+#define File_Invalid INVALID_HANDLE_VALUE
+
+File FileOpenRead(LPCTSTR s);
+File FileOpenWrite(LPCTSTR s);
+File FileOpenTemp(LPTSTR s);
+
+bool FileReplace(LPCTSTR To, LPCTSTR From);
+
+void FileRead(File f, void* buf, DWORD size);
+int FileReadBuf(File f, void* buf, DWORD size);
+void FileWrite(File f, const void* buf, DWORD size);
+
+bool FileValid(File f);
+void FileClose(File f);
+
+void SeekBeg(File f, long offset);
+void SeekCur(File f, long offset);
+void SeekEnd(File f, long offset);
+
+int FilePos(File f);
+int FileLen(File f);
+
+void FileGetDate(File f, datCentral* data);
+u32 FileGetAttrib(File f, LPCTSTR FileName);
=======================================
--- /dev/null
+++ /src/BlueZip/General.cpp Thu Apr 15 13:50:08 2004
@@ -0,0 +1,9 @@
+#include "BlueHead.h"
+
+LPTSTR CopyString(LPCTSTR s)
+{
+ const int i = strlen(s);
+ LPTSTR res = new char[i+1];
+ memcpy(res, s, i+1);
+ return res;
+}
=======================================
--- /dev/null
+++ /src/BlueZip/General.h Thu Apr 15 13:50:08 2004
@@ -0,0 +1,2 @@
+
+LPTSTR CopyString(LPCTSTR s);
=======================================
--- /dev/null
+++ /src/BlueZip/Inflate.cpp Thu Apr 15 13:50:08 2004
@@ -0,0 +1,1015 @@
+#include "BlueHead.h"
+#include <stdio.h>
+
+
+File hOut; //THIS MUST BE SET BY MY PROGRAM
+File hIn;
+
+#undef malloc
+#undef free
+
+void Neil_Init(File Out, File In)
+{
+ hOut = Out;
+ hIn = In;
+}
+
+
+
+#include "inflate.h" //Used to be globals.h
+struct Globals G;
+
+
+//From consts.h
+const u16 mask_bits[] = {
+ 0x0000,
+ 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
+ 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
+};
+
+//From unzpriv.h
+struct huft {
+ u8 e; /* number of extra bits or operation */
+ u8 b; /* number of bits in this code or subcode */
+ union {
+ u16 n; /* literal, length base, or distance base */
+ struct huft *t; /* pointer to next level of table */
+ } v;
+};
+# define redirSlide G.area.Slide
+
+
+
+
+
+//NEIL SPECIFIC END
+
+
+#define PKZIP_BUG_WORKAROUND /* PKZIP 1.93a problem--live with it */
+
+#define __INFLATE_C /* identifies this source module */
+
+/* #define DEBUG */
+#define INFMOD /* tell inflate.h to include code to be compiled */
+//#include "inflate.h"
+
+#if (defined(DLL) && !defined(NO_SLIDE_REDIR))
+# define wsize G._wsize /* wsize is a variable */
+#else
+# define wsize WSIZE /* wsize is a constant */
+#endif
+
+
+inline int NextByte()
+{
+ unsigned char c;
+ FileRead(hIn, &c, 1);
+ return c;
+}
+
+#ifndef NEXTBYTE /* default is to simply get a byte from stdin */
+# define NEXTBYTE NextByte()
+#endif
+
+
+
+#ifndef MESSAGE /* only used twice, for fixed strings--NOT
general-purpose */
+# define MESSAGE(str,len,flag) fprintf(stderr,(char *)(str))
+#endif
+
+
+void inline FLUSH(int n)
+{
+ FileWrite(hOut, redirSlide, n);
+ CRC(redirSlide, n);}
+//#ifndef FLUSH /* default is to simply write the buffer to
stdout */
+//# define FLUSH(n) \
+//#endif
+/* Warning: the fwrite above might not work on 16-bit compilers, since
+ 0x8000 might be interpreted as -32,768 by the library function. */
+
+#ifndef Trace
+# ifdef DEBUG
+# define Trace(x) fprintf x
+# else
+# define Trace(x)
+# endif
+#endif
+
+
+/*---------------------------------------------------------------------------*/
+
+/* Function prototypes */
+#ifndef OF
+# ifdef __STDC__
+# define OF(a) a
+# else
+# define OF(a) ()
+# endif
+#endif /* !OF */
+int inflate_codes OF((__GPRO__ struct huft *tl, struct huft *td,
+ int bl, int bd));
+static int inflate_stored OF((__GPRO));
+static int inflate_fixed OF((__GPRO));
+static int inflate_dynamic OF((__GPRO));
+static int inflate_block OF((__GPRO__ int *e));
+
+
+/* The inflate algorithm uses a sliding 32K byte window on the uncompressed
+ stream to find repeated byte strings. This is implemented here as a
+ circular buffer. The index is updated simply by incrementing and then
+ and'ing with 0x7fff (32K-1). */
+/* It is left to other modules to supply the 32K area. It is assumed
+ to be usable as if it were declared "uch slide[32768];" or as just
+ "uch *slide;" and then malloc'ed in the latter case. The definition
+ must be in unzip.h, included above. */
+
+
+/* unsigned wp; moved to globals.h */ /* current position in slide */
+
+#define INVALID_CODE 99
+#define IS_INVALID_CODE(c) ((c) == INVALID_CODE)
+
+/* Tables for deflate from PKZIP's appnote.txt. */
+static const uint border[] = { /* Order of the bit length code lengths */
+ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
+static const u16 cplens[] = { /* Copy lengths for literal codes 257..285
*/
+ 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
+ 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
+ /* note: see note #13 above about the 258 in this list. */
+static const u16 cplext[] = { /* Extra bits for literal codes 257..285 */
+ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
+ 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, INVALID_CODE, INVALID_CODE};
+static const u16 cpdist[] = { /* Copy offsets for distance codes 0..29 */
+ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
+ 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
+#ifdef USE_DEFLATE64
+ 8193, 12289, 16385, 24577, 32769, 49153};
+#else
+ 8193, 12289, 16385, 24577};
+#endif
+static const u16 cpdext[] = { /* Extra bits for distance codes */
+ 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
+ 7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
+#ifdef USE_DEFLATE64
+ 12, 12, 13, 13, 14, 14};
+#else
+ 12, 12, 13, 13};
+#endif
+#ifdef USE_DEFLATE64
+# define NUMDISTS 32
+#else
+# define NUMDISTS 30
+#endif
+
+
+/* moved to consts.h (included in unzip.c), resp. funzip.c */
+#if 0
+/* And'ing with mask_bits[n] masks the lower n bits */
+ZCONST u16 near mask_bits[] = {
+ 0x0000,
+ 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
+ 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
+};
+#endif /* 0 */
+
+
+/* Macros for inflate() bit peeking and grabbing.
+ The usage is:
+
+ NEEDBITS(j)
+ x = b & mask_bits[j];
+ DUMPBITS(j)
+
+ where NEEDBITS makes sure that b has at least j bits in it, and
+ DUMPBITS removes the bits from b. The macros use the variable k
+ for the number of bits in b. Normally, b and k are register
+ variables for speed and are initialized at the begining of a
+ routine that uses these macros from a global bit buffer and count.
+
+ In order to not ask for more bits than there are in the compressed
+ stream, the Huffman tables are constructed to only ask for just
+ enough bits to make up the end-of-block code (value 256). Then no
+ bytes need to be "returned" to the buffer at the end of the last
+ block. See the huft_build() routine.
+ */
+
+/* These have been moved to globals.h */
+#if 0
+ulg bb; /* bit buffer */
+unsigned bk; /* bits in bit buffer */
+#endif
+
+//EOF is not a valid
+//#ifndef CHECK_EOF
+//# define CHECK_EOF /* default as of 5.13/5.2 */
+//#endif
+
+#ifndef CHECK_EOF
+# define NEEDBITS(n) {while(k<(n)){b|=((u32)NEXTBYTE)<<k;k+=8;}}
+#else
+# define NEEDBITS(n) {while(k<(n)){int c=NEXTBYTE;\
+ if(c==EOF){retval=1;goto cleanup_and_exit;}\
+ b|=((u32)c)<<k;k+=8;}}
+#endif
+
+#define DUMPBITS(n) {b>>=(n);k-=(n);}
+
+
+/*
+ Huffman code decoding is performed using a multi-level table lookup.
+ The fastest way to decode is to simply build a lookup table whose
+ size is determined by the longest code. However, the time it takes
+ to build this table can also be a factor if the data being decoded
+ are not very long. The most common codes are necessarily the
+ shortest codes, so those codes dominate the decoding time, and hence
+ the speed. The idea is you can have a shorter table that decodes the
+ shorter, more probable codes, and then point to subsidiary tables for
+ the longer codes. The time it costs to decode the longer codes is
+ then traded against the time it takes to make longer tables.
+
+ This results of this trade are in the variables lbits and dbits
+ below. lbits is the number of bits the first level table for literal/
+ length codes can decode in one step, and dbits is the same thing for
+ the distance codes. Subsequent tables are also less than or equal to
+ those sizes. These values may be adjusted either when all of the
+ codes are shorter than that, in which case the longest code length in
+ bits is used, or when the shortest code is *longer* than the requested
+ table size, in which case the length of the shortest code in bits is
+ used.
+
+ There are two different values for the two tables, since they code a
+ different number of possibilities each. The literal/length table
+ codes 286 possible values, or in a flat code, a little over eight
+ bits. The distance table codes 30 possible values, or a little less
+ than five bits, flat. The optimum values for speed end up being
+ about one bit more than those, so lbits is 8+1 and dbits is 5+1.
+ The optimum values may differ though from machine to machine, and
+ possibly even between compilers. Your mileage may vary.
+ */
+
+
+static const int lbits = 9; /* bits in base literal/length lookup table
*/
+static const int dbits = 6; /* bits in base distance lookup table */
+
+
+#ifndef ASM_INFLATECODES
+
+int inflate_codes(__G__ __GDEF huft* tl, huft* td, int bl, int
bd)
+// __GDEF
+//struct huft *tl, *td; /* literal/length and distance decoder tables */
+//int bl, bd; /* number of bits decoded by tl[] and td[] */
+/* inflate (decompress) the codes in a deflated (compressed) block.
+ Return an error code or zero if it all goes ok. */
+{
+ register unsigned e; /* table entry flag/number of extra bits */
+ unsigned n, d; /* length and index for copy */
+ unsigned w; /* current window position */
+ struct huft *t; /* pointer to table entry */
+ unsigned ml, md; /* masks for bl and bd bits */
+ u32 b; /* bit buffer */
+ register unsigned k; /* number of bits in bit buffer */
+ int retval = 0; /* error code returned: initialized to "no error"
*/
+
+
+ /* make local copies of globals */
+ b = G.bb; /* initialize bit buffer */
+ k = G.bk;
+ w = G.wp; /* initialize window position */
+
+
+ /* inflate the coded data */
+ ml = mask_bits[bl]; /* precompute masks for speed */
+ md = mask_bits[bd];
+ while (1) /* do until end of block */
+ {
+ NEEDBITS((unsigned)bl)
+ if ((e = (t = tl + ((unsigned)b & ml))->e) > 16)
+ do {
+ if (IS_INVALID_CODE(e))
+ return 1;
+ DUMPBITS(t->b)
+ e -= 16;
+ NEEDBITS(e)
+ } while ((e = (t = t->v.t + ((unsigned)b & mask_bits[e]))->e) > 16);
+ DUMPBITS(t->b)
+ if (e == 16) /* then it's a literal */
+ {
+ redirSlide[w++] = (u8)t->v.n;
+ if (w == wsize)
+ {
+ FLUSH(w);
+ w = 0;
+ }
+ }
+ else /* it's an EOB or a length */
+ {
+ /* exit if end of block */
+ if (e == 15)
+ break;
+
+ /* get length of block to copy */
+ NEEDBITS(e)
+ n = t->v.n + ((unsigned)b & mask_bits[e]);
+ DUMPBITS(e)
+#if (defined(USE_DEFLATE64) && !defined(FUNZIP))
+ if (n == 258 && G.lrec.compression_method == ENHDEFLATED) {
+ /* fetch length bits */
+ NEEDBITS(16)
+ n = ((unsigned)b & 0xffff) + 3;
+ DUMPBITS(16)
+ }
+#endif
+
+ /* decode distance of block to copy */
+ NEEDBITS((unsigned)bd)
+ if ((e = (t = td + ((unsigned)b & md))->e) > 16)
+ do {
+ if (IS_INVALID_CODE(e))
+ return 1;
+ DUMPBITS(t->b)
+ e -= 16;
+ NEEDBITS(e)
+ } while ((e = (t = t->v.t + ((unsigned)b & mask_bits[e]))->e) >
16);
+ DUMPBITS(t->b)
+ NEEDBITS(e)
+ d = w - t->v.n - ((unsigned)b & mask_bits[e]);
+ DUMPBITS(e)
+
+ /* do the copy */
+ do {
+#if (defined(DLL) && !defined(NO_SLIDE_REDIR))
+ if (G.redirect_slide) {/* &= w/ wsize unnecessary & wrong if
redirect */
+ if (d >= wsize)
+ return 1; /* invalid compressed data */
+ n -= (e = (e = wsize - (d > w ? d : w)) > n ? n : e);
+ }
+ else
+#endif
+ n -= (e = (e = wsize - ((d &= wsize-1) > w ? d : w)) > n ? n :
e);
+#ifndef NOMEMCPY
+ if (w - d >= e) /* (this test assumes unsigned comparison)
*/
+ {
+ memcpy(redirSlide + w, redirSlide + d, e);
+ w += e;
+ d += e;
+ }
+ else /* do it slowly to avoid memcpy() overlap
*/
+#endif /* !NOMEMCPY */
+ do {
+ redirSlide[w++] = redirSlide[d++];
+ } while (--e);
+ if (w == wsize)
+ {
+ FLUSH(w);
+ w = 0;
+ }
+ } while (n);
+ }
+ }
+
+
+ /* restore the globals from the locals */
+ G.wp = w; /* restore global window pointer */
+ G.bb = b; /* restore global bit buffer */
+ G.bk = k;
+
+ return retval;
+}
+
+#endif /* ASM_INFLATECODES */
+
+
+
+static int inflate_stored(__G)
+ __GDEF
+/* "decompress" an inflated type 0 (stored) block. */
+{
+ unsigned n; /* number of bytes in block */
+ unsigned w; /* current window position */
+ register u32 b; /* bit buffer */
+ register unsigned k; /* number of bits in bit buffer */
+ int retval = 0; /* error code returned: initialized to "no error"
*/
+
+
+ /* make local copies of globals */
+ Trace((stderr, "\nstored block"));
+ b = G.bb; /* initialize bit buffer */
+ k = G.bk;
+ w = G.wp; /* initialize window position */
+
+
+ /* go to byte boundary */
+ n = k & 7;
+ DUMPBITS(n);
+
+
+ /* get the length and its complement */
+ NEEDBITS(16)
+ n = ((unsigned)b & 0xffff);
+ DUMPBITS(16)
+ NEEDBITS(16)
+ if (n != (unsigned)((~b) & 0xffff))
+ return 1; /* error in compressed data */
+ DUMPBITS(16)
+
+
+ /* read and output the compressed data */
+ while (n--)
+ {
+ NEEDBITS(8)
+ redirSlide[w++] = (u8)b;
+ if (w == wsize)
+ {
+ FLUSH(w);
+ w = 0;
+ }
+ DUMPBITS(8)
+ }
+
+
+ /* restore the globals from the locals */
+ G.wp = w; /* restore global window pointer */
+ G.bb = b; /* restore global bit buffer */
+ G.bk = k;
+
+ return retval;
+}
+
+
+/* Globals for literal tables (built once) */
+/* Moved to globals.h */
+#if 0
+struct huft *fixed_tl = (struct huft *)NULL;
+struct huft *fixed_td;
+int fixed_bl, fixed_bd;
+#endif
+
+int huft_build(__GPRO__ const uint *b, uint n, uint s, const u16* d, const
u16* e, struct huft **t, int *m);
+int huft_free(huft* t); /* inflate.c */
+
+
+static int inflate_fixed(__G)
+ __GDEF
+/* decompress an inflated type 1 (fixed Huffman codes) block. We should
+ either replace this with a custom decoder, or at least precompute the
+ Huffman tables. */
+{
+ /* if first time, set up tables for fixed blocks */
+ Trace((stderr, "\nliteral block"));
+ if (G.fixed_tl == (struct huft *)NULL)
+ {
+ int i; /* temporary variable */
+ unsigned l[288]; /* length list for huft_build */
+
+ /* literal table */
+ for (i = 0; i < 144; i++)
+ l[i] = 8;
+ for (; i < 256; i++)
+ l[i] = 9;
+ for (; i < 280; i++)
+ l[i] = 7;
+ for (; i < 288; i++) /* make a complete, but wrong code set */
+ l[i] = 8;
+ G.fixed_bl = 7;
+ if ((i = huft_build(__G__ l, 288, 257, cplens, cplext,
+ &G.fixed_tl, &G.fixed_bl)) != 0)
+ {
+ G.fixed_tl = (struct huft *)NULL;
+ return i;
+ }
+
+ /* distance table */
+ for (i = 0; i < NUMDISTS; i++) /* make an incomplete code set */
+ l[i] = 5;
+ G.fixed_bd = 5;
+ if ((i = huft_build(__G__ l, NUMDISTS, 0, cpdist, cpdext,
+ &G.fixed_td, &G.fixed_bd)) > 1)
+ {
+ huft_free(G.fixed_tl);
+ G.fixed_td = G.fixed_tl = (struct huft *)NULL;
+ return i;
+ }
+ }
+
+ /* decompress until an end-of-block code */
+ return inflate_codes(__G__ G.fixed_tl, G.fixed_td,
+ G.fixed_bl, G.fixed_bd);
+}
+
+
+
+static int inflate_dynamic(__G)
+ __GDEF
+/* decompress an inflated type 2 (dynamic Huffman codes) block. */
+{
+ int i; /* temporary variables */
+ unsigned j;
+ unsigned l; /* last length */
+ unsigned m; /* mask for bit lengths table */
+ unsigned n; /* number of lengths to get */
+ struct huft *tl; /* literal/length code table */
+ struct huft *td; /* distance code table */
+ int bl; /* lookup bits for tl */
+ int bd; /* lookup bits for td */
+ unsigned nb; /* number of bit length codes */
+ unsigned nl; /* number of literal/length codes */
+ unsigned nd; /* number of distance codes */
+#ifdef PKZIP_BUG_WORKAROUND
+ unsigned ll[288+32]; /* literal/length and distance code lengths */
+#else
+ unsigned ll[286+NUMDISTS]; /* literal/length and distance code lengths */
+#endif
+ register u32 b; /* bit buffer */
+ register unsigned k; /* number of bits in bit buffer */
+ int retval = 0; /* error code returned: initialized to "no error"
*/
+
+
+ /* make local bit buffer */
+ Trace((stderr, "\ndynamic block"));
+ b = G.bb;
+ k = G.bk;
+
+
+ /* read in table lengths */
+ NEEDBITS(5)
+ nl = 257 + ((unsigned)b & 0x1f); /* number of literal/length codes
*/
+ DUMPBITS(5)
+ NEEDBITS(5)
+ nd = 1 + ((unsigned)b & 0x1f); /* number of distance codes */
+ DUMPBITS(5)
+ NEEDBITS(4)
+ nb = 4 + ((unsigned)b & 0xf); /* number of bit length codes */
+ DUMPBITS(4)
+#ifdef PKZIP_BUG_WORKAROUND
+ if (nl > 288 || nd > 32)
+#else
+ if (nl > 286 || nd > NUMDISTS)
+#endif
+ return 1; /* bad lengths */
+
+
+ /* read in bit-length-code lengths */
+ for (j = 0; j < nb; j++)
+ {
+ NEEDBITS(3)
+ ll[border[j]] = (unsigned)b & 7;
+ DUMPBITS(3)
+ }
+ for (; j < 19; j++)
+ ll[border[j]] = 0;
+
+
+ /* build decoding table for trees--single level, 7 bit lookup */
+ bl = 7;
+ retval = huft_build(__G__ ll, 19, 19, NULL, NULL, &tl, &bl);
+ if (bl == 0) /* no bit lengths */
+ retval = 1;
+ if (retval)
+ {
+ if (retval == 1)
+ huft_free(tl);
+ return retval; /* incomplete code set */
+ }
+
+
+ /* read in literal and distance code lengths */
+ n = nl + nd;
+ m = mask_bits[bl];
+ i = l = 0;
+ while ((unsigned)i < n)
+ {
+ NEEDBITS((unsigned)bl)
+ j = (td = tl + ((unsigned)b & m))->b;
+ DUMPBITS(j)
+ j = td->v.n;
+ if (j < 16) /* length of code in bits (0..15) */
+ ll[i++] = l = j; /* save last length in l */
+ else if (j == 16) /* repeat last length 3 to 6 times */
+ {
+ NEEDBITS(2)
+ j = 3 + ((unsigned)b & 3);
+ DUMPBITS(2)
+ if ((unsigned)i + j > n)
+ return 1;
+ while (j--)
+ ll[i++] = l;
+ }
+ else if (j == 17) /* 3 to 10 zero length codes */
+ {
+ NEEDBITS(3)
+ j = 3 + ((unsigned)b & 7);
+ DUMPBITS(3)
+ if ((unsigned)i + j > n)
+ return 1;
+ while (j--)
+ ll[i++] = 0;
+ l = 0;
+ }
+ else /* j == 18: 11 to 138 zero length codes */
+ {
+ NEEDBITS(7)
+ j = 11 + ((unsigned)b & 0x7f);
+ DUMPBITS(7)
+ if ((unsigned)i + j > n)
+ return 1;
+ while (j--)
+ ll[i++] = 0;
+ l = 0;
+ }
+ }
+
+
+ /* free decoding table for trees */
+ huft_free(tl);
+
+
+ /* restore the global bit buffer */
+ G.bb = b;
+ G.bk = k;
+
+
+ /* build the decoding tables for literal/length and distance codes */
+ bl = lbits;
+ retval = huft_build(__G__ ll, nl, 257, cplens, cplext, &tl, &bl);
+ if (bl == 0) /* no literals or lengths */
+ retval = 1;
+ if (retval)
+ {
+ if (retval == 1) {
+ huft_free(tl);
+ }
+ return retval; /* incomplete code set */
+ }
+ bd = dbits;
+ retval = huft_build(__G__ ll + nl, nd, 0, cpdist, cpdext, &td, &bd);
+#ifdef PKZIP_BUG_WORKAROUND
+ if (retval == 1)
+ retval = 0;
+#endif
+ if (bd == 0 && nl > 257) /* lengths but no distances */
+ retval = 1;
+ if (retval)
+ {
+ if (retval == 1) {
+ huft_free(td);
+ }
+ huft_free(tl);
+ return retval;
+ }
+
+ /* decompress until an end-of-block code */
+ retval = inflate_codes(__G__ tl, td, bl, bd);
+
+ /* free the decoding tables, return */
+ huft_free(tl);
+ huft_free(td);
+ return retval;
+}
+
+
+
+static int inflate_block(__G__ __GDEF int* e)
+ /* last block flag */
+/* decompress an inflated block */
+{
+ unsigned t; /* block type */
+ register u32 b; /* bit buffer */
+ register unsigned k; /* number of bits in bit buffer */
+ int retval = 0; /* error code returned: initialized to "no error"
*/
+
+
+ /* make local bit buffer */
+ b = G.bb;
+ k = G.bk;
+
+
+ /* read in last block bit */
+ NEEDBITS(1)
+ *e = (int)b & 1;
+ DUMPBITS(1)
+
+
+ /* read in block type */
+ NEEDBITS(2)
+ t = (unsigned)b & 3;
+ DUMPBITS(2)
+
+
+ /* restore the global bit buffer */
+ G.bb = b;
+ G.bk = k;
+
+
+ /* inflate that block type */
+ if (t == 2)
+ return inflate_dynamic(__G);
+ if (t == 0)
+ return inflate_stored(__G);
+ if (t == 1)
+ return inflate_fixed(__G);
+
+
+ /* bad block type */
+ retval = 2;
+
+ return retval;
+}
+
+
+
+int inflate(__G)
+ __GDEF
+/* decompress an inflated entry */
+{
+ int e; /* last block flag */
+ int r; /* result code */
+#ifdef DEBUG
+ unsigned h = 0; /* maximum struct huft's malloc'ed */
+#endif
+
+#if (defined(DLL) && !defined(NO_SLIDE_REDIR))
+ if (G.redirect_slide)
+ wsize = G.redirect_size, redirSlide = G.redirect_buffer;
+ else
+ wsize = WSIZE, redirSlide = slide; /* how they're #defined if !DLL */
+#endif
+
+ /* initialize window, bit buffer */
+ G.wp = 0;
+ G.bk = 0;
+ G.bb = 0;
+
+
+ /* decompress until the last block */
+ do {
+#ifdef DEBUG
+ G.hufts = 0;
+#endif
+ if ((r = inflate_block(__G__ &e)) != 0)
+ return r;
+#ifdef DEBUG
+ if (G.hufts > h)
+ h = G.hufts;
+#endif
+ } while (!e);
+
+ Trace((stderr, "\n%u bytes in Huffman tables (%d/entry)\n",
+ h * sizeof(struct huft), sizeof(struct huft)));
+
+ /* flush out redirSlide and return (success, unless final FLUSH failed)
*/
+ FLUSH(G.wp);
+ return 0;
+}
+
+
+
+int inflate_free(__G)
+ __GDEF
+{
+ if (G.fixed_tl != (struct huft *)NULL)
+ {
+ huft_free(G.fixed_td);
+ huft_free(G.fixed_tl);
+ G.fixed_td = G.fixed_tl = (struct huft *)NULL;
+ }
+ return 0;
+}
+
+
+/*
+ * GRR: moved huft_build() and huft_free() down here; used by explode()
+ * and fUnZip regardless of whether USE_ZLIB defined or not
+ */
+
+
+/* If BMAX needs to be larger than 16, then h and x[] should be ulg. */
+#define BMAX 16 /* maximum bit length of any code (16 for explode)
*/
+#define N_MAX 288 /* maximum number of codes in any set */
+
+
+int huft_build(__G__ __GDEF const uint* b, uint n, uint s, const u16* d,
const u16* e, huft** t, int* m)
+// __GDEF
+// const unsigned *b; /* code lengths in bits (all assumed <= BMAX) */
+// unsigned n; /* number of codes (assumed <= N_MAX) */
+// unsigned s; /* number of simple-valued codes (0..s-1) */
+// const u16 *d; /* list of base values for non-simple codes */
+// const u16 *e; /* list of extra bits for non-simple codes */
+// struct huft **t; /* result: starting table */
+// int *m; /* maximum lookup bits, returns actual */
+/* Given a list of code lengths and a maximum table size, make a set of
+ tables to decode that set of codes. Return zero on success, one if
+ the given code set is incomplete (the tables are still built in this
+ case), two if the input is invalid (all zero length codes or an
+ oversubscribed set of lengths), and three if not enough memory.
+ The code with value 256 is special, and the tables are constructed
+ so that no bits beyond that code are fetched when that code is
+ decoded. */
+{
+ unsigned a; /* counter for codes of length k */
+ unsigned c[BMAX+1]; /* bit length count table */
+ unsigned el; /* length of EOB code (value 256) */
+ unsigned f; /* i repeats in table every f entries */
+ int g; /* maximum code length */
+ int h; /* table level */
+ register unsigned i; /* counter, current code */
+ register unsigned j; /* counter */
+ register int k; /* number of bits in current code */
+ int lx[BMAX+1]; /* memory for l[-1..BMAX-1] */
+ int *l = lx+1; /* stack of bits per table */
+ register unsigned *p; /* pointer into c[], b[], or v[] */
+ register struct huft *q; /* points to current table */
+ struct huft r; /* table entry for structure assignment */
+ struct huft *u[BMAX]; /* table stack */
+ unsigned v[N_MAX]; /* values in order of bit length */
+ register int w; /* bits before this table == (l * h) */
+ unsigned x[BMAX+1]; /* bit offsets, then code stack */
+ unsigned *xp; /* pointer into x */
+ int y; /* number of dummy codes added */
+ unsigned z; /* number of entries in current table */
+
+
+ /* Generate counts for each bit length */
+ el = n > 256 ? b[256] : BMAX; /* set length of EOB code, if any */
+ memset((char *)c, 0, sizeof(c));
+ p = (unsigned *)b; i = n;
+ do {
+ c[*p]++; p++; /* assume all entries <= BMAX */
+ } while (--i);
+ if (c[0] == n) /* null input--all zero length codes */
+ {
+ *t = (struct huft *)NULL;
+ *m = 0;
+ return 0;
+ }
+
+
+ /* Find minimum and maximum length, bound *m by those */
+ for (j = 1; j <= BMAX; j++)
+ if (c[j])
+ break;
+ k = j; /* minimum code length */
+ if ((unsigned)*m < j)
+ *m = j;
+ for (i = BMAX; i; i--)
+ if (c[i])
+ break;
+ g = i; /* maximum code length */
+ if ((unsigned)*m > i)
+ *m = i;
+
+
+ /* Adjust last length count to fill out codes, if needed */
+ for (y = 1 << j; j < i; j++, y <<= 1)
+ if ((y -= c[j]) < 0)
+ return 2; /* bad input: more codes than bits */
+ if ((y -= c[i]) < 0)
+ return 2;
+ c[i] += y;
+
+
+ /* Generate starting offsets into the value table for each length */
+ x[1] = j = 0;
+ p = c + 1; xp = x + 2;
+ while (--i) { /* note that i == g from above */
+ *xp++ = (j += *p++);
+ }
+
+
+ /* Make a table of values in order of bit lengths */
+ memset((char *)v, 0, sizeof(v));
+ p = (unsigned *)b; i = 0;
+ do {
+ if ((j = *p++) != 0)
+ v[x[j]++] = i;
+ } while (++i < n);
+ n = x[g]; /* set n to length of v */
+
+
+ /* Generate the Huffman codes and for each, make the table entries */
+ x[0] = i = 0; /* first Huffman code is zero */
+ p = v; /* grab values in bit order */
+ h = -1; /* no tables yet--level -1 */
+ w = l[-1] = 0; /* no bits decoded yet */
+ u[0] = (struct huft *)NULL; /* just to keep compilers happy */
+ q = (struct huft *)NULL; /* ditto */
+ z = 0; /* ditto */
+
+ /* go through the bit lengths (k already is bits in shortest code) */
+ for (; k <= g; k++)
+ {
+ a = c[k];
+ while (a--)
+ {
+ /* here i is the Huffman code of length k bits for value *p */
+ /* make tables up to required level */
+ while (k > w + l[h])
+ {
+ w += l[h++]; /* add bits already decoded */
+
+ /* compute minimum size table less than or equal to *m bits */
+ z = (z = g - w) > (unsigned)*m ? *m : z; /* upper limit */
+ if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */
+ { /* too few codes for k-w bit table */
+ f -= a + 1; /* deduct codes from patterns left */
+ xp = c + k;
+ while (++j < z) /* try smaller tables up to z bits */
+ {
+ if ((f <<= 1) <= *++xp)
+ break; /* enough codes to use up j bits */
+ f -= *xp; /* else deduct codes from patterns */
+ }
+ }
+ if ((unsigned)w + j > el && (unsigned)w < el)
+ j = el - w; /* make EOB code end at table */
+ z = 1 << j; /* table entries for j-bit table */
+ l[h] = j; /* set table size in stack */
+
+ /* allocate and link in new table */
+ if ((q = (struct huft *)malloc((z + 1)*sizeof(struct huft))) ==
+ (struct huft *)NULL)
+ {
+ if (h)
+ huft_free(u[0]);
+ return 3; /* not enough memory */
+ }
+#ifdef DEBUG
+ G.hufts += z + 1; /* track memory usage */
+#endif
+ *t = q + 1; /* link to list for huft_free() */
+ *(t = &(q->v.t)) = (struct huft *)NULL;
+ u[h] = ++q; /* table starts after link */
+
+ /* connect to last table, if there is one */
+ if (h)
+ {
+ x[h] = i; /* save pattern for backing up */
+ r.b = (u8)l[h-1]; /* bits to dump before this table */
+ r.e = (u8)(16 + j); /* bits in this table */
+ r.v.t = q; /* pointer to this table */
+ j = (i & ((1 << w) - 1)) >> (w - l[h-1]);
+ u[h-1][j] = r; /* connect to last table */
+ }
+ }
+
+ /* set up table entry in r */
+ r.b = (u8)(k - w);
+ if (p >= v + n)
+ r.e = INVALID_CODE; /* out of values--invalid code */
+ else if (*p < s)
+ {
+ r.e = (u8)(*p < 256 ? 16 : 15); /* 256 is end-of-block code */
+ r.v.n = (u16)*p++; /* simple code is just the value
*/
+ }
+ else
+ {
+ r.e = (u8)e[*p - s]; /* non-simple--look up in lists */
+ r.v.n = d[*p++ - s];
+ }
+
+ /* fill code-like entries with r */
+ f = 1 << (k - w);
+ for (j = i >> w; j < z; j += f)
+ q[j] = r;
+
+ /* backwards increment the k-bit code i */
+ for (j = 1 << (k - 1); i & j; j >>= 1)
+ i ^= j;
+ i ^= j;
+
+ /* backup over finished tables */
+ while ((i & ((1 << w) - 1)) != x[h])
+ w -= l[--h]; /* don't need to update q */
+ }
+ }
+
+
+ /* return actual size of base table */
+ *m = l[0];
+
+
+ /* Return true (1) if we were given an incomplete table */
+ return y != 0 && g != 1;
+}
+
+
+
+int huft_free(huft* t)
+//struct huft *t; /* table to free */
***The diff for this file has been truncated for email.***
=======================================
--- /dev/null
+++ /src/BlueZip/Inflate.h Thu Apr 15 13:50:08 2004
@@ -0,0 +1,422 @@
+//privzip.h
+
+#define WSIZE 0x8000 /* window size--must be a power of two, and */
+
+
+#define MAX_BITS 13 /* used in unshrink() */
+#define HSIZE (1 << MAX_BITS) /* size of global work area */
+ union work {
+ struct { /* unshrink(): */
+ int Parent[HSIZE]; /* (8192 * sizeof(shrint)) == 16KB minimum */
+ u8 value[HSIZE]; /* 8KB */
+ u8 Stack[HSIZE]; /* 8KB */
+ } shrink; /* total = 32KB minimum; 80KB on
Cray/Alpha */
+ u8 Slide[WSIZE]; /* explode(), inflate(), unreduce() */
+ };
+
+
+
+/*
+
+ Copyright (c) 1990-2001 Info-ZIP. All rights reserved.
+
+ See the accompanying file LICENSE, version 2000-Apr-09 or later
+ (the contents of which are also included in unzip.h) for terms of use.
+ If, for some reason, all these files are missing, the Info-ZIP license
+ also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
+*/
+/*---------------------------------------------------------------------------
+
+ globals.h
+
+ There is usually no need to include this file since unzip.h includes it.
+
+ This header file is used by all of the UnZip source files. It contains
+ a struct definition that is used to "house" all of the global variables.
+ This is done to allow for multithreaded environments (OS/2, NT, Win95,
+ Unix) to call UnZip through an API without a semaphore. REENTRANT should
+ be defined for all platforms that require this.
+
+ GLOBAL CONSTRUCTOR AND DESTRUCTOR (API WRITERS READ THIS!!!)
+ ------------------------------------------------------------
+
+ No, it's not C++, but it's as close as we can get with K&R.
+
+ The main() of each process that uses these globals must include the
+ CONSTRUCTGLOBALS; statement. This will malloc enough memory for the
+ structure and initialize any variables that require it. This must
+ also be done by any API function that jumps into the middle of the
+ code.
+
+ The DESTROYGLOBALS; statement should be inserted before EVERY "EXIT(n)".
+ Naturally, it also needs to be put before any API returns as well.
+ In fact, it's much more important in API functions since the process
+ will NOT end, and therefore the memory WON'T automatically be freed
+ by the operating system.
+
+ USING VARIABLES FROM THE STRUCTURE
+ ----------------------------------
+
+ All global variables must now be prefixed with `G.' which is either a
+ global struct (in which case it should be the only global variable) or
+ a macro for the value of a local pointer variable that is passed from
+ function to function. Yes, this is a pain. But it's the only way to
+ allow full reentrancy.
+
+ ADDING VARIABLES TO THE STRUCTURE
+ ---------------------------------
+
+ If you make the inclusion of any variables conditional, be sure to only
+ check macros that are GUARANTEED to be included in every module.
+ For instance, newzip and pwdarg are needed only if CRYPT is TRUE,
+ but this is defined after unzip.h has been read. If you are not careful,
+ some modules will expect your variable to be part of this struct while
+ others won't. This will cause BIG problems. (Inexplicable crashes at
+ strange times, car fires, etc.) When in doubt, always include it!
+
+ Note also that UnZipSFX needs a few variables that UnZip doesn't.
However,
+ it also includes some object files from UnZip. If we were to
conditionally
+ include the extra variables that UnZipSFX needs, the object files from
+ UnZip would not mesh with the UnZipSFX object files. Result: we just
+ include the UnZipSFX variables every time. (It's only an extra 4 bytes
+ so who cares!)
+
+ ADDING FUNCTIONS
+ ----------------
+
+ To support this new global struct, all functions must now conditionally
+ pass the globals pointer (pG) to each other. This is supported by 5
macros:
+ __GPRO, __GPRO__, __G, __G__ and __GDEF. A function that needs no other
+ parameters would look like this:
+
+ int extract_or_test_files(__G)
+ __GDEF
+ {
+ ... stuff ...
+ }
+
+ A function with other parameters would look like:
+
+ int memextract(__G__ tgt, tgtsize, src, srcsize)
+ __GDEF
+ u8 *tgt, *src;
+ u32 tgtsize, srcsize;
+ {
+ ... stuff ...
+ }
+
+ In the Function Prototypes section of unzpriv.h, you should use __GPRO
and
+ __GPRO__ instead:
+
+ int uz_opts OF((__GPRO__ int *pargc, char
***pargv));
+ int process_zipfiles OF((__GPRO));
+
+ Note that there is NO comma after __G__ or __GPRO__ and no semi-colon
after
+ __GDEF. I wish there was another way but I don't think there is.
+
+
+ TESTING THE CODE
+ -----------------
+
+ Whether your platform requires reentrancy or not, you should always try
+ building with REENTRANT defined if any functions have been added. It is
+ pretty easy to forget a __G__ or a __GDEF and this mistake will only show
+ up if REENTRANT is defined. All platforms should run with REENTRANT
+ defined. Platforms that can't take advantage of it will just be paying
+ a performance penalty needlessly.
+
+ SIGNAL MADNESS
+ --------------
+
+ This whole pointer passing scheme falls apart when it comes to SIGNALs.
+ I handle this situation 2 ways right now. If you define USETHREADID,
+ UnZip will include a 64-entry table. Each entry can hold a global
+ pointer and thread ID for one thread. This should allow up to 64
+ threads to access UnZip simultaneously. Calling DESTROYGLOBALS()
+ will free the global struct and zero the table entry. If somebody
+ forgets to call DESTROYGLOBALS(), this table will eventually fill up
+ and UnZip will exit with an error message. A good way to test your
+ code to make sure you didn't forget a DESTROYGLOBALS() is to change
+ THREADID_ENTRIES to 3 or 4 in globals.c, making the table real small.
+ Then make a small test program that calls your API a dozen times.
+
+ Those platforms that don't have threads still need to be able to compile
+ with REENTRANT defined to test and see if new code is correctly written
+ to work either way. For these platforms, I simply keep a global pointer
+ called GG that points to the Globals structure. Good enough for testing.
+
+ I believe that NT has thread level storage. This could probably be used
+ to store a global pointer for the sake of the signal handler more cleanly
+ than my table approach.
+
+
---------------------------------------------------------------------------*/
+
+#ifndef __globals_h
+#define __globals_h
+
+#ifdef USE_ZLIB
+# include "zlib.h"
+#endif
+
+
+/*************/
+/* Globals */
+/*************/
+
+typedef struct Globals {
+#ifdef DLL
+ zvoid *callerglobs; /* pointer to structure of pass-through global
vars */
+#endif
+
+
+#ifndef FUNZIP
+ /* command options specific to the high level command line interface */
+#ifdef MORE
+ int M_flag; /* -M: built-in "more" function */
+#endif
+
+ /* internal flags and general globals */
+#ifdef MORE
+ int height; /* check for SIGWINCH, etc., eventually... */
+ int lines; /* count of lines displayed on current screen */
+# if (defined(SCREENWIDTH) && defined(SCREENLWRAP))
+ int width;
+ int chars; /* count of screen characters in current line */
+# endif
+#endif /* MORE */
+#if (defined(IZ_CHECK_TZ) && defined(USE_EF_UT_TIME))
+ int tz_is_valid; /* indicates that timezone info can be used */
+#endif
+ int noargs; /* did true command line have *any* arguments? */
+ unsigned filespecs; /* number of real file specifications to be
matched */
+ unsigned xfilespecs; /* number of excluded filespecs to be matched */
+ int process_all_files;
+ int overwrite_mode; /* 0 - query, 1 - always, 2 - never */
+ int create_dirs; /* used by main(), mapname(), checkdir() */
+ int extract_flag;
+ int newzip; /* reset in extract.c; used in crypt.c */
+
+ //NEIL: WHAT ARE THESE?
+ //LONGINT real_ecrec_offset;
+ //LONGINT expect_ecrec_offset;
+ long csize; /* used by decompr. (NEXTBYTE): must be signed */
+ long used_csize; /* used by extract_or_test_member(), explode() */
+
+#ifdef DLL
+ int fValidate; /* true if only validating an archive */
+ int filenotfound;
+ int redirect_data; /* redirect data to memory buffer */
+ int redirect_text; /* redirect text output to buffer */
+# ifndef NO_SLIDE_REDIR
+ int redirect_slide; /* redirect decompression area to mem buffer */
+ unsigned _wsize;
+# endif
+ unsigned redirect_size; /* size of redirected output buffer */
+ u8 *redirect_buffer; /* pointer to head of allocated buffer */
+ u8 *redirect_pointer; /* pointer past end of written data */
+# ifndef NO_SLIDE_REDIR
+ u8 *redirect_sldptr; /* head of decompression slide buffer */
+# endif
+# ifdef OS2DLL
+ cbList(processExternally); /* call-back list */
+# endif
+#endif /* DLL */
+
+ char **pfnames;
+ char **pxnames;
+ char sig[4];
+ char answerbuf[10];
+// min_info info[DIR_BLKSIZ];
+// min_info *pInfo;
+#endif /* !FUNZIP */
+ union work area; /* see unzpriv.h for definition of
work */
+
+#ifdef FUNZIP
+ FILE *in; /* file descriptor of compressed
stream */
+#endif
+ u8 *inbuf; /* input buffer (any size is OK) */
+ u8 *inptr; /* pointer into input buffer */
+ int incnt;
+
+#ifndef FUNZIP
+ u32 bitbuf;
+ int bits_left; /* unreduce and unshrink only */
+ int zipeof;
+ char *argv0; /* used for NT and EXE_EXTENSION */
+ char *wildzipfn;
+ char *zipfn; /* GRR: WINDLL: must nuke any malloc'd zipfn...
*/
+#ifdef USE_STRM_INPUT
+ FILE *zipfd; /* zipfile file descriptor */
+#else
+ int zipfd; /* zipfile file handle */
+#endif
+// LONGINT ziplen;
+ //LONGINT cur_zipfile_bufstart; /* extract_or_test, readbuf,
ReadByte */
+// LONGINT extra_bytes; /* used in unzip.c, misc.c */
+ u8 *extra_field; /* Unix, VMS, Mac, OS/2, Acorn, ... */
+ u8 *hold;
+
+// local_file_hdr lrec; /* used in unzip.c, extract.c */
+// cdir_file_hdr crec; /* used in unzip.c, extract.c, misc.c
*/
+// ecdir_rec ecrec; /* used in unzip.c, extract.c */
+// struct stat statbuf; /* used by main, mapname,
check_for_newer */
+
+ int mem_mode;
+ u8 *outbufptr; /* extract.c static */
+ u32 outsize; /* extract.c static */
+ int reported_backslash; /* extract.c static */
+ int disk_full;
+ int newfile;
+
+ int didCRlast; /* fileio static */
+ u32 numlines; /* fileio static: number of lines
printed */
+ int sol; /* fileio static: at start of line */
+ int no_ecrec; /* process static */
+#ifdef SYMLINKS
+ int symlnk;
+#endif
+#ifdef NOVELL_BUG_FAILSAFE
+ int dne; /* true if stat() says file doesn't
exist */
+#endif
+
+ FILE *outfile;
+ u8 *outbuf;
+ u8 *realbuf;
+
+#ifndef VMS /* if SMALL_MEM, outbuf2 is initialized
in */
+ u8 *outbuf2; /* process_zipfiles() (never changes);
*/
+#endif /* else malloc'd ONLY if unshrink and
-a */
+#endif /* !FUNZIP */
+ u8 *outptr;
+ u32 outcnt; /* number of chars stored in outbuf */
+#ifndef FUNZIP
+ char filename[MAX_PATH]; /* also used by NT for temporary SFX
path */
+
+#ifdef CMS_MVS
+ char *tempfn; /* temp file used; erase on close */
+#endif
+
+ char *key; /* crypt static: decryption password or NULL */
+ int nopwd; /* crypt static */
+#endif /* !FUNZIP */
+ u32 keys[3]; /* crypt static: keys defining pseudo-random
sequence */
+
+#if (!defined(DOS_FLX_H68_NLM_OS2_W32) && !defined(AMIGA)
&& !defined(RISCOS))
+#if (!defined(MACOS) && !defined(ATARI) && !defined(VMS))
+ int echofd; /* ttyio static: file descriptor whose echo is off
*/
+#endif /* !(MACOS || ATARI || VMS) */
+#endif /* !(DOS_FLX_H68_NLM_OS2_W32 || AMIGA || RISCOS) */
+
+ unsigned hufts; /* track memory usage */
+
+#ifdef USE_ZLIB
+ int inflInit; /* inflate static: zlib inflate()
initialized */
+ z_stream dstrm; /* inflate global: decompression stream */
+#else
+ struct huft *fixed_tl; /* inflate static */
+ struct huft *fixed_td; /* inflate static */
+ int fixed_bl, fixed_bd; /* inflate static */
+ unsigned wp; /* inflate static: current position in slide
*/
+ u32 bb; /* inflate static: bit buffer */
+ unsigned bk; /* inflate static: bits in bit buffer */
+#endif /* ?USE_ZLIB */
+
+#ifndef FUNZIP
+#ifdef SMALL_MEM
+ char rgchBigBuffer[512];
+ char rgchSmallBuffer[96];
+ char rgchSmallBuffer2[160]; /* boosted to 160 for local3[] in unzip.c
*/
+#endif
+
+ // MsgFn *message;
+ //InputFn *input;
+// PauseFn *mpause;
+ // PasswdFn *decr_passwd;
+ //StatCBFn *statreportcb;
+#ifdef WINDLL
+ LPUSERFUNCTIONS lpUserFunctions;
+#endif
+
+ int incnt_leftover; /* so improved NEXTBYTE does not waste input
*/
+ u8 *inptr_leftover;
+
+#ifdef VMS_TEXT_CONV
+ int VMS_line_state; /* so native VMS variable-length text files
are */
+ int VMS_line_length; /* readable on other platforms */
+ int VMS_line_pad;
+#endif
+#endif /* !FUNZIP */
+
+#ifdef SYSTEM_SPECIFIC_GLOBALS
+ SYSTEM_SPECIFIC_GLOBALS
+#endif
+
+} Uz_Globs; /* end of struct Globals */
+
+
+/***************************************************************************/
+
+
+#ifdef FUNZIP
+# if (!defined(USE_ZLIB) || defined(USE_OWN_CRCTAB))
+ extern ZCONST u32 near crc_32_tab[256];
+# else
+ extern ZCONST u32 Far *crc_32_tab;
+# endif
+# define CRC_32_TAB crc_32_tab
+#else
+# define CRC_32_TAB G.crc_32_tab
+#endif
+
+
+Uz_Globs *globalsCtor(void);
+
+/* pseudo constant sigs; they are initialized at runtime so unzip
executable
+ * won't look like a zipfile
+ */
+extern char local_hdr_sig[4];
+extern char central_hdr_sig[4];
+extern char end_central_sig[4];
+/* extern char extd_local_sig[4]; NOT USED YET */
+
+#ifdef REENTRANT
+# define G (*(Uz_Globs *)pG)
+# define __G pG
+# define __G__ pG,
+# define __GPRO Uz_Globs *pG
+# define __GPRO__ Uz_Globs *pG,
+# define __GDEF Uz_Globs *pG;
+# ifdef USETHREADID
+ extern int lastScan;
+ void deregisterGlobalPointer OF((__GPRO));
+ Uz_Globs *getGlobalPointer OF((void));
+# define GETGLOBALS() Uz_Globs *pG = getGlobalPointer();
+# define DESTROYGLOBALS() {free_G_buffers(pG);
deregisterGlobalPointer(pG);}
+# else
+ extern Uz_Globs *GG;
+# define GETGLOBALS() Uz_Globs *pG = GG;
+# define DESTROYGLOBALS() {free_G_buffers(pG); free(pG);}
+# endif /* ?USETHREADID */
+# define CONSTRUCTGLOBALS() Uz_Globs *pG = globalsCtor()
+#else /* !REENTRANT */
+ extern Uz_Globs G;
+# define __G
+# define __G__
+# define __GPRO void
+# define __GPRO__
+# define __GDEF
+# define GETGLOBALS()
+# define CONSTRUCTGLOBALS() globalsCtor()
+# define DESTROYGLOBALS()
+#endif /* ?REENTRANT */
+
+#define uO G.UzO
+
+#endif /* __globals_h */
+
+
+//COPIED FROM Inflate.cpp by Neil
+int inflate();
+void Neil_Init(File Out, File In);
+
+extern struct Globals G;
=======================================
--- /dev/null
+++ /src/BlueZip/License.txt Thu Apr 15 13:50:08 2004
@@ -0,0 +1,49 @@
+This is version 1999-Oct-05 of the Info-ZIP copyright and license.
+The definitive version of this document should be available at
+ftp://ftp.cdrom.com/pub/infozip/license.html indefinitely.
+
+
+Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
+
+For the purposes of this copyright and license, "Info-ZIP" is defined as
+the following set of individuals:
+
+ Mark Adler, John Bush, Karl Davis, Harald Denker, Jean-Michel Dubois,
+ Jean-loup Gailly, Hunter Goatley, Ian Gorman, Chris Herborth, Dirk
Haase,
+ Greg Hartwig, Robert Heath, Jonathan Hudson, Paul Kienitz, David
Kirschbaum,
+ Johnny Lee, Onno van der Linden, Igor Mandrichenko, Steve P. Miller,
+ Sergio Monesi, Keith Owens, George Petrov, Greg Roelofs, Kai Uwe Rommel,
+ Steve Salisbury, Dave Smith, Christian Spieler, Antoine Verheijen,
+ Paul von Behren, Rich Wales, Mike White
+
+This software is provided "as is," without warranty of any kind, express
+or implied. In no event shall Info-ZIP or its contributors be held liable
+for any direct, indirect, incidental, special or consequential damages
+arising out of the use of or inability to use this software.
+
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the following restrictions:
+
+ 1. Redistributions of source code must retain the above copyright
notice,
+ definition, disclaimer, and this list of conditions.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, definition, disclaimer, and this list of conditions in
+ documentation and/or other materials provided with the distribution.
+
+ 3. Altered versions--including, but not limited to, ports to new
operating
+ systems, existing ports with new graphical interfaces, and dynamic,
+ shared, or static library versions--must be plainly marked as such
+ and must not be misrepresented as being the original source. Such
+ altered versions also must not be misrepresented as being Info-ZIP
+ releases--including, but not limited to, labeling of the altered
+ versions with the names "Info-ZIP" (or any variation thereof,
including,
+ but not limited to, different capitalizations), "Pocket
UnZip," "WiZ"
+ or "MacZip" without the explicit permission of Info-ZIP. Such
altered
+ versions are further prohibited from misrepresentative use of the
+ Zip-Bugs or Info-ZIP e-mail addresses or of the Info-ZIP URL(s).
+
+ 4. Info-ZIP retains the right to use the
names "Info-ZIP," "Zip," "UnZip,"
+ "WiZ," "Pocket UnZip," "Pocket Zip," and "MacZip" for its own
source and
+ binary releases.
=======================================
--- /dev/null
+++ /src/BlueZip/ReadZip.cpp Thu Apr 15 13:50:08 2004
@@ -0,0 +1,136 @@
+#include "BlueHead.h"
+
+bool BlueZip::Read()
+{
+ File f = FileOpenRead(FileName); //ZIP
file
+
+ if (!FileValid(f))
+ {
+ ErrMsg("Failed to open the ZIP file");
+ return false;
+ }
+
+ bool Res = ScanZip(f);
+ FileClose(f);
+ return Res;
+}
+
+
+bool BlueZip::ScanZip(File f)
+{
+ int i, n; //Global enumeration variable
+ long sig; //signature variable
+
+ //TASK 1: Find the last occurance of 'sigEnd' in the file
+ //Use a 4096 character buffer for decent sized transfers
+ const int BlockSize = 4096;
+
+ char* EndBuffer = new char[BlockSize + 3]; //do not overflow
+ int fLen = FileLen(f);
+ EndBuffer[0] = 0; //ensure you do not match already present static
+
+ do
+ {
+ //Copy over the trailing information
+ EndBuffer[BlockSize+0] = EndBuffer[0];
+ EndBuffer[BlockSize+1] = EndBuffer[2];
+ EndBuffer[BlockSize+2] = EndBuffer[1];
+
+ if (fLen >= BlockSize)
+ {
+ n = 0;
+ fLen -= BlockSize;
+ SeekBeg(f, fLen);
+ FileRead(f, EndBuffer, BlockSize);
+ }
+ else
+ {
+ n = BlockSize - fLen;
+ SeekBeg(f, 0);
+ FileRead(f, &EndBuffer[n], fLen);
+ fLen = 0;
+ }
+
+ //Look for the end signature
+ for (i = BlockSize; i >= n; i--)
+ {
+ if (stream32(EndBuffer, i) == sigEnd)
+ {
+ //Use n as a temp variable
+ n = fLen + (i-n) + 4;
+ fLen = -1;
+ SeekBeg(f, n); //Skip over the signature
+ break; //for
+ }
+ }
+ }
+ while (fLen > 0);
+ delete[] EndBuffer;
+ //warn: garbage at the end of the file ignored
+
+ if (fLen == 0)
+ {
+ ErrMsg("Failed to find the end signature");
+ return false;
+ }
+
+ //END TASK 1
+
+ //TASK 2: Read in the end header
+ ReadEnd(f);
+
+ //Check for mutliple disks
+ if (data.DiskNum != data.Count)
+ {
+ ErrMsg("Does not support multiple disk archives");
+ return false;
+ }
+ //END TASK 2
+
+ //TASK 3: Read central header
+ //Goto the central header
+ //This is directly before the footer
+ n -= data.Size + 4;
+ SeekBeg(f, n);
+ FilePosDelta = n - data.Offset;
+
+#ifdef _DEBUG
+ i = 0; //do a manual count of the files
+#endif
+
+ FileRead(f, &sig, 4);
+ zList** next = &Files;
+
+ while (sig == sigCentral)
+ {
+ zList* z = new zList;
+
+ // Insert into list
+ *next = z;
+ next = &z->next;
+
+ z->ReadCentral(f);
+
+#ifdef _DEBUG //Maintain a count of the files
+ i++;
+#endif
+
+ // Read next signature
+ FileRead(f, &sig, 4);
+ }
+ //END TASK 3
+
+ AssertD(data.Count == i); //Unexpected number of items
+
+ //Neil alteration
+ //DO NOT READ IN THE LOCAL HEADERS, assume they are correct
+ //and do not contain any different information from the
+ //central ones
+
+ //Results: Speed up, smaller size
+ // Less code for me to write
+ // Does not detect badly encoded ZIP files (but does maintain
them)
+
+
+ return true;
+}
=======================================
--- /dev/null
+++ /src/BlueZip/Store.cpp Thu Apr 15 13:50:08 2004
@@ -0,0 +1,71 @@
+#include "BlueHead.h"
+#include <stdio.h>
+#include "inflate.h"
+
+void FileDataCopy(File From, File To, int Len)
+{
+ //Optimisation possible, use static buffers from Deflate/Inflate
+ const int BlockSize = 4096;
+ u8 Buffer[BlockSize];
+
+ int i;
+ while(Len != 0)
+ {
+ i = min(Len, BlockSize);
+ FileRead(From, Buffer, i);
+ FileWrite(To, Buffer, i);
+
+ CRC(Buffer, i); //Perform the
+
+ Len -= i;
+ }
+}
+
+
+void ReadStore(File In, File Out, zList* z)
+{
+ //Read from In - the zip file
+ //In is at the start of the file (i.e. sigLocal)
+ //Out is at the begining, currently the length is 0
+ //z contains the table entry
+
+ datCentral hLocal;
+ u32 sig;
+ FileRead(In, &sig, 4);
+ Assert(sig == sigLocal);
+
+ hLocal.ReadLocal(In);
+
+ //Skip to the begining of the actual data
+ SeekCur(In, hLocal.lFileName + hLocal.lExtra);
+
+ //Check that WinZip would accept this as a file, that has been stored
+ if (hLocal.CompMode == compStore)
+ {
+ Assert(hLocal.CompSize == hLocal.OrigSize);
+
+ FileDataCopy(In, Out, hLocal.CompSize);
+ }
+ else
+ {
+ //use the Zip inflate routine
+ //use the global G
+ Neil_Init(Out, In);
+
+ //If not 0 then a failure, I think
+ inflate();
+ }
+}
+
+void WriteStore(File In, File Out, zList* z)
+{
+ //Read from In - the binary file
+ //In is at the begining
+ //Out is the ZIP file, and is ready to receive data
+ //z contains the table entry, including the correct OrigSize
+ //must set CompMode, CompSize
+
+ z->data.CompMode = compStore;
+ z->data.CompSize = z->data.OrigSize;
+ FileDataCopy(In, Out, z->data.OrigSize);
+}
=======================================
--- /dev/null
+++ /src/BlueZip/Structs.cpp Thu Apr 15 13:50:08 2004
@@ -0,0 +1,147 @@
+#include "BlueHead.h"
+
+#define Set16(pos, res) \
+ *((u16*) (&data[pos])) = res
+
+#define Set32(pos, res) \
+ *((u32*) (&data[pos])) = res
+
+#define Get16(pos) \
+ *((u16*) (&data[pos]))
+
+#define Get32(pos) \
+ *((u32*) (&data[pos]))
+
+
+
+void datCentral::ReadLocal(File f)
+{
+ char data[ldatLocal]; //26
+ FileRead(f, data, ldatLocal);
+
+ //16
+ VerNeed = Get16(0);
+ Flags = Get16(2);
+ CompMode = Get16(4);
+ Time = Get16(6);
+ Date = Get16(8);
+ //32
+ CRC = Get32(10);
+ CompSize = Get32(14);
+ OrigSize = Get32(18);
+ //16
+ lFileName = Get16(22);
+ lExtra = Get16(24);
+}
+
+void datCentral::WriteLocal(File f)
+{
+ char data[ldatLocal]; //26
+
+ //16
+ Set16(0, VerNeed);
+ Set16(2, Flags);
+ Set16(4, CompMode);
+ Set16(6, Time);
+ Set16(8, Date);
+ //32
+ Set32(10, CRC);
+ Set32(14, CompSize);
+ Set32(18, OrigSize);
+ //16
+ Set16(22, lFileName);
+ Set16(24, lExtra);
+
+ FileWrite(f, data, ldatLocal);
+}
+
+void datCentral::Read(File f)
+{
+ char data[ldatCentral]; //42
+ FileRead(f, data, ldatCentral);
+
+ //16
+ VerMake = Get16(0);
+ VerNeed = Get16(2);
+ Flags = Get16(4);
+ CompMode = Get16(6);
+ Time = Get16(8);
+ Date = Get16(10);
+ //32
+ CRC = Get32(12);
+ CompSize = Get32(16);
+ OrigSize = Get32(20);
+ //16
+ lFileName = Get16(24);
+ lExtra = Get16(26);
+ lComment = Get16(28);
+ Disk = Get16(30);
+ IntAttr = Get16(32);
+ //32
+ ExtAttr = Get32(34);
+ Offset = Get32(38);
+}
+
+void datCentral::Write(File f)
+{
+ char data[ldatCentral]; //42
+
+ //16
+ Set16(0, VerMake);
+ Set16(2, VerNeed);
+ Set16(4, Flags);
+ Set16(6, CompMode);
+ Set16(8, Time);
+ Set16(10, Date);
+ //32
+ Set32(12, CRC);
+ Set32(16, CompSize);
+ Set32(20, OrigSize);
+ //16
+ Set16(24, lFileName);
+ Set16(26, lExtra);
+ Set16(28, lComment);
+ Set16(30, Disk);
+ Set16(32, IntAttr);
+ //32
+ Set32(34, ExtAttr);
+ Set32(38, Offset);
+
+ FileWrite(f, data, ldatCentral);
+}
+
+void datEnd::Read(File f)
+{
+ char data[ldatEnd]; //18
+ FileRead(f, data, ldatEnd);
+
+ //16
+ DiskNo = Get16(0);
+ DiskOne = Get16(2);
+ DiskNum = Get16(4);
+ Count = Get16(6);
+ //32
+ Size = Get32(8);
+ Offset = Get32(12);
+ //16
+ lComment = Get16(16);
+}
+
+void datEnd::Write(File f)
+{
+ char data[ldatEnd]; //18
+
+ //16
+ Set16(0, DiskNo);
+ Set16(2, DiskOne);
+ Set16(4, DiskNum);
+ Set16(6, Count);
+ //32
+ Set32(8, Size);
+ Set32(12, Offset);
+ //16
+ Set16(16, lComment);
+
+ FileWrite(f, data, ldatEnd);
+}
+
=======================================
--- /dev/null
+++ /src/BlueZip/Structs.h Thu Apr 15 13:50:08 2004
@@ -0,0 +1,98 @@
+
+//Compression modes
+enum CompModes
+{
+ compStore = 0,
+ compDeflate = 8,
+};
+
+//Signatures
+enum Signature
+{
+ sigLocal = 0x04034b50,
+ sigCentral = 0x02014b50,
+ sigEnd = 0x06054b50,
+ sigExtra = 0x08074b50, //Local
+};
+
+//Use actual headers
+
+//LOCHEAD 26, sizeof(datLocal) = 26
+const int ldatLocal = 26;
+/* Reference only: Use dat Central with some unused fields
+class datLocal
+{
+public:
+ u16 VerNeed; //LOCVER - Version needed to extract
+ u16 Flags; //LOCFLG - encrypt, deflate flags
+ u16 CompMode; //LOCHOW - compression method
+ u16 Time; //LOCTIM - last modified file time, DOS format
+ u16 Date; //LOCDAT - last modified file date, DOS format
+ u32 CRC; //LOCCRC - uncompressed crc-32 for file
+ u32 CompSize; //LOCSIZ - compressed size in zip file
+ u32 OrigSize; //LOCLEN - uncompressed size
+ u16 lFileName; //LOCNAM - length of filename
+ u16 lExtra; //LOCEXT - length of extra field
+
+ void Read(File f);
+ void Write(File f);
+};
+*/
+
+/* NEIL: Not currently required
+struct datExtra
+{
+ u32 CRC; //EXTCRC - uncompressed crc-32 for file
+ u32 CompSize; //EXTSIZ - compressed size in zip file
+ u32 OrigSize; //EXTLEN - uncompressed size
+};*/
+
+//CENHEAD 42, sizeof(datCentral) = 42
+const int ldatCentral = 42;
+class datCentral
+{
+public:
+ u16 VerMake; //CENVEM - version made by
+
+ //SAME AS LOCAL
+ u16 VerNeed; //LOCVER - Version needed to extract
+ u16 Flags; //LOCFLG - encrypt, deflate flags
+ u16 CompMode; //LOCHOW - compression method
+ u16 Time; //LOCTIM - last modified file time, DOS format
+ u16 Date; //LOCDAT - last modified file date, DOS format
+ u32 CRC; //LOCCRC - uncompressed crc-32 for file
+ u32 CompSize; //LOCSIZ - compressed size in zip file
+ u32 OrigSize; //LOCLEN - uncompressed size
+ u16 lFileName; //LOCNAM - length of filename
+ u16 lExtra; //LOCEXT - length of extra field
+ //END
+
+ u16 lComment; //CENCOM - file comment length
+ u16 Disk; //CENDSK - disk number start
+ u16 IntAttr; //CENATT - internal file attributes
+ u32 ExtAttr; //CENATX - external file attributes
+ u32 Offset; //CENOFF - relative offset of local header
+
+ void Read(File f);
+ void Write(File f);
+
+ void ReadLocal(File f);
+ void WriteLocal(File f);
+};
+
+//ENDHEAD 18, sizeof(datEnd) = 18
+const int ldatEnd = 18;
+class datEnd
+{
+public:
+ u16 DiskNo; //ENDDSK - number of this disk
+ u16 DiskOne; //ENDBEG - number of the starting disk
+ u16 DiskNum; //ENDSUB - entries on this disk
+ u16 Count; //ENDTOT - total number of entries
+ u32 Size; //ENDSIZ - size of entire central directory
+ u32 Offset; //ENDOFF - offset of central on starting disk
+ u16 lComment; //ENDCOM - length of zip file comment
+
+ void Read(File f);
+ void Write(File f);
+};
=======================================
--- /dev/null
+++ /src/BlueZip/Trees.cpp Thu Apr 15 13:50:08 2004
@@ -0,0 +1,1238 @@
+#include "CompHead.h"
+
+#ifndef NO_COMPRESSION
+
+/*
+ Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
+
+ See the accompanying file LICENSE, version 1999-Oct-05 or later
+ (the contents of which are also included in zip.h) for terms of use.
+ If, for some reason, both of these files are missing, the Info-ZIP
license
+ also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
+*/
+/*
+ * trees.c by Jean-loup Gailly
+ *
+ * This is a new version of im_ctree.c originally written by Richard B.
Wales
+ * for the defunct implosion method.
+ * The low level bit string handling routines from bits.c (originally
+ * im_bits.c written by Richard B. Wales) have been merged into this
version
+ * of trees.c.
+ *
+ * PURPOSE
+ *
+ * Encode various sets of source values using variable-length
+ * binary code trees.
+ * Output the resulting variable-length bit strings.
+ * Compression can be done to a file or to memory.
+ *
+ * DISCUSSION
+ *
+ * The PKZIP "deflation" process uses several Huffman trees. The more
+ * common source values are represented by shorter bit sequences.
+ *
+ * Each code tree is stored in the ZIP file in a compressed form
+ * which is itself a Huffman encoding of the lengths of
+ * all the code strings (in ascending order by source values).
+ * The actual code strings are reconstructed from the lengths in
+ * the UNZIP process, as described in the "application note"
+ * (APPNOTE.TXT) distributed as part of PKWARE's PKZIP program.
+ *
+ * The PKZIP "deflate" file format interprets compressed file data
+ * as a sequence of bits. Multi-bit strings in the file may cross
+ * byte boundaries without restriction.
+ * The first bit of each byte is the low-order bit.
+ *
+ * The routines in this file allow a variable-length bit value to
+ * be output right-to-left (useful for literal values). For
+ * left-to-right output (useful for code strings from the tree
routines),
+ * the bits must have been reversed first with bi_reverse().
+ *
+ * For in-memory compression, the compressed bit stream goes directly
+ * into the requested output buffer. The buffer is limited to 64K on
+ * 16 bit machines; flushing of the output buffer during compression
+ * process is not supported.
+ * The input data is read in blocks by the (*read_buf)() function.
+ *
+ * For more details about input to and output from the deflation
routines,
+ * see the actual input functions for (*read_buf)(), flush_outbuf(),
and
+ * the filecompress() resp. memcompress() wrapper functions which
handle
+ * the I/O setup.
+ *
+ * REFERENCES
+ *
+ * Lynch, Thomas J.
+ * Data Compression: Techniques and Applications, pp. 53-55.
+ * Lifetime Learning Publications, 1985. ISBN 0-534-03418-7.
+ *
+ * Storer, James A.
+ * Data Compression: Methods and Theory, pp. 49-50.
+ * Computer Science Press, 1988. ISBN 0-7167-8156-5.
+ *
+ * Sedgewick, R.
+ * Algorithms, p290.
+ * Addison-Wesley, 1983. ISBN 0-201-06672-6.
+ *
+ * INTERFACE
+ *
+ * void ct_init (ush *attr, int *method)
+ * Allocate the match buffer, initialize the various tables and
save
+ * the location of the internal file attribute (ascii/binary) and
+ * method (DEFLATE/STORE)
+ *
+ * void ct_tally (int dist, int lc);
+ * Save the match info and tally the frequency counts.
+ *
+ * u32 flush_block (char *buf, u32 stored_len, int eof)
+ * Determine the best encoding for the current block: dynamic
trees,
+ * static trees or store, and output the encoded block to the zip
+ * file. Returns the total compressed length for the file so far.
+ *
+ * void bi_init (char *tgt_buf, unsigned tgt_size, int flsh_allowed)
+ * Initialize the bit string routines.
+ *
+ * Most of the bit string output functions are only used internally
+ * in this source file, they are normally declared as "local" routines:
+ *
+ * local void send_bits (int value, int length)
+ * Write out a bit string, taking the source bits right to
+ * left.
+ *
+ * local unsigned bi_reverse (unsigned code, int len)
+ * Reverse the bits of a bit string, taking the source bits left
to
+ * right and emitting them right to left.
+ *
+ * local void bi_windup (void)
+ * Write out any remaining bits in an incomplete byte.
+ *
+ * local void copy_block(char *buf, unsigned len, int header)
+ * Copy a stored block to the zip file, storing first the length
and
+ * its one's complement if requested.
+ *
+ * All output that exceeds the bitstring output buffer size (as
initialized
+ * by bi_init() is fed through an externally provided transfer routine
+ * which flushes the bitstring output buffer on request and resets the
+ * buffer fill counter:
+ *
+ * extern void flush_outbuf(char *o_buf, unsigned *o_idx);
+ *
+ */
+
+#include <ctype.h>
+
+/*
===========================================================================
+ * Constants
+ */
+
+const uint MAX_BITS = 15;
+/* All codes must not exceed MAX_BITS bits */
+
+const uint MAX_BL_BITS = 7;
+/* Bit length codes must not exceed MAX_BL_BITS bits */
+
+const uint LENGTH_CODES = 29;
+/* number of length codes, not counting the special END_BLOCK code */
+
+const uint LITERALS = 256;
+/* number of literal bytes 0..255 */
+
+const uint END_BLOCK = 256;
+/* end of block literal code */
+
+const uint L_CODES = (LITERALS + 1 + LENGTH_CODES);
+/* number of Literal or Length codes, including the END_BLOCK code */
+
+const uint D_CODES = 30;
+/* number of distance codes */
+
+const uint BL_CODES = 19;
+/* number of codes used to transfer the bit lengths */
+
+
+int extra_lbits[LENGTH_CODES] /* extra bits for each length code */
+ = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0};
+
+int extra_dbits[D_CODES] /* extra bits for each distance code */
+ = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13};
+
+int extra_blbits[BL_CODES]/* extra bits for each bit length code */
+ = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};
+
+const uint STORED_BLOCK = 0;
+const uint STATIC_TREES = 1;
+const uint DYN_TREES = 2;
+/* The three kinds of block type */
+
+const uint LIT_BUFSIZE = 0x8000;
+const uint DIST_BUFSIZE = LIT_BUFSIZE;
+/* Sizes of match buffers for literals/lengths and distances. There are
+ * 4 reasons for limiting LIT_BUFSIZE to 64K:
+ * - frequencies can be kept in 16 bit counters
+ * - if compression is not successful for the first block, all input
data is
+ * still in the window so we can still emit a stored block even when
input
+ * comes from standard input. (This can also be done for all blocks if
+ * LIT_BUFSIZE is not greater than 32K.)
+ * - if compression is not successful for a file smaller than 64K, we can
+ * even emit a stored file instead of a stored block (saving 5 bytes).
+ * - creating new Huffman trees less frequently may not provide fast
+ * adaptation to changes in the input data statistics. (Take for
+ * example a binary file with poorly compressible code followed by
+ * a highly compressible string table.) Smaller buffer sizes give
+ * fast adaptation but have of course the overhead of transmitting
trees
+ * more frequently.
+ * - I can't count above 4
+ * The current code is general and allows DIST_BUFSIZE < LIT_BUFSIZE (to
save
+ * memory at the expense of compression). Some optimizations would be
possible
+ * if we rely on DIST_BUFSIZE == LIT_BUFSIZE.
+ */
+
+const uint REP_3_6 = 16;
+/* repeat previous bit length 3-6 times (2 bits of repeat count) */
+
+const uint REPZ_3_10 = 17;
+/* repeat a zero length 3-10 times (3 bits of repeat count) */
+
+const uint REPZ_11_138 = 18;
+/* repeat a zero length 11-138 times (7 bits of repeat count) */
+
+/*
===========================================================================
+ * Local data
+ */
+
+/* Data structure describing a single value and its code string. */
+typedef struct ct_data {
+ union {
+ u16 freq; /* frequency count */
+ u16 code; /* bit string */
+ } fc;
+ union {
+ u16 dad; /* father node in Huffman tree */
+ u16 len; /* length of bit string */
+ } dl;
+} ct_data;
+
+#define Freq fc.freq
+#define Code fc.code
+#define Dad dl.dad
+#define Len dl.len
+
+const uint HEAP_SIZE = (2 * L_CODES) + 1;
+// maximum heap size
+
+ct_data dyn_ltree[HEAP_SIZE]; /* literal and length tree */
+ct_data dyn_dtree[2*D_CODES+1]; /* distance tree */
+
+ct_data static_ltree[L_CODES+2];
+/* The static literal tree. Since the bit lengths are imposed, there is no
+ * need for the L_CODES extra codes used during heap construction. However
+ * The codes 286 and 287 are needed to build a canonical tree (see ct_init
+ * below).
+ */
+
+ct_data static_dtree[D_CODES];
+/* The static distance tree. (Actually a trivial tree since all codes use
+ * 5 bits.)
+ */
+
+ct_data bl_tree[2*BL_CODES+1];
+/* Huffman tree for the bit lengths */
+
+struct tree_desc {
+ ct_data near *dyn_tree; /* the dynamic tree */
+ ct_data near *static_tree; /* corresponding static tree or NULL */
+ int near *extra_bits; /* extra bits for each code or NULL */
+ int extra_base; /* base index for extra_bits */
+ int elems; /* max number of elements in the tree */
+ int max_length; /* max bit length for the codes */
+ int max_code; /* largest code with non zero frequency */
+};
+
+tree_desc l_desc =
+{dyn_ltree, static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS, 0};
+
+tree_desc d_desc =
+{dyn_dtree, static_dtree, extra_dbits, 0, D_CODES, MAX_BITS, 0};
+
+tree_desc bl_desc =
+{bl_tree, NULL, extra_blbits, 0, BL_CODES, MAX_BL_BITS, 0};
+
+
+u16 bl_count[MAX_BITS+1];
+/* number of codes at each bit length for an optimal tree */
+
+u8 bl_order[BL_CODES]
+ = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};
+/* The lengths of the bit length codes are sent in order of decreasing
+ * probability, to avoid transmitting the lengths for unused bit length
codes.
+ */
+
+int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
+int heap_len; /* number of elements in the heap */
+int heap_max; /* element of largest frequency */
+/* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
+ * The same heap array is used to build all trees.
+ */
+
+u8 near depth[2*L_CODES+1];
+/* Depth of each subtree used as tie breaker for trees of equal frequency
*/
+
+u8 length_code[MaxMatch - MinMatch + 1];
+/* length code for each normalized match length (0 == MIN_MATCH) */
+
+u8 dist_code[512];
+/* distance codes. The first 256 values correspond to the distances
+ * 3 .. 258, the last 256 values correspond to the top 8 bits of
+ * the 15 bit distances.
+ */
+
+int near base_length[LENGTH_CODES];
+/* First normalized length for each code (0 = MIN_MATCH) */
+
+int near base_dist[D_CODES];
+/* First normalized distance for each code (0 = distance of 1) */
+
+u8 l_buf[LIT_BUFSIZE]; /* buffer for literals/lengths */
+u16 d_buf[DIST_BUFSIZE]; /* buffer for distances */
+
+
+u8 flag_buf[(LIT_BUFSIZE/8)];
+/* flag_buf is a bit array distinguishing literals from lengths in
+ * l_buf, and thus indicating the presence or absence of a distance.
+ */
+
+uint last_lit; /* running index in l_buf */
+uint last_dist; /* running index in d_buf */
+uint last_flags; /* running index in flag_buf */
+u8 flags; /* current flags not yet saved in flag_buf */
+u8 flag_bit; /* current bit used in flags */
+/* bits are filled in flags starting at bit 0 (least significant).
+ * Note: these flags are overkill in the current code since we don't
+ * take advantage of DIST_BUFSIZE == LIT_BUFSIZE.
+ */
+
+u32 opt_len; /* bit length of current block with optimal trees */
+u32 static_len; /* bit length of current block with static trees */
+
+u32 cmpr_bytelen; /* total byte length of compressed file */
+u32 cmpr_len_bits; /* number of bits past 'cmpr_bytelen' */
+
+#ifdef _DEBUG
+u32 input_len; /* total byte length of input file */
+/* input_len is for debugging only since we can get it by other means. */
+#endif
+
+int *file_method; /* pointer to DEFLATE or STORE */
+
+/*
===========================================================================
+ * Local data used by the "bit string" routines.
+ */
+
+int flush_flg;
+
+uint bi_buf;
+/* Output buffer. bits are inserted starting at the bottom (least
significant
+ * bits). The width of bi_buf must be at least 16 bits.
+ */
+
+const uint Buf_size = (8 * 2*sizeof(char));
+/* Number of bits used within bi_buf. (bi_buf may be implemented on
+ * more than 16 bits on some systems.)
+ */
+
+int bi_valid;
+/* Number of valid bits in bi_buf. All bits above the last valid bit
+ * are always zero.
+ */
+
+char *out_buf;
+/* Current output buffer. */
+
+uint out_offset;
+/* Current offset in output buffer.
+ * On 16 bit machines, the buffer is limited to 64K.
+ */
+
+uint out_size;
+/* Size of current output buffer */
+
+/* Output a 16 bit value to the bit stream, lower (oldest) byte first */
+#define PUTSHORT(w) \
+{ if (out_offset >= out_size-1) \
+ flush_outbuf(out_buf, &out_offset); \
+ out_buf[out_offset++] = (char) ((w) & 0xff); \
+ out_buf[out_offset++] = (char) ((u16)(w) >> 8); \
+}
+
+#define PUTBYTE(b) \
+{ if (out_offset >= out_size) \
+ flush_outbuf(out_buf, &out_offset); \
+ out_buf[out_offset++] = (char) (b); \
+}
+
+#ifdef _DEBUG
+u32 bits_sent; /* bit length of the compressed data */
+extern u32 isize; /* byte length of input file */
+#endif
+
+extern long BlockStart; /* window offset of current block */
+extern uint StrStart; /* window offset of current string */
+
+
+/*
===========================================================================
+ * Local (static) routines in this file.
+ */
+
+void init_block (void);
+void pqdownheap (ct_data near *tree, int k);
+void gen_bitlen (tree_desc near *desc);
+void gen_codes (ct_data near *tree, int max_code);
+void build_tree (tree_desc near *desc);
+void scan_tree (ct_data near *tree, int max_code);
+void send_tree (ct_data near *tree, int max_code);
+int build_bl_tree (void);
+void send_all_trees (int lcodes, int dcodes, int blcodes);
+void compress_block (ct_data near *ltree, ct_data near *dtree);
+void set_file_type (void);
+void send_bits (int value, int length);
+unsigned bi_reverse (unsigned code, int len);
+void bi_windup (void);
+void copy_block (char *buf, unsigned len, int header);
+
+
+#ifndef _DEBUG
+# define send_code(c, tree) send_bits(tree[c].Code, tree[c].Len)
+ /* Send a code of the given tree. c and tree must not have side effects
*/
+
+#else /* _DEBUG */
+# define send_code(c, tree) \
+ { ; \
+ send_bits(tree[c].Code, tree[c].Len); }
+#endif
+
+#define d_code(dist) \
+ ((dist) < 256 ? dist_code[dist] : dist_code[256+((dist)>>7)])
+/* Mapping from a distance to a distance code. dist is the distance - 1 and
+ * must not have side effects. dist_code[256] and dist_code[257] are never
+ * used.
+ */
+
+/*
===========================================================================
+ * Allocate the match buffer, initialize the various tables and save the
+ * location of the internal file attribute (ascii/binary) and method
+ * (DEFLATE/STORE).
+ */
+void ct_init(int* method)
+ //ush *attr; /* pointer to internal file attribute */
+ //int *method; /* pointer to compression method */
+{
+ int n; /* iterates over tree elements */
+ int bits; /* bit counter */
+ int length; /* length value */
+ int code; /* code value */
+ int dist; /* distance index */
+
+ file_method = method;
+ cmpr_bytelen = cmpr_len_bits = 0L;
+#ifdef _DEBUG
+ input_len = 0L;
+#endif
+
+ if (static_dtree[0].Len != 0) return; /* ct_init already called */
+
+ /* Initialize the mapping length (0..255) -> length code (0..28) */
+ length = 0;
+ for (code = 0; code < LENGTH_CODES-1; code++) {
+ base_length[code] = length;
+ for (n = 0; n < (1<<extra_lbits[code]); n++) {
+ length_code[length++] = (u8)code;
+ }
+ }
+ Assert(length == 256);//, "ct_init: length != 256");
+ /* Note that the length 255 (match length 258) can be represented
+ * in two different ways: code 284 + 5 bits or code 285, so we
+ * overwrite length_code[255] to use the best encoding:
+ */
+ length_code[length-1] = (u8)code;
+
+ /* Initialize the mapping dist (0..32K) -> dist code (0..29) */
+ dist = 0;
+ for (code = 0 ; code < 16; code++) {
+ base_dist[code] = dist;
+ for (n = 0; n < (1<<extra_dbits[code]); n++) {
+ dist_code[dist++] = (u8)code;
+ }
+ }
+ Assert(dist == 256);//, "ct_init: dist != 256");
+ dist >>= 7; /* from now on, all distances are divided by 128 */
+ for ( ; code < D_CODES; code++) {
+ base_dist[code] = dist << 7;
+ for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) {
+ dist_code[256 + dist++] = (u8)code;
+ }
+ }
+ Assert(dist == 256);//, "ct_init: 256+dist != 512");
+
+ /* Construct the codes of the static literal tree */
+ for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0;
+ n = 0;
+ while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++;
+ while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++;
+ while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++;
+ while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++;
+ /* Codes 286 and 287 do not exist, but we must include them in the
+ * tree construction to get a canonical Huffman tree (longest code
+ * all ones)
+ */
+ gen_codes((ct_data near *)static_ltree, L_CODES+1);
+
+ /* The static distance tree is trivial: */
+ for (n = 0; n < D_CODES; n++) {
+ static_dtree[n].Len = 5;
+ static_dtree[n].Code = (u16)bi_reverse(n, 5);
+ }
+
+ /* Initialize the first block of the first file: */
+ init_block();
+}
+
+/*
===========================================================================
+ * Initialize a new block.
+ */
+void init_block()
+{
+ int n; /* iterates over tree elements */
+
+ /* Initialize the trees. */
+ for (n = 0; n < L_CODES; n++) dyn_ltree[n].Freq = 0;
+ for (n = 0; n < D_CODES; n++) dyn_dtree[n].Freq = 0;
+ for (n = 0; n < BL_CODES; n++) bl_tree[n].Freq = 0;
+
+ dyn_ltree[END_BLOCK].Freq = 1;
+ opt_len = static_len = 0L;
+ last_lit = last_dist = last_flags = 0;
+ flags = 0; flag_bit = 1;
+}
+
+#define SMALLEST 1
+/* Index within the heap array of least frequent node in the Huffman tree
*/
+
+
+/*
===========================================================================
+ * Remove the smallest element from the heap and recreate the heap with
+ * one less element. Updates heap and heap_len.
+ */
+#define pqremove(tree, top) \
+{\
+ top = heap[SMALLEST]; \
+ heap[SMALLEST] = heap[heap_len--]; \
+ pqdownheap(tree, SMALLEST); \
+}
+
+/*
===========================================================================
+ * Compares to subtrees, using the tree depth as tie breaker when
+ * the subtrees have equal frequency. This minimizes the worst case length.
+ */
+#define smaller(tree, n, m) \
+ (tree[n].Freq < tree[m].Freq || \
+ (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m]))
+
+/*
===========================================================================
+ * Restore the heap property by moving down the tree starting at node k,
+ * exchanging a node with the smallest of its two sons if necessary,
stopping
+ * when the heap property is re-established (each father smaller than its
+ * two sons).
+ */
+void pqdownheap(ct_data near *tree, int k)
+ //ct_data near *tree; /* the tree to restore */
+ //int k; /* node to move down */
+{
+ int v = heap[k];
+ int j = k << 1; /* left son of k */
+ int htemp; /* required because of bug in SASC compiler */
+
+ while (j <= heap_len) {
+ /* Set j to the smallest of the two sons: */
+ if (j < heap_len && smaller(tree, heap[j+1], heap[j])) j++;
+
+ /* Exit if v is smaller than both sons */
+ htemp = heap[j];
+ if (smaller(tree, v, htemp)) break;
+
+ /* Exchange v with the smallest son */
+ heap[k] = htemp;
+ k = j;
+
+ /* And continue down the tree, setting j to the left son of k */
+ j <<= 1;
+ }
+ heap[k] = v;
+}
+
+/*
===========================================================================
+ * Compute the optimal bit lengths for a tree and update the total bit
length
+ * for the current block.
+ * IN assertion: the fields freq and dad are set, heap[heap_max] and
+ * above are the tree nodes sorted by increasing frequency.
+ * OUT assertions: the field len is set to the optimal bit length, the
+ * array bl_count contains the frequencies for each bit length.
+ * The length opt_len is updated; static_len is also updated if stree
is
+ * not null.
+ */
+void gen_bitlen(tree_desc near *desc)
+ //tree_desc near *desc; /* the tree descriptor */
+{
+ ct_data near *tree = desc->dyn_tree;
+ int near *extra = desc->extra_bits;
+ int base = desc->extra_base;
+ int max_code = desc->max_code;
+ int max_length = desc->max_length;
+ ct_data near *stree = desc->static_tree;
+ int h; /* heap index */
+ int n, m; /* iterate over the tree elements */
+ int bits; /* bit length */
+ int xbits; /* extra bits */
+ u16 f; /* frequency */
+ int overflow = 0; /* number of elements with bit length too large */
+
+ for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0;
+
+ /* In a first pass, compute the optimal bit lengths (which may
+ * overflow in the case of the bit length tree).
+ */
+ tree[heap[heap_max]].Len = 0; /* root of the heap */
+
+ for (h = heap_max+1; h < HEAP_SIZE; h++) {
+ n = heap[h];
+ bits = tree[tree[n].Dad].Len + 1;
+ if (bits > max_length) bits = max_length, overflow++;
+ tree[n].Len = (u16)bits;
+ /* We overwrite tree[n].Dad which is no longer needed */
+
+ if (n > max_code) continue; /* not a leaf node */
+
+ bl_count[bits]++;
+ xbits = 0;
+ if (n >= base) xbits = extra[n-base];
+ f = tree[n].Freq;
+ opt_len += (u32)f * (bits + xbits);
+ if (stree) static_len += (u32)f * (stree[n].Len + xbits);
+ }
+ if (overflow == 0) return;
+
+ /* Find the first bit length which could increase: */
+ do {
+ bits = max_length-1;
+ while (bl_count[bits] == 0) bits--;
+ bl_count[bits]--; /* move one leaf down the tree */
+ bl_count[bits+1] += (u16)2; /* move one overflow item as its
brother */
+ bl_count[max_length]--;
+ /* The brother of the overflow item also moves one step up,
+ * but this does not affect bl_count[max_length]
+ */
+ overflow -= 2;
+ } while (overflow > 0);
+
+ /* Now recompute all bit lengths, scanning in increasing frequency.
+ * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all
+ * lengths instead of fixing only the wrong ones. This idea is taken
+ * from 'ar' written by Haruhiko Okumura.)
+ */
+ for (bits = max_length; bits != 0; bits--) {
+ n = bl_count[bits];
+ while (n != 0) {
+ m = heap[--h];
+ if (m > max_code) continue;
+ if (tree[m].Len != (u16)bits) {
+ opt_len +=
((long)bits-(long)tree[m].Len)*(long)tree[m].Freq;
+ tree[m].Len = (u16)bits;
+ }
+ n--;
+ }
+ }
+}
+
+/*
===========================================================================
+ * Generate the codes for a given tree and bit counts (which need not be
+ * optimal).
+ * IN assertion: the array bl_count contains the bit length statistics for
+ * the given tree and the field len is set for all tree elements.
+ * OUT assertion: the field code is set for all tree elements of non
+ * zero code length.
+ */
+void gen_codes (ct_data near *tree, int max_code)
+ //ct_data near *tree; /* the tree to decorate */
+ //int max_code; /* largest code with non zero frequency */
+{
+ u16 next_code[MAX_BITS+1]; /* next code value for each bit length */
+ u16 code = 0; /* running code value */
+ int bits; /* bit index */
+ int n; /* code index */
+
+ /* The distribution counts are first used to generate the code values
+ * without bit reversal.
+ */
+ for (bits = 1; bits <= MAX_BITS; bits++) {
+ next_code[bits] = code = (u16)((code + bl_count[bits-1]) << 1);
+ }
+ /* Check that the bit counts in bl_count are consistent. The last code
+ * must be all ones.
+ */
+ Assert(code + bl_count[MAX_BITS]-1 == (1<< ((u16) MAX_BITS)) -
1);//inconsistent bit counts
+
+ for (n = 0; n <= max_code; n++) {
+ int len = tree[n].Len;
+ if (len == 0) continue;
+ /* Now reverse the bits */
+ tree[n].Code = (u16)bi_reverse(next_code[len]++, len);
+ }
+}
+
+/*
===========================================================================
+ * Construct one Huffman tree and assigns the code bit strings and lengths.
+ * Update the total bit length for the current block.
+ * IN assertion: the field freq is set for all tree elements.
+ * OUT assertions: the fields len and code are set to the optimal bit
length
+ * and corresponding code. The length opt_len is updated; static_len is
+ * also updated if stree is not null. The field max_code is set.
+ */
+void build_tree(tree_desc near *desc)
+ //tree_desc near *desc; /* the tree descriptor */
+{
+ ct_data near *tree = desc->dyn_tree;
+ ct_data near *stree = desc->static_tree;
+ int elems = desc->elems;
+ int n, m; /* iterate over heap elements */
+ int max_code = -1; /* largest code with non zero frequency */
+ int node = elems; /* next internal node of the tree */
+
+ /* Construct the initial heap, with least frequent element in
+ * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
+ * heap[0] is not used.
+ */
+ heap_len = 0, heap_max = HEAP_SIZE;
+
+ for (n = 0; n < elems; n++) {
+ if (tree[n].Freq != 0) {
+ heap[++heap_len] = max_code = n;
+ depth[n] = 0;
+ } else {
+ tree[n].Len = 0;
+ }
+ }
+
+ /* The pkzip format requires that at least one distance code exists,
+ * and that at least one bit should be sent even if there is only one
+ * possible code. So to avoid special checks later on we force at least
+ * two codes of non zero frequency.
+ */
+ while (heap_len < 2) {
+ int new_ = heap[++heap_len] = (max_code < 2 ? ++max_code : 0);
+ tree[new_].Freq = 1;
+ depth[new_] = 0;
+ opt_len--; if (stree) static_len -= stree[new_].Len;
+ /* new is 0 or 1 so it does not have extra bits */
+ }
+ desc->max_code = max_code;
+
+ /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
+ * establish sub-heaps of increasing lengths:
+ */
+ for (n = heap_len/2; n >= 1; n--) pqdownheap(tree, n);
+
+ /* Construct the Huffman tree by repeatedly combining the least two
+ * frequent nodes.
+ */
+ do {
+ pqremove(tree, n); /* n = node of least frequency */
+ m = heap[SMALLEST]; /* m = node of next least frequency */
+
+ heap[--heap_max] = n; /* keep the nodes sorted by frequency */
+ heap[--heap_max] = m;
+
+ /* Create a new node father of n and m */
+ tree[node].Freq = (u16)(tree[n].Freq + tree[m].Freq);
+ depth[node] = (u8) (max(depth[n], depth[m]) + 1);
+ tree[n].Dad = tree[m].Dad = (u16)node;
+
+ /* and insert the new node in the heap */
+ heap[SMALLEST] = node++;
+ pqdownheap(tree, SMALLEST);
+
+ } while (heap_len >= 2);
+
+ heap[--heap_max] = heap[SMALLEST];
+
+ /* At this point, the fields freq and dad are set. We can now
+ * generate the bit lengths.
+ */
+ gen_bitlen((tree_desc near *)desc);
+
+ /* The field len is now set, we can generate the bit codes */
+ gen_codes ((ct_data near *)tree, max_code);
+}
+
+/*
===========================================================================
+ * Scan a literal or distance tree to determine the frequencies of the
codes
+ * in the bit length tree. Updates opt_len to take into account the repeat
+ * counts. (The contribution of the bit length codes will be added later
+ * during the construction of bl_tree.)
+ */
+void scan_tree (ct_data near *tree, int max_code)
+ //ct_data near *tree; /* the tree to be scanned */
+ //int max_code; /* and its largest code of non zero frequency */
+{
+ int n; /* iterates over all tree elements */
+ int prevlen = -1; /* last emitted length */
+ int curlen; /* length of current code */
+ int nextlen = tree[0].Len; /* length of next code */
+ int count = 0; /* repeat count of the current code */
+ int max_count = 7; /* max repeat count */
+ int min_count = 4; /* min repeat count */
+
+ if (nextlen == 0) max_count = 138, min_count = 3;
+ tree[max_code+1].Len = (u16)-1; /* guard */
+
+ for (n = 0; n <= max_code; n++) {
+ curlen = nextlen; nextlen = tree[n+1].Len;
+ if (++count < max_count && curlen == nextlen) {
+ continue;
+ } else if (count < min_count) {
+ bl_tree[curlen].Freq += (u16)count;
+ } else if (curlen != 0) {
+ if (curlen != prevlen) bl_tree[curlen].Freq++;
+ bl_tree[REP_3_6].Freq++;
+ } else if (count <= 10) {
+ bl_tree[REPZ_3_10].Freq++;
+ } else {
+ bl_tree[REPZ_11_138].Freq++;
+ }
+ count = 0; prevlen = curlen;
+ if (nextlen == 0) {
+ max_count = 138, min_count = 3;
+ } else if (curlen == nextlen) {
+ max_count = 6, min_count = 3;
+ } else {
+ max_count = 7, min_count = 4;
+ }
+ }
+}
+
+/*
===========================================================================
+ * Send a literal or distance tree in compressed form, using the codes in
+ * bl_tree.
+ */
+void send_tree (ct_data near *tree, int max_code)
+ //ct_data near *tree; /* the tree to be scanned */
+ //int max_code; /* and its largest code of non zero frequency */
+{
+ int n; /* iterates over all tree elements */
+ int prevlen = -1; /* last emitted length */
+ int curlen; /* length of current code */
+ int nextlen = tree[0].Len; /* length of next code */
+ int count = 0; /* repeat count of the current code */
+ int max_count = 7; /* max repeat count */
+ int min_count = 4; /* min repeat count */
+
+ /* tree[max_code+1].Len = -1; */ /* guard already set */
+ if (nextlen == 0) max_count = 138, min_count = 3;
+
+ for (n = 0; n <= max_code; n++) {
+ curlen = nextlen; nextlen = tree[n+1].Len;
+ if (++count < max_count && curlen == nextlen) {
+ continue;
+ } else if (count < min_count) {
+ do { send_code(curlen, bl_tree); } while (--count != 0);
+
+ } else if (curlen != 0) {
+ if (curlen != prevlen) {
+ send_code(curlen, bl_tree); count--;
+ }
+ Assert(count >= 3 && count <= 6);//, " 3_6?");
+ send_code(REP_3_6, bl_tree); send_bits(count-3, 2);
+
+ } else if (count <= 10) {
+ send_code(REPZ_3_10, bl_tree); send_bits(count-3, 3);
+
+ } else {
+ send_code(REPZ_11_138, bl_tree); send_bits(count-11, 7);
+ }
+ count = 0; prevlen = curlen;
+ if (nextlen == 0) {
+ max_count = 138, min_count = 3;
+ } else if (curlen == nextlen) {
+ max_count = 6, min_count = 3;
+ } else {
+ max_count = 7, min_count = 4;
+ }
+ }
+}
+
+/*
===========================================================================
+ * Construct the Huffman tree for the bit lengths and return the index in
+ * bl_order of the last bit length code to send.
+ */
+int build_bl_tree()
+{
+ int max_blindex; /* index of last bit length code of non zero freq */
+
+ /* Determine the bit length frequencies for literal and distance trees
*/
+ scan_tree((ct_data near *)dyn_ltree, l_desc.max_code);
+ scan_tree((ct_data near *)dyn_dtree, d_desc.max_code);
+
+ /* Build the bit length tree: */
+ build_tree((tree_desc near *)(&bl_desc));
+ /* opt_len now includes the length of the tree representations, except
+ * the lengths of the bit lengths codes and the 5+5+4 bits for the
counts.
+ */
+
+ /* Determine the number of bit length codes to send. The pkzip format
+ * requires that at least 4 bit length codes be sent. (appnote.txt says
+ * 3 but the actual value used is 4.)
+ */
+ for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) {
+ if (bl_tree[bl_order[max_blindex]].Len != 0) break;
+ }
+ /* Update opt_len to include the bit length tree and counts */
+ opt_len += 3*(max_blindex+1) + 5+5+4;
+
+ return max_blindex;
+}
+
+/*
===========================================================================
+ * Send the header for a block using dynamic Huffman trees: the counts, the
+ * lengths of the bit length codes, the literal tree and the distance tree.
+ * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
+ */
+void send_all_trees(int lcodes, int dcodes, int blcodes)
+ //int lcodes, dcodes, blcodes; /* number of codes for each tree */
+{
+ int rank; /* index in bl_order */
+
+ Assert(lcodes >= 257 && dcodes >= 1 && blcodes >= 4);//, "not enough
codes");
+ Assert(lcodes <= L_CODES && dcodes <= D_CODES && blcodes <=
BL_CODES);//,
+ //"too many codes");
+
+ send_bits(lcodes-257, 5);
+ /* not +255 as stated in appnote.txt 1.93a or -256 in 2.04c */
+ send_bits(dcodes-1, 5);
+ send_bits(blcodes-4, 4); /* not -3 as stated in appnote.txt */
+ for (rank = 0; rank < blcodes; rank++) {
+ send_bits(bl_tree[bl_order[rank]].Len, 3);
+ }
+
+ send_tree((ct_data near *)dyn_ltree, lcodes-1); /* send the literal
tree */
+
+ send_tree((ct_data near *)dyn_dtree, dcodes-1); /* send the distance
tree */
+}
+
+/*
===========================================================================
+ * Determine the best encoding for the current block: dynamic trees, static
+ * trees or store, and output the encoded block to the zip file. This
function
+ * returns the total compressed length (in bytes) for the file so far.
+ */
+u32 flush_block(char *buf, u32 stored_len, int eof)
+ //char *buf; /* input block, or NULL if too old */
+ //u32 stored_len; /* length of input block */
+ //int eof; /* true if this is the last block for a file */
+{
+ u32 opt_lenb, static_lenb; /* opt_len and static_len in bytes */
+ int max_blindex; /* index of last bit length code of non zero freq */
+
+ flag_buf[last_flags] = flags; /* Save the flags for the last 8 items */
+
+ /* Construct the literal and distance trees */
+ build_tree((tree_desc near *)(&l_desc));
+
+ build_tree((tree_desc near *)(&d_desc));
+ /* At this point, opt_len and static_len are the total bit lengths of
+ * the compressed block data, excluding the tree representations.
+ */
+
+ /* Build the bit length tree for the above two trees, and get the index
+ * in bl_order of the last bit length code to send.
+ */
+ max_blindex = build_bl_tree();
+
+ /* Determine the best encoding. Compute first the block length in
bytes */
+ opt_lenb = (opt_len+3+7)>>3;
+ static_lenb = (static_len+3+7)>>3;
+#ifdef _DEBUG
+ input_len += stored_len; /* for debugging only */
+#endif
+
+ if (static_lenb <= opt_lenb) opt_lenb = static_lenb;
+
+ /* If compression failed and this is the first and last block,
+ * the whole file is transformed into a stored file:
+ */
+ if (stored_len <= opt_lenb && eof && file_method != NULL &&
+ cmpr_bytelen == 0L && cmpr_len_bits == 0L) {
+ /* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */
+ if (buf == NULL) error ("block vanished");
+
+ copy_block(buf, (unsigned)stored_len, 0); /* without header */
+ cmpr_bytelen = stored_len;
+ *file_method = compStore;
+ } else
+
+ if (stored_len+4 <= opt_lenb && buf != (char*)NULL) {
+ /* 4: two words for the lengths *
+ /* The test buf != NULL is only necessary if LIT_BUFSIZE >
WSIZE.
+ * Otherwise we can't have processed more than WSIZE input bytes
since
+ * the last block flush, because compression would have been
+ * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to
+ * transform a block into a stored block.
+ */
+ send_bits((STORED_BLOCK<<1)+eof, 3); /* send block type */
+ cmpr_bytelen += ((cmpr_len_bits + 3 + 7) >> 3) + stored_len + 4;
+ cmpr_len_bits = 0L;
+
+ copy_block(buf, (unsigned)stored_len, 1); /* with header */
+
+ } else if (static_lenb == opt_lenb) {
+ send_bits((STATIC_TREES<<1)+eof, 3);
+ compress_block((ct_data near *)static_ltree, (ct_data near
*)static_dtree);
+ cmpr_len_bits += 3 + static_len;
+ cmpr_bytelen += cmpr_len_bits >> 3;
+ cmpr_len_bits &= 7L;
+ } else {
***The diff for this file has been truncated for email.***
=======================================
--- /dev/null
+++ /src/BlueZip/WriteZip.cpp Thu Apr 15 13:50:08 2004
@@ -0,0 +1,121 @@
+#include "BlueHead.h"
+
+#ifndef NO_COMPRESSION
+
+//Write the file back out, with the changes
+bool BlueZip::Write(bool Store)
+{
+ //TODO: Do not use a TempFile, send straight to the output
+
+ char TempFileName[MAX_PATH];
+ File f;
+
+ zList* z;
+ zList** next = &Files; //where to insert the next zList
+
+ int i, j; //global enumeration variables
+
+ if ((Files == NULL) && (Pending == NULL))
+ {
+ ErrMsg("Blank ZIP files not allowed");
+ return false;
+ }
+
+ //Always use a temporary file name (they may have the ZIP file on a
floppy)
+ f = FileOpenTemp(TempFileName);
+ if (!FileValid(f))
+ {
+ ErrMsg(Failed to open the temporary file);
+ return false;
+ }
+
+ if (Files != NULL)
+ {
+ File Orig = FileOpenRead(FileName);
+ if (!FileValid(Orig))
+ {
+ ErrMsg("Failed to open the reading file");
+ return false;
+ }
+
+ const int BlockSize = 4096;
+ char* Buffer = new char[BlockSize];
+ datCentral hLocal;
+ for (z = Files; z != NULL; z = z->next)
+ {
+ if (!z->Delete)
+ {
+ //Remove any that have dropped out of the list
+ *next = z;
+ next = &z->next;
+
+ //Perform a ZIP copy
+ SeekBeg(Orig, z->data.Offset + z->FileDeltaPos);
+ z->data.Offset = FilePos(f);
+
+ u32 sig;
+ FileRead(Orig, &sig, 4);
+ Assert(sig == sigLocal);
+ FileWrite(f, &sig, 4);
+
+ hLocal.ReadLocal(Orig);
+ hLocal.WriteLocal(f);
+
+ i = hLocal.CompSize + hLocal.lFileName +
hLocal.lExtra;
+ while(i != 0)
+ {
+ j = min(i, BlockSize);
+ FileRead(Orig, Buffer, j);
+ FileWrite(f, Buffer, j);
+ i -= j;
+ }
+ }
+ }
+ FileClose(Orig);
+ delete[] Buffer;
+ }
+
+
+ while (Pending != NULL)
+ {
+ fList* fAdd = Pending;
+ Pending = Pending->next;
+
+ z = fAdd->ZipUp(f, Store);
+ if (z == NULL)
+ {
+ ErrMsg("Failed to add the file");
+ }
+ else
+ {
+ *next = z;
+ next = &z->next;
+ }
+
+ delete fAdd;
+
+ }
+
+ //Write out the central header
+ data.Count = 0;
+ data.Offset = FilePos(f);
+ for (z = Files; z != NULL; z = z->next, data.Count++)
+ z->WriteCentral(f);
+
+ data.Size = FilePos(f) - data.Offset;
+ WriteEnd(f);
+
+ FileClose(f);
+
+ //Using a temp file
+ if (!FileReplace(FileName, TempFileName))
+ {
+ ErrMsg("Failed to copy the temporary file");
+ return false;
+ }
+
+ return true;
+}
+
+
+#endif //!NO_COMPRESSION
=======================================
--- /dev/null
+++ /src/BlueZip/fList.cpp Thu Apr 15 13:50:08 2004
@@ -0,0 +1,117 @@
+#include "BlueHead.h"
+
+#ifndef NO_COMPRESSION
+
+/* : Required by the deflate routines */
+void SetupDeftree(File In, File Out, int my_level);
+u32 filecompress(int* method);
+u32 GetCRC();
+
+
+fList::fList(LPCTSTR NewFile, fList* prev)
+{
+ FileName = CopyString(NewFile);
+ //Replace \ with /
+ int i;
+ for (i = 0; FileName[i] != 0; i++)
+ {
+ if (FileName[i] == '\\') FileName[i] = '/';
+ }
+ next = prev;
+}
+
+fList::~fList()
+{
+ if (FileName != NULL)
+ delete[] FileName;
+}
+
+zList* fList::ZipUp(File f, bool Store)
+{
+ zList* z = new zList;
+
+ //Open the new file
+ File In = FileOpenRead(FileName);
+ if (!FileValid(In))
+ {
+ ErrMsg("Failed to open the file to compress in");
+ return NULL;
+ }
+
+ z->data.ExtAttr = FileGetAttrib(In, FileName);
+
+ //Copy over the filename
+ char* s = strrchr(FileName, '/');
+ if (s == NULL)
+ {
+ z->FileName = FileName;
+ }
+ else
+ {
+ z->FileName = CopyString(&s[1]);
+ delete[] FileName;
+ }
+ FileName = NULL;
+ z->data.lFileName = strlen(z->FileName);
+
+ //Get some information on the filename
+ //Not implemented properly yet
+
+
+ //PK[UN]ZIP 2.0 made these files and will be able to extract them
+ z->data.VerMake = 20;
+ z->data.Disk = 0;
+ z->data.Offset = FilePos(f);
+ z->data.Disk = 0;
+
+ z->data.IntAttr = 0; //BINARY - like I care if it's text?
+ FileGetDate(In, &z->data);
+
+
+ z->data.lExtra = 0;
+ z->data.lComment = 0;
+ z->data.OrigSize = FileLen(In);
+
+
+ //Info-Zip would write out the local header here
+ SeekCur(f, 4 + ldatLocal + z->data.lFileName);
+
+ //Just store it
+ InitCRC();
+ if (Store) //Just store it
+ WriteStore(In, f, z);
+ else
+ {
+/* CRC CHECK
+ u8* Buffer = new u8[z->data.CompSize];
+ SeekBeg(In, 0);
+ FileRead(In, Buffer, z->data.CompSize);
+ FileWrite(f, Buffer, z->data.CompSize);
+ z->data.CRC = CRC(0, Buffer, z->data.CompSize);
+ delete[] Buffer;
+
+*/
+ int Method = compDeflate;
+ SetupDeftree(In, f, 9);
+ z->data.CompSize = filecompress(&Method);
+ z->data.CompMode = Method;
+ }
+
+ z->data.CRC = GetCRC();
+ z->data.VerNeed = (z->data.CompMode == compDeflate ? 20 : 10);
+ //Version needed is 20, because using compress, 10 for just store
+
+ //WinZIP compatible hacks
+ z->data.Flags = 2;
+
+ FileClose(In);
+
+ int LocalFileEnd = FilePos(f);
+ SeekBeg(f, z->data.Offset);
+ z->WriteLocal(f);
+
+ SeekBeg(f, LocalFileEnd);
+ return z;
+}
+
+#endif //!NO_COMPRESSION
=======================================
--- /dev/null
+++ /src/BlueZip/fList.h Thu Apr 15 13:50:08 2004
@@ -0,0 +1,16 @@
+
+#ifndef NO_COMPRESSION
+
+class fList
+{
+public:
+ char* FileName;
+ fList* next;
+
+ fList(LPCTSTR FileName, fList* prev);
+ ~fList();
+ zList* ZipUp(File f, bool Store);
+};
+
+#endif //!NO_COMPRESSION
+
=======================================
--- /dev/null
+++ /src/BlueZip/zList.cpp Thu Apr 15 13:50:08 2004
@@ -0,0 +1,65 @@
+#include "BlueHead.h"
+
+zList::zList()
+{
+ FileName = NULL;
+ Extra = NULL;
+ Comment = NULL;
+ next = NULL;
+ Delete = false;
+}
+
+zList::~zList()
+{
+ if (FileName) delete[] FileName;
+ if (Extra) delete[] Extra;
+ if (Comment) delete[] Comment;
+}
+
+void zList::WriteLocal(File f)
+{
+ long l = sigLocal;
+ FileWrite(f, &l, 4);
+ data.WriteLocal(f);
+
+ FileWrite(f, FileName, data.lFileName);
+ if (data.lExtra) FileWrite(f, Extra, data.lExtra);
+ //No comment available, only in central header
+}
+
+void zList::WriteCentral(File f)
+{
+ long l = sigCentral;
+ FileWrite(f, &l, 4);
+ data.Write(f);
+
+ FileWrite(f, FileName, data.lFileName);
+ if (data.lExtra) FileWrite(f, Extra, data.lExtra);
+ if (data.lComment) FileWrite(f, Comment, data.lComment);
+}
+
+void zList::ReadCentral(File f)
+{
+ data.Read(f);
+
+ // Read file name, extra field and comment field
+ // if (z->nam == 0) then 0 length name error
+
+ FileName = new char[data.lFileName+1];
+ FileRead(f, FileName, data.lFileName);
+ FileName[data.lFileName] = '\0'; // terminate name
+
+ if (data.lExtra)
+ {
+ Extra = new char[data.lExtra];
+ FileRead(f, Extra, data.lExtra);
+ }
+
+ if (data.lComment)
+ {
+ Comment = new char[data.lComment];
+ FileRead(f, Comment, data.lComment);
+ }
+}
+
+
=======================================
--- /dev/null
+++ /src/BlueZip/zList.h Thu Apr 15 13:50:08 2004
@@ -0,0 +1,25 @@
+// Structures for in-memory file information
+
+class __declspec(dllexport) zList
+{
+public:
+ datCentral data;
+
+ char* FileName; //File name in zip file
+ char* Extra; //Extra in central
+ char* Comment; //Comment (set only if com != 0)
+
+ bool Delete; //Should the file be removed on execute
+ zList* next;
+
+ zList();
+ ~zList();
+
+ void WriteCentral(File f);
+ void ReadCentral(File f);
+
+ void WriteLocal(File f);
+
+ int OriginalSize(){return data.OrigSize;}
+ int CompressedSize(){return data.CompSize;}
+};
=======================================
--- /dev/null
+++ /src/Debug/Installer.res Thu Apr 15 13:50:08 2004
Binary file, no diff available.
=======================================
--- /dev/null
+++ /src/FileCode.cpp Thu Apr 15 13:50:08 2004
@@ -0,0 +1,53 @@
+#include "Header.h"
+
+bool Exists(char* File)
+{
+ return (GetFileAttributes(File) != 0xffffffff);
+}
+
+bool ExistsDir(char* File)
+{
+ DWORD Attr = GetFileAttributes(File);
+ return ((Attr != 0xffffffff) && (Attr & FILE_ATTRIBUTE_DIRECTORY));
+}
+
+bool CanReadWrite(char* File)
+{
+ HANDLE hFile = CreateFile(File, GENERIC_READ | GENERIC_WRITE,
+ 0, NULL, OPEN_EXISTING, 0, NULL);
+
+ if (hFile == INVALID_HANDLE_VALUE) return false;
+ CloseHandle(hFile);
+ return true;
+}
+
+void NormalPath(char* File)
+{
+ for (int i = 0; File[i] != 0; i++)
+ {
+ if (File[i] == '/')
+ File[i] = '\\';
+ }
+}
+
+// The first file passed must end in a \\ character
+bool CreateFolder(char* File)
+{
+ char* s = strrchr(File, '\\');
+ if (s == NULL)
+ return false;
+
+ int BufChar = s[0];
+ s[0] = 0;
+ bool Success = false;
+ if (!CreateDirectory(File, NULL))
+ {
+ if (CreateFolder(File) && CreateDirectory(File, NULL))
+ Success = true;
+ }
+ else
+ Success = true;
+
+ s[0] = BufChar;
+ return Success;
+}
=======================================
--- /dev/null
+++ /src/FileCode.h Thu Apr 15 13:50:08 2004
@@ -0,0 +1,7 @@
+
+
+bool Exists(char* File);
+bool ExistsDir(char* File);
+bool CanReadWrite(char* File);
+void NormalPath(char* File);
+bool CreateFolder(char* File);
=======================================
--- /dev/null
+++ /src/Header.h Thu Apr 15 13:50:08 2004
@@ -0,0 +1,4 @@
+#define WIN32_MEAN_AND_LEAN
+#include <windows.h>
+
+const int MyMaxPath = MAX_PATH * 2;
=======================================
--- /dev/null
+++ /src/Installer.dsp Thu Apr 15 13:50:08 2004
@@ -0,0 +1,236 @@
+# Microsoft Developer Studio Project File - Name="Installer" - Package
Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Application" 0x0101
+
+CFG=Installer - 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 "Installer.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 "Installer.mak" CFG="Installer - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "Installer - Win32 Release" (based on "Win32 (x86) Application")
+!MESSAGE "Installer - Win32 Debug" (based on "Win32 (x86) Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "Installer - 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 Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS"
/D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS"
/D "_MBCS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "NDEBUG"
+# ADD RSC /l 0x809 /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:windows /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 comctl32.lib /nologo /subsystem:windows /machine:I386
/OPT:NOWIN98
+# SUBTRACT LINK32 /pdb:none
+
+!ELSEIF "$(CFG)" == "Installer - 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 Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG"
/D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG"
/D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x809 /d "_DEBUG"
+# ADD RSC /l 0x809 /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:windows /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 comctl32.lib /nologo /subsystem:windows /debug /machine:I386
/pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "Installer - Win32 Release"
+# Name "Installer - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\FileCode.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\FileCode.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Header.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Installer.rc
+# End Source File
+# Begin Source File
+
+SOURCE=.\Parameters.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\Setup.ico
+# End Source File
+# Begin Source File
+
+SOURCE=.\ShellCode.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\ShellCode.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\StartCode.cpp
+# End Source File
+# End Group
+# Begin Group "BlueZip"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\BlueZip\BlueHead.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\BlueZip\BlueZip.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\BlueZip\BlueZip.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\BlueZip\CompHead.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\BlueZip\CRC.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\BlueZip\Deflate.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\BlueZip\DefTree.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\BlueZip\Errors.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\BlueZip\FileIO.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\BlueZip\FileIO.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\BlueZip\fList.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\BlueZip\fList.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\BlueZip\General.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\BlueZip\General.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\BlueZip\Inflate.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\BlueZip\Inflate.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\BlueZip\ReadZip.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\BlueZip\Store.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\BlueZip\Structs.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\BlueZip\Structs.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\BlueZip\Trees.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\BlueZip\WriteZip.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\BlueZip\zList.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\BlueZip\zList.h
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE=".\Pingus-Installer.manifest"
+# End Source File
+# End Target
+# End Project
=======================================
--- /dev/null
+++ /src/Installer.dsw Thu Apr 15 13:50:08 2004
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "Installer"=.\Installer.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
=======================================
--- /dev/null
+++ /src/Installer.rc Thu Apr 15 13:50:08 2004
@@ -0,0 +1,129 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.K.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+dlgInstall DIALOG DISCARDABLE 0, 0, 308, 193
+STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Pingus Installer"
+FONT 8, "MS Sans Serif"
+BEGIN
+ LTEXT "#",lblInstallTo,7,42,294,10,NOT WS_VISIBLE
+ LTEXT "#",lblInstallFile,7,58,294,8,NOT WS_VISIBLE
+ CONTROL "",barTop,"Static",SS_ETCHEDHORZ,0,33,313,1
+ LTEXT "This will install Pingus on your computer\n\nPlease
select an installation directory.",
+ lblWelcome,7,42,154,25
+ EDITTEXT txtEdit,7,74,263,12,ES_AUTOHSCROLL
+ PUSHBUTTON "...",cmdBrowse,277,74,24,12
+ PUSHBUTTON "Cancel",IDCANCEL,191,172,50,14
+ DEFPUSHBUTTON "Install",IDOK,251,172,50,14
+ CONTROL "Run program after installation",chkExecute,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,7,124,294,11
+ CONTROL "Create shortcut on desktop",chkShortcut,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,7,100,294,10
+ CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,-1,164,311,1
+ LTEXT "Windows Installer © Neil Mitchell
1999-2004",IDC_STATIC,
+ 7,176,155,10,WS_DISABLED
+ CONTROL "Progress2",prgBar,"msctls_progress32",NOT
WS_VISIBLE,7,
+ 74,294,12
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE
+BEGIN
+ dlgInstall, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 301
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 186
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_ICON1 ICON DISCARDABLE "Setup.ico"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// 24
+//
+
+1 24 DISCARDABLE "Pingus-Installer.manifest"
+#endif // English (U.K.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
=======================================
--- /dev/null
+++ /src/Parameters.h Thu Apr 15 13:50:08 2004
@@ -0,0 +1,24 @@
+//These are configuration parameters
+
+
+//Default directory
+//The resulting value will be "C:\Program Files\" + Value
+#define InstallDir "Pingus"
+
+//Primary program
+//This is the first file that will be checked for overwrite access
+//If this is the main .exe it will allow them first refusal if they are
currently
+//running the program
+//Use NULL for no primary file
+#define PrimaryFile "Pingus.exe"
+
+//Program name
+//Text of what your program is called
+#define ProgramName "Pingus"
+
+
+#define Description "GPL multiplatform Lemmings(tm) clone"
+
+
+#define Copyright "Ingo Ruhnke 2000-2004"
+
=======================================
--- /dev/null
+++ /src/Pingus-Installer.manifest Thu Apr 15 13:50:08 2004
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1"
manifestVersion="1.0"><assemblyIdentity version="1.0.0.0"
processorArchitecture="x86" name="Pingus Installer" type="win32"
/><dependency><dependentAssembly><assemblyIdentity type="win32"
name="Microsoft.Windows.Common-Controls" version="6.0.0.0"
processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*"
/></dependentAssembly></dependency></assembly>
=======================================
--- /dev/null
+++ /src/Release/Installer.res Thu Apr 15 13:50:08 2004
Binary file, no diff available.
=======================================
--- /dev/null
+++ /src/Setup.ico Thu Apr 15 13:50:08 2004
Binary file, no diff available.
=======================================
--- /dev/null
+++ /src/ShellCode.cpp Thu Apr 15 13:50:08 2004
@@ -0,0 +1,118 @@
+#include "Header.h"
+#include "Parameters.h"
+#include <shlobj.h>
+
+
+bool OleReady;
+
+void ShellInit()
+{
+ HRESULT hres = OleInitialize(NULL);
+ OleReady = ((hres == S_FALSE) || (hres == S_OK));
+}
+
+void ShellDest()
+{
+ if (OleReady)
+ OleUninitialize();
+}
+
+
+bool CreateShortcut(char* Destination, char* Target, char* Parameters,
char* Desc)
+{
+ if (!OleReady)
+ return false;
+
+ HRESULT hres;
+ IShellLink* psl;
+
+ // Get a pointer to the IShellLink interface.
+ hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
+ IID_IShellLink, (LPVOID*)&psl);
+ if (SUCCEEDED(hres))
+ {
+ IPersistFile* ppf;
+
+ // Set the path to the shortcut target and add the description.
+ psl->SetPath(Target);
+ if (Parameters != NULL) psl->SetArguments(Parameters);
+ if (Desc != NULL) psl->SetDescription(Desc);
+
+ // Query IShellLink for the IPersistFile interface for saving the
+ // shortcut in persistent storage.
+ hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf);
+
+ if (SUCCEEDED(hres))
+ {
+ WCHAR wsz[MAX_PATH];
+
+ // Ensure that the string is Unicode.
+ MultiByteToWideChar(CP_ACP, 0, Destination, -1, wsz, MAX_PATH);
+
+ // Save the link by calling IPersistFile::Save.
+ hres = ppf->Save(wsz, TRUE);
+ ppf->Release();
+ }
+ psl->Release();
+ }
+ return (SUCCEEDED(hres) ? true : false);
+}
+
+
+bool GetFolder(HWND hDlg, int nFolder, char* Buffer)
+{
+ LPITEMIDLIST idl;
+ SHGetSpecialFolderLocation(hDlg, nFolder, &idl);
+ if (idl == 0) return false;
+
+ BOOL res = SHGetPathFromIDList(idl, Buffer);
+ CoTaskMemFree(idl);
+ return (res != FALSE);
+}
+
+
+bool CreateDesktopShortcut(HWND hDlg, char* Target)
+{
+ char DesktopBuf[MyMaxPath];
+ if (!GetFolder(hDlg, CSIDL_DESKTOP, DesktopBuf))
+ return false;
+
+ strcat(DesktopBuf, "\\" ProgramName ".lnk");
+
+ return CreateShortcut(DesktopBuf, Target, NULL, ProgramName " - "
Description);
+}
+
+
+void GetProgramFiles(HWND hDlg, char* Buffer)
+{
+ char* s = getenv("PROGRAMFILES");
+ strcpy(Buffer, (s != NULL ? s : "C:\\Program Files"));
+}
+
+
+
+
+void Browse(HWND hDlg, HWND hText)
+{
+ const int bif_NEWDIALOGSTYLE = 0x40;
+
+ BROWSEINFO bi;
+ bi.hwndOwner = hDlg;
+ bi.pidlRoot = NULL;
+ bi.pszDisplayName = NULL;
+ bi.lpszTitle = "Please select the installation folder";
+ bi.ulFlags = BIF_RETURNONLYFSDIRS | bif_NEWDIALOGSTYLE;
+ bi.lpfn = NULL;
+ bi.lParam = 0;
+ bi.iImage = 0;
+
+ LPITEMIDLIST idl = SHBrowseForFolder(&bi);
+
+ if (idl != NULL)
+ {
+ char Buffer[MyMaxPath];
+ SHGetPathFromIDList(idl, Buffer);
+ SetWindowText(hText, Buffer);
+ CoTaskMemFree(idl);
+ }
+}
=======================================
--- /dev/null
+++ /src/ShellCode.h Thu Apr 15 13:50:08 2004
@@ -0,0 +1,8 @@
+
+
+void ShellInit();
+void ShellDest();
+
+bool CreateDesktopShortcut(HWND hDlg, char* Target);
+void Browse(HWND hDlg, HWND hText);
+void GetProgramFiles(HWND hDlg, char* Buffer);
=======================================
--- /dev/null
+++ /src/StartCode.cpp Thu Apr 15 13:50:08 2004
@@ -0,0 +1,299 @@
+#include "header.h"
+#include "FileCode.h"
+#include "ShellCode.h"
+#include <commctrl.h>
+
+
+#define PLAY_NICELY
+#include "BlueZip\BlueHead.h"
+
+#include "resource.h"
+#include "Parameters.h"
+
+//Really no clue whats up with handles, needs more investigating (culprit
- BlueZip!!)
+
+
+
+#define ErrBox(Msg) MessageBox(hDlg, Msg, ProgramName " Installer",
MB_ICONERROR)
+#define QuestBox(Msg, Flag) MessageBox(hDlg, Msg, ProgramName "
Installer", MB_ICONQUESTION | Flag)
+#define InfoBox(Msg) MessageBox(hDlg, Msg, ProgramName " Installer",
MB_ICONINFORMATION)
+
+// GLOBAL STATE
+HINSTANCE hInst;
+bool InDoEvents = false;
+// END GLOBAL STATE
+
+
+void InitDialog(HWND hDlg)
+{
+ InitCommonControls();
+
+ char Buffer[MyMaxPath];
+ GetProgramFiles(hDlg, Buffer);
+ strcat(Buffer, "\\");
+ strcat(Buffer, InstallDir);
+
+ SetDlgItemText(hDlg, txtEdit, Buffer);
+ CheckDlgButton(hDlg, chkExecute, BST_CHECKED);
+ CheckDlgButton(hDlg, chkShortcut, BST_CHECKED);
+}
+
+void PaintDialog(HWND hDlg)
+{
+ const char* Msg = ProgramName " - " Description "\n© " Copyright;
+ static int MsgLen = strlen(Msg);
+
+ PAINTSTRUCT ps;
+ HDC hDC = BeginPaint(hDlg, &ps);
+
+ SelectObject(hDC, GetStockObject(DEFAULT_GUI_FONT));
+
+ RECT rc = {0, 0, 463, 54};
+
+ Rectangle(hDC, rc.left, rc.top, rc.right, rc.bottom);
+ FillRect(hDC, &rc, (HBRUSH) GetStockObject(WHITE_BRUSH));
+ rc.top = 13;
+ DrawText(hDC, Msg, MsgLen, &rc, DT_WORDBREAK | DT_CENTER);
+
+ EndPaint(hDlg, &ps);
+}
+
+void ErrDialog(HWND hDlg, char* Msg, char* Variable)
+{
+ char ErrBuffer[MyMaxPath * 2];
+ strcpy(ErrBuffer, Msg);
+ strcat(ErrBuffer, Variable);
+ ErrBox(ErrBuffer);
+}
+
+void DoEvents()
+{
+ InDoEvents = true;
+ MSG msg;
+ while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
+ {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+ InDoEvents = false;
+}
+
+
+bool DoInstall(char* InstallTo, bool RunOnEnd, HWND hDlg)
+{
+ char ZipFile[MyMaxPath];
+ GetModuleFileName(hInst, ZipFile, MyMaxPath);
+
+#ifdef _DEBUG
+ //make practical debugging a reality
+ strcat(ZipFile, ".zip");
+#endif
+
+ BlueZip b(ZipFile);
+ if (!b.Read())
+ {
+ ErrBox("Corrupt installer data, please try redownloading");
+ return true;
+ }
+
+ //Now replace / with \ to make it less confusing
+ NormalPath(InstallTo);
+
+ //And guarantee it has a trailing slash
+ int BufLen = strlen(InstallTo);
+ char* BufPos = &InstallTo[BufLen];
+ if ((BufLen > 0) && (BufPos[-1] != '\\'))
+ {
+ BufPos[0] = '\\';
+ BufPos++;
+ BufPos[0] = 0;
+ }
+
+
+ //Now see if you can create the directory
+ if (ExistsDir(InstallTo))
+ {
+ if (QuestBox("The directory already exists, continuing may overwrite
some files.\n"
+ "\n"
+ "Do you wish to continue?", MB_YESNO) == IDNO)
+ return false;
+ }
+ else
+ {
+ if (!CreateFolder(InstallTo))
+ {
+ ErrBox("Could not create the specified directory");
+ return false;
+ }
+ }
+
+
+
+ //Buffer is C:\\Program Files\\ProgramDir\\<space>
+ //BufPos is <space>
+
+ //Now test the primary file
+ int TimeOut = 2; //seconds before giving up and asking the user
+ if (PrimaryFile != NULL)
+ {
+ strcpy(BufPos, PrimaryFile);
+ while (Exists(InstallTo) && !DeleteFile(InstallTo))
+ {
+ if (TimeOut > 0)
+ {
+ TimeOut--;
+ Sleep(1000);
+ DoEvents();
+ }
+ else
+ {
+ if (QuestBox("The program \"" PrimaryFile "\" is currently running,
please exit it before continuing.",
+ MB_RETRYCANCEL) == IDCANCEL)
+ return false;
+ }
+ }
+ }
+
+ const int PrgFactor = 4096;
+ int Sum = 0;
+ for (zList* i = b.Files; i != NULL; i = i->next)
+ Sum += i->CompressedSize();
+ SendDlgItemMessage(hDlg, prgBar, PBM_SETRANGE, 0, MAKELPARAM(0, Sum /
PrgFactor));
+ Sum = 0;
+
+
+ //now you have access to at least the file Str
+ //extract all the files
+ for (i = b.Files; i != NULL; i = i->next)
+ {
+ SendDlgItemMessage(hDlg, prgBar, PBM_SETPOS, Sum / PrgFactor,
0);
+ Sum += i->CompressedSize();
+
+ strcpy(BufPos, i->FileName);
+ NormalPath(BufPos);
+ SetDlgItemText(hDlg, lblInstallFile, InstallTo);
+ DoEvents();
+
+ //if the last char is a '\' then directory
+ if (BufPos[strlen(BufPos)-1] == '\\')
+ {
+ if (!ExistsDir(InstallTo) && !CreateFolder(InstallTo))
+ {
+ ErrDialog(hDlg, "Could not create the
directory\n\n", InstallTo);
+ return false;
+ }
+ }
+ else
+ {
+ if ( (Exists(InstallTo) && !DeleteFile(InstallTo)) ||
+ (!b.GetFile(i, InstallTo)))
+ {
+ ErrDialog(hDlg, "Could not extract the
file\n\n", InstallTo);
+ return false;
+ }
+ }
+ }
+ SendDlgItemMessage(hDlg, prgBar, PBM_SETPOS, Sum / PrgFactor, 0);
+ SetDlgItemText(hDlg, lblInstallFile, "Finalising...");
+
+ //now InstallTo points to the primary file
+ strcpy(BufPos, PrimaryFile);
+ if (IsDlgButtonChecked(hDlg, chkShortcut) == BST_CHECKED)
+ {
+ if (!CreateDesktopShortcut(hDlg, InstallTo))
+ ErrBox("Could not create the desktop shortcut");
+ }
+
+ if (RunOnEnd)
+ {
+ if ((int) ShellExecute(hDlg, NULL, InstallTo, NULL, NULL,
SW_SHOWDEFAULT) <= 32)
+ ErrBox("Could not run file " PrimaryFile);
+ }
+
+ if (hDlg != NULL)
+ InfoBox(ProgramName " successfully installed");
+ return true;
+}
+
+void ShowProgress(HWND hDlg, bool State)
+{
+ int Show[] = {txtEdit, cmdBrowse, lblWelcome, 0};
+ int Hide[] = {prgBar, lblInstallTo, lblInstallFile, 0};
+ int Enable[] = {chkExecute, chkShortcut, IDOK, IDCANCEL, 0};
+
+ int i;
+ for (i = 0; Show[i] != 0; i++)
+ ShowWindow(GetDlgItem(hDlg, Show[i]), (State ? SW_HIDE :
SW_SHOW));
+ for (i = 0; Hide[i] != 0; i++)
+ ShowWindow(GetDlgItem(hDlg, Hide[i]), (State ? SW_SHOW :
SW_HIDE));
+ for (i = 0; Enable[i] != 0; i++)
+ EnableWindow(GetDlgItem(hDlg, Enable[i]), !State);
+
+ DoEvents();
+}
+
+bool TryInstall(HWND hDlg)
+{
+ char Buffer[MyMaxPath];
+ GetDlgItemText(hDlg, txtEdit, Buffer, MyMaxPath);
+ SetDlgItemText(hDlg, lblInstallFile, "Initialising...");
+ SendDlgItemMessage(hDlg, prgBar, PBM_SETPOS, 0, 0);
+
+ char Buff2[MyMaxPath];
+ strcpy(Buff2, "Installing to ");
+ strcat(Buff2, Buffer);
+ SetDlgItemText(hDlg, lblInstallTo, Buff2);
+
+ ShowProgress(hDlg, true);
+
+ return DoInstall(Buffer, IsDlgButtonChecked(hDlg, chkExecute) ==
BST_CHECKED, hDlg);
+}
+
+int CALLBACK DlgFunc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ switch(uMsg)
+ {
+ case WM_INITDIALOG:
+ ShellInit();
+ InitDialog(hDlg);
+ break;
+
+ case WM_DESTROY:
+ ShellDest();
+ break;
+
+ case WM_PAINT:
+ PaintDialog(hDlg);
+ break;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam))
+ {
+ case IDCANCEL:
+ if (!InDoEvents)
+ EndDialog(hDlg, 0);
+ break;
+
+ case IDOK:
+ if (TryInstall(hDlg))
+ EndDialog(hDlg, 0);
+ else
+ ShowProgress(hDlg, false);
+ break;
+
+ case cmdBrowse:
+ Browse(hDlg, GetDlgItem(hDlg, txtEdit));
+ break;
+ }
+ break;
+ }
+
+ return FALSE;
+}
+
+int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
lpCmdLine, int nCmdShow)
+{
+ hInst = hInstance;
+ DialogBox(hInstance, MAKEINTRESOURCE(dlgInstall), NULL, DlgFunc);
+ return 0;
+}
=======================================
--- /dev/null
+++ /src/resource.h Thu Apr 15 13:50:08 2004
@@ -0,0 +1,26 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by Installer.rc
+//
+#define dlgInstall 101
+#define IDI_ICON1 103
+#define txtEdit 1000
+#define cmdBrowse 1001
+#define chkExecute 1003
+#define chkShortcut 1004
+#define barTop 1009
+#define prgBar 1012
+#define lblWelcome 1013
+#define lblInstallTo 1014
+#define lblInstallFile 1015
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 107
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1016
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
=======================================
--- /dev/null
+++ /start.png Thu Apr 15 13:50:08 2004
Binary file, no diff available.
==============================================================================
Revision: 960718fb73a0
Author: David Philippi <address@hidden>
Date: Thu Apr 15 14:36:33 2004
Log: remove unrequired files
http://code.google.com/p/pingus/source/detail?r=960718fb73a0&repo=windows-installer
Deleted:
/source.zip
/src/Debug/Installer.res
/src/Release/Installer.res
=======================================
--- /source.zip Thu Apr 15 13:50:08 2004
+++ /dev/null
Binary file, no diff available.
=======================================
--- /src/Debug/Installer.res Thu Apr 15 13:50:08 2004
+++ /dev/null
Binary file, no diff available.
=======================================
--- /src/Release/Installer.res Thu Apr 15 13:50:08 2004
+++ /dev/null
Binary file, no diff available.
==============================================================================
Revision: 4f26142530c2
Author: David Philippi <address@hidden>
Date: Fri Apr 16 12:25:47 2004
Log: add patch and ran dos2unix
http://code.google.com/p/pingus/source/detail?r=4f26142530c2&repo=windows-installer
Modified:
/src/BlueZip/BlueHead.h
/src/BlueZip/BlueZip.cpp
/src/BlueZip/BlueZip.h
/src/BlueZip/CRC.cpp
/src/BlueZip/CompHead.h
/src/BlueZip/DefTree.cpp
/src/BlueZip/Deflate.cpp
/src/BlueZip/Errors.h
/src/BlueZip/FileIO.cpp
/src/BlueZip/FileIO.h
/src/BlueZip/General.cpp
/src/BlueZip/General.h
/src/BlueZip/Inflate.cpp
/src/BlueZip/Inflate.h
/src/BlueZip/License.txt
/src/BlueZip/ReadZip.cpp
/src/BlueZip/Store.cpp
/src/BlueZip/Structs.cpp
/src/BlueZip/Structs.h
/src/BlueZip/Trees.cpp
/src/BlueZip/WriteZip.cpp
/src/BlueZip/fList.cpp
/src/BlueZip/fList.h
/src/BlueZip/zList.cpp
/src/BlueZip/zList.h
/src/FileCode.cpp
/src/FileCode.h
/src/Header.h
/src/Installer.dsp
/src/Installer.dsw
/src/Installer.rc
/src/Parameters.h
/src/Pingus-Installer.manifest
/src/ShellCode.cpp
/src/ShellCode.h
/src/StartCode.cpp
/src/resource.h
=======================================
--- /src/Installer.rc Thu Apr 15 13:50:08 2004
+++ /src/Installer.rc Fri Apr 16 12:25:47 2004
@@ -67,14 +67,16 @@
PUSHBUTTON "Cancel",IDCANCEL,191,172,50,14
DEFPUSHBUTTON "Install",IDOK,251,172,50,14
CONTROL "Run program after installation",chkExecute,"Button",
- BS_AUTOCHECKBOX | WS_TABSTOP,7,124,294,11
- CONTROL "Create shortcut on desktop",chkShortcut,"Button",
+ BS_AUTOCHECKBOX | WS_TABSTOP,7,140,294,11
+ CONTROL "Create shortcut on
Desktop",chkShortcutDesktop,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,7,100,294,10
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,-1,164,311,1
LTEXT "Windows Installer © Neil Mitchell
1999-2004",IDC_STATIC,
7,176,155,10,WS_DISABLED
CONTROL "Progress2",prgBar,"msctls_progress32",NOT
WS_VISIBLE,7,
74,294,12
+ CONTROL "Create shortcut in the Start Menu",chkShortcutStart,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,111,294,10
END
=======================================
--- /src/ShellCode.cpp Thu Apr 15 13:50:08 2004
+++ /src/ShellCode.cpp Fri Apr 16 12:25:47 2004
@@ -18,7 +18,7 @@
}
-bool CreateShortcut(char* Destination, char* Target, char* Parameters,
char* Desc)
+bool CreateShortcut(char* Destination, char* Target, char* StartIn, char*
Parameters, char* Desc)
{
if (!OleReady)
return false;
@@ -37,6 +37,7 @@
psl->SetPath(Target);
if (Parameters != NULL) psl->SetArguments(Parameters);
if (Desc != NULL) psl->SetDescription(Desc);
+ if (StartIn != NULL) psl->SetWorkingDirectory(StartIn);
// Query IShellLink for the IPersistFile interface for saving the
// shortcut in persistent storage.
@@ -71,15 +72,47 @@
}
-bool CreateDesktopShortcut(HWND hDlg, char* Target)
-{
- char DesktopBuf[MyMaxPath];
- if (!GetFolder(hDlg, CSIDL_DESKTOP, DesktopBuf))
+bool CreateDesktopShortcut(HWND hDlg, char* Folder)
+{
+ char Destination[MyMaxPath];
+ if (!GetFolder(hDlg, CSIDL_DESKTOP, Destination))
return false;
- strcat(DesktopBuf, "\\" ProgramName ".lnk");
-
- return CreateShortcut(DesktopBuf, Target, NULL, ProgramName " - "
Description);
+ strcat(Destination, "\\" ProgramName ".lnk");
+
+ char Target[MyMaxPath];
+ strcpy(Target, Folder);
+ strcat(Target, "\\" PrimaryFile);
+
+ return CreateShortcut(Destination, Target, Folder, NULL, ProgramName "
- " Description);
+}
+
+bool CreateStartMenuShortcut(HWND hDlg, char* Folder)
+{
+ char Destination[MyMaxPath];
+ if (!GetFolder(hDlg, CSIDL_PROGRAMS, Destination))
+ return false;
+
+ strcat(Destination, "\\" ProgramName);
+ if (!CreateDirectory(Destination, NULL))
+ return false;
+
+ char* i = &Destination[strlen(Destination)];
+ i[0] = '\\';
+ i++;
+
+ char Target[MyMaxPath];
+ strcpy(Target, Folder);
+ strcat(Target, "\\" PrimaryFile);
+
+ strcpy(i, ProgramName ".lnk");
+ bool res = CreateShortcut(Destination, Target, Folder, NULL,
ProgramName " - " Description);
+
+ strcpy(i, "Readme.lnk");
+ strcpy(&Target[strlen(Folder)+1], "readme.htm");
+ res &= CreateShortcut(Destination, Target, NULL, NULL, ProgramName " -
Read Me");
+
+ return res;
}
=======================================
--- /src/ShellCode.h Thu Apr 15 13:50:08 2004
+++ /src/ShellCode.h Fri Apr 16 12:25:47 2004
@@ -3,6 +3,7 @@
void ShellInit();
void ShellDest();
-bool CreateDesktopShortcut(HWND hDlg, char* Target);
+bool CreateDesktopShortcut(HWND hDlg, char* Folder);
+bool CreateStartMenuShortcut(HWND hDlg, char* Folder);
void Browse(HWND hDlg, HWND hText);
void GetProgramFiles(HWND hDlg, char* Buffer);
=======================================
--- /src/StartCode.cpp Thu Apr 15 13:50:08 2004
+++ /src/StartCode.cpp Fri Apr 16 12:25:47 2004
@@ -35,7 +35,8 @@
SetDlgItemText(hDlg, txtEdit, Buffer);
CheckDlgButton(hDlg, chkExecute, BST_CHECKED);
- CheckDlgButton(hDlg, chkShortcut, BST_CHECKED);
+ CheckDlgButton(hDlg, chkShortcutDesktop, BST_CHECKED);
+ CheckDlgButton(hDlg, chkShortcutStart, BST_CHECKED);
}
void PaintDialog(HWND hDlg)
@@ -196,14 +197,22 @@
SendDlgItemMessage(hDlg, prgBar, PBM_SETPOS, Sum / PrgFactor, 0);
SetDlgItemText(hDlg, lblInstallFile, "Finalising...");
- //now InstallTo points to the primary file
- strcpy(BufPos, PrimaryFile);
- if (IsDlgButtonChecked(hDlg, chkShortcut) == BST_CHECKED)
+ //now InstallTo is the install directory, plus a \\ character
+ BufPos[-1] = 0;
+ if (IsDlgButtonChecked(hDlg, chkShortcutDesktop) == BST_CHECKED)
{
if (!CreateDesktopShortcut(hDlg, InstallTo))
- ErrBox("Could not create the desktop shortcut");
- }
-
+ ErrBox("Could not create the Desktop shortcut");
+ }
+ if (IsDlgButtonChecked(hDlg, chkShortcutStart) == BST_CHECKED)
+ {
+ if (!CreateStartMenuShortcut(hDlg, InstallTo))
+ ErrBox("Could not create the Start Menu shortcut");
+ }
+ BufPos[-1] = '\\';
+
+ //now InstallTo is the directory
+ strcpy(BufPos, PrimaryFile);
if (RunOnEnd)
{
if ((int) ShellExecute(hDlg, NULL, InstallTo, NULL, NULL,
SW_SHOWDEFAULT) <= 32)
@@ -219,7 +228,7 @@
{
int Show[] = {txtEdit, cmdBrowse, lblWelcome, 0};
int Hide[] = {prgBar, lblInstallTo, lblInstallFile, 0};
- int Enable[] = {chkExecute, chkShortcut, IDOK, IDCANCEL, 0};
+ int Enable[] = {chkExecute, chkShortcutDesktop, chkShortcutStart, IDOK,
IDCANCEL, 0};
int i;
for (i = 0; Show[i] != 0; i++)
=======================================
--- /src/resource.h Thu Apr 15 13:50:08 2004
+++ /src/resource.h Fri Apr 16 12:25:47 2004
@@ -8,6 +8,8 @@
#define cmdBrowse 1001
#define chkExecute 1003
#define chkShortcut 1004
+#define chkShortcutDesktop 1004
+#define chkShortcutStart 1005
#define barTop 1009
#define prgBar 1012
#define lblWelcome 1013
==============================================================================
Revision: fa392afde534
Author: David Philippi <address@hidden>
Date: Fri Apr 16 14:21:06 2004
Log: unix2dos
http://code.google.com/p/pingus/source/detail?r=fa392afde534&repo=windows-installer
Modified:
/src/Installer.dsp
/src/Installer.dsw
==============================================================================
Revision: d06a0440285d
Author: David Philippi <address@hidden>
Date: Sun Apr 18 13:54:42 2004
Log: display space on drive, better error handling
http://code.google.com/p/pingus/source/detail?r=d06a0440285d&repo=windows-installer
Modified:
/src/BlueZip/BlueZip.cpp
/src/BlueZip/BlueZip.h
/src/FileCode.cpp
/src/FileCode.h
/src/Installer.rc
/src/ShellCode.cpp
/src/StartCode.cpp
/src/resource.h
=======================================
--- /src/BlueZip/BlueZip.cpp Fri Apr 16 12:25:47 2004
+++ /src/BlueZip/BlueZip.cpp Sun Apr 18 13:54:42 2004
@@ -1,6 +1,6 @@
#include "BlueHead.h"
-BlueZip::BlueZip(LPCTSTR FileName)
+void BlueZip::Setup(LPCTSTR FileName)
{
this->FileName = CopyString(FileName);
=======================================
--- /src/BlueZip/BlueZip.h Fri Apr 16 12:25:47 2004
+++ /src/BlueZip/BlueZip.h Sun Apr 18 13:54:42 2004
@@ -13,6 +13,8 @@
bool ScanZip(File f);
void ReadEnd(File f);
+ void Setup(LPCTSTR FileName);
+
#ifndef NO_COMPRESSION
fList* Pending; // List of names to add
void WriteEnd(File f);
@@ -24,7 +26,10 @@
zList* Files; // A point to the first file in the ZIP
- BlueZip(LPCTSTR FileName);
+ BlueZip(){};
+ BlueZip(LPCTSTR FileName){Setup(FileName);}
+ void SetZipFile(LPCTSTR FileName){Setup(FileName);}
+
~BlueZip();
bool Read(); //Load the file into memory
=======================================
--- /src/FileCode.cpp Fri Apr 16 12:25:47 2004
+++ /src/FileCode.cpp Sun Apr 18 13:54:42 2004
@@ -28,26 +28,74 @@
if (File[i] == '/')
File[i] = '\\';
}
+ if (File[i-1] == '\\')
+ File[i-1] = 0;
}
-// The first file passed must end in a \\ character
-bool CreateFolder(char* File)
+bool ParentFolder(char* File)
{
char* s = strrchr(File, '\\');
if (s == NULL)
return false;
- int BufChar = s[0];
s[0] = 0;
- bool Success = false;
- if (!CreateDirectory(File, NULL))
- {
- if (CreateFolder(File) && CreateDirectory(File, NULL))
- Success = true;
+ return true;
+}
+
+void UnparentFolder(char* File)
+{
+ File[strlen(File)] = '\\';
+}
+
+
+bool EnsureFolder(char* File)
+{
+ if (ExistsDir(File))
+ return true;
+
+ if (ParentFolder(File))
+ {
+ bool Res = EnsureFolder(File);
+ UnparentFolder(File);
+ if (!Res) return false;
+ }
+
+ return (CreateDirectory(File, NULL) != 0);
+}
+
+void FileSize(__int64 Size, char* Buffer)
+{
+ //set the number of bytes as a Windows standard file count
+ const TCHAR PreFix[] = "KMGTP";
+ //make sure to 3 sf
+
+ if (Size < 1000)
+ {
+ itoa((int) Size, Buffer, 10);
+ strcat(Buffer, " bytes");
}
else
- Success = true;
-
- s[0] = BufChar;
- return Success;
-}
+ {
+ int i, j = 1024;
+ for (i = 0; Size > j * 999; i++)
+ j *= 1024;
+
+ itoa((int) (Size / (__int64) j), Buffer, 10);
+ int k = strlen(Buffer);
+ if (k != 3)
+ {
+ Buffer[k] = '.';
+ j = ((int) (Size % j) * 1000) / j;
+ int l = 100;
+ for (k++; k != 4; k++)
+ {
+ Buffer[k] = (j / l) + '0';
+ j %= l;
+ l /= 10;
+ }
+ }
+ Buffer[k + 0] = PreFix[i];
+ Buffer[k + 1] = 'B';
+ Buffer[k + 2] = 0;
+ }
+}
=======================================
--- /src/FileCode.h Fri Apr 16 12:25:47 2004
+++ /src/FileCode.h Sun Apr 18 13:54:42 2004
@@ -4,4 +4,7 @@
bool ExistsDir(char* File);
bool CanReadWrite(char* File);
void NormalPath(char* File);
-bool CreateFolder(char* File);
+bool EnsureFolder(char* File);
+void FileSize(__int64 Size, char* Buffer);
+
+const int MaxFileSizeBuf = 10;
=======================================
--- /src/Installer.rc Fri Apr 16 12:25:47 2004
+++ /src/Installer.rc Sun Apr 18 13:54:42 2004
@@ -27,18 +27,18 @@
// TEXTINCLUDE
//
-1 TEXTINCLUDE DISCARDABLE
+1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
-2 TEXTINCLUDE DISCARDABLE
+2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
-3 TEXTINCLUDE DISCARDABLE
+3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
@@ -69,14 +69,15 @@
CONTROL "Run program after installation",chkExecute,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,7,140,294,11
CONTROL "Create shortcut on
Desktop",chkShortcutDesktop,"Button",
- BS_AUTOCHECKBOX | WS_TABSTOP,7,100,294,10
+ BS_AUTOCHECKBOX | WS_TABSTOP,7,114,294,10
CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,-1,164,311,1
LTEXT "Windows Installer © Neil Mitchell
1999-2004",IDC_STATIC,
7,176,155,10,WS_DISABLED
CONTROL "Progress2",prgBar,"msctls_progress32",NOT
WS_VISIBLE,7,
74,294,12
CONTROL "Create shortcut in the Start Menu",chkShortcutStart,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,111,294,10
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,124,294,10
+ LTEXT "#",lblSpace,7,89,294,9
END
@@ -86,7 +87,7 @@
//
#ifdef APSTUDIO_INVOKED
-GUIDELINES DESIGNINFO DISCARDABLE
+GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
dlgInstall, DIALOG
BEGIN
=======================================
--- /src/ShellCode.cpp Fri Apr 16 12:25:47 2004
+++ /src/ShellCode.cpp Sun Apr 18 13:54:42 2004
@@ -1,6 +1,7 @@
#include "Header.h"
#include "Parameters.h"
#include <shlobj.h>
+#include "FileCode.h"
bool OleReady;
@@ -94,12 +95,11 @@
return false;
strcat(Destination, "\\" ProgramName);
- if (!CreateDirectory(Destination, NULL))
+ if (!EnsureFolder(Destination))
return false;
+ strcat(Destination, "\\");
char* i = &Destination[strlen(Destination)];
- i[0] = '\\';
- i++;
char Target[MyMaxPath];
strcpy(Target, Folder);
@@ -124,6 +124,20 @@
+int CALLBACK BrowseCallbackProc(HWND hWnd, UINT uMsg, LPARAM lParam,
LPARAM lpData)
+{
+ switch(uMsg)
+ {
+ case BFFM_INITIALIZED:
+ char Buffer[MyMaxPath];
+ GetWindowText((HWND) lpData, Buffer, MyMaxPath);
+ SendMessage(hWnd, BFFM_SETSELECTION, TRUE, (LPARAM) Buffer);
+ break;
+ }
+
+ return 0;
+}
+
void Browse(HWND hDlg, HWND hText)
{
@@ -133,10 +147,10 @@
bi.hwndOwner = hDlg;
bi.pidlRoot = NULL;
bi.pszDisplayName = NULL;
- bi.lpszTitle = "Please select the installation folder";
+ bi.lpszTitle = "Select the installation folder for " ProgramName;
bi.ulFlags = BIF_RETURNONLYFSDIRS | bif_NEWDIALOGSTYLE;
- bi.lpfn = NULL;
- bi.lParam = 0;
+ bi.lpfn = &BrowseCallbackProc;
+ bi.lParam = (LPARAM) hText;
bi.iImage = 0;
LPITEMIDLIST idl = SHBrowseForFolder(&bi);
=======================================
--- /src/StartCode.cpp Fri Apr 16 12:25:47 2004
+++ /src/StartCode.cpp Sun Apr 18 13:54:42 2004
@@ -2,6 +2,7 @@
#include "FileCode.h"
#include "ShellCode.h"
#include <commctrl.h>
+#include <stdio.h>
#define PLAY_NICELY
@@ -10,8 +11,6 @@
#include "resource.h"
#include "Parameters.h"
-//Really no clue whats up with handles, needs more investigating (culprit
- BlueZip!!)
-
#define ErrBox(Msg) MessageBox(hDlg, Msg, ProgramName " Installer",
MB_ICONERROR)
@@ -21,9 +20,19 @@
// GLOBAL STATE
HINSTANCE hInst;
bool InDoEvents = false;
+BlueZip zip;
+
+int TotalCompSize;
+int TotalRealSize;
// END GLOBAL STATE
+//Predefines
+void PathChanged(HWND hDlg);
+//end
+
+
+
void InitDialog(HWND hDlg)
{
InitCommonControls();
@@ -37,6 +46,67 @@
CheckDlgButton(hDlg, chkExecute, BST_CHECKED);
CheckDlgButton(hDlg, chkShortcutDesktop, BST_CHECKED);
CheckDlgButton(hDlg, chkShortcutStart, BST_CHECKED);
+
+ char ZipFile[MyMaxPath];
+ GetModuleFileName(hInst, ZipFile, MyMaxPath);
+
+#ifdef _DEBUG
+ //make practical debugging a reality
+ strcat(ZipFile, ".zip");
+#endif
+
+ zip.SetZipFile(ZipFile);
+ if (!zip.Read())
+ {
+ ErrBox("Corrupt installer data, please try redownloading");
+ DestroyWindow(hDlg);
+ return;
+ }
+
+ TotalCompSize = 0;
+ TotalRealSize = 0;
+ for (zList* i = zip.Files; i != NULL; i = i->next)
+ {
+ TotalCompSize += i->CompressedSize();
+ TotalRealSize += i->OriginalSize();
+ }
+ PathChanged(hDlg);
+}
+
+void PathChanged(HWND hDlg)
+{
+ static char LastPath = -1;
+ char Buffer[MyMaxPath];
+
+ GetDlgItemText(hDlg, txtEdit, Buffer, MyMaxPath);
+ char NewLastPath;
+ if (Buffer[1] == ':')
+ NewLastPath = toupper(Buffer[0]);
+ else
+ NewLastPath = 0;
+ if ((NewLastPath > 'Z') || (NewLastPath < 'A'))
+ NewLastPath = 0;
+
+ if (LastPath == NewLastPath)
+ return;
+ LastPath = NewLastPath;
+
+ char Buf[MaxFileSizeBuf];
+ FileSize(TotalRealSize, Buf);
+ int Len = sprintf(Buffer, "Space required is %s", Buf);
+
+ if (LastPath != 0)
+ {
+ ULARGE_INTEGER DriveSpace;
+ char Buf[4] = {LastPath, ':', '\\', 0};
+ if (!GetDiskFreeSpaceEx(Buf, &DriveSpace, NULL, NULL))
+ DriveSpace.QuadPart = 0;
+
+ FileSize(DriveSpace.QuadPart, Buf);
+ sprintf(&Buffer[Len], ", installing on drive %c: which has %s free",
LastPath, Buf);
+ }
+
+ SetDlgItemText(hDlg, lblSpace, Buffer);
}
void PaintDialog(HWND hDlg)
@@ -82,34 +152,10 @@
bool DoInstall(char* InstallTo, bool RunOnEnd, HWND hDlg)
{
- char ZipFile[MyMaxPath];
- GetModuleFileName(hInst, ZipFile, MyMaxPath);
-
-#ifdef _DEBUG
- //make practical debugging a reality
- strcat(ZipFile, ".zip");
-#endif
-
- BlueZip b(ZipFile);
- if (!b.Read())
- {
- ErrBox("Corrupt installer data, please try redownloading");
- return true;
- }
-
//Now replace / with \ to make it less confusing
+ //And guarantee it has no trailing slash
NormalPath(InstallTo);
- //And guarantee it has a trailing slash
- int BufLen = strlen(InstallTo);
- char* BufPos = &InstallTo[BufLen];
- if ((BufLen > 0) && (BufPos[-1] != '\\'))
- {
- BufPos[0] = '\\';
- BufPos++;
- BufPos[0] = 0;
- }
-
//Now see if you can create the directory
if (ExistsDir(InstallTo))
@@ -121,15 +167,16 @@
}
else
{
- if (!CreateFolder(InstallTo))
+ if (!EnsureFolder(InstallTo))
{
ErrBox("Could not create the specified directory");
return false;
}
}
-
-
+ strcat(InstallTo, "\\");
+ int BufLen = strlen(InstallTo);
+ char* BufPos = &InstallTo[BufLen];
//Buffer is C:\\Program Files\\ProgramDir\\<space>
//BufPos is <space>
@@ -156,29 +203,27 @@
}
const int PrgFactor = 4096;
- int Sum = 0;
- for (zList* i = b.Files; i != NULL; i = i->next)
- Sum += i->CompressedSize();
- SendDlgItemMessage(hDlg, prgBar, PBM_SETRANGE, 0, MAKELPARAM(0, Sum /
PrgFactor));
- Sum = 0;
+ SendDlgItemMessage(hDlg, prgBar, PBM_SETRANGE, 0, MAKELPARAM(0,
TotalCompSize / PrgFactor));
+ int Done = 0;
//now you have access to at least the file Str
//extract all the files
- for (i = b.Files; i != NULL; i = i->next)
- {
- SendDlgItemMessage(hDlg, prgBar, PBM_SETPOS, Sum / PrgFactor,
0);
- Sum += i->CompressedSize();
+ for (zList* i = zip.Files; i != NULL; i = i->next)
+ {
+ Done += i->CompressedSize();
strcpy(BufPos, i->FileName);
+ char LastChar = BufPos[strlen(BufPos)-1];
+ bool IsFolder = ((LastChar == '\\') || (LastChar == '/'));
NormalPath(BufPos);
- SetDlgItemText(hDlg, lblInstallFile, InstallTo);
+ SetDlgItemText(hDlg, lblInstallFile, BufPos);
DoEvents();
-
+
//if the last char is a '\' then directory
- if (BufPos[strlen(BufPos)-1] == '\\')
- {
- if (!ExistsDir(InstallTo) && !CreateFolder(InstallTo))
+ if (IsFolder)
+ {
+ if (!EnsureFolder(InstallTo))
{
ErrDialog(hDlg, "Could not create the
directory\n\n", InstallTo);
return false;
@@ -187,14 +232,14 @@
else
{
if ( (Exists(InstallTo) && !DeleteFile(InstallTo)) ||
- (!b.GetFile(i, InstallTo)))
+ (!zip.GetFile(i, InstallTo)))
{
ErrDialog(hDlg, "Could not extract the
file\n\n", InstallTo);
return false;
}
}
- }
- SendDlgItemMessage(hDlg, prgBar, PBM_SETPOS, Sum / PrgFactor, 0);
+ SendDlgItemMessage(hDlg, prgBar, PBM_SETPOS, Done / PrgFactor,
0);
+ }
SetDlgItemText(hDlg, lblInstallFile, "Finalising...");
//now InstallTo is the install directory, plus a \\ character
@@ -293,6 +338,11 @@
case cmdBrowse:
Browse(hDlg, GetDlgItem(hDlg, txtEdit));
break;
+
+ case txtEdit:
+ if ((HIWORD(wParam) == EN_CHANGE) && (TotalRealSize !=
0))
+ PathChanged(hDlg);
+ break;
}
break;
}
=======================================
--- /src/resource.h Fri Apr 16 12:25:47 2004
+++ /src/resource.h Sun Apr 18 13:54:42 2004
@@ -15,14 +15,15 @@
#define lblWelcome 1013
#define lblInstallTo 1014
#define lblInstallFile 1015
+#define lblSpace 1016
// Next default values for new objects
-//
+//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 107
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1016
+#define _APS_NEXT_CONTROL_VALUE 1017
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
==============================================================================
Revision: 7d9b738b40c9
Author: David Philippi <address@hidden>
Date: Thu Dec 30 16:34:22 2004
Log: updated mail address
http://code.google.com/p/pingus/source/detail?r=7d9b738b40c9&repo=windows-installer
Modified:
/readme.txt
=======================================
--- /readme.txt Thu Apr 15 13:50:08 2004
+++ /readme.txt Thu Dec 30 16:34:22 2004
@@ -10,4 +10,4 @@
Cancel an active install
Allow you to uninstall Pingus
-Written by Neil Mitchell, address@hidden for help if required,
or the Pingus mailing list.
+Written by Neil Mitchell, ndmitchell -AT- gmail.com for help if required,
or the Pingus mailing list.
==============================================================================
Revision: aa142c1d49e4
Author: Jason Green <address@hidden>
Date: Mon Dec 5 09:00:26 2005
Log: Set SVN end of line style on everything to native.
Got rid of colmap hack in preparation for my Clanlib patch.
Cleaned up a few unneeded #includes.
http://code.google.com/p/pingus/source/detail?r=aa142c1d49e4&repo=windows-installer
Modified:
/readme.txt
/src/Installer.dsp
/src/Installer.dsw
==============================================================================
Revision: 2040f317ec20
Author: Ingo Ruhnke <address@hidden>
Date: Sat Feb 11 06:32:52 2006
Log: Started Pingus-SDL branch
http://code.google.com/p/pingus/source/detail?r=2040f317ec20&repo=windows-installer
==============================================================================
Revision: 0afc1f04bbb6
Author: Jimmy Salmon <address@hidden>
Date: Sun Aug 19 14:20:27 2007
Log: Added nsis installer
http://code.google.com/p/pingus/source/detail?r=0afc1f04bbb6&repo=windows-installer
Added:
/Microsoft.VC80.CRT.manifest
/SDL.dll
/SDL_mixer.dll
/libiconv2.dll
/msvcp80.dll
/msvcr80.dll
/ogg.dll
/pingus.nsi
/release.sh
/smpeg.dll
/vorbis.dll
/vorbisfile.dll
Deleted:
/installer.exe
/readme.txt
/run.png
/src/BlueZip/BlueHead.h
/src/BlueZip/BlueZip.cpp
/src/BlueZip/BlueZip.h
/src/BlueZip/CRC.cpp
/src/BlueZip/CompHead.h
/src/BlueZip/DefTree.cpp
/src/BlueZip/Deflate.cpp
/src/BlueZip/Errors.h
/src/BlueZip/FileIO.cpp
/src/BlueZip/FileIO.h
/src/BlueZip/General.cpp
/src/BlueZip/General.h
/src/BlueZip/Inflate.cpp
/src/BlueZip/Inflate.h
/src/BlueZip/License.txt
/src/BlueZip/ReadZip.cpp
/src/BlueZip/Store.cpp
/src/BlueZip/Structs.cpp
/src/BlueZip/Structs.h
/src/BlueZip/Trees.cpp
/src/BlueZip/WriteZip.cpp
/src/BlueZip/fList.cpp
/src/BlueZip/fList.h
/src/BlueZip/zList.cpp
/src/BlueZip/zList.h
/src/FileCode.cpp
/src/FileCode.h
/src/Header.h
/src/Installer.dsp
/src/Installer.dsw
/src/Installer.rc
/src/Parameters.h
/src/Pingus-Installer.manifest
/src/Setup.ico
/src/ShellCode.cpp
/src/ShellCode.h
/src/StartCode.cpp
/src/resource.h
/start.png
=======================================
--- /dev/null
+++ /Microsoft.VC80.CRT.manifest Sun Aug 19 14:20:27 2007
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+ <noInheritable/>
+ <assemblyIdentity
+ type="win32"
+ name="Microsoft.VC80.CRT"
+ version="8.0.50727.762"
+ processorArchitecture="x86"
+ publicKeyToken="1fc8b3b9a1e18e3b"
+ />
+ <file name="msvcr80.dll"/>
+ <file name="msvcp80.dll"/>
+</assembly>
=======================================
--- /dev/null
+++ /SDL.dll Sun Aug 19 14:20:27 2007
Binary file, no diff available.
=======================================
--- /dev/null
+++ /SDL_mixer.dll Sun Aug 19 14:20:27 2007
Binary file, no diff available.
=======================================
--- /dev/null
+++ /libiconv2.dll Sun Aug 19 14:20:27 2007
Binary file, no diff available.
=======================================
--- /dev/null
+++ /msvcp80.dll Sun Aug 19 14:20:27 2007
Binary file, no diff available.
=======================================
--- /dev/null
+++ /msvcr80.dll Sun Aug 19 14:20:27 2007
Binary file, no diff available.
=======================================
--- /dev/null
+++ /ogg.dll Sun Aug 19 14:20:27 2007
Binary file, no diff available.
=======================================
--- /dev/null
+++ /pingus.nsi Sun Aug 19 14:20:27 2007
@@ -0,0 +1,65 @@
+!include "MUI.nsh"
+
+!define NAME "Pingus"
+
+Name "${NAME}"
+OutFile "Pingus-0.7.exe"
+
+#!define MUI_ICON "src/win32/icon1.ico"
+#!define MUI_UNICON "src/win32/icon1.ico"
+
+InstallDir "$PROGRAMFILES\${NAME}"
+InstallDirRegKey HKCU "Software\${NAME}" ""
+
+Var MUI_TEMP
+Var STARTMENU_FOLDER
+
+!define MUI_ABORTWARNING
+
+!insertmacro MUI_PAGE_WELCOME
+!insertmacro MUI_PAGE_DIRECTORY
+
+!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU"
+!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\${NAME}"
+!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
+!insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER
+
+!insertmacro MUI_PAGE_INSTFILES
+
+;!define MUI_FINISHPAGE_TEXT ""
+!define MUI_FINISHPAGE_RUN "$INSTDIR\pingus.exe"
+;!define MUI_FINISHPAGE_RUN_TEXT ""
+!insertmacro MUI_PAGE_FINISH
+
+!insertmacro MUI_UNPAGE_CONFIRM
+!insertmacro MUI_UNPAGE_INSTFILES
+
+!insertmacro MUI_LANGUAGE "English"
+
+
+Section "${NAME}" SecDummy
+ SectionIn RO
+ SetOutPath "$INSTDIR"
+ File /r "pingus\*.*"
+ WriteRegStr HKCU "Software\${NAME}" "" $INSTDIR
+ !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
+ CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
+
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\${NAME}.lnk" "$INSTDIR\pingus.exe"
+
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\uninstall.exe"
+ !insertmacro MUI_STARTMENU_WRITE_END
+ WriteUninstaller "$INSTDIR\Uninstall.exe"
+SectionEnd
+
+
+Section "Uninstall"
+ RMDir /r "$INSTDIR"
+
+ !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
+
+ Delete "$SMPROGRAMS\$MUI_TEMP\${NAME}.lnk"
+ Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
+ RMDir "$SMPROGRAMS\$MUI_TEMP"
+
+ DeleteRegKey /ifempty HKCU "Software\${NAME}"
+SectionEnd
+
=======================================
--- /dev/null
+++ /release.sh Sun Aug 19 14:20:27 2007
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+echo "Exporting svn"
+svn export . pingus
+rm -rf pingus/src
+rm -f pingus/pingus.sln
+rm -f pingus/pingus.vcproj
+rm -f pingus/SConstruct
+
+cp Release/pingus.exe pingus
+cp contrib/windows_installer/libiconv2.dll pingus
+cp contrib/windows_installer/msvcp80.dll pingus
+cp contrib/windows_installer/msvcr80.dll pingus
+cp contrib/windows_installer/ogg.dll pingus
+cp contrib/windows_installer/SDL.dll pingus
+cp contrib/windows_installer/SDL_mixer.dll pingus
+cp contrib/windows_installer/smpeg.dll pingus
+cp contrib/windows_installer/vorbis.dll pingus
+cp contrib/windows_installer/vorbisfile.dll pingus
+cp contrib/windows_installer/Microsoft.VC80.CRT.manifest pingus
+
+echo "Creating installer"
+"c:/Program Files/NSIS/makensis.exe" /NOCD
contrib/windows_installer/pingus.nsi
+
+echo "Cleaning up"
+rm -rf pingus
+
+echo "Done"
+
=======================================
--- /dev/null
+++ /smpeg.dll Sun Aug 19 14:20:27 2007
Binary file, no diff available.
=======================================
--- /dev/null
+++ /vorbis.dll Sun Aug 19 14:20:27 2007
File is too large to display a diff.
=======================================
--- /dev/null
+++ /vorbisfile.dll Sun Aug 19 14:20:27 2007
Binary file, no diff available.
=======================================
--- /installer.exe Thu Apr 15 13:50:08 2004
+++ /dev/null
Binary file, no diff available.
=======================================
--- /readme.txt Mon Dec 5 09:00:26 2005
+++ /dev/null
@@ -1,13 +0,0 @@
-This is the Pingus Windows Installer
-
-The installer, when built in release mode, can be concatenated with a zip
that you use to install and executed. The command line for doing this in
DOS is:
-
-copy /b installer.exe + pingus.zip Pingus-Setup.exe
-
-Its not too badly written so it should be possible to tweak the code as
required. The additional overhead of the installer is 20.5Kb
-
-The things the installer does not do:
- Cancel an active install
- Allow you to uninstall Pingus
-
-Written by Neil Mitchell, ndmitchell -AT- gmail.com for help if required,
or the Pingus mailing list.
=======================================
--- /run.png Thu Apr 15 13:50:08 2004
+++ /dev/null
Binary file, no diff available.
=======================================
--- /src/BlueZip/BlueHead.h Fri Apr 16 12:25:47 2004
+++ /dev/null
@@ -1,70 +0,0 @@
-#define WIN32_MEAN_AND_LEAN
-#include <windows.h>
-
-#ifdef _DEBUG
-# define Assert(a) if (!(a)) _asm int 3;
-# define AssertD(a)if (!(a)) _asm int 3; //use if it has to create extra
data to Assert on
-#else
-# define Assert(a) __assume(a); //Microsoft specific, speed up programs
-# define AssertD(a) //nothing
-#endif
-
-#if defined(_DEBUG) && defined(ERR_BREAK)
-# define ErrMsg(a) _asm int 3;
-#else
-# define ErrMsg(a) //nothing
-#endif
-
-//to remove Compression define NO_COMPRESSION
-#define NO_COMPRESSION
-
-//Make good programming practice
-#ifndef PLAY_NICELY
-#define malloc MALLOC_IS_OLD
-#define free FREE_IS_OLD
-#define strdup STRDUP_IS_OLD
-#define BOOL BOOL_IS_FOR_CRAP_C_COMPILERS_ONLY
-#endif //!PLAY_NICELY
-
-typedef unsigned char u8;
-typedef unsigned short u16;
-typedef unsigned long u32;
-typedef unsigned int uint;
-
-// Macros for reading shorts and longs from an array of bytes
-u16 inline stream16(char* b, int i)
-{
- return *((u16*) &b[i]);
-}
-
-u32 inline stream32(char* b, int i)
-{
- return *((u32*) &b[i]);
-}
-
-class datLocal;
-class datCentral;
-class datEnd;
-
-#include "General.h"
-#include "FileIO.h"
-#include "Structs.h"
-
-
-class BlueZip;
-class zList;
-class fList;
-
-#include "BlueZip.h"
-#include "zList.h"
-#include "fList.h"
-
-//From CRC
-void CRC(const u8* buf, uint len);
-void InitCRC();
-u32 GetCRC();
-
-
-//From Store.cpp
-void ReadStore(File In, File Out, zList* z);
-void WriteStore(File In, File Out, zList* z);
=======================================
--- /src/BlueZip/BlueZip.cpp Sun Apr 18 13:54:42 2004
+++ /dev/null
@@ -1,105 +0,0 @@
-#include "BlueHead.h"
-
-void BlueZip::Setup(LPCTSTR FileName)
-{
- this->FileName = CopyString(FileName);
-
- //Initialise for a blank file name
- Files = NULL;
- Comment = NULL;
- data.lComment = 0;
-
-#ifndef NO_COMPRESSION
- Pending = NULL;
-#endif
-}
-
-BlueZip::~BlueZip()
-{
- delete[] FileName;
- if (Comment) delete[] Comment;
-
- while (Files != NULL)
- {
- zList* z = Files;
- Files = Files->next;
- delete z;
- }
-
-#ifndef NO_COMPRESSION
- while (Pending != NULL)
- {
- fList* f = Pending;
- Pending = Pending->next;
- delete f;
- }
-#endif
-}
-
-#ifndef NO_COMPRESSION
-
-void BlueZip::AddFile(LPCTSTR FileName)
-{
- Pending = new fList(FileName, Pending);
-}
-
-void BlueZip::WriteEnd(File f)
-{
- //Handle mutliple disks correctly (i.e. don't)
- data.DiskNo = 0;
- data.DiskOne = 0;
- data.DiskNum = data.Count;
-
- long l = sigEnd;
- FileWrite(f, &l, 4);
- data.Write(f);
- if (data.lComment)
- FileWrite(f, Comment, data.lComment);
-}
-
-#endif //!NO_COMPRESSION
-
-
-void BlueZip::ReadEnd(File f)
-{
- data.Read(f);
-
- if (data.lComment)
- {
- Comment = new char[data.lComment];
- FileRead(f, Comment, data.lComment);
- }
-}
-
-bool BlueZip::GetFile(zList* z, LPCTSTR FileName)
-{
- //First open the ZIP file for reading
- File Orig = FileOpenRead(this->FileName);
- if (!FileValid(Orig))
- {
- ErrMsg("Failed to open the reading file");
- return false;
- }
-
- File Out = FileOpenWrite(FileName);
- if (!FileValid(Out))
- {
- ErrMsg("Failed to open the output file");
- return false;
- }
-
- //Perform CRC checks yourself
- InitCRC();
- SeekBeg(Orig, z->data.Offset + FilePosDelta);
- ReadStore(Orig, Out, z);
-
- if (z->data.CRC != GetCRC())
- {
- ErrMsg("Failed on the CRC");
- return false;
- }
-
- FileClose(Orig);
- FileClose(Out);
- return true;
-}
=======================================
--- /src/BlueZip/BlueZip.h Sun Apr 18 13:54:42 2004
+++ /dev/null
@@ -1,43 +0,0 @@
-
-class __declspec(dllexport) BlueZip
-{
-private:
- datEnd data; // The end header
- char* Comment; // Actual comment
-
- int FilePosDelta; // The value added to begin seeks to compenstate for
SFX headers
-
- LPTSTR FileName;
-
- //Used by ReadFile
- bool ScanZip(File f);
- void ReadEnd(File f);
-
- void Setup(LPCTSTR FileName);
-
-#ifndef NO_COMPRESSION
- fList* Pending; // List of names to add
- void WriteEnd(File f);
-
- //fList** PendingNext; - Implement this to add in order
-#endif
-
-public:
- zList* Files; // A point to the first file in the ZIP
-
-
- BlueZip(){};
- BlueZip(LPCTSTR FileName){Setup(FileName);}
- void SetZipFile(LPCTSTR FileName){Setup(FileName);}
-
- ~BlueZip();
-
- bool Read(); //Load the file into memory
-
-#ifndef NO_COMPRESSION
- bool Write(bool Store = false); //Write the file back out
- void AddFile(LPCTSTR FileName);
-#endif
-
- bool GetFile(zList* z, LPCTSTR FileName);
-};
=======================================
--- /src/BlueZip/CRC.cpp Fri Apr 16 12:25:47 2004
+++ /dev/null
@@ -1,111 +0,0 @@
-#include "BlueHead.h"
-//Create a CRC value for a buffer
-
-//First define the table
-const u32 CrcTable[256] =
-{
- 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
- 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
- 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
- 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
- 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
- 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
- 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
- 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
- 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
- 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
- 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
- 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
- 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
- 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
- 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
- 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
- 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
- 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
- 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
- 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
- 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
- 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
- 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
- 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
- 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
- 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
- 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
- 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
- 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
- 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
- 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
- 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
- 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
- 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
- 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
- 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
- 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
- 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
- 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
- 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
- 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
- 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
- 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
- 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
- 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
- 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
- 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
- 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
- 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
- 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
- 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
- 0x2d02ef8dL
-};
-
-
-//One atomic operation
-#define DO1(buf) CRC32(*buf++)
-#define DO2(buf) DO1(buf); DO1(buf)
-#define DO4(buf) DO2(buf); DO2(buf)
-#define DO8(buf) DO4(buf); DO4(buf)
-
-
-//Local variable holding the CRC value:
-u32 CrcRegister;
-
-void inline CRC32(u8 b)
-{
- CrcRegister = CrcTable[((int)CrcRegister ^ b) & 0xff] ^ (CrcRegister >>
8);
-}
-
-void InitCRC()
-{
- //Do the inversion at this stage, save the odd clock cycle
- CrcRegister = 0xffffffffL;
-}
-
-u32 GetCRC()
-{
- //Check code is compatible with ZIP code, may vary based on word size
- Assert((CrcRegister ^ 0xffffffffL) == ~CrcRegister);
- return ~CrcRegister;
-}
-
-void CRC(const u8* buf, uint len)
-{
-//crc - the shift register
-//buf - the buffer containing the data
-//len - the length of the buffer
-
-// Run a set of bytes through the crc shift register. If buf is a NULL
-// pointer, then initialize the crc shift register contents instead.
-// Return the current crc in either case.
- if (buf == NULL) return;
-
- //unroll the loops
- for (; len >= 8; len -= 8)
- {
- //Will be expanded to 8 different calls
- DO8(buf);
- }
- for (; len /* >= 1 */; len--)
- {
- DO1(buf);
- }
-}
=======================================
--- /src/BlueZip/CompHead.h Fri Apr 16 12:25:47 2004
+++ /dev/null
@@ -1,44 +0,0 @@
-#include "BlueHead.h"
-
-#define error(a) _asm int 3
-
-
-
-const uint MinMatch = 3;
-const uint MaxMatch = 258;
-/* The minimum and maximum match lengths */
-
-const uint WSize = 0x8000;
-/* Maximum window size = 32K. If you are really short of memory, compile
- * with a smaller WSIZE but this reduces the compression ratio for files
- * of size > WSIZE. WSIZE must be a power of two in the current
implementation.
- */
-
-const uint MinLookahead = (MaxMatch + MinMatch + 1);
-/* Minimum amount of lookahead, except at the end of the input file.
- * See deflate.c for comments about the MIN_MATCH+1.
- */
-
-const uint MaxDist = (WSize - MinLookahead);
-/* In order to simplify the code, particularly on 16 bit machines, match
- * distances are limited to MAX_DIST instead of WSIZE.
- */
-
-/* Public globals */
-
-
-void flush_outbuf(char *, unsigned *);
-uint ReadBuf(char *buf, unsigned size);
-
-
-
- /* in deflate.c */
-void LmInit();
-u32 Deflate();
-
- /* in trees.c */
-void ct_init (int *);
-bool ct_tally (int, int);
-u32 flush_block (char far *, u32, int);
-void bi_init (char *, unsigned int, int);
-
=======================================
--- /src/BlueZip/DefTree.cpp Fri Apr 16 12:25:47 2004
+++ /dev/null
@@ -1,44 +0,0 @@
-#include "CompHead.h"
-
-#ifndef NO_COMPRESSION
-
-#ifdef _DEBUG
- extern u32 isize; /* byte length of input file, for debug
only */
-#endif
-
-File ifile; /* file to compress */
-File zfile; /* output zip file */
-
-void SetupDeftree(File In, File Out, int my_level)
-{
- ifile = In;
- zfile = Out;
-}
-
-
-uint ReadBuf(char* buf, uint size)
-{
- //IN assertion: size >= 2 (for end-of-line translation)
-
- //Do not do end of line translation, who cares (use TextPad!)
- const uint len = FileReadBuf(ifile, buf, size);
- if (len != 0)
- CRC((u8*) buf, len);
-
-#ifdef _DEBUG
- isize += (u32) len;
-#endif
- return len;
-}
-
-void flush_outbuf(char* buf, uint* size)
-{
- if (*size != 0) {
- FileWrite(zfile, buf, *size);
- }
- *size = 0;
-}
-
-
-
-#endif //!NO_COMPRESSION
=======================================
--- /src/BlueZip/Deflate.cpp Fri Apr 16 12:25:47 2004
+++ /dev/null
@@ -1,539 +0,0 @@
-#include "CompHead.h"
-
-//exclude from some builds
-#ifndef NO_COMPRESSION
-
-
-//PUBLIC SECTION
-#ifdef _DEBUG
-unsigned long isize;
-#endif
-//END PUBLIC SECTION
-
-
-
-//INIT SECTION
-char FileOutbuf[1024]; // output buffer for compression to file
-//END
-
-
-
-const uint HashBits = 15; // Number of bits used to hash strings
-
-const uint HashSize (1 << HashBits);
-const uint HashMask = HashSize - 1;
-const uint WMask = (WSize - 1);
-// HASH_SIZE and WSIZE must be powers of two
-
-const uint NIL = 0;
-// Tail of hash chains
-
-const uint TooFar = 4096;
-// Matches of length 3 are discarded if their distance exceeds TOO_FAR
-
-//
===========================================================================
-// Local data used by the "longest match" routines.
-
-typedef u16 Pos;
-typedef uint IPos;
-// A Pos is an index in the character window. We use short instead of int
to
-// save space in the various tables. IPos is used only for parameter
passing.
-
-u8 Window[2 * WSize];
-// Sliding window. Input bytes are read into the second half of the window,
-// and move to the first half later to keep a dictionary of at least WSIZE
-// bytes. With this organization, matches are limited to a distance of
-// WSIZE-MAX_MATCH bytes, but this ensures that IO is always
-// performed with a length multiple of the block size. Also, it limits
-// the window size to 64K, which is quite useful on MSDOS.
-
-Pos Prev[WSize];
-// Link to older string with same hash index. To limit the size of this
-// array to 64K, this link is maintained only for the last 32K strings.
-// An index in this array is thus a window index modulo 32K.
-
-Pos Head[HashSize];
-// Heads of the hash chains or NIL. If your compiler thinks that
-// HASH_SIZE is a dynamic value, recompile with -DDYN_ALLOC.
-
-
-const u32 WindowSize = 2 * WSize;
-// The size of the window
-
-long BlockStart;
-// window position at the beginning of the current output block. Gets
-// negative when the window is moved backwards.
-
-uint InsH; // hash index of string to be inserted
-
-const uint HShift = ((HashBits + MinMatch - 1) / MinMatch);
-// Number of bits by which ins_h and del_h must be shifted at each
-// input step. It must be such that after MIN_MATCH steps, the oldest
-// byte no longer takes part in the hash key, that is:
-// H_SHIFT * MIN_MATCH >= HASH_BITS
-
-uint PrevLength;
-// Length of the best match at previous step. Matches not greater than this
-// are discarded. This is used in the lazy match evaluation.
-
-uint StrStart; // start of string to insert
-uint MatchStart; // start of matching string
-bool EOFile; // flag set at end of input file
-uint LookAhead; // number of valid bytes ahead in window
-
-//Parameters for compression mode
-
-const uint MaxChainLength = 4096;
-// To speed up deflation, hash chains are never searched beyond this
length.
-// A higher limit improves compression ratio but degrades the speed.
-
-const uint MaxLazyMatch = 258;
-// Attempt to find a better match only when the current match is strictly
-// smaller than this value. This mechanism is used only for compression
-// levels >= 4.
-
-const uint GoodMatch = 32;
-// Use a faster search when the previous match is longer than this
-
-int NiceMatch; // Stop searching when current match exceeds this
-
-
-const int Equal = 0;
-/* result of memcmp for equal strings */
-
-/*
===========================================================================
- * Prototypes for local functions.
- */
-
-void FillWindow();
-int LongestMatch(IPos CurMatch);
-
-#ifdef _DEBUG
-void CheckMatch(IPos Start, IPos Match, int Length);
-#endif
-
-/*
===========================================================================
- * Update a hash value with the given input byte
- * IN assertion: all calls to to UPDATE_HASH are made with consecutive
- * input characters, so that a running hash key can be computed from the
- * previous key instead of complete recalculation each time.
- */
-
-void inline UpdateHash(u8 b)
-{
- InsH = ((InsH << HShift) ^ b) & HashMask;
-}
-
-/*
===========================================================================
- * Insert string s in the dictionary and set match_head to the previous
head
- * of the hash chain (the most recent string with same hash key). Return
- * the previous length of the hash chain.
- * IN assertion: all calls to to INSERT_STRING are made with consecutive
- * input characters and the first MIN_MATCH bytes of s are valid
- * (except for the last MIN_MATCH-1 bytes of the input file).
- */
-
-IPos inline InsertString(IPos HashHead) //StrStart is the other value
-{
- UpdateHash(Window[StrStart + (MinMatch - 1)]);
- IPos i = Head[InsH];
- Prev[StrStart & WMask] = i;
- Head[InsH] = StrStart;
- return i;
-}
-
-
-/*
===========================================================================
- * Initialize the "longest match" routines for a new file
- *
- * IN assertion: window_size is > 0 if the input file is already read or
- * mmap'ed in the window[] array, 0 otherwise. In the first case,
- * window_size is sufficient to contain the whole input file plus
- * MIN_LOOKAHEAD bytes (to avoid referencing memory beyond the end
- * of window[] when looking for matches towards the end).
- */
-void LmInit()
-{
- // Initialize the hash table (avoiding 64K overflow for 16 bit systems).
- // prev[] will be initialized on the fly.
- Head[HashSize-1] = NIL;
- memset((char*) Head, NIL, (uint) (HashSize - 1) * sizeof(*Head));
-
- // Set the default configuration parameters:
- //Do not try to find matches longer than the maximum
- NiceMatch = MaxMatch;
-
- StrStart = 0;
- BlockStart = 0;
-
- // Read 64K in one step, double the window size
- LookAhead = ReadBuf((char*) Window, WSize * 2);
-
- EOFile = (LookAhead == 0);
- if (EOFile) return;
-
- // Make sure that we always have enough lookahead. This is important
- // if input comes from a device such as a tty.
- if (LookAhead < MinLookahead)
- FillWindow();
-
- InsH = 0;
-
- uint j;
- for (j = 0; j < MinMatch - 1; j++)
- UpdateHash(Window[j]);
- // If lookahead < MIN_MATCH, ins_h is garbage, but this is
- // not important since only literal bytes will be emitted.
-}
-
-//
===========================================================================
-// Set match_start to the longest match starting at the given string and
-// return its length. Matches shorter or equal to prev_length are
discarded,
-// in which case the result is equal to prev_length and match_start is
-// garbage.
-// IN assertions: cur_match is the head of the hash chain for the current
-// string (strstart) and its distance is <= MAX_DIST, and prev_length >=
1
-
-int LongestMatch(IPos CurMatch)
-{
- uint ChainLength = MaxChainLength; // max hash chain length
- u8* Scan = Window + StrStart; // current string
- u8* Match; //
matched string
- int Len; //
length of current match
- int BestLen = PrevLength; // best match length so
far
-
- IPos Limit = StrStart > (IPos)MaxDist ? StrStart - (IPos)MaxDist : NIL;
- // Stop when cur_match becomes <= limit. To simplify the code,
- // we prevent matches with the string of window index 0.
-
-
- u8* StrEnd = Window + StrStart + MaxMatch;
- u8 ScanEnd1 = Scan[BestLen - 1];
- u8 ScanEnd = Scan[BestLen];
-
- /* Do not waste too much time if we already have a good match: */
- if (PrevLength >= GoodMatch)
- {
- ChainLength >>= 2;
- }
-
- Assert(StrStart <= WindowSize - MinLookahead);//, "insufficient
lookahead");
-
- do
- {
- Assert(CurMatch < StrStart);//, "no future");
- Match = Window + CurMatch;
-
- /* Skip to next match if the match length cannot increase
- * or if the match length is less than 2:
- */
-
- if (Match[BestLen] != ScanEnd ||
- Match[BestLen - 1] != ScanEnd1 ||
- *Match != Scan[0] ||
- *++Match != Scan[1])
- continue;
-
- // The check at best_len-1 can be removed because it will be made
- // again later. (This heuristic is not always a win.)
- // It is not necessary to compare scan[2] and match[2] since they
- // are always equal when the other bytes match, given that
- // the hash keys are equal and that HASH_BITS >= 8.
- Scan += 2;
- Match++;
-
- /* We check for insufficient lookahead only every 8th comparison;
- * the 256th check will be made at strstart+258.
- */
- do {
- } while ((*++Scan == *++Match) && (*++Scan == *++Match) &&
- (*++Scan == *++Match) && (*++Scan == *++Match)
&&
- (*++Scan == *++Match) && (*++Scan == *++Match)
&&
- (*++Scan == *++Match) && (*++Scan == *++Match)
&&
- Scan < StrEnd);
-
- Assert(Scan <= Window + (uint)(WindowSize-1));//, "wild scan");
-
- Len = MaxMatch - (int)(StrEnd - Scan);
- Scan = StrEnd - MaxMatch;
-
- if (Len > BestLen) {
- MatchStart = CurMatch;
- BestLen = Len;
- if (Len >= NiceMatch) break;
-
- ScanEnd1 = Scan[BestLen - 1];
- ScanEnd = Scan[BestLen];
- }
- } while ((CurMatch = Prev[CurMatch & WMask]) > Limit
- && --ChainLength != 0);
-
- return BestLen;
-}
-
-
-#ifdef _DEBUG
-/*
===========================================================================
- * Check that the match at match_start is indeed a match.
- */
-void CheckMatch(IPos Start, IPos Match, int Len)
-{
- // check that the match is indeed a match
- if (memcmp((char*) Window + Match,
- (char*) Window + Start, Len) != Equal)
- {
- error("invalid match");
- }
-}
-#else
-# define CheckMatch(Start, Match, Len)
-#endif
-
-/*
===========================================================================
- * Fill the window when the lookahead becomes insufficient.
- * Updates strstart and lookahead, and sets eofile if end of input file.
- *
- * IN assertion: lookahead < MIN_LOOKAHEAD && strstart + lookahead > 0
- * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD
- * At least one byte has been read, or eofile is set; file reads are
- * performed for at least two bytes (required for the translate_eol
option).
- */
-void FillWindow()
-{
- uint n, m;
- uint More; // Amount of free space at the end of the window.
-
- do
- {
- More = (unsigned)(WindowSize - (u32)LookAhead - (u32)StrStart);
-
- // 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 (More == (unsigned)EOF)
- {
- //Occurs for files one byte long
- More--;
- }
- else if (StrStart >= WSize + MaxDist)
- {
- // By the IN assertion, the window is not empty so we can't
confuse
- // more == 0 with more == 64K on a 16 bit machine.
- memcpy((char*) Window, (char*) Window + WSize, (uint) WSize);
- MatchStart -= WSize;
- StrStart -= WSize; // we now have strstart >= MAX_DIST:
-
- BlockStart -= (long) WSize;
-
- //Neil Optimisation, HASH_SIZE == WSIZE
- //:. only do one loop, with two operations in it
-
- //This must be true, if not use the original ZIP code
- Assert(HashSize == WSize);
-
-
- for (n = 0; n < HashSize; n++)
- {
- m = Head[n];
- //NB: Do NOT use MAX as More is uint :. always
> 0
- Head[n] = (Pos) (m >= WSize ? m-WSize : NIL);
-
- //Dependant on WSIZE
- m = Prev[n];
- Prev[n] = (Pos)(m >= WSize ? m-WSize : NIL);
- // If n is not on any hash chain, prev[n] is
garbage but
- // its value will never be used.
- }
- More += WSize;
- }
- if (EOFile) return;
-
- /* If there was no sliding:
- * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD -
1 &&
- * more == window_size - lookahead - strstart
- * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)
- * => more >= window_size - 2*WSIZE + 2
- * In the MMAP or BIG_MEM case (not yet supported in gzip),
- * window_size == input_size + MIN_LOOKAHEAD &&
- * strstart + lookahead <= input_size => more >= MIN_LOOKAHEAD.
- * Otherwise, window_size == 2*WSIZE so more >= 2.
- * If there was sliding, more >= WSIZE. So in all cases, more >= 2.
- */
- Assert(More >= 2); //more < 2
-
- n = ReadBuf((char*) Window + StrStart + LookAhead, More);
- EOFile = (n == 0);
- LookAhead += n;
-
- } while ((LookAhead < MinLookahead) && !EOFile);
-}
-
-/*
===========================================================================
- * Flush the current block, with given end-of-file flag.
- * IN assertion: strstart is set to the end of the current match.
- */
-
-inline u32 DoFlushBlock(bool eof)
-{
- return flush_block(BlockStart >= 0L ?
(char*)&Window[(unsigned)BlockStart] : \
- (char*)NULL, (long)StrStart - BlockStart, eof);
-}
-
-
-/*
===========================================================================
- * Same as above, but achieves better compression. We use a lazy
- * evaluation for matches: a match is finally adopted only if there is
- * no better match at the next window position.
- */
-u32 Deflate()
-{
-
- IPos HashHead = NIL; // head of hash chain
- IPos PrevMatch; // previous
match
- bool Flush; // set
if current block must be flushed
- bool MatchAvailable = false; // set if previous match exists
- uint MatchLength = MinMatch - 1; // length of best match
-
-#ifdef _DEBUG
- extern u32 isize; // byte length of input file, for debug only
-#endif
-
- // Process the input block.
- while (LookAhead != 0)
- {
- // Insert the string window[strstart .. strstart+2] in the
- // dictionary, and set hash_head to the head of the hash chain:
- if (LookAhead >= MinMatch)
- HashHead = InsertString(HashHead);
-
- // Find the longest match, discarding those <= prev_length.
- PrevLength = MatchLength;
- PrevMatch = MatchStart;
- MatchLength = MinMatch - 1;
-
- if ((HashHead != NIL) &&
- (PrevLength < MaxLazyMatch) &&
- (StrStart - HashHead <= MaxDist))
- {
- // To simplify the code, we prevent matches with the string
- // of window index 0 (in particular we have to avoid a match
- // of the string with itself at the start of the input file).
-
- // Do not look for matches beyond the end of the input.
- // This is necessary to make deflate deterministic.
- if ((uint) NiceMatch > LookAhead)
- NiceMatch = (int) LookAhead;
-
- MatchLength = LongestMatch(HashHead);
- // LongestMatch() sets match_start
- if (MatchLength > LookAhead)
- MatchLength = LookAhead;
-
- // Ignore a length 3 match if it is too distant:
- if ((MatchLength == MinMatch) && (StrStart - MatchStart >
TooFar))
- {
- // If prev_match is also MIN_MATCH, match_start is garbage
- // but we will ignore the current match anyway.
- MatchLength = MinMatch - 1;
- }
- }
- // If there was a match at the previous step and the current
- // match is not better, output the previous match:
- if ((PrevLength >= MinMatch) && (MatchLength <= PrevLength))
- {
- uint MaxInsert = StrStart + LookAhead - MinMatch;
- CheckMatch(StrStart - 1, PrevMatch, PrevLength);
-
- Flush = ct_tally(StrStart - 1 - PrevMatch, PrevLength -
MinMatch);
-
- // Insert in hash table all strings up to the end of the match.
- // strstart-1 and strstart are already inserted.
- LookAhead -= PrevLength - 1;
- PrevLength -= 2;
- do
- {
- if (++StrStart <= MaxInsert)
- {
- HashHead = InsertString(HashHead);
- // strstart never exceeds WSIZE-MAX_MATCH, so there are
- // always MIN_MATCH bytes ahead.
- }
- }
- while (--PrevLength != 0);
-
- StrStart++;
- MatchAvailable = false;
- MatchLength = MinMatch - 1;
-
- if (Flush)
- {
- DoFlushBlock(false);
- BlockStart = StrStart;
- }
-
- }
- else if (MatchAvailable)
- {
- // If there was no match at the previous position, output a
- // single literal. If there was a match but the current match
- // is longer, truncate the previous match to a single literal.
- if (ct_tally (0, Window[StrStart-1]))
- {
- DoFlushBlock(false);
- BlockStart = StrStart;
- }
- StrStart++;
- LookAhead--;
- }
- else
- {
- /* There is no previous match to compare with, wait for
- * the next step to decide.
- */
- MatchAvailable = true;
- StrStart++;
- LookAhead--;
- }
- AssertD((StrStart <= isize) && (LookAhead <= isize));//, "a bit
too far");
-
- // Make sure that we always have enough lookahead, except
- // at the end of the input file. We need MAX_MATCH bytes
- // for the next match, plus MIN_MATCH bytes to insert the
- // string following the next match.
- if (LookAhead < MinLookahead)
- FillWindow();
- }
-
- if (MatchAvailable)
- ct_tally (0, Window[StrStart-1]);
-
- return DoFlushBlock(true); // eof
-}
-
-
-
-
-
-
-
-//NEIL SPECIFIC
-
-
-u32 filecompress(int* cmpr_method)
-{
-
- /* Set the defaults for file compression. */
- //zfile = zipfile; handled in SetupDefTree
-
-#ifdef _DEBUG
- isize = 0;
-#endif
-
- /* Initialize deflate's internals and execute file compression. */
- bi_init(FileOutbuf, sizeof(FileOutbuf), true);
- ct_init(cmpr_method);
- LmInit();
- return Deflate();
-}
-
-#endif //!NO_COMPRESSION
=======================================
--- /src/BlueZip/Errors.h Fri Apr 16 12:25:47 2004
+++ /dev/null
@@ -1,4 +0,0 @@
-//Error messages, with descriptive text
-//Can be turned off with the command
-//Can either send the text, or 0xffffffff
-
=======================================
--- /src/BlueZip/FileIO.cpp Fri Apr 16 12:25:47 2004
+++ /dev/null
@@ -1,141 +0,0 @@
-#include "BlueHead.h"
-
-File FileOpenRead(LPCTSTR s)
-{
- return CreateFile(s, GENERIC_READ,
- FILE_SHARE_READ, NULL, OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL, NULL);
-}
-
-File FileOpenWrite(LPCTSTR s)
-{
- return CreateFile(s, GENERIC_WRITE,
- FILE_SHARE_READ, NULL, CREATE_NEW,
- FILE_ATTRIBUTE_NORMAL, NULL);
-}
-
-void FileRead(File f, void* buf, DWORD size)
-{
- DWORD d;
- ReadFile(f, buf, size, &d, NULL);
- Assert(size == d);
-}
-
-int FileReadBuf(File f, void* buf, DWORD size)
-{
- DWORD d;
- ReadFile(f, buf, size, &d, NULL);
- return d;
-}
-
-void FileWrite(File f, const void* buf, DWORD size)
-{
- DWORD d;
- WriteFile(f, buf, size, &d, NULL);
- Assert(size == d);
-}
-
-
-bool FileValid(File f)
-{
- return (f != File_Invalid);
-}
-
-void FileClose(File f)
-{
-#ifdef _DEBUG
- if (!CloseHandle(f)) _asm int 3;
-#else
- CloseHandle(f);
-#endif
-}
-
-
-bool FileReplace(LPCTSTR To, LPCTSTR From)
-{
- //First remove the existing file
- DeleteFile(To);
- //Then copy it accross
- return (MoveFile(From, To) != FALSE);
-}
-
-File FileOpenTemp(LPTSTR s)
-{
- char Buffer[MAX_PATH];
-
- if ((GetTempPath(MAX_PATH, Buffer) == 0) ||
- (GetTempFileName(Buffer, "ZIP", 0, s) == 0))
- return File_Invalid;
-
- return CreateFile(s, GENERIC_WRITE,
- FILE_SHARE_READ, NULL, CREATE_ALWAYS, //Create Always, not
Create New
- FILE_ATTRIBUTE_NORMAL, NULL);;
-}
-
-
-//return TRUE for success, FALSE for failure
-//fseek returns 0 for success
-
-void inline _p_Seek(File f, long offset, DWORD origin)
-{
-#ifdef _DEBUG
- if (SetFilePointer(f, offset, NULL, origin) == 0xFFFFFFFF) _asm int 3;
-#else
- SetFilePointer(f, offset, NULL, origin);
-#endif
-}
-
-void SeekBeg(File f, long offset)
-{_p_Seek(f, offset, FILE_BEGIN);}
-
-void SeekCur(File f, long offset)
-{_p_Seek(f, offset, FILE_CURRENT);}
-
-void SeekEnd(File f, long offset)
-{_p_Seek(f, offset, FILE_END);}
-
-
-int FilePos(File f)
-{
- DWORD d = SetFilePointer(f, 0, NULL, FILE_CURRENT);
- Assert(d != 0xFFFFFFFF);
- return d;
-}
-
-int FileLen(File f)
-{
- return GetFileSize(f, NULL);
-}
-
-void FileGetDate(File f, datCentral* data)
-{
- FILETIME ft;
-#ifdef _DEBUG
- if (!GetFileTime(f, NULL, NULL, &ft)) _asm int 3;
- if (!FileTimeToDosDateTime(&ft, &data->Date, &data->Time)) _asm int 3;
-#else
- GetFileTime(f, &ft, NULL, NULL);
- FileTimeToDosDateTime(&ft, &data->Date, &data->Time);
-#endif
-}
-
-#define A_RONLY 0x01
-#define A_HIDDEN 0x02
-#define A_SYSTEM 0x04
-#define A_LABEL 0x08
-#define A_DIR 0x10
-#define A_ARCHIVE 0x20
-
-u32 FileGetAttrib(File f, LPCTSTR FileName)
-{
- DWORD Attr = GetFileAttributes(FileName);
- Assert(Attr != 0xFFFFFFFF);
-
- return(
- (Attr & FILE_ATTRIBUTE_READONLY ? A_RONLY :0) |
- (Attr & FILE_ATTRIBUTE_HIDDEN ? A_HIDDEN :0) |
- (Attr & FILE_ATTRIBUTE_SYSTEM ? A_SYSTEM :0) |
- (Attr & FILE_ATTRIBUTE_DIRECTORY ? A_DIR :0) |
- (Attr & FILE_ATTRIBUTE_ARCHIVE ? A_ARCHIVE :0));
-}
-
=======================================
--- /src/BlueZip/FileIO.h Fri Apr 16 12:25:47 2004
+++ /dev/null
@@ -1,27 +0,0 @@
-
-//Use Windows (reliable) file IO routines
-#define File HANDLE
-#define File_Invalid INVALID_HANDLE_VALUE
-
-File FileOpenRead(LPCTSTR s);
-File FileOpenWrite(LPCTSTR s);
-File FileOpenTemp(LPTSTR s);
-
-bool FileReplace(LPCTSTR To, LPCTSTR From);
-
-void FileRead(File f, void* buf, DWORD size);
-int FileReadBuf(File f, void* buf, DWORD size);
-void FileWrite(File f, const void* buf, DWORD size);
-
-bool FileValid(File f);
-void FileClose(File f);
-
-void SeekBeg(File f, long offset);
-void SeekCur(File f, long offset);
-void SeekEnd(File f, long offset);
-
-int FilePos(File f);
-int FileLen(File f);
-
-void FileGetDate(File f, datCentral* data);
-u32 FileGetAttrib(File f, LPCTSTR FileName);
=======================================
--- /src/BlueZip/General.cpp Fri Apr 16 12:25:47 2004
+++ /dev/null
@@ -1,9 +0,0 @@
-#include "BlueHead.h"
-
-LPTSTR CopyString(LPCTSTR s)
-{
- const int i = strlen(s);
- LPTSTR res = new char[i+1];
- memcpy(res, s, i+1);
- return res;
-}
=======================================
--- /src/BlueZip/General.h Fri Apr 16 12:25:47 2004
+++ /dev/null
@@ -1,2 +0,0 @@
-
-LPTSTR CopyString(LPCTSTR s);
=======================================
--- /src/BlueZip/Inflate.cpp Fri Apr 16 12:25:47 2004
+++ /dev/null
@@ -1,1015 +0,0 @@
-#include "BlueHead.h"
-#include <stdio.h>
-
-
-File hOut; //THIS MUST BE SET BY MY PROGRAM
-File hIn;
-
-#undef malloc
-#undef free
-
-void Neil_Init(File Out, File In)
-{
- hOut = Out;
- hIn = In;
-}
-
-
-
-#include "inflate.h" //Used to be globals.h
-struct Globals G;
-
-
-//From consts.h
-const u16 mask_bits[] = {
- 0x0000,
- 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
- 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
-};
-
-//From unzpriv.h
-struct huft {
- u8 e; /* number of extra bits or operation */
- u8 b; /* number of bits in this code or subcode */
- union {
- u16 n; /* literal, length base, or distance base */
- struct huft *t; /* pointer to next level of table */
- } v;
-};
-# define redirSlide G.area.Slide
-
-
-
-
-
-//NEIL SPECIFIC END
-
-
-#define PKZIP_BUG_WORKAROUND /* PKZIP 1.93a problem--live with it */
-
-#define __INFLATE_C /* identifies this source module */
-
-/* #define DEBUG */
-#define INFMOD /* tell inflate.h to include code to be compiled */
-//#include "inflate.h"
-
-#if (defined(DLL) && !defined(NO_SLIDE_REDIR))
-# define wsize G._wsize /* wsize is a variable */
-#else
-# define wsize WSIZE /* wsize is a constant */
-#endif
-
-
-inline int NextByte()
-{
- unsigned char c;
- FileRead(hIn, &c, 1);
- return c;
-}
-
-#ifndef NEXTBYTE /* default is to simply get a byte from stdin */
-# define NEXTBYTE NextByte()
-#endif
-
-
-
-#ifndef MESSAGE /* only used twice, for fixed strings--NOT
general-purpose */
-# define MESSAGE(str,len,flag) fprintf(stderr,(char *)(str))
-#endif
-
-
-void inline FLUSH(int n)
-{
- FileWrite(hOut, redirSlide, n);
- CRC(redirSlide, n);}
-//#ifndef FLUSH /* default is to simply write the buffer to
stdout */
-//# define FLUSH(n) \
-//#endif
-/* Warning: the fwrite above might not work on 16-bit compilers, since
- 0x8000 might be interpreted as -32,768 by the library function. */
-
-#ifndef Trace
-# ifdef DEBUG
-# define Trace(x) fprintf x
-# else
-# define Trace(x)
-# endif
-#endif
-
-
-/*---------------------------------------------------------------------------*/
-
-/* Function prototypes */
-#ifndef OF
-# ifdef __STDC__
-# define OF(a) a
-# else
-# define OF(a) ()
-# endif
-#endif /* !OF */
-int inflate_codes OF((__GPRO__ struct huft *tl, struct huft *td,
- int bl, int bd));
-static int inflate_stored OF((__GPRO));
-static int inflate_fixed OF((__GPRO));
-static int inflate_dynamic OF((__GPRO));
-static int inflate_block OF((__GPRO__ int *e));
-
-
-/* The inflate algorithm uses a sliding 32K byte window on the uncompressed
- stream to find repeated byte strings. This is implemented here as a
- circular buffer. The index is updated simply by incrementing and then
- and'ing with 0x7fff (32K-1). */
-/* It is left to other modules to supply the 32K area. It is assumed
- to be usable as if it were declared "uch slide[32768];" or as just
- "uch *slide;" and then malloc'ed in the latter case. The definition
- must be in unzip.h, included above. */
-
-
-/* unsigned wp; moved to globals.h */ /* current position in slide */
-
-#define INVALID_CODE 99
-#define IS_INVALID_CODE(c) ((c) == INVALID_CODE)
-
-/* Tables for deflate from PKZIP's appnote.txt. */
-static const uint border[] = { /* Order of the bit length code lengths */
- 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
-static const u16 cplens[] = { /* Copy lengths for literal codes 257..285
*/
- 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
- 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
- /* note: see note #13 above about the 258 in this list. */
-static const u16 cplext[] = { /* Extra bits for literal codes 257..285 */
- 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
- 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, INVALID_CODE, INVALID_CODE};
-static const u16 cpdist[] = { /* Copy offsets for distance codes 0..29 */
- 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
- 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
-#ifdef USE_DEFLATE64
- 8193, 12289, 16385, 24577, 32769, 49153};
-#else
- 8193, 12289, 16385, 24577};
-#endif
-static const u16 cpdext[] = { /* Extra bits for distance codes */
- 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
- 7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
-#ifdef USE_DEFLATE64
- 12, 12, 13, 13, 14, 14};
-#else
- 12, 12, 13, 13};
-#endif
-#ifdef USE_DEFLATE64
-# define NUMDISTS 32
-#else
-# define NUMDISTS 30
-#endif
-
-
-/* moved to consts.h (included in unzip.c), resp. funzip.c */
-#if 0
-/* And'ing with mask_bits[n] masks the lower n bits */
-ZCONST u16 near mask_bits[] = {
- 0x0000,
- 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
- 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
-};
-#endif /* 0 */
-
-
-/* Macros for inflate() bit peeking and grabbing.
- The usage is:
-
- NEEDBITS(j)
- x = b & mask_bits[j];
- DUMPBITS(j)
-
- where NEEDBITS makes sure that b has at least j bits in it, and
- DUMPBITS removes the bits from b. The macros use the variable k
- for the number of bits in b. Normally, b and k are register
- variables for speed and are initialized at the begining of a
- routine that uses these macros from a global bit buffer and count.
-
- In order to not ask for more bits than there are in the compressed
- stream, the Huffman tables are constructed to only ask for just
- enough bits to make up the end-of-block code (value 256). Then no
- bytes need to be "returned" to the buffer at the end of the last
- block. See the huft_build() routine.
- */
-
-/* These have been moved to globals.h */
-#if 0
-ulg bb; /* bit buffer */
-unsigned bk; /* bits in bit buffer */
-#endif
-
-//EOF is not a valid
-//#ifndef CHECK_EOF
-//# define CHECK_EOF /* default as of 5.13/5.2 */
-//#endif
-
-#ifndef CHECK_EOF
-# define NEEDBITS(n) {while(k<(n)){b|=((u32)NEXTBYTE)<<k;k+=8;}}
-#else
-# define NEEDBITS(n) {while(k<(n)){int c=NEXTBYTE;\
- if(c==EOF){retval=1;goto cleanup_and_exit;}\
- b|=((u32)c)<<k;k+=8;}}
-#endif
-
-#define DUMPBITS(n) {b>>=(n);k-=(n);}
-
-
-/*
- Huffman code decoding is performed using a multi-level table lookup.
- The fastest way to decode is to simply build a lookup table whose
- size is determined by the longest code. However, the time it takes
- to build this table can also be a factor if the data being decoded
- are not very long. The most common codes are necessarily the
- shortest codes, so those codes dominate the decoding time, and hence
- the speed. The idea is you can have a shorter table that decodes the
- shorter, more probable codes, and then point to subsidiary tables for
- the longer codes. The time it costs to decode the longer codes is
- then traded against the time it takes to make longer tables.
-
- This results of this trade are in the variables lbits and dbits
- below. lbits is the number of bits the first level table for literal/
- length codes can decode in one step, and dbits is the same thing for
- the distance codes. Subsequent tables are also less than or equal to
- those sizes. These values may be adjusted either when all of the
- codes are shorter than that, in which case the longest code length in
- bits is used, or when the shortest code is *longer* than the requested
- table size, in which case the length of the shortest code in bits is
- used.
-
- There are two different values for the two tables, since they code a
- different number of possibilities each. The literal/length table
- codes 286 possible values, or in a flat code, a little over eight
- bits. The distance table codes 30 possible values, or a little less
- than five bits, flat. The optimum values for speed end up being
- about one bit more than those, so lbits is 8+1 and dbits is 5+1.
- The optimum values may differ though from machine to machine, and
- possibly even between compilers. Your mileage may vary.
- */
-
-
-static const int lbits = 9; /* bits in base literal/length lookup table
*/
-static const int dbits = 6; /* bits in base distance lookup table */
-
-
-#ifndef ASM_INFLATECODES
-
-int inflate_codes(__G__ __GDEF huft* tl, huft* td, int bl, int
bd)
-// __GDEF
-//struct huft *tl, *td; /* literal/length and distance decoder tables */
-//int bl, bd; /* number of bits decoded by tl[] and td[] */
-/* inflate (decompress) the codes in a deflated (compressed) block.
- Return an error code or zero if it all goes ok. */
-{
- register unsigned e; /* table entry flag/number of extra bits */
- unsigned n, d; /* length and index for copy */
- unsigned w; /* current window position */
- struct huft *t; /* pointer to table entry */
- unsigned ml, md; /* masks for bl and bd bits */
- u32 b; /* bit buffer */
- register unsigned k; /* number of bits in bit buffer */
- int retval = 0; /* error code returned: initialized to "no error"
*/
-
-
- /* make local copies of globals */
- b = G.bb; /* initialize bit buffer */
- k = G.bk;
- w = G.wp; /* initialize window position */
-
-
- /* inflate the coded data */
- ml = mask_bits[bl]; /* precompute masks for speed */
- md = mask_bits[bd];
- while (1) /* do until end of block */
- {
- NEEDBITS((unsigned)bl)
- if ((e = (t = tl + ((unsigned)b & ml))->e) > 16)
- do {
- if (IS_INVALID_CODE(e))
- return 1;
- DUMPBITS(t->b)
- e -= 16;
- NEEDBITS(e)
- } while ((e = (t = t->v.t + ((unsigned)b & mask_bits[e]))->e) > 16);
- DUMPBITS(t->b)
- if (e == 16) /* then it's a literal */
- {
- redirSlide[w++] = (u8)t->v.n;
- if (w == wsize)
- {
- FLUSH(w);
- w = 0;
- }
- }
- else /* it's an EOB or a length */
- {
- /* exit if end of block */
- if (e == 15)
- break;
-
- /* get length of block to copy */
- NEEDBITS(e)
- n = t->v.n + ((unsigned)b & mask_bits[e]);
- DUMPBITS(e)
-#if (defined(USE_DEFLATE64) && !defined(FUNZIP))
- if (n == 258 && G.lrec.compression_method == ENHDEFLATED) {
- /* fetch length bits */
- NEEDBITS(16)
- n = ((unsigned)b & 0xffff) + 3;
- DUMPBITS(16)
- }
-#endif
-
- /* decode distance of block to copy */
- NEEDBITS((unsigned)bd)
- if ((e = (t = td + ((unsigned)b & md))->e) > 16)
- do {
- if (IS_INVALID_CODE(e))
- return 1;
- DUMPBITS(t->b)
- e -= 16;
- NEEDBITS(e)
- } while ((e = (t = t->v.t + ((unsigned)b & mask_bits[e]))->e) >
16);
- DUMPBITS(t->b)
- NEEDBITS(e)
- d = w - t->v.n - ((unsigned)b & mask_bits[e]);
- DUMPBITS(e)
-
- /* do the copy */
- do {
-#if (defined(DLL) && !defined(NO_SLIDE_REDIR))
- if (G.redirect_slide) {/* &= w/ wsize unnecessary & wrong if
redirect */
- if (d >= wsize)
- return 1; /* invalid compressed data */
- n -= (e = (e = wsize - (d > w ? d : w)) > n ? n : e);
- }
- else
-#endif
- n -= (e = (e = wsize - ((d &= wsize-1) > w ? d : w)) > n ? n :
e);
-#ifndef NOMEMCPY
- if (w - d >= e) /* (this test assumes unsigned comparison)
*/
- {
- memcpy(redirSlide + w, redirSlide + d, e);
- w += e;
- d += e;
- }
- else /* do it slowly to avoid memcpy() overlap
*/
-#endif /* !NOMEMCPY */
- do {
- redirSlide[w++] = redirSlide[d++];
- } while (--e);
- if (w == wsize)
- {
- FLUSH(w);
- w = 0;
- }
- } while (n);
- }
- }
-
-
- /* restore the globals from the locals */
- G.wp = w; /* restore global window pointer */
- G.bb = b; /* restore global bit buffer */
- G.bk = k;
-
- return retval;
-}
-
-#endif /* ASM_INFLATECODES */
-
-
-
-static int inflate_stored(__G)
- __GDEF
-/* "decompress" an inflated type 0 (stored) block. */
-{
- unsigned n; /* number of bytes in block */
- unsigned w; /* current window position */
- register u32 b; /* bit buffer */
- register unsigned k; /* number of bits in bit buffer */
- int retval = 0; /* error code returned: initialized to "no error"
*/
-
-
- /* make local copies of globals */
- Trace((stderr, "\nstored block"));
- b = G.bb; /* initialize bit buffer */
- k = G.bk;
- w = G.wp; /* initialize window position */
-
-
- /* go to byte boundary */
- n = k & 7;
- DUMPBITS(n);
-
-
- /* get the length and its complement */
- NEEDBITS(16)
- n = ((unsigned)b & 0xffff);
- DUMPBITS(16)
- NEEDBITS(16)
- if (n != (unsigned)((~b) & 0xffff))
- return 1; /* error in compressed data */
- DUMPBITS(16)
-
-
- /* read and output the compressed data */
- while (n--)
- {
- NEEDBITS(8)
- redirSlide[w++] = (u8)b;
- if (w == wsize)
- {
- FLUSH(w);
- w = 0;
- }
- DUMPBITS(8)
- }
-
-
- /* restore the globals from the locals */
- G.wp = w; /* restore global window pointer */
- G.bb = b; /* restore global bit buffer */
- G.bk = k;
-
- return retval;
-}
-
-
-/* Globals for literal tables (built once) */
-/* Moved to globals.h */
-#if 0
-struct huft *fixed_tl = (struct huft *)NULL;
-struct huft *fixed_td;
-int fixed_bl, fixed_bd;
-#endif
-
-int huft_build(__GPRO__ const uint *b, uint n, uint s, const u16* d, const
u16* e, struct huft **t, int *m);
-int huft_free(huft* t); /* inflate.c */
-
-
-static int inflate_fixed(__G)
- __GDEF
-/* decompress an inflated type 1 (fixed Huffman codes) block. We should
- either replace this with a custom decoder, or at least precompute the
- Huffman tables. */
-{
- /* if first time, set up tables for fixed blocks */
- Trace((stderr, "\nliteral block"));
- if (G.fixed_tl == (struct huft *)NULL)
- {
- int i; /* temporary variable */
- unsigned l[288]; /* length list for huft_build */
-
- /* literal table */
- for (i = 0; i < 144; i++)
- l[i] = 8;
- for (; i < 256; i++)
- l[i] = 9;
- for (; i < 280; i++)
- l[i] = 7;
- for (; i < 288; i++) /* make a complete, but wrong code set */
- l[i] = 8;
- G.fixed_bl = 7;
- if ((i = huft_build(__G__ l, 288, 257, cplens, cplext,
- &G.fixed_tl, &G.fixed_bl)) != 0)
- {
- G.fixed_tl = (struct huft *)NULL;
- return i;
- }
-
- /* distance table */
- for (i = 0; i < NUMDISTS; i++) /* make an incomplete code set */
- l[i] = 5;
- G.fixed_bd = 5;
- if ((i = huft_build(__G__ l, NUMDISTS, 0, cpdist, cpdext,
- &G.fixed_td, &G.fixed_bd)) > 1)
- {
- huft_free(G.fixed_tl);
- G.fixed_td = G.fixed_tl = (struct huft *)NULL;
- return i;
- }
- }
-
- /* decompress until an end-of-block code */
- return inflate_codes(__G__ G.fixed_tl, G.fixed_td,
- G.fixed_bl, G.fixed_bd);
-}
-
-
-
-static int inflate_dynamic(__G)
- __GDEF
-/* decompress an inflated type 2 (dynamic Huffman codes) block. */
-{
- int i; /* temporary variables */
- unsigned j;
- unsigned l; /* last length */
- unsigned m; /* mask for bit lengths table */
- unsigned n; /* number of lengths to get */
- struct huft *tl; /* literal/length code table */
- struct huft *td; /* distance code table */
- int bl; /* lookup bits for tl */
- int bd; /* lookup bits for td */
- unsigned nb; /* number of bit length codes */
- unsigned nl; /* number of literal/length codes */
- unsigned nd; /* number of distance codes */
-#ifdef PKZIP_BUG_WORKAROUND
- unsigned ll[288+32]; /* literal/length and distance code lengths */
-#else
- unsigned ll[286+NUMDISTS]; /* literal/length and distance code lengths */
-#endif
- register u32 b; /* bit buffer */
- register unsigned k; /* number of bits in bit buffer */
- int retval = 0; /* error code returned: initialized to "no error"
*/
-
-
- /* make local bit buffer */
- Trace((stderr, "\ndynamic block"));
- b = G.bb;
- k = G.bk;
-
-
- /* read in table lengths */
- NEEDBITS(5)
- nl = 257 + ((unsigned)b & 0x1f); /* number of literal/length codes
*/
- DUMPBITS(5)
- NEEDBITS(5)
- nd = 1 + ((unsigned)b & 0x1f); /* number of distance codes */
- DUMPBITS(5)
- NEEDBITS(4)
- nb = 4 + ((unsigned)b & 0xf); /* number of bit length codes */
- DUMPBITS(4)
-#ifdef PKZIP_BUG_WORKAROUND
- if (nl > 288 || nd > 32)
-#else
- if (nl > 286 || nd > NUMDISTS)
-#endif
- return 1; /* bad lengths */
-
-
- /* read in bit-length-code lengths */
- for (j = 0; j < nb; j++)
- {
- NEEDBITS(3)
- ll[border[j]] = (unsigned)b & 7;
- DUMPBITS(3)
- }
- for (; j < 19; j++)
- ll[border[j]] = 0;
-
-
- /* build decoding table for trees--single level, 7 bit lookup */
- bl = 7;
- retval = huft_build(__G__ ll, 19, 19, NULL, NULL, &tl, &bl);
- if (bl == 0) /* no bit lengths */
- retval = 1;
- if (retval)
- {
- if (retval == 1)
- huft_free(tl);
- return retval; /* incomplete code set */
- }
-
-
- /* read in literal and distance code lengths */
- n = nl + nd;
- m = mask_bits[bl];
- i = l = 0;
- while ((unsigned)i < n)
- {
- NEEDBITS((unsigned)bl)
- j = (td = tl + ((unsigned)b & m))->b;
- DUMPBITS(j)
- j = td->v.n;
- if (j < 16) /* length of code in bits (0..15) */
- ll[i++] = l = j; /* save last length in l */
- else if (j == 16) /* repeat last length 3 to 6 times */
- {
- NEEDBITS(2)
- j = 3 + ((unsigned)b & 3);
- DUMPBITS(2)
- if ((unsigned)i + j > n)
- return 1;
- while (j--)
- ll[i++] = l;
- }
- else if (j == 17) /* 3 to 10 zero length codes */
- {
- NEEDBITS(3)
- j = 3 + ((unsigned)b & 7);
- DUMPBITS(3)
- if ((unsigned)i + j > n)
- return 1;
- while (j--)
- ll[i++] = 0;
- l = 0;
- }
- else /* j == 18: 11 to 138 zero length codes */
- {
- NEEDBITS(7)
- j = 11 + ((unsigned)b & 0x7f);
- DUMPBITS(7)
- if ((unsigned)i + j > n)
- return 1;
- while (j--)
- ll[i++] = 0;
- l = 0;
- }
- }
-
-
- /* free decoding table for trees */
- huft_free(tl);
-
-
- /* restore the global bit buffer */
- G.bb = b;
- G.bk = k;
-
-
- /* build the decoding tables for literal/length and distance codes */
- bl = lbits;
- retval = huft_build(__G__ ll, nl, 257, cplens, cplext, &tl, &bl);
- if (bl == 0) /* no literals or lengths */
- retval = 1;
- if (retval)
- {
- if (retval == 1) {
- huft_free(tl);
- }
- return retval; /* incomplete code set */
- }
- bd = dbits;
- retval = huft_build(__G__ ll + nl, nd, 0, cpdist, cpdext, &td, &bd);
-#ifdef PKZIP_BUG_WORKAROUND
- if (retval == 1)
- retval = 0;
-#endif
- if (bd == 0 && nl > 257) /* lengths but no distances */
- retval = 1;
- if (retval)
- {
- if (retval == 1) {
- huft_free(td);
- }
- huft_free(tl);
- return retval;
- }
-
- /* decompress until an end-of-block code */
- retval = inflate_codes(__G__ tl, td, bl, bd);
-
- /* free the decoding tables, return */
- huft_free(tl);
- huft_free(td);
- return retval;
-}
-
-
-
-static int inflate_block(__G__ __GDEF int* e)
- /* last block flag */
-/* decompress an inflated block */
-{
- unsigned t; /* block type */
- register u32 b; /* bit buffer */
- register unsigned k; /* number of bits in bit buffer */
- int retval = 0; /* error code returned: initialized to "no error"
*/
-
-
- /* make local bit buffer */
- b = G.bb;
- k = G.bk;
-
-
- /* read in last block bit */
- NEEDBITS(1)
- *e = (int)b & 1;
- DUMPBITS(1)
-
-
- /* read in block type */
- NEEDBITS(2)
- t = (unsigned)b & 3;
- DUMPBITS(2)
-
-
- /* restore the global bit buffer */
- G.bb = b;
- G.bk = k;
-
-
- /* inflate that block type */
- if (t == 2)
- return inflate_dynamic(__G);
- if (t == 0)
- return inflate_stored(__G);
- if (t == 1)
- return inflate_fixed(__G);
-
-
- /* bad block type */
- retval = 2;
-
- return retval;
-}
-
-
-
-int inflate(__G)
- __GDEF
-/* decompress an inflated entry */
-{
- int e; /* last block flag */
- int r; /* result code */
-#ifdef DEBUG
- unsigned h = 0; /* maximum struct huft's malloc'ed */
-#endif
-
-#if (defined(DLL) && !defined(NO_SLIDE_REDIR))
- if (G.redirect_slide)
- wsize = G.redirect_size, redirSlide = G.redirect_buffer;
- else
- wsize = WSIZE, redirSlide = slide; /* how they're #defined if !DLL */
-#endif
-
- /* initialize window, bit buffer */
- G.wp = 0;
- G.bk = 0;
- G.bb = 0;
-
-
- /* decompress until the last block */
- do {
-#ifdef DEBUG
- G.hufts = 0;
-#endif
- if ((r = inflate_block(__G__ &e)) != 0)
- return r;
-#ifdef DEBUG
- if (G.hufts > h)
- h = G.hufts;
-#endif
- } while (!e);
-
- Trace((stderr, "\n%u bytes in Huffman tables (%d/entry)\n",
- h * sizeof(struct huft), sizeof(struct huft)));
-
- /* flush out redirSlide and return (success, unless final FLUSH failed)
*/
- FLUSH(G.wp);
- return 0;
-}
-
-
-
-int inflate_free(__G)
- __GDEF
-{
- if (G.fixed_tl != (struct huft *)NULL)
- {
- huft_free(G.fixed_td);
- huft_free(G.fixed_tl);
- G.fixed_td = G.fixed_tl = (struct huft *)NULL;
- }
- return 0;
-}
-
-
-/*
- * GRR: moved huft_build() and huft_free() down here; used by explode()
- * and fUnZip regardless of whether USE_ZLIB defined or not
- */
-
-
-/* If BMAX needs to be larger than 16, then h and x[] should be ulg. */
-#define BMAX 16 /* maximum bit length of any code (16 for explode)
*/
-#define N_MAX 288 /* maximum number of codes in any set */
-
-
-int huft_build(__G__ __GDEF const uint* b, uint n, uint s, const u16* d,
const u16* e, huft** t, int* m)
-// __GDEF
-// const unsigned *b; /* code lengths in bits (all assumed <= BMAX) */
-// unsigned n; /* number of codes (assumed <= N_MAX) */
-// unsigned s; /* number of simple-valued codes (0..s-1) */
-// const u16 *d; /* list of base values for non-simple codes */
-// const u16 *e; /* list of extra bits for non-simple codes */
-// struct huft **t; /* result: starting table */
-// int *m; /* maximum lookup bits, returns actual */
-/* Given a list of code lengths and a maximum table size, make a set of
- tables to decode that set of codes. Return zero on success, one if
- the given code set is incomplete (the tables are still built in this
- case), two if the input is invalid (all zero length codes or an
- oversubscribed set of lengths), and three if not enough memory.
- The code with value 256 is special, and the tables are constructed
- so that no bits beyond that code are fetched when that code is
- decoded. */
-{
- unsigned a; /* counter for codes of length k */
- unsigned c[BMAX+1]; /* bit length count table */
- unsigned el; /* length of EOB code (value 256) */
- unsigned f; /* i repeats in table every f entries */
- int g; /* maximum code length */
- int h; /* table level */
- register unsigned i; /* counter, current code */
- register unsigned j; /* counter */
- register int k; /* number of bits in current code */
- int lx[BMAX+1]; /* memory for l[-1..BMAX-1] */
- int *l = lx+1; /* stack of bits per table */
- register unsigned *p; /* pointer into c[], b[], or v[] */
- register struct huft *q; /* points to current table */
- struct huft r; /* table entry for structure assignment */
- struct huft *u[BMAX]; /* table stack */
- unsigned v[N_MAX]; /* values in order of bit length */
- register int w; /* bits before this table == (l * h) */
- unsigned x[BMAX+1]; /* bit offsets, then code stack */
- unsigned *xp; /* pointer into x */
- int y; /* number of dummy codes added */
- unsigned z; /* number of entries in current table */
-
-
- /* Generate counts for each bit length */
- el = n > 256 ? b[256] : BMAX; /* set length of EOB code, if any */
- memset((char *)c, 0, sizeof(c));
- p = (unsigned *)b; i = n;
- do {
- c[*p]++; p++; /* assume all entries <= BMAX */
- } while (--i);
- if (c[0] == n) /* null input--all zero length codes */
- {
- *t = (struct huft *)NULL;
- *m = 0;
- return 0;
- }
-
-
- /* Find minimum and maximum length, bound *m by those */
- for (j = 1; j <= BMAX; j++)
- if (c[j])
- break;
- k = j; /* minimum code length */
- if ((unsigned)*m < j)
- *m = j;
- for (i = BMAX; i; i--)
- if (c[i])
- break;
- g = i; /* maximum code length */
- if ((unsigned)*m > i)
- *m = i;
-
-
- /* Adjust last length count to fill out codes, if needed */
- for (y = 1 << j; j < i; j++, y <<= 1)
- if ((y -= c[j]) < 0)
- return 2; /* bad input: more codes than bits */
- if ((y -= c[i]) < 0)
- return 2;
- c[i] += y;
-
-
- /* Generate starting offsets into the value table for each length */
- x[1] = j = 0;
- p = c + 1; xp = x + 2;
- while (--i) { /* note that i == g from above */
- *xp++ = (j += *p++);
- }
-
-
- /* Make a table of values in order of bit lengths */
- memset((char *)v, 0, sizeof(v));
- p = (unsigned *)b; i = 0;
- do {
- if ((j = *p++) != 0)
- v[x[j]++] = i;
- } while (++i < n);
- n = x[g]; /* set n to length of v */
-
-
- /* Generate the Huffman codes and for each, make the table entries */
- x[0] = i = 0; /* first Huffman code is zero */
- p = v; /* grab values in bit order */
- h = -1; /* no tables yet--level -1 */
- w = l[-1] = 0; /* no bits decoded yet */
- u[0] = (struct huft *)NULL; /* just to keep compilers happy */
- q = (struct huft *)NULL; /* ditto */
- z = 0; /* ditto */
-
- /* go through the bit lengths (k already is bits in shortest code) */
- for (; k <= g; k++)
- {
- a = c[k];
- while (a--)
- {
- /* here i is the Huffman code of length k bits for value *p */
- /* make tables up to required level */
- while (k > w + l[h])
- {
- w += l[h++]; /* add bits already decoded */
-
- /* compute minimum size table less than or equal to *m bits */
- z = (z = g - w) > (unsigned)*m ? *m : z; /* upper limit */
- if ((f = 1 << (j = k - w)) > a + 1) /* try a k-w bit table */
- { /* too few codes for k-w bit table */
- f -= a + 1; /* deduct codes from patterns left */
- xp = c + k;
- while (++j < z) /* try smaller tables up to z bits */
- {
- if ((f <<= 1) <= *++xp)
- break; /* enough codes to use up j bits */
- f -= *xp; /* else deduct codes from patterns */
- }
- }
- if ((unsigned)w + j > el && (unsigned)w < el)
- j = el - w; /* make EOB code end at table */
- z = 1 << j; /* table entries for j-bit table */
- l[h] = j; /* set table size in stack */
-
- /* allocate and link in new table */
- if ((q = (struct huft *)malloc((z + 1)*sizeof(struct huft))) ==
- (struct huft *)NULL)
- {
- if (h)
- huft_free(u[0]);
- return 3; /* not enough memory */
- }
-#ifdef DEBUG
- G.hufts += z + 1; /* track memory usage */
-#endif
- *t = q + 1; /* link to list for huft_free() */
- *(t = &(q->v.t)) = (struct huft *)NULL;
- u[h] = ++q; /* table starts after link */
-
- /* connect to last table, if there is one */
- if (h)
- {
- x[h] = i; /* save pattern for backing up */
- r.b = (u8)l[h-1]; /* bits to dump before this table */
- r.e = (u8)(16 + j); /* bits in this table */
- r.v.t = q; /* pointer to this table */
- j = (i & ((1 << w) - 1)) >> (w - l[h-1]);
- u[h-1][j] = r; /* connect to last table */
- }
- }
-
- /* set up table entry in r */
- r.b = (u8)(k - w);
- if (p >= v + n)
- r.e = INVALID_CODE; /* out of values--invalid code */
- else if (*p < s)
- {
- r.e = (u8)(*p < 256 ? 16 : 15); /* 256 is end-of-block code */
- r.v.n = (u16)*p++; /* simple code is just the value
*/
- }
- else
- {
- r.e = (u8)e[*p - s]; /* non-simple--look up in lists */
- r.v.n = d[*p++ - s];
- }
-
- /* fill code-like entries with r */
- f = 1 << (k - w);
- for (j = i >> w; j < z; j += f)
- q[j] = r;
-
- /* backwards increment the k-bit code i */
- for (j = 1 << (k - 1); i & j; j >>= 1)
- i ^= j;
- i ^= j;
-
- /* backup over finished tables */
- while ((i & ((1 << w) - 1)) != x[h])
- w -= l[--h]; /* don't need to update q */
- }
- }
-
-
- /* return actual size of base table */
- *m = l[0];
-
-
- /* Return true (1) if we were given an incomplete table */
- return y != 0 && g != 1;
-}
-
-
-
-int huft_free(huft* t)
-//struct huft *t; /* table to free */
***The diff for this file has been truncated for email.***
=======================================
--- /src/BlueZip/Inflate.h Fri Apr 16 12:25:47 2004
+++ /dev/null
@@ -1,422 +0,0 @@
-//privzip.h
-
-#define WSIZE 0x8000 /* window size--must be a power of two, and */
-
-
-#define MAX_BITS 13 /* used in unshrink() */
-#define HSIZE (1 << MAX_BITS) /* size of global work area */
- union work {
- struct { /* unshrink(): */
- int Parent[HSIZE]; /* (8192 * sizeof(shrint)) == 16KB minimum */
- u8 value[HSIZE]; /* 8KB */
- u8 Stack[HSIZE]; /* 8KB */
- } shrink; /* total = 32KB minimum; 80KB on
Cray/Alpha */
- u8 Slide[WSIZE]; /* explode(), inflate(), unreduce() */
- };
-
-
-
-/*
-
- Copyright (c) 1990-2001 Info-ZIP. All rights reserved.
-
- See the accompanying file LICENSE, version 2000-Apr-09 or later
- (the contents of which are also included in unzip.h) for terms of use.
- If, for some reason, all these files are missing, the Info-ZIP license
- also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html
-*/
-/*---------------------------------------------------------------------------
-
- globals.h
-
- There is usually no need to include this file since unzip.h includes it.
-
- This header file is used by all of the UnZip source files. It contains
- a struct definition that is used to "house" all of the global variables.
- This is done to allow for multithreaded environments (OS/2, NT, Win95,
- Unix) to call UnZip through an API without a semaphore. REENTRANT should
- be defined for all platforms that require this.
-
- GLOBAL CONSTRUCTOR AND DESTRUCTOR (API WRITERS READ THIS!!!)
- ------------------------------------------------------------
-
- No, it's not C++, but it's as close as we can get with K&R.
-
- The main() of each process that uses these globals must include the
- CONSTRUCTGLOBALS; statement. This will malloc enough memory for the
- structure and initialize any variables that require it. This must
- also be done by any API function that jumps into the middle of the
- code.
-
- The DESTROYGLOBALS; statement should be inserted before EVERY "EXIT(n)".
- Naturally, it also needs to be put before any API returns as well.
- In fact, it's much more important in API functions since the process
- will NOT end, and therefore the memory WON'T automatically be freed
- by the operating system.
-
- USING VARIABLES FROM THE STRUCTURE
- ----------------------------------
-
- All global variables must now be prefixed with `G.' which is either a
- global struct (in which case it should be the only global variable) or
- a macro for the value of a local pointer variable that is passed from
- function to function. Yes, this is a pain. But it's the only way to
- allow full reentrancy.
-
- ADDING VARIABLES TO THE STRUCTURE
- ---------------------------------
-
- If you make the inclusion of any variables conditional, be sure to only
- check macros that are GUARANTEED to be included in every module.
- For instance, newzip and pwdarg are needed only if CRYPT is TRUE,
- but this is defined after unzip.h has been read. If you are not careful,
- some modules will expect your variable to be part of this struct while
- others won't. This will cause BIG problems. (Inexplicable crashes at
- strange times, car fires, etc.) When in doubt, always include it!
-
- Note also that UnZipSFX needs a few variables that UnZip doesn't.
However,
- it also includes some object files from UnZip. If we were to
conditionally
- include the extra variables that UnZipSFX needs, the object files from
- UnZip would not mesh with the UnZipSFX object files. Result: we just
- include the UnZipSFX variables every time. (It's only an extra 4 bytes
- so who cares!)
-
- ADDING FUNCTIONS
- ----------------
-
- To support this new global struct, all functions must now conditionally
- pass the globals pointer (pG) to each other. This is supported by 5
macros:
- __GPRO, __GPRO__, __G, __G__ and __GDEF. A function that needs no other
- parameters would look like this:
-
- int extract_or_test_files(__G)
- __GDEF
- {
- ... stuff ...
- }
-
- A function with other parameters would look like:
-
- int memextract(__G__ tgt, tgtsize, src, srcsize)
- __GDEF
- u8 *tgt, *src;
- u32 tgtsize, srcsize;
- {
- ... stuff ...
- }
-
- In the Function Prototypes section of unzpriv.h, you should use __GPRO
and
- __GPRO__ instead:
-
- int uz_opts OF((__GPRO__ int *pargc, char
***pargv));
- int process_zipfiles OF((__GPRO));
-
- Note that there is NO comma after __G__ or __GPRO__ and no semi-colon
after
- __GDEF. I wish there was another way but I don't think there is.
-
-
- TESTING THE CODE
- -----------------
-
- Whether your platform requires reentrancy or not, you should always try
- building with REENTRANT defined if any functions have been added. It is
- pretty easy to forget a __G__ or a __GDEF and this mistake will only show
- up if REENTRANT is defined. All platforms should run with REENTRANT
- defined. Platforms that can't take advantage of it will just be paying
- a performance penalty needlessly.
-
- SIGNAL MADNESS
- --------------
-
- This whole pointer passing scheme falls apart when it comes to SIGNALs.
- I handle this situation 2 ways right now. If you define USETHREADID,
- UnZip will include a 64-entry table. Each entry can hold a global
- pointer and thread ID for one thread. This should allow up to 64
- threads to access UnZip simultaneously. Calling DESTROYGLOBALS()
- will free the global struct and zero the table entry. If somebody
- forgets to call DESTROYGLOBALS(), this table will eventually fill up
- and UnZip will exit with an error message. A good way to test your
- code to make sure you didn't forget a DESTROYGLOBALS() is to change
- THREADID_ENTRIES to 3 or 4 in globals.c, making the table real small.
- Then make a small test program that calls your API a dozen times.
-
- Those platforms that don't have threads still need to be able to compile
- with REENTRANT defined to test and see if new code is correctly written
- to work either way. For these platforms, I simply keep a global pointer
- called GG that points to the Globals structure. Good enough for testing.
-
- I believe that NT has thread level storage. This could probably be used
- to store a global pointer for the sake of the signal handler more cleanly
- than my table approach.
-
-
---------------------------------------------------------------------------*/
-
-#ifndef __globals_h
-#define __globals_h
-
-#ifdef USE_ZLIB
-# include "zlib.h"
-#endif
-
-
-/*************/
-/* Globals */
-/*************/
-
-typedef struct Globals {
-#ifdef DLL
- zvoid *callerglobs; /* pointer to structure of pass-through global
vars */
-#endif
-
-
-#ifndef FUNZIP
- /* command options specific to the high level command line interface */
-#ifdef MORE
- int M_flag; /* -M: built-in "more" function */
-#endif
-
- /* internal flags and general globals */
-#ifdef MORE
- int height; /* check for SIGWINCH, etc., eventually... */
- int lines; /* count of lines displayed on current screen */
-# if (defined(SCREENWIDTH) && defined(SCREENLWRAP))
- int width;
- int chars; /* count of screen characters in current line */
-# endif
-#endif /* MORE */
-#if (defined(IZ_CHECK_TZ) && defined(USE_EF_UT_TIME))
- int tz_is_valid; /* indicates that timezone info can be used */
-#endif
- int noargs; /* did true command line have *any* arguments? */
- unsigned filespecs; /* number of real file specifications to be
matched */
- unsigned xfilespecs; /* number of excluded filespecs to be matched */
- int process_all_files;
- int overwrite_mode; /* 0 - query, 1 - always, 2 - never */
- int create_dirs; /* used by main(), mapname(), checkdir() */
- int extract_flag;
- int newzip; /* reset in extract.c; used in crypt.c */
-
- //NEIL: WHAT ARE THESE?
- //LONGINT real_ecrec_offset;
- //LONGINT expect_ecrec_offset;
- long csize; /* used by decompr. (NEXTBYTE): must be signed */
- long used_csize; /* used by extract_or_test_member(), explode() */
-
-#ifdef DLL
- int fValidate; /* true if only validating an archive */
- int filenotfound;
- int redirect_data; /* redirect data to memory buffer */
- int redirect_text; /* redirect text output to buffer */
-# ifndef NO_SLIDE_REDIR
- int redirect_slide; /* redirect decompression area to mem buffer */
- unsigned _wsize;
-# endif
- unsigned redirect_size; /* size of redirected output buffer */
- u8 *redirect_buffer; /* pointer to head of allocated buffer */
- u8 *redirect_pointer; /* pointer past end of written data */
-# ifndef NO_SLIDE_REDIR
- u8 *redirect_sldptr; /* head of decompression slide buffer */
-# endif
-# ifdef OS2DLL
- cbList(processExternally); /* call-back list */
-# endif
-#endif /* DLL */
-
- char **pfnames;
- char **pxnames;
- char sig[4];
- char answerbuf[10];
-// min_info info[DIR_BLKSIZ];
-// min_info *pInfo;
-#endif /* !FUNZIP */
- union work area; /* see unzpriv.h for definition of
work */
-
-#ifdef FUNZIP
- FILE *in; /* file descriptor of compressed
stream */
-#endif
- u8 *inbuf; /* input buffer (any size is OK) */
- u8 *inptr; /* pointer into input buffer */
- int incnt;
-
-#ifndef FUNZIP
- u32 bitbuf;
- int bits_left; /* unreduce and unshrink only */
- int zipeof;
- char *argv0; /* used for NT and EXE_EXTENSION */
- char *wildzipfn;
- char *zipfn; /* GRR: WINDLL: must nuke any malloc'd zipfn...
*/
-#ifdef USE_STRM_INPUT
- FILE *zipfd; /* zipfile file descriptor */
-#else
- int zipfd; /* zipfile file handle */
-#endif
-// LONGINT ziplen;
- //LONGINT cur_zipfile_bufstart; /* extract_or_test, readbuf,
ReadByte */
-// LONGINT extra_bytes; /* used in unzip.c, misc.c */
- u8 *extra_field; /* Unix, VMS, Mac, OS/2, Acorn, ... */
- u8 *hold;
-
-// local_file_hdr lrec; /* used in unzip.c, extract.c */
-// cdir_file_hdr crec; /* used in unzip.c, extract.c, misc.c
*/
-// ecdir_rec ecrec; /* used in unzip.c, extract.c */
-// struct stat statbuf; /* used by main, mapname,
check_for_newer */
-
- int mem_mode;
- u8 *outbufptr; /* extract.c static */
- u32 outsize; /* extract.c static */
- int reported_backslash; /* extract.c static */
- int disk_full;
- int newfile;
-
- int didCRlast; /* fileio static */
- u32 numlines; /* fileio static: number of lines
printed */
- int sol; /* fileio static: at start of line */
- int no_ecrec; /* process static */
-#ifdef SYMLINKS
- int symlnk;
-#endif
-#ifdef NOVELL_BUG_FAILSAFE
- int dne; /* true if stat() says file doesn't
exist */
-#endif
-
- FILE *outfile;
- u8 *outbuf;
- u8 *realbuf;
-
-#ifndef VMS /* if SMALL_MEM, outbuf2 is initialized
in */
- u8 *outbuf2; /* process_zipfiles() (never changes);
*/
-#endif /* else malloc'd ONLY if unshrink and
-a */
-#endif /* !FUNZIP */
- u8 *outptr;
- u32 outcnt; /* number of chars stored in outbuf */
-#ifndef FUNZIP
- char filename[MAX_PATH]; /* also used by NT for temporary SFX
path */
-
-#ifdef CMS_MVS
- char *tempfn; /* temp file used; erase on close */
-#endif
-
- char *key; /* crypt static: decryption password or NULL */
- int nopwd; /* crypt static */
-#endif /* !FUNZIP */
- u32 keys[3]; /* crypt static: keys defining pseudo-random
sequence */
-
-#if (!defined(DOS_FLX_H68_NLM_OS2_W32) && !defined(AMIGA)
&& !defined(RISCOS))
-#if (!defined(MACOS) && !defined(ATARI) && !defined(VMS))
- int echofd; /* ttyio static: file descriptor whose echo is off
*/
-#endif /* !(MACOS || ATARI || VMS) */
-#endif /* !(DOS_FLX_H68_NLM_OS2_W32 || AMIGA || RISCOS) */
-
- unsigned hufts; /* track memory usage */
-
-#ifdef USE_ZLIB
- int inflInit; /* inflate static: zlib inflate()
initialized */
- z_stream dstrm; /* inflate global: decompression stream */
-#else
- struct huft *fixed_tl; /* inflate static */
- struct huft *fixed_td; /* inflate static */
- int fixed_bl, fixed_bd; /* inflate static */
- unsigned wp; /* inflate static: current position in slide
*/
- u32 bb; /* inflate static: bit buffer */
- unsigned bk; /* inflate static: bits in bit buffer */
-#endif /* ?USE_ZLIB */
-
-#ifndef FUNZIP
-#ifdef SMALL_MEM
- char rgchBigBuffer[512];
- char rgchSmallBuffer[96];
- char rgchSmallBuffer2[160]; /* boosted to 160 for local3[] in unzip.c
*/
-#endif
-
- // MsgFn *message;
- //InputFn *input;
-// PauseFn *mpause;
- // PasswdFn *decr_passwd;
- //StatCBFn *statreportcb;
-#ifdef WINDLL
- LPUSERFUNCTIONS lpUserFunctions;
-#endif
-
- int incnt_leftover; /* so improved NEXTBYTE does not waste input
*/
- u8 *inptr_leftover;
-
-#ifdef VMS_TEXT_CONV
- int VMS_line_state; /* so native VMS variable-length text files
are */
- int VMS_line_length; /* readable on other platforms */
- int VMS_line_pad;
-#endif
-#endif /* !FUNZIP */
-
-#ifdef SYSTEM_SPECIFIC_GLOBALS
- SYSTEM_SPECIFIC_GLOBALS
-#endif
-
-} Uz_Globs; /* end of struct Globals */
-
-
-/***************************************************************************/
-
-
-#ifdef FUNZIP
-# if (!defined(USE_ZLIB) || defined(USE_OWN_CRCTAB))
- extern ZCONST u32 near crc_32_tab[256];
-# else
- extern ZCONST u32 Far *crc_32_tab;
-# endif
-# define CRC_32_TAB crc_32_tab
-#else
-# define CRC_32_TAB G.crc_32_tab
-#endif
-
-
-Uz_Globs *globalsCtor(void);
-
-/* pseudo constant sigs; they are initialized at runtime so unzip
executable
- * won't look like a zipfile
- */
-extern char local_hdr_sig[4];
-extern char central_hdr_sig[4];
-extern char end_central_sig[4];
-/* extern char extd_local_sig[4]; NOT USED YET */
-
-#ifdef REENTRANT
-# define G (*(Uz_Globs *)pG)
-# define __G pG
-# define __G__ pG,
-# define __GPRO Uz_Globs *pG
-# define __GPRO__ Uz_Globs *pG,
-# define __GDEF Uz_Globs *pG;
-# ifdef USETHREADID
- extern int lastScan;
- void deregisterGlobalPointer OF((__GPRO));
- Uz_Globs *getGlobalPointer OF((void));
-# define GETGLOBALS() Uz_Globs *pG = getGlobalPointer();
-# define DESTROYGLOBALS() {free_G_buffers(pG);
deregisterGlobalPointer(pG);}
-# else
- extern Uz_Globs *GG;
-# define GETGLOBALS() Uz_Globs *pG = GG;
-# define DESTROYGLOBALS() {free_G_buffers(pG); free(pG);}
-# endif /* ?USETHREADID */
-# define CONSTRUCTGLOBALS() Uz_Globs *pG = globalsCtor()
-#else /* !REENTRANT */
- extern Uz_Globs G;
-# define __G
-# define __G__
-# define __GPRO void
-# define __GPRO__
-# define __GDEF
-# define GETGLOBALS()
-# define CONSTRUCTGLOBALS() globalsCtor()
-# define DESTROYGLOBALS()
-#endif /* ?REENTRANT */
-
-#define uO G.UzO
-
-#endif /* __globals_h */
-
-
-//COPIED FROM Inflate.cpp by Neil
-int inflate();
-void Neil_Init(File Out, File In);
-
-extern struct Globals G;
=======================================
--- /src/BlueZip/License.txt Fri Apr 16 12:25:47 2004
+++ /dev/null
@@ -1,49 +0,0 @@
-This is version 1999-Oct-05 of the Info-ZIP copyright and license.
-The definitive version of this document should be available at
-ftp://ftp.cdrom.com/pub/infozip/license.html indefinitely.
-
-
-Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
-
-For the purposes of this copyright and license, "Info-ZIP" is defined as
-the following set of individuals:
-
- Mark Adler, John Bush, Karl Davis, Harald Denker, Jean-Michel Dubois,
- Jean-loup Gailly, Hunter Goatley, Ian Gorman, Chris Herborth, Dirk
Haase,
- Greg Hartwig, Robert Heath, Jonathan Hudson, Paul Kienitz, David
Kirschbaum,
- Johnny Lee, Onno van der Linden, Igor Mandrichenko, Steve P. Miller,
- Sergio Monesi, Keith Owens, George Petrov, Greg Roelofs, Kai Uwe Rommel,
- Steve Salisbury, Dave Smith, Christian Spieler, Antoine Verheijen,
- Paul von Behren, Rich Wales, Mike White
-
-This software is provided "as is," without warranty of any kind, express
-or implied. In no event shall Info-ZIP or its contributors be held liable
-for any direct, indirect, incidental, special or consequential damages
-arising out of the use of or inability to use this software.
-
-Permission is granted to anyone to use this software for any purpose,
-including commercial applications, and to alter it and redistribute it
-freely, subject to the following restrictions:
-
- 1. Redistributions of source code must retain the above copyright
notice,
- definition, disclaimer, and this list of conditions.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, definition, disclaimer, and this list of conditions in
- documentation and/or other materials provided with the distribution.
-
- 3. Altered versions--including, but not limited to, ports to new
operating
- systems, existing ports with new graphical interfaces, and dynamic,
- shared, or static library versions--must be plainly marked as such
- and must not be misrepresented as being the original source. Such
- altered versions also must not be misrepresented as being Info-ZIP
- releases--including, but not limited to, labeling of the altered
- versions with the names "Info-ZIP" (or any variation thereof,
including,
- but not limited to, different capitalizations), "Pocket
UnZip," "WiZ"
- or "MacZip" without the explicit permission of Info-ZIP. Such
altered
- versions are further prohibited from misrepresentative use of the
- Zip-Bugs or Info-ZIP e-mail addresses or of the Info-ZIP URL(s).
-
- 4. Info-ZIP retains the right to use the
names "Info-ZIP," "Zip," "UnZip,"
- "WiZ," "Pocket UnZip," "Pocket Zip," and "MacZip" for its own
source and
- binary releases.
=======================================
--- /src/BlueZip/ReadZip.cpp Fri Apr 16 12:25:47 2004
+++ /dev/null
@@ -1,136 +0,0 @@
-#include "BlueHead.h"
-
-bool BlueZip::Read()
-{
- File f = FileOpenRead(FileName); //ZIP
file
-
- if (!FileValid(f))
- {
- ErrMsg("Failed to open the ZIP file");
- return false;
- }
-
- bool Res = ScanZip(f);
- FileClose(f);
- return Res;
-}
-
-
-bool BlueZip::ScanZip(File f)
-{
- int i, n; //Global enumeration variable
- long sig; //signature variable
-
- //TASK 1: Find the last occurance of 'sigEnd' in the file
- //Use a 4096 character buffer for decent sized transfers
- const int BlockSize = 4096;
-
- char* EndBuffer = new char[BlockSize + 3]; //do not overflow
- int fLen = FileLen(f);
- EndBuffer[0] = 0; //ensure you do not match already present static
-
- do
- {
- //Copy over the trailing information
- EndBuffer[BlockSize+0] = EndBuffer[0];
- EndBuffer[BlockSize+1] = EndBuffer[2];
- EndBuffer[BlockSize+2] = EndBuffer[1];
-
- if (fLen >= BlockSize)
- {
- n = 0;
- fLen -= BlockSize;
- SeekBeg(f, fLen);
- FileRead(f, EndBuffer, BlockSize);
- }
- else
- {
- n = BlockSize - fLen;
- SeekBeg(f, 0);
- FileRead(f, &EndBuffer[n], fLen);
- fLen = 0;
- }
-
- //Look for the end signature
- for (i = BlockSize; i >= n; i--)
- {
- if (stream32(EndBuffer, i) == sigEnd)
- {
- //Use n as a temp variable
- n = fLen + (i-n) + 4;
- fLen = -1;
- SeekBeg(f, n); //Skip over the signature
- break; //for
- }
- }
- }
- while (fLen > 0);
- delete[] EndBuffer;
- //warn: garbage at the end of the file ignored
-
- if (fLen == 0)
- {
- ErrMsg("Failed to find the end signature");
- return false;
- }
-
- //END TASK 1
-
- //TASK 2: Read in the end header
- ReadEnd(f);
-
- //Check for mutliple disks
- if (data.DiskNum != data.Count)
- {
- ErrMsg("Does not support multiple disk archives");
- return false;
- }
- //END TASK 2
-
- //TASK 3: Read central header
- //Goto the central header
- //This is directly before the footer
- n -= data.Size + 4;
- SeekBeg(f, n);
- FilePosDelta = n - data.Offset;
-
-#ifdef _DEBUG
- i = 0; //do a manual count of the files
-#endif
-
- FileRead(f, &sig, 4);
- zList** next = &Files;
-
- while (sig == sigCentral)
- {
- zList* z = new zList;
-
- // Insert into list
- *next = z;
- next = &z->next;
-
- z->ReadCentral(f);
-
-#ifdef _DEBUG //Maintain a count of the files
- i++;
-#endif
-
- // Read next signature
- FileRead(f, &sig, 4);
- }
- //END TASK 3
-
- AssertD(data.Count == i); //Unexpected number of items
-
- //Neil alteration
- //DO NOT READ IN THE LOCAL HEADERS, assume they are correct
- //and do not contain any different information from the
- //central ones
-
- //Results: Speed up, smaller size
- // Less code for me to write
- // Does not detect badly encoded ZIP files (but does maintain
them)
-
-
- return true;
-}
=======================================
--- /src/BlueZip/Store.cpp Fri Apr 16 12:25:47 2004
+++ /dev/null
@@ -1,71 +0,0 @@
-#include "BlueHead.h"
-#include <stdio.h>
-#include "inflate.h"
-
-void FileDataCopy(File From, File To, int Len)
-{
- //Optimisation possible, use static buffers from Deflate/Inflate
- const int BlockSize = 4096;
- u8 Buffer[BlockSize];
-
- int i;
- while(Len != 0)
- {
- i = min(Len, BlockSize);
- FileRead(From, Buffer, i);
- FileWrite(To, Buffer, i);
-
- CRC(Buffer, i); //Perform the
-
- Len -= i;
- }
-}
-
-
-void ReadStore(File In, File Out, zList* z)
-{
- //Read from In - the zip file
- //In is at the start of the file (i.e. sigLocal)
- //Out is at the begining, currently the length is 0
- //z contains the table entry
-
- datCentral hLocal;
- u32 sig;
- FileRead(In, &sig, 4);
- Assert(sig == sigLocal);
-
- hLocal.ReadLocal(In);
-
- //Skip to the begining of the actual data
- SeekCur(In, hLocal.lFileName + hLocal.lExtra);
-
- //Check that WinZip would accept this as a file, that has been stored
- if (hLocal.CompMode == compStore)
- {
- Assert(hLocal.CompSize == hLocal.OrigSize);
-
- FileDataCopy(In, Out, hLocal.CompSize);
- }
- else
- {
- //use the Zip inflate routine
- //use the global G
- Neil_Init(Out, In);
-
- //If not 0 then a failure, I think
- inflate();
- }
-}
-
-void WriteStore(File In, File Out, zList* z)
-{
- //Read from In - the binary file
- //In is at the begining
- //Out is the ZIP file, and is ready to receive data
- //z contains the table entry, including the correct OrigSize
- //must set CompMode, CompSize
-
- z->data.CompMode = compStore;
- z->data.CompSize = z->data.OrigSize;
- FileDataCopy(In, Out, z->data.OrigSize);
-}
=======================================
--- /src/BlueZip/Structs.cpp Fri Apr 16 12:25:47 2004
+++ /dev/null
@@ -1,147 +0,0 @@
-#include "BlueHead.h"
-
-#define Set16(pos, res) \
- *((u16*) (&data[pos])) = res
-
-#define Set32(pos, res) \
- *((u32*) (&data[pos])) = res
-
-#define Get16(pos) \
- *((u16*) (&data[pos]))
-
-#define Get32(pos) \
- *((u32*) (&data[pos]))
-
-
-
-void datCentral::ReadLocal(File f)
-{
- char data[ldatLocal]; //26
- FileRead(f, data, ldatLocal);
-
- //16
- VerNeed = Get16(0);
- Flags = Get16(2);
- CompMode = Get16(4);
- Time = Get16(6);
- Date = Get16(8);
- //32
- CRC = Get32(10);
- CompSize = Get32(14);
- OrigSize = Get32(18);
- //16
- lFileName = Get16(22);
- lExtra = Get16(24);
-}
-
-void datCentral::WriteLocal(File f)
-{
- char data[ldatLocal]; //26
-
- //16
- Set16(0, VerNeed);
- Set16(2, Flags);
- Set16(4, CompMode);
- Set16(6, Time);
- Set16(8, Date);
- //32
- Set32(10, CRC);
- Set32(14, CompSize);
- Set32(18, OrigSize);
- //16
- Set16(22, lFileName);
- Set16(24, lExtra);
-
- FileWrite(f, data, ldatLocal);
-}
-
-void datCentral::Read(File f)
-{
- char data[ldatCentral]; //42
- FileRead(f, data, ldatCentral);
-
- //16
- VerMake = Get16(0);
- VerNeed = Get16(2);
- Flags = Get16(4);
- CompMode = Get16(6);
- Time = Get16(8);
- Date = Get16(10);
- //32
- CRC = Get32(12);
- CompSize = Get32(16);
- OrigSize = Get32(20);
- //16
- lFileName = Get16(24);
- lExtra = Get16(26);
- lComment = Get16(28);
- Disk = Get16(30);
- IntAttr = Get16(32);
- //32
- ExtAttr = Get32(34);
- Offset = Get32(38);
-}
-
-void datCentral::Write(File f)
-{
- char data[ldatCentral]; //42
-
- //16
- Set16(0, VerMake);
- Set16(2, VerNeed);
- Set16(4, Flags);
- Set16(6, CompMode);
- Set16(8, Time);
- Set16(10, Date);
- //32
- Set32(12, CRC);
- Set32(16, CompSize);
- Set32(20, OrigSize);
- //16
- Set16(24, lFileName);
- Set16(26, lExtra);
- Set16(28, lComment);
- Set16(30, Disk);
- Set16(32, IntAttr);
- //32
- Set32(34, ExtAttr);
- Set32(38, Offset);
-
- FileWrite(f, data, ldatCentral);
-}
-
-void datEnd::Read(File f)
-{
- char data[ldatEnd]; //18
- FileRead(f, data, ldatEnd);
-
- //16
- DiskNo = Get16(0);
- DiskOne = Get16(2);
- DiskNum = Get16(4);
- Count = Get16(6);
- //32
- Size = Get32(8);
- Offset = Get32(12);
- //16
- lComment = Get16(16);
-}
-
-void datEnd::Write(File f)
-{
- char data[ldatEnd]; //18
-
- //16
- Set16(0, DiskNo);
- Set16(2, DiskOne);
- Set16(4, DiskNum);
- Set16(6, Count);
- //32
- Set32(8, Size);
- Set32(12, Offset);
- //16
- Set16(16, lComment);
-
- FileWrite(f, data, ldatEnd);
-}
-
=======================================
--- /src/BlueZip/Structs.h Fri Apr 16 12:25:47 2004
+++ /dev/null
@@ -1,98 +0,0 @@
-
-//Compression modes
-enum CompModes
-{
- compStore = 0,
- compDeflate = 8,
-};
-
-//Signatures
-enum Signature
-{
- sigLocal = 0x04034b50,
- sigCentral = 0x02014b50,
- sigEnd = 0x06054b50,
- sigExtra = 0x08074b50, //Local
-};
-
-//Use actual headers
-
-//LOCHEAD 26, sizeof(datLocal) = 26
-const int ldatLocal = 26;
-/* Reference only: Use dat Central with some unused fields
-class datLocal
-{
-public:
- u16 VerNeed; //LOCVER - Version needed to extract
- u16 Flags; //LOCFLG - encrypt, deflate flags
- u16 CompMode; //LOCHOW - compression method
- u16 Time; //LOCTIM - last modified file time, DOS format
- u16 Date; //LOCDAT - last modified file date, DOS format
- u32 CRC; //LOCCRC - uncompressed crc-32 for file
- u32 CompSize; //LOCSIZ - compressed size in zip file
- u32 OrigSize; //LOCLEN - uncompressed size
- u16 lFileName; //LOCNAM - length of filename
- u16 lExtra; //LOCEXT - length of extra field
-
- void Read(File f);
- void Write(File f);
-};
-*/
-
-/* NEIL: Not currently required
-struct datExtra
-{
- u32 CRC; //EXTCRC - uncompressed crc-32 for file
- u32 CompSize; //EXTSIZ - compressed size in zip file
- u32 OrigSize; //EXTLEN - uncompressed size
-};*/
-
-//CENHEAD 42, sizeof(datCentral) = 42
-const int ldatCentral = 42;
-class datCentral
-{
-public:
- u16 VerMake; //CENVEM - version made by
-
- //SAME AS LOCAL
- u16 VerNeed; //LOCVER - Version needed to extract
- u16 Flags; //LOCFLG - encrypt, deflate flags
- u16 CompMode; //LOCHOW - compression method
- u16 Time; //LOCTIM - last modified file time, DOS format
- u16 Date; //LOCDAT - last modified file date, DOS format
- u32 CRC; //LOCCRC - uncompressed crc-32 for file
- u32 CompSize; //LOCSIZ - compressed size in zip file
- u32 OrigSize; //LOCLEN - uncompressed size
- u16 lFileName; //LOCNAM - length of filename
- u16 lExtra; //LOCEXT - length of extra field
- //END
-
- u16 lComment; //CENCOM - file comment length
- u16 Disk; //CENDSK - disk number start
- u16 IntAttr; //CENATT - internal file attributes
- u32 ExtAttr; //CENATX - external file attributes
- u32 Offset; //CENOFF - relative offset of local header
-
- void Read(File f);
- void Write(File f);
-
- void ReadLocal(File f);
- void WriteLocal(File f);
-};
-
-//ENDHEAD 18, sizeof(datEnd) = 18
-const int ldatEnd = 18;
-class datEnd
-{
-public:
- u16 DiskNo; //ENDDSK - number of this disk
- u16 DiskOne; //ENDBEG - number of the starting disk
- u16 DiskNum; //ENDSUB - entries on this disk
- u16 Count; //ENDTOT - total number of entries
- u32 Size; //ENDSIZ - size of entire central directory
- u32 Offset; //ENDOFF - offset of central on starting disk
- u16 lComment; //ENDCOM - length of zip file comment
-
- void Read(File f);
- void Write(File f);
-};
=======================================
--- /src/BlueZip/Trees.cpp Fri Apr 16 12:25:47 2004
+++ /dev/null
@@ -1,1238 +0,0 @@
-#include "CompHead.h"
-
-#ifndef NO_COMPRESSION
-
-/*
- Copyright (c) 1990-1999 Info-ZIP. All rights reserved.
-
- See the accompanying file LICENSE, version 1999-Oct-05 or later
- (the contents of which are also included in zip.h) for terms of use.
- If, for some reason, both of these files are missing, the Info-ZIP
license
- also may be found at: ftp://ftp.cdrom.com/pub/infozip/license.html
-*/
-/*
- * trees.c by Jean-loup Gailly
- *
- * This is a new version of im_ctree.c originally written by Richard B.
Wales
- * for the defunct implosion method.
- * The low level bit string handling routines from bits.c (originally
- * im_bits.c written by Richard B. Wales) have been merged into this
version
- * of trees.c.
- *
- * PURPOSE
- *
- * Encode various sets of source values using variable-length
- * binary code trees.
- * Output the resulting variable-length bit strings.
- * Compression can be done to a file or to memory.
- *
- * DISCUSSION
- *
- * The PKZIP "deflation" process uses several Huffman trees. The more
- * common source values are represented by shorter bit sequences.
- *
- * Each code tree is stored in the ZIP file in a compressed form
- * which is itself a Huffman encoding of the lengths of
- * all the code strings (in ascending order by source values).
- * The actual code strings are reconstructed from the lengths in
- * the UNZIP process, as described in the "application note"
- * (APPNOTE.TXT) distributed as part of PKWARE's PKZIP program.
- *
- * The PKZIP "deflate" file format interprets compressed file data
- * as a sequence of bits. Multi-bit strings in the file may cross
- * byte boundaries without restriction.
- * The first bit of each byte is the low-order bit.
- *
- * The routines in this file allow a variable-length bit value to
- * be output right-to-left (useful for literal values). For
- * left-to-right output (useful for code strings from the tree
routines),
- * the bits must have been reversed first with bi_reverse().
- *
- * For in-memory compression, the compressed bit stream goes directly
- * into the requested output buffer. The buffer is limited to 64K on
- * 16 bit machines; flushing of the output buffer during compression
- * process is not supported.
- * The input data is read in blocks by the (*read_buf)() function.
- *
- * For more details about input to and output from the deflation
routines,
- * see the actual input functions for (*read_buf)(), flush_outbuf(),
and
- * the filecompress() resp. memcompress() wrapper functions which
handle
- * the I/O setup.
- *
- * REFERENCES
- *
- * Lynch, Thomas J.
- * Data Compression: Techniques and Applications, pp. 53-55.
- * Lifetime Learning Publications, 1985. ISBN 0-534-03418-7.
- *
- * Storer, James A.
- * Data Compression: Methods and Theory, pp. 49-50.
- * Computer Science Press, 1988. ISBN 0-7167-8156-5.
- *
- * Sedgewick, R.
- * Algorithms, p290.
- * Addison-Wesley, 1983. ISBN 0-201-06672-6.
- *
- * INTERFACE
- *
- * void ct_init (ush *attr, int *method)
- * Allocate the match buffer, initialize the various tables and
save
- * the location of the internal file attribute (ascii/binary) and
- * method (DEFLATE/STORE)
- *
- * void ct_tally (int dist, int lc);
- * Save the match info and tally the frequency counts.
- *
- * u32 flush_block (char *buf, u32 stored_len, int eof)
- * Determine the best encoding for the current block: dynamic
trees,
- * static trees or store, and output the encoded block to the zip
- * file. Returns the total compressed length for the file so far.
- *
- * void bi_init (char *tgt_buf, unsigned tgt_size, int flsh_allowed)
- * Initialize the bit string routines.
- *
- * Most of the bit string output functions are only used internally
- * in this source file, they are normally declared as "local" routines:
- *
- * local void send_bits (int value, int length)
- * Write out a bit string, taking the source bits right to
- * left.
- *
- * local unsigned bi_reverse (unsigned code, int len)
- * Reverse the bits of a bit string, taking the source bits left
to
- * right and emitting them right to left.
- *
- * local void bi_windup (void)
- * Write out any remaining bits in an incomplete byte.
- *
- * local void copy_block(char *buf, unsigned len, int header)
- * Copy a stored block to the zip file, storing first the length
and
- * its one's complement if requested.
- *
- * All output that exceeds the bitstring output buffer size (as
initialized
- * by bi_init() is fed through an externally provided transfer routine
- * which flushes the bitstring output buffer on request and resets the
- * buffer fill counter:
- *
- * extern void flush_outbuf(char *o_buf, unsigned *o_idx);
- *
- */
-
-#include <ctype.h>
-
-/*
===========================================================================
- * Constants
- */
-
-const uint MAX_BITS = 15;
-/* All codes must not exceed MAX_BITS bits */
-
-const uint MAX_BL_BITS = 7;
-/* Bit length codes must not exceed MAX_BL_BITS bits */
-
-const uint LENGTH_CODES = 29;
-/* number of length codes, not counting the special END_BLOCK code */
-
-const uint LITERALS = 256;
-/* number of literal bytes 0..255 */
-
-const uint END_BLOCK = 256;
-/* end of block literal code */
-
-const uint L_CODES = (LITERALS + 1 + LENGTH_CODES);
-/* number of Literal or Length codes, including the END_BLOCK code */
-
-const uint D_CODES = 30;
-/* number of distance codes */
-
-const uint BL_CODES = 19;
-/* number of codes used to transfer the bit lengths */
-
-
-int extra_lbits[LENGTH_CODES] /* extra bits for each length code */
- = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0};
-
-int extra_dbits[D_CODES] /* extra bits for each distance code */
- = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13};
-
-int extra_blbits[BL_CODES]/* extra bits for each bit length code */
- = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};
-
-const uint STORED_BLOCK = 0;
-const uint STATIC_TREES = 1;
-const uint DYN_TREES = 2;
-/* The three kinds of block type */
-
-const uint LIT_BUFSIZE = 0x8000;
-const uint DIST_BUFSIZE = LIT_BUFSIZE;
-/* Sizes of match buffers for literals/lengths and distances. There are
- * 4 reasons for limiting LIT_BUFSIZE to 64K:
- * - frequencies can be kept in 16 bit counters
- * - if compression is not successful for the first block, all input
data is
- * still in the window so we can still emit a stored block even when
input
- * comes from standard input. (This can also be done for all blocks if
- * LIT_BUFSIZE is not greater than 32K.)
- * - if compression is not successful for a file smaller than 64K, we can
- * even emit a stored file instead of a stored block (saving 5 bytes).
- * - creating new Huffman trees less frequently may not provide fast
- * adaptation to changes in the input data statistics. (Take for
- * example a binary file with poorly compressible code followed by
- * a highly compressible string table.) Smaller buffer sizes give
- * fast adaptation but have of course the overhead of transmitting
trees
- * more frequently.
- * - I can't count above 4
- * The current code is general and allows DIST_BUFSIZE < LIT_BUFSIZE (to
save
- * memory at the expense of compression). Some optimizations would be
possible
- * if we rely on DIST_BUFSIZE == LIT_BUFSIZE.
- */
-
-const uint REP_3_6 = 16;
-/* repeat previous bit length 3-6 times (2 bits of repeat count) */
-
-const uint REPZ_3_10 = 17;
-/* repeat a zero length 3-10 times (3 bits of repeat count) */
-
-const uint REPZ_11_138 = 18;
-/* repeat a zero length 11-138 times (7 bits of repeat count) */
-
-/*
===========================================================================
- * Local data
- */
-
-/* Data structure describing a single value and its code string. */
-typedef struct ct_data {
- union {
- u16 freq; /* frequency count */
- u16 code; /* bit string */
- } fc;
- union {
- u16 dad; /* father node in Huffman tree */
- u16 len; /* length of bit string */
- } dl;
-} ct_data;
-
-#define Freq fc.freq
-#define Code fc.code
-#define Dad dl.dad
-#define Len dl.len
-
-const uint HEAP_SIZE = (2 * L_CODES) + 1;
-// maximum heap size
-
-ct_data dyn_ltree[HEAP_SIZE]; /* literal and length tree */
-ct_data dyn_dtree[2*D_CODES+1]; /* distance tree */
-
-ct_data static_ltree[L_CODES+2];
-/* The static literal tree. Since the bit lengths are imposed, there is no
- * need for the L_CODES extra codes used during heap construction. However
- * The codes 286 and 287 are needed to build a canonical tree (see ct_init
- * below).
- */
-
-ct_data static_dtree[D_CODES];
-/* The static distance tree. (Actually a trivial tree since all codes use
- * 5 bits.)
- */
-
-ct_data bl_tree[2*BL_CODES+1];
-/* Huffman tree for the bit lengths */
-
-struct tree_desc {
- ct_data near *dyn_tree; /* the dynamic tree */
- ct_data near *static_tree; /* corresponding static tree or NULL */
- int near *extra_bits; /* extra bits for each code or NULL */
- int extra_base; /* base index for extra_bits */
- int elems; /* max number of elements in the tree */
- int max_length; /* max bit length for the codes */
- int max_code; /* largest code with non zero frequency */
-};
-
-tree_desc l_desc =
-{dyn_ltree, static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS, 0};
-
-tree_desc d_desc =
-{dyn_dtree, static_dtree, extra_dbits, 0, D_CODES, MAX_BITS, 0};
-
-tree_desc bl_desc =
-{bl_tree, NULL, extra_blbits, 0, BL_CODES, MAX_BL_BITS, 0};
-
-
-u16 bl_count[MAX_BITS+1];
-/* number of codes at each bit length for an optimal tree */
-
-u8 bl_order[BL_CODES]
- = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};
-/* The lengths of the bit length codes are sent in order of decreasing
- * probability, to avoid transmitting the lengths for unused bit length
codes.
- */
-
-int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
-int heap_len; /* number of elements in the heap */
-int heap_max; /* element of largest frequency */
-/* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
- * The same heap array is used to build all trees.
- */
-
-u8 near depth[2*L_CODES+1];
-/* Depth of each subtree used as tie breaker for trees of equal frequency
*/
-
-u8 length_code[MaxMatch - MinMatch + 1];
-/* length code for each normalized match length (0 == MIN_MATCH) */
-
-u8 dist_code[512];
-/* distance codes. The first 256 values correspond to the distances
- * 3 .. 258, the last 256 values correspond to the top 8 bits of
- * the 15 bit distances.
- */
-
-int near base_length[LENGTH_CODES];
-/* First normalized length for each code (0 = MIN_MATCH) */
-
-int near base_dist[D_CODES];
-/* First normalized distance for each code (0 = distance of 1) */
-
-u8 l_buf[LIT_BUFSIZE]; /* buffer for literals/lengths */
-u16 d_buf[DIST_BUFSIZE]; /* buffer for distances */
-
-
-u8 flag_buf[(LIT_BUFSIZE/8)];
-/* flag_buf is a bit array distinguishing literals from lengths in
- * l_buf, and thus indicating the presence or absence of a distance.
- */
-
-uint last_lit; /* running index in l_buf */
-uint last_dist; /* running index in d_buf */
-uint last_flags; /* running index in flag_buf */
-u8 flags; /* current flags not yet saved in flag_buf */
-u8 flag_bit; /* current bit used in flags */
-/* bits are filled in flags starting at bit 0 (least significant).
- * Note: these flags are overkill in the current code since we don't
- * take advantage of DIST_BUFSIZE == LIT_BUFSIZE.
- */
-
-u32 opt_len; /* bit length of current block with optimal trees */
-u32 static_len; /* bit length of current block with static trees */
-
-u32 cmpr_bytelen; /* total byte length of compressed file */
-u32 cmpr_len_bits; /* number of bits past 'cmpr_bytelen' */
-
-#ifdef _DEBUG
-u32 input_len; /* total byte length of input file */
-/* input_len is for debugging only since we can get it by other means. */
-#endif
-
-int *file_method; /* pointer to DEFLATE or STORE */
-
-/*
===========================================================================
- * Local data used by the "bit string" routines.
- */
-
-int flush_flg;
-
-uint bi_buf;
-/* Output buffer. bits are inserted starting at the bottom (least
significant
- * bits). The width of bi_buf must be at least 16 bits.
- */
-
-const uint Buf_size = (8 * 2*sizeof(char));
-/* Number of bits used within bi_buf. (bi_buf may be implemented on
- * more than 16 bits on some systems.)
- */
-
-int bi_valid;
-/* Number of valid bits in bi_buf. All bits above the last valid bit
- * are always zero.
- */
-
-char *out_buf;
-/* Current output buffer. */
-
-uint out_offset;
-/* Current offset in output buffer.
- * On 16 bit machines, the buffer is limited to 64K.
- */
-
-uint out_size;
-/* Size of current output buffer */
-
-/* Output a 16 bit value to the bit stream, lower (oldest) byte first */
-#define PUTSHORT(w) \
-{ if (out_offset >= out_size-1) \
- flush_outbuf(out_buf, &out_offset); \
- out_buf[out_offset++] = (char) ((w) & 0xff); \
- out_buf[out_offset++] = (char) ((u16)(w) >> 8); \
-}
-
-#define PUTBYTE(b) \
-{ if (out_offset >= out_size) \
- flush_outbuf(out_buf, &out_offset); \
- out_buf[out_offset++] = (char) (b); \
-}
-
-#ifdef _DEBUG
-u32 bits_sent; /* bit length of the compressed data */
-extern u32 isize; /* byte length of input file */
-#endif
-
-extern long BlockStart; /* window offset of current block */
-extern uint StrStart; /* window offset of current string */
-
-
-/*
===========================================================================
- * Local (static) routines in this file.
- */
-
-void init_block (void);
-void pqdownheap (ct_data near *tree, int k);
-void gen_bitlen (tree_desc near *desc);
-void gen_codes (ct_data near *tree, int max_code);
-void build_tree (tree_desc near *desc);
-void scan_tree (ct_data near *tree, int max_code);
-void send_tree (ct_data near *tree, int max_code);
-int build_bl_tree (void);
-void send_all_trees (int lcodes, int dcodes, int blcodes);
-void compress_block (ct_data near *ltree, ct_data near *dtree);
-void set_file_type (void);
-void send_bits (int value, int length);
-unsigned bi_reverse (unsigned code, int len);
-void bi_windup (void);
-void copy_block (char *buf, unsigned len, int header);
-
-
-#ifndef _DEBUG
-# define send_code(c, tree) send_bits(tree[c].Code, tree[c].Len)
- /* Send a code of the given tree. c and tree must not have side effects
*/
-
-#else /* _DEBUG */
-# define send_code(c, tree) \
- { ; \
- send_bits(tree[c].Code, tree[c].Len); }
-#endif
-
-#define d_code(dist) \
- ((dist) < 256 ? dist_code[dist] : dist_code[256+((dist)>>7)])
-/* Mapping from a distance to a distance code. dist is the distance - 1 and
- * must not have side effects. dist_code[256] and dist_code[257] are never
- * used.
- */
-
-/*
===========================================================================
- * Allocate the match buffer, initialize the various tables and save the
- * location of the internal file attribute (ascii/binary) and method
- * (DEFLATE/STORE).
- */
-void ct_init(int* method)
- //ush *attr; /* pointer to internal file attribute */
- //int *method; /* pointer to compression method */
-{
- int n; /* iterates over tree elements */
- int bits; /* bit counter */
- int length; /* length value */
- int code; /* code value */
- int dist; /* distance index */
-
- file_method = method;
- cmpr_bytelen = cmpr_len_bits = 0L;
-#ifdef _DEBUG
- input_len = 0L;
-#endif
-
- if (static_dtree[0].Len != 0) return; /* ct_init already called */
-
- /* Initialize the mapping length (0..255) -> length code (0..28) */
- length = 0;
- for (code = 0; code < LENGTH_CODES-1; code++) {
- base_length[code] = length;
- for (n = 0; n < (1<<extra_lbits[code]); n++) {
- length_code[length++] = (u8)code;
- }
- }
- Assert(length == 256);//, "ct_init: length != 256");
- /* Note that the length 255 (match length 258) can be represented
- * in two different ways: code 284 + 5 bits or code 285, so we
- * overwrite length_code[255] to use the best encoding:
- */
- length_code[length-1] = (u8)code;
-
- /* Initialize the mapping dist (0..32K) -> dist code (0..29) */
- dist = 0;
- for (code = 0 ; code < 16; code++) {
- base_dist[code] = dist;
- for (n = 0; n < (1<<extra_dbits[code]); n++) {
- dist_code[dist++] = (u8)code;
- }
- }
- Assert(dist == 256);//, "ct_init: dist != 256");
- dist >>= 7; /* from now on, all distances are divided by 128 */
- for ( ; code < D_CODES; code++) {
- base_dist[code] = dist << 7;
- for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) {
- dist_code[256 + dist++] = (u8)code;
- }
- }
- Assert(dist == 256);//, "ct_init: 256+dist != 512");
-
- /* Construct the codes of the static literal tree */
- for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0;
- n = 0;
- while (n <= 143) static_ltree[n++].Len = 8, bl_count[8]++;
- while (n <= 255) static_ltree[n++].Len = 9, bl_count[9]++;
- while (n <= 279) static_ltree[n++].Len = 7, bl_count[7]++;
- while (n <= 287) static_ltree[n++].Len = 8, bl_count[8]++;
- /* Codes 286 and 287 do not exist, but we must include them in the
- * tree construction to get a canonical Huffman tree (longest code
- * all ones)
- */
- gen_codes((ct_data near *)static_ltree, L_CODES+1);
-
- /* The static distance tree is trivial: */
- for (n = 0; n < D_CODES; n++) {
- static_dtree[n].Len = 5;
- static_dtree[n].Code = (u16)bi_reverse(n, 5);
- }
-
- /* Initialize the first block of the first file: */
- init_block();
-}
-
-/*
===========================================================================
- * Initialize a new block.
- */
-void init_block()
-{
- int n; /* iterates over tree elements */
-
- /* Initialize the trees. */
- for (n = 0; n < L_CODES; n++) dyn_ltree[n].Freq = 0;
- for (n = 0; n < D_CODES; n++) dyn_dtree[n].Freq = 0;
- for (n = 0; n < BL_CODES; n++) bl_tree[n].Freq = 0;
-
- dyn_ltree[END_BLOCK].Freq = 1;
- opt_len = static_len = 0L;
- last_lit = last_dist = last_flags = 0;
- flags = 0; flag_bit = 1;
-}
-
-#define SMALLEST 1
-/* Index within the heap array of least frequent node in the Huffman tree
*/
-
-
-/*
===========================================================================
- * Remove the smallest element from the heap and recreate the heap with
- * one less element. Updates heap and heap_len.
- */
-#define pqremove(tree, top) \
-{\
- top = heap[SMALLEST]; \
- heap[SMALLEST] = heap[heap_len--]; \
- pqdownheap(tree, SMALLEST); \
-}
-
-/*
===========================================================================
- * Compares to subtrees, using the tree depth as tie breaker when
- * the subtrees have equal frequency. This minimizes the worst case length.
- */
-#define smaller(tree, n, m) \
- (tree[n].Freq < tree[m].Freq || \
- (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m]))
-
-/*
===========================================================================
- * Restore the heap property by moving down the tree starting at node k,
- * exchanging a node with the smallest of its two sons if necessary,
stopping
- * when the heap property is re-established (each father smaller than its
- * two sons).
- */
-void pqdownheap(ct_data near *tree, int k)
- //ct_data near *tree; /* the tree to restore */
- //int k; /* node to move down */
-{
- int v = heap[k];
- int j = k << 1; /* left son of k */
- int htemp; /* required because of bug in SASC compiler */
-
- while (j <= heap_len) {
- /* Set j to the smallest of the two sons: */
- if (j < heap_len && smaller(tree, heap[j+1], heap[j])) j++;
-
- /* Exit if v is smaller than both sons */
- htemp = heap[j];
- if (smaller(tree, v, htemp)) break;
-
- /* Exchange v with the smallest son */
- heap[k] = htemp;
- k = j;
-
- /* And continue down the tree, setting j to the left son of k */
- j <<= 1;
- }
- heap[k] = v;
-}
-
-/*
===========================================================================
- * Compute the optimal bit lengths for a tree and update the total bit
length
- * for the current block.
- * IN assertion: the fields freq and dad are set, heap[heap_max] and
- * above are the tree nodes sorted by increasing frequency.
- * OUT assertions: the field len is set to the optimal bit length, the
- * array bl_count contains the frequencies for each bit length.
- * The length opt_len is updated; static_len is also updated if stree
is
- * not null.
- */
-void gen_bitlen(tree_desc near *desc)
- //tree_desc near *desc; /* the tree descriptor */
-{
- ct_data near *tree = desc->dyn_tree;
- int near *extra = desc->extra_bits;
- int base = desc->extra_base;
- int max_code = desc->max_code;
- int max_length = desc->max_length;
- ct_data near *stree = desc->static_tree;
- int h; /* heap index */
- int n, m; /* iterate over the tree elements */
- int bits; /* bit length */
- int xbits; /* extra bits */
- u16 f; /* frequency */
- int overflow = 0; /* number of elements with bit length too large */
-
- for (bits = 0; bits <= MAX_BITS; bits++) bl_count[bits] = 0;
-
- /* In a first pass, compute the optimal bit lengths (which may
- * overflow in the case of the bit length tree).
- */
- tree[heap[heap_max]].Len = 0; /* root of the heap */
-
- for (h = heap_max+1; h < HEAP_SIZE; h++) {
- n = heap[h];
- bits = tree[tree[n].Dad].Len + 1;
- if (bits > max_length) bits = max_length, overflow++;
- tree[n].Len = (u16)bits;
- /* We overwrite tree[n].Dad which is no longer needed */
-
- if (n > max_code) continue; /* not a leaf node */
-
- bl_count[bits]++;
- xbits = 0;
- if (n >= base) xbits = extra[n-base];
- f = tree[n].Freq;
- opt_len += (u32)f * (bits + xbits);
- if (stree) static_len += (u32)f * (stree[n].Len + xbits);
- }
- if (overflow == 0) return;
-
- /* Find the first bit length which could increase: */
- do {
- bits = max_length-1;
- while (bl_count[bits] == 0) bits--;
- bl_count[bits]--; /* move one leaf down the tree */
- bl_count[bits+1] += (u16)2; /* move one overflow item as its
brother */
- bl_count[max_length]--;
- /* The brother of the overflow item also moves one step up,
- * but this does not affect bl_count[max_length]
- */
- overflow -= 2;
- } while (overflow > 0);
-
- /* Now recompute all bit lengths, scanning in increasing frequency.
- * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all
- * lengths instead of fixing only the wrong ones. This idea is taken
- * from 'ar' written by Haruhiko Okumura.)
- */
- for (bits = max_length; bits != 0; bits--) {
- n = bl_count[bits];
- while (n != 0) {
- m = heap[--h];
- if (m > max_code) continue;
- if (tree[m].Len != (u16)bits) {
- opt_len +=
((long)bits-(long)tree[m].Len)*(long)tree[m].Freq;
- tree[m].Len = (u16)bits;
- }
- n--;
- }
- }
-}
-
-/*
===========================================================================
- * Generate the codes for a given tree and bit counts (which need not be
- * optimal).
- * IN assertion: the array bl_count contains the bit length statistics for
- * the given tree and the field len is set for all tree elements.
- * OUT assertion: the field code is set for all tree elements of non
- * zero code length.
- */
-void gen_codes (ct_data near *tree, int max_code)
- //ct_data near *tree; /* the tree to decorate */
- //int max_code; /* largest code with non zero frequency */
-{
- u16 next_code[MAX_BITS+1]; /* next code value for each bit length */
- u16 code = 0; /* running code value */
- int bits; /* bit index */
- int n; /* code index */
-
- /* The distribution counts are first used to generate the code values
- * without bit reversal.
- */
- for (bits = 1; bits <= MAX_BITS; bits++) {
- next_code[bits] = code = (u16)((code + bl_count[bits-1]) << 1);
- }
- /* Check that the bit counts in bl_count are consistent. The last code
- * must be all ones.
- */
- Assert(code + bl_count[MAX_BITS]-1 == (1<< ((u16) MAX_BITS)) -
1);//inconsistent bit counts
-
- for (n = 0; n <= max_code; n++) {
- int len = tree[n].Len;
- if (len == 0) continue;
- /* Now reverse the bits */
- tree[n].Code = (u16)bi_reverse(next_code[len]++, len);
- }
-}
-
-/*
===========================================================================
- * Construct one Huffman tree and assigns the code bit strings and lengths.
- * Update the total bit length for the current block.
- * IN assertion: the field freq is set for all tree elements.
- * OUT assertions: the fields len and code are set to the optimal bit
length
- * and corresponding code. The length opt_len is updated; static_len is
- * also updated if stree is not null. The field max_code is set.
- */
-void build_tree(tree_desc near *desc)
- //tree_desc near *desc; /* the tree descriptor */
-{
- ct_data near *tree = desc->dyn_tree;
- ct_data near *stree = desc->static_tree;
- int elems = desc->elems;
- int n, m; /* iterate over heap elements */
- int max_code = -1; /* largest code with non zero frequency */
- int node = elems; /* next internal node of the tree */
-
- /* Construct the initial heap, with least frequent element in
- * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].
- * heap[0] is not used.
- */
- heap_len = 0, heap_max = HEAP_SIZE;
-
- for (n = 0; n < elems; n++) {
- if (tree[n].Freq != 0) {
- heap[++heap_len] = max_code = n;
- depth[n] = 0;
- } else {
- tree[n].Len = 0;
- }
- }
-
- /* The pkzip format requires that at least one distance code exists,
- * and that at least one bit should be sent even if there is only one
- * possible code. So to avoid special checks later on we force at least
- * two codes of non zero frequency.
- */
- while (heap_len < 2) {
- int new_ = heap[++heap_len] = (max_code < 2 ? ++max_code : 0);
- tree[new_].Freq = 1;
- depth[new_] = 0;
- opt_len--; if (stree) static_len -= stree[new_].Len;
- /* new is 0 or 1 so it does not have extra bits */
- }
- desc->max_code = max_code;
-
- /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,
- * establish sub-heaps of increasing lengths:
- */
- for (n = heap_len/2; n >= 1; n--) pqdownheap(tree, n);
-
- /* Construct the Huffman tree by repeatedly combining the least two
- * frequent nodes.
- */
- do {
- pqremove(tree, n); /* n = node of least frequency */
- m = heap[SMALLEST]; /* m = node of next least frequency */
-
- heap[--heap_max] = n; /* keep the nodes sorted by frequency */
- heap[--heap_max] = m;
-
- /* Create a new node father of n and m */
- tree[node].Freq = (u16)(tree[n].Freq + tree[m].Freq);
- depth[node] = (u8) (max(depth[n], depth[m]) + 1);
- tree[n].Dad = tree[m].Dad = (u16)node;
-
- /* and insert the new node in the heap */
- heap[SMALLEST] = node++;
- pqdownheap(tree, SMALLEST);
-
- } while (heap_len >= 2);
-
- heap[--heap_max] = heap[SMALLEST];
-
- /* At this point, the fields freq and dad are set. We can now
- * generate the bit lengths.
- */
- gen_bitlen((tree_desc near *)desc);
-
- /* The field len is now set, we can generate the bit codes */
- gen_codes ((ct_data near *)tree, max_code);
-}
-
-/*
===========================================================================
- * Scan a literal or distance tree to determine the frequencies of the
codes
- * in the bit length tree. Updates opt_len to take into account the repeat
- * counts. (The contribution of the bit length codes will be added later
- * during the construction of bl_tree.)
- */
-void scan_tree (ct_data near *tree, int max_code)
- //ct_data near *tree; /* the tree to be scanned */
- //int max_code; /* and its largest code of non zero frequency */
-{
- int n; /* iterates over all tree elements */
- int prevlen = -1; /* last emitted length */
- int curlen; /* length of current code */
- int nextlen = tree[0].Len; /* length of next code */
- int count = 0; /* repeat count of the current code */
- int max_count = 7; /* max repeat count */
- int min_count = 4; /* min repeat count */
-
- if (nextlen == 0) max_count = 138, min_count = 3;
- tree[max_code+1].Len = (u16)-1; /* guard */
-
- for (n = 0; n <= max_code; n++) {
- curlen = nextlen; nextlen = tree[n+1].Len;
- if (++count < max_count && curlen == nextlen) {
- continue;
- } else if (count < min_count) {
- bl_tree[curlen].Freq += (u16)count;
- } else if (curlen != 0) {
- if (curlen != prevlen) bl_tree[curlen].Freq++;
- bl_tree[REP_3_6].Freq++;
- } else if (count <= 10) {
- bl_tree[REPZ_3_10].Freq++;
- } else {
- bl_tree[REPZ_11_138].Freq++;
- }
- count = 0; prevlen = curlen;
- if (nextlen == 0) {
- max_count = 138, min_count = 3;
- } else if (curlen == nextlen) {
- max_count = 6, min_count = 3;
- } else {
- max_count = 7, min_count = 4;
- }
- }
-}
-
-/*
===========================================================================
- * Send a literal or distance tree in compressed form, using the codes in
- * bl_tree.
- */
-void send_tree (ct_data near *tree, int max_code)
- //ct_data near *tree; /* the tree to be scanned */
- //int max_code; /* and its largest code of non zero frequency */
-{
- int n; /* iterates over all tree elements */
- int prevlen = -1; /* last emitted length */
- int curlen; /* length of current code */
- int nextlen = tree[0].Len; /* length of next code */
- int count = 0; /* repeat count of the current code */
- int max_count = 7; /* max repeat count */
- int min_count = 4; /* min repeat count */
-
- /* tree[max_code+1].Len = -1; */ /* guard already set */
- if (nextlen == 0) max_count = 138, min_count = 3;
-
- for (n = 0; n <= max_code; n++) {
- curlen = nextlen; nextlen = tree[n+1].Len;
- if (++count < max_count && curlen == nextlen) {
- continue;
- } else if (count < min_count) {
- do { send_code(curlen, bl_tree); } while (--count != 0);
-
- } else if (curlen != 0) {
- if (curlen != prevlen) {
- send_code(curlen, bl_tree); count--;
- }
- Assert(count >= 3 && count <= 6);//, " 3_6?");
- send_code(REP_3_6, bl_tree); send_bits(count-3, 2);
-
- } else if (count <= 10) {
- send_code(REPZ_3_10, bl_tree); send_bits(count-3, 3);
-
- } else {
- send_code(REPZ_11_138, bl_tree); send_bits(count-11, 7);
- }
- count = 0; prevlen = curlen;
- if (nextlen == 0) {
- max_count = 138, min_count = 3;
- } else if (curlen == nextlen) {
- max_count = 6, min_count = 3;
- } else {
- max_count = 7, min_count = 4;
- }
- }
-}
-
-/*
===========================================================================
- * Construct the Huffman tree for the bit lengths and return the index in
- * bl_order of the last bit length code to send.
- */
-int build_bl_tree()
-{
- int max_blindex; /* index of last bit length code of non zero freq */
-
- /* Determine the bit length frequencies for literal and distance trees
*/
- scan_tree((ct_data near *)dyn_ltree, l_desc.max_code);
- scan_tree((ct_data near *)dyn_dtree, d_desc.max_code);
-
- /* Build the bit length tree: */
- build_tree((tree_desc near *)(&bl_desc));
- /* opt_len now includes the length of the tree representations, except
- * the lengths of the bit lengths codes and the 5+5+4 bits for the
counts.
- */
-
- /* Determine the number of bit length codes to send. The pkzip format
- * requires that at least 4 bit length codes be sent. (appnote.txt says
- * 3 but the actual value used is 4.)
- */
- for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) {
- if (bl_tree[bl_order[max_blindex]].Len != 0) break;
- }
- /* Update opt_len to include the bit length tree and counts */
- opt_len += 3*(max_blindex+1) + 5+5+4;
-
- return max_blindex;
-}
-
-/*
===========================================================================
- * Send the header for a block using dynamic Huffman trees: the counts, the
- * lengths of the bit length codes, the literal tree and the distance tree.
- * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
- */
-void send_all_trees(int lcodes, int dcodes, int blcodes)
- //int lcodes, dcodes, blcodes; /* number of codes for each tree */
-{
- int rank; /* index in bl_order */
-
- Assert(lcodes >= 257 && dcodes >= 1 && blcodes >= 4);//, "not enough
codes");
- Assert(lcodes <= L_CODES && dcodes <= D_CODES && blcodes <=
BL_CODES);//,
- //"too many codes");
-
- send_bits(lcodes-257, 5);
- /* not +255 as stated in appnote.txt 1.93a or -256 in 2.04c */
- send_bits(dcodes-1, 5);
- send_bits(blcodes-4, 4); /* not -3 as stated in appnote.txt */
- for (rank = 0; rank < blcodes; rank++) {
- send_bits(bl_tree[bl_order[rank]].Len, 3);
- }
-
- send_tree((ct_data near *)dyn_ltree, lcodes-1); /* send the literal
tree */
-
- send_tree((ct_data near *)dyn_dtree, dcodes-1); /* send the distance
tree */
-}
-
-/*
===========================================================================
- * Determine the best encoding for the current block: dynamic trees, static
- * trees or store, and output the encoded block to the zip file. This
function
- * returns the total compressed length (in bytes) for the file so far.
- */
-u32 flush_block(char *buf, u32 stored_len, int eof)
- //char *buf; /* input block, or NULL if too old */
- //u32 stored_len; /* length of input block */
- //int eof; /* true if this is the last block for a file */
-{
- u32 opt_lenb, static_lenb; /* opt_len and static_len in bytes */
- int max_blindex; /* index of last bit length code of non zero freq */
-
- flag_buf[last_flags] = flags; /* Save the flags for the last 8 items */
-
- /* Construct the literal and distance trees */
- build_tree((tree_desc near *)(&l_desc));
-
- build_tree((tree_desc near *)(&d_desc));
- /* At this point, opt_len and static_len are the total bit lengths of
- * the compressed block data, excluding the tree representations.
- */
-
- /* Build the bit length tree for the above two trees, and get the index
- * in bl_order of the last bit length code to send.
- */
- max_blindex = build_bl_tree();
-
- /* Determine the best encoding. Compute first the block length in
bytes */
- opt_lenb = (opt_len+3+7)>>3;
- static_lenb = (static_len+3+7)>>3;
-#ifdef _DEBUG
- input_len += stored_len; /* for debugging only */
-#endif
-
- if (static_lenb <= opt_lenb) opt_lenb = static_lenb;
-
- /* If compression failed and this is the first and last block,
- * the whole file is transformed into a stored file:
- */
- if (stored_len <= opt_lenb && eof && file_method != NULL &&
- cmpr_bytelen == 0L && cmpr_len_bits == 0L) {
- /* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */
- if (buf == NULL) error ("block vanished");
-
- copy_block(buf, (unsigned)stored_len, 0); /* without header */
- cmpr_bytelen = stored_len;
- *file_method = compStore;
- } else
-
- if (stored_len+4 <= opt_lenb && buf != (char*)NULL) {
- /* 4: two words for the lengths *
- /* The test buf != NULL is only necessary if LIT_BUFSIZE >
WSIZE.
- * Otherwise we can't have processed more than WSIZE input bytes
since
- * the last block flush, because compression would have been
- * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to
- * transform a block into a stored block.
- */
- send_bits((STORED_BLOCK<<1)+eof, 3); /* send block type */
- cmpr_bytelen += ((cmpr_len_bits + 3 + 7) >> 3) + stored_len + 4;
- cmpr_len_bits = 0L;
-
- copy_block(buf, (unsigned)stored_len, 1); /* with header */
-
- } else if (static_lenb == opt_lenb) {
- send_bits((STATIC_TREES<<1)+eof, 3);
- compress_block((ct_data near *)static_ltree, (ct_data near
*)static_dtree);
- cmpr_len_bits += 3 + static_len;
- cmpr_bytelen += cmpr_len_bits >> 3;
- cmpr_len_bits &= 7L;
- } else {
***The diff for this file has been truncated for email.***
=======================================
--- /src/BlueZip/WriteZip.cpp Fri Apr 16 12:25:47 2004
+++ /dev/null
@@ -1,121 +0,0 @@
-#include "BlueHead.h"
-
-#ifndef NO_COMPRESSION
-
-//Write the file back out, with the changes
-bool BlueZip::Write(bool Store)
-{
- //TODO: Do not use a TempFile, send straight to the output
-
- char TempFileName[MAX_PATH];
- File f;
-
- zList* z;
- zList** next = &Files; //where to insert the next zList
-
- int i, j; //global enumeration variables
-
- if ((Files == NULL) && (Pending == NULL))
- {
- ErrMsg("Blank ZIP files not allowed");
- return false;
- }
-
- //Always use a temporary file name (they may have the ZIP file on a
floppy)
- f = FileOpenTemp(TempFileName);
- if (!FileValid(f))
- {
- ErrMsg(Failed to open the temporary file);
- return false;
- }
-
- if (Files != NULL)
- {
- File Orig = FileOpenRead(FileName);
- if (!FileValid(Orig))
- {
- ErrMsg("Failed to open the reading file");
- return false;
- }
-
- const int BlockSize = 4096;
- char* Buffer = new char[BlockSize];
- datCentral hLocal;
- for (z = Files; z != NULL; z = z->next)
- {
- if (!z->Delete)
- {
- //Remove any that have dropped out of the list
- *next = z;
- next = &z->next;
-
- //Perform a ZIP copy
- SeekBeg(Orig, z->data.Offset + z->FileDeltaPos);
- z->data.Offset = FilePos(f);
-
- u32 sig;
- FileRead(Orig, &sig, 4);
- Assert(sig == sigLocal);
- FileWrite(f, &sig, 4);
-
- hLocal.ReadLocal(Orig);
- hLocal.WriteLocal(f);
-
- i = hLocal.CompSize + hLocal.lFileName +
hLocal.lExtra;
- while(i != 0)
- {
- j = min(i, BlockSize);
- FileRead(Orig, Buffer, j);
- FileWrite(f, Buffer, j);
- i -= j;
- }
- }
- }
- FileClose(Orig);
- delete[] Buffer;
- }
-
-
- while (Pending != NULL)
- {
- fList* fAdd = Pending;
- Pending = Pending->next;
-
- z = fAdd->ZipUp(f, Store);
- if (z == NULL)
- {
- ErrMsg("Failed to add the file");
- }
- else
- {
- *next = z;
- next = &z->next;
- }
-
- delete fAdd;
-
- }
-
- //Write out the central header
- data.Count = 0;
- data.Offset = FilePos(f);
- for (z = Files; z != NULL; z = z->next, data.Count++)
- z->WriteCentral(f);
-
- data.Size = FilePos(f) - data.Offset;
- WriteEnd(f);
-
- FileClose(f);
-
- //Using a temp file
- if (!FileReplace(FileName, TempFileName))
- {
- ErrMsg("Failed to copy the temporary file");
- return false;
- }
-
- return true;
-}
-
-
-#endif //!NO_COMPRESSION
=======================================
--- /src/BlueZip/fList.cpp Fri Apr 16 12:25:47 2004
+++ /dev/null
@@ -1,117 +0,0 @@
-#include "BlueHead.h"
-
-#ifndef NO_COMPRESSION
-
-/* : Required by the deflate routines */
-void SetupDeftree(File In, File Out, int my_level);
-u32 filecompress(int* method);
-u32 GetCRC();
-
-
-fList::fList(LPCTSTR NewFile, fList* prev)
-{
- FileName = CopyString(NewFile);
- //Replace \ with /
- int i;
- for (i = 0; FileName[i] != 0; i++)
- {
- if (FileName[i] == '\\') FileName[i] = '/';
- }
- next = prev;
-}
-
-fList::~fList()
-{
- if (FileName != NULL)
- delete[] FileName;
-}
-
-zList* fList::ZipUp(File f, bool Store)
-{
- zList* z = new zList;
-
- //Open the new file
- File In = FileOpenRead(FileName);
- if (!FileValid(In))
- {
- ErrMsg("Failed to open the file to compress in");
- return NULL;
- }
-
- z->data.ExtAttr = FileGetAttrib(In, FileName);
-
- //Copy over the filename
- char* s = strrchr(FileName, '/');
- if (s == NULL)
- {
- z->FileName = FileName;
- }
- else
- {
- z->FileName = CopyString(&s[1]);
- delete[] FileName;
- }
- FileName = NULL;
- z->data.lFileName = strlen(z->FileName);
-
- //Get some information on the filename
- //Not implemented properly yet
-
-
- //PK[UN]ZIP 2.0 made these files and will be able to extract them
- z->data.VerMake = 20;
- z->data.Disk = 0;
- z->data.Offset = FilePos(f);
- z->data.Disk = 0;
-
- z->data.IntAttr = 0; //BINARY - like I care if it's text?
- FileGetDate(In, &z->data);
-
-
- z->data.lExtra = 0;
- z->data.lComment = 0;
- z->data.OrigSize = FileLen(In);
-
-
- //Info-Zip would write out the local header here
- SeekCur(f, 4 + ldatLocal + z->data.lFileName);
-
- //Just store it
- InitCRC();
- if (Store) //Just store it
- WriteStore(In, f, z);
- else
- {
-/* CRC CHECK
- u8* Buffer = new u8[z->data.CompSize];
- SeekBeg(In, 0);
- FileRead(In, Buffer, z->data.CompSize);
- FileWrite(f, Buffer, z->data.CompSize);
- z->data.CRC = CRC(0, Buffer, z->data.CompSize);
- delete[] Buffer;
-
-*/
- int Method = compDeflate;
- SetupDeftree(In, f, 9);
- z->data.CompSize = filecompress(&Method);
- z->data.CompMode = Method;
- }
-
- z->data.CRC = GetCRC();
- z->data.VerNeed = (z->data.CompMode == compDeflate ? 20 : 10);
- //Version needed is 20, because using compress, 10 for just store
-
- //WinZIP compatible hacks
- z->data.Flags = 2;
-
- FileClose(In);
-
- int LocalFileEnd = FilePos(f);
- SeekBeg(f, z->data.Offset);
- z->WriteLocal(f);
-
- SeekBeg(f, LocalFileEnd);
- return z;
-}
-
-#endif //!NO_COMPRESSION
=======================================
--- /src/BlueZip/fList.h Fri Apr 16 12:25:47 2004
+++ /dev/null
@@ -1,16 +0,0 @@
-
-#ifndef NO_COMPRESSION
-
-class fList
-{
-public:
- char* FileName;
- fList* next;
-
- fList(LPCTSTR FileName, fList* prev);
- ~fList();
- zList* ZipUp(File f, bool Store);
-};
-
-#endif //!NO_COMPRESSION
-
=======================================
--- /src/BlueZip/zList.cpp Fri Apr 16 12:25:47 2004
+++ /dev/null
@@ -1,65 +0,0 @@
-#include "BlueHead.h"
-
-zList::zList()
-{
- FileName = NULL;
- Extra = NULL;
- Comment = NULL;
- next = NULL;
- Delete = false;
-}
-
-zList::~zList()
-{
- if (FileName) delete[] FileName;
- if (Extra) delete[] Extra;
- if (Comment) delete[] Comment;
-}
-
-void zList::WriteLocal(File f)
-{
- long l = sigLocal;
- FileWrite(f, &l, 4);
- data.WriteLocal(f);
-
- FileWrite(f, FileName, data.lFileName);
- if (data.lExtra) FileWrite(f, Extra, data.lExtra);
- //No comment available, only in central header
-}
-
-void zList::WriteCentral(File f)
-{
- long l = sigCentral;
- FileWrite(f, &l, 4);
- data.Write(f);
-
- FileWrite(f, FileName, data.lFileName);
- if (data.lExtra) FileWrite(f, Extra, data.lExtra);
- if (data.lComment) FileWrite(f, Comment, data.lComment);
-}
-
-void zList::ReadCentral(File f)
-{
- data.Read(f);
-
- // Read file name, extra field and comment field
- // if (z->nam == 0) then 0 length name error
-
- FileName = new char[data.lFileName+1];
- FileRead(f, FileName, data.lFileName);
- FileName[data.lFileName] = '\0'; // terminate name
-
- if (data.lExtra)
- {
- Extra = new char[data.lExtra];
- FileRead(f, Extra, data.lExtra);
- }
-
- if (data.lComment)
- {
- Comment = new char[data.lComment];
- FileRead(f, Comment, data.lComment);
- }
-}
-
-
=======================================
--- /src/BlueZip/zList.h Fri Apr 16 12:25:47 2004
+++ /dev/null
@@ -1,25 +0,0 @@
-// Structures for in-memory file information
-
-class __declspec(dllexport) zList
-{
-public:
- datCentral data;
-
- char* FileName; //File name in zip file
- char* Extra; //Extra in central
- char* Comment; //Comment (set only if com != 0)
-
- bool Delete; //Should the file be removed on execute
- zList* next;
-
- zList();
- ~zList();
-
- void WriteCentral(File f);
- void ReadCentral(File f);
-
- void WriteLocal(File f);
-
- int OriginalSize(){return data.OrigSize;}
- int CompressedSize(){return data.CompSize;}
-};
=======================================
--- /src/FileCode.cpp Sun Apr 18 13:54:42 2004
+++ /dev/null
@@ -1,101 +0,0 @@
-#include "Header.h"
-
-bool Exists(char* File)
-{
- return (GetFileAttributes(File) != 0xffffffff);
-}
-
-bool ExistsDir(char* File)
-{
- DWORD Attr = GetFileAttributes(File);
- return ((Attr != 0xffffffff) && (Attr & FILE_ATTRIBUTE_DIRECTORY));
-}
-
-bool CanReadWrite(char* File)
-{
- HANDLE hFile = CreateFile(File, GENERIC_READ | GENERIC_WRITE,
- 0, NULL, OPEN_EXISTING, 0, NULL);
-
- if (hFile == INVALID_HANDLE_VALUE) return false;
- CloseHandle(hFile);
- return true;
-}
-
-void NormalPath(char* File)
-{
- for (int i = 0; File[i] != 0; i++)
- {
- if (File[i] == '/')
- File[i] = '\\';
- }
- if (File[i-1] == '\\')
- File[i-1] = 0;
-}
-
-bool ParentFolder(char* File)
-{
- char* s = strrchr(File, '\\');
- if (s == NULL)
- return false;
-
- s[0] = 0;
- return true;
-}
-
-void UnparentFolder(char* File)
-{
- File[strlen(File)] = '\\';
-}
-
-
-bool EnsureFolder(char* File)
-{
- if (ExistsDir(File))
- return true;
-
- if (ParentFolder(File))
- {
- bool Res = EnsureFolder(File);
- UnparentFolder(File);
- if (!Res) return false;
- }
-
- return (CreateDirectory(File, NULL) != 0);
-}
-
-void FileSize(__int64 Size, char* Buffer)
-{
- //set the number of bytes as a Windows standard file count
- const TCHAR PreFix[] = "KMGTP";
- //make sure to 3 sf
-
- if (Size < 1000)
- {
- itoa((int) Size, Buffer, 10);
- strcat(Buffer, " bytes");
- }
- else
- {
- int i, j = 1024;
- for (i = 0; Size > j * 999; i++)
- j *= 1024;
-
- itoa((int) (Size / (__int64) j), Buffer, 10);
- int k = strlen(Buffer);
- if (k != 3)
- {
- Buffer[k] = '.';
- j = ((int) (Size % j) * 1000) / j;
- int l = 100;
- for (k++; k != 4; k++)
- {
- Buffer[k] = (j / l) + '0';
- j %= l;
- l /= 10;
- }
- }
- Buffer[k + 0] = PreFix[i];
- Buffer[k + 1] = 'B';
- Buffer[k + 2] = 0;
- }
-}
=======================================
--- /src/FileCode.h Sun Apr 18 13:54:42 2004
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-bool Exists(char* File);
-bool ExistsDir(char* File);
-bool CanReadWrite(char* File);
-void NormalPath(char* File);
-bool EnsureFolder(char* File);
-void FileSize(__int64 Size, char* Buffer);
-
-const int MaxFileSizeBuf = 10;
=======================================
--- /src/Header.h Fri Apr 16 12:25:47 2004
+++ /dev/null
@@ -1,4 +0,0 @@
-#define WIN32_MEAN_AND_LEAN
-#include <windows.h>
-
-const int MyMaxPath = MAX_PATH * 2;
=======================================
--- /src/Installer.dsp Mon Dec 5 09:00:26 2005
+++ /dev/null
@@ -1,236 +0,0 @@
-# Microsoft Developer Studio Project File - Name="Installer" - Package
Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Application" 0x0101
-
-CFG=Installer - 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 "Installer.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 "Installer.mak" CFG="Installer - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "Installer - Win32 Release" (based on "Win32 (x86) Application")
-!MESSAGE "Installer - Win32 Debug" (based on "Win32 (x86) Application")
-!MESSAGE
-
-# Begin Project
-# PROP AllowPerConfigDependencies 0
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "Installer - 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 Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS"
/D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS"
/D "_MBCS" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /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:windows /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 comctl32.lib /nologo /subsystem:windows /machine:I386
/OPT:NOWIN98
-# SUBTRACT LINK32 /pdb:none
-
-!ELSEIF "$(CFG)" == "Installer - 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 Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG"
/D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG"
/D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
-# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /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:windows /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 comctl32.lib /nologo /subsystem:windows /debug /machine:I386
/pdbtype:sept
-
-!ENDIF
-
-# Begin Target
-
-# Name "Installer - Win32 Release"
-# Name "Installer - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\FileCode.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\FileCode.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\Header.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\Installer.rc
-# End Source File
-# Begin Source File
-
-SOURCE=.\Parameters.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\Setup.ico
-# End Source File
-# Begin Source File
-
-SOURCE=.\ShellCode.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\ShellCode.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\StartCode.cpp
-# End Source File
-# End Group
-# Begin Group "BlueZip"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\BlueZip\BlueHead.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\BlueZip\BlueZip.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\BlueZip\BlueZip.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\BlueZip\CompHead.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\BlueZip\CRC.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\BlueZip\Deflate.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\BlueZip\DefTree.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\BlueZip\Errors.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\BlueZip\FileIO.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\BlueZip\FileIO.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\BlueZip\fList.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\BlueZip\fList.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\BlueZip\General.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\BlueZip\General.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\BlueZip\Inflate.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\BlueZip\Inflate.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\BlueZip\ReadZip.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\BlueZip\Store.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\BlueZip\Structs.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\BlueZip\Structs.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\BlueZip\Trees.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\BlueZip\WriteZip.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\BlueZip\zList.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\BlueZip\zList.h
-# End Source File
-# End Group
-# Begin Source File
-
-SOURCE=".\Pingus-Installer.manifest"
-# End Source File
-# End Target
-# End Project
=======================================
--- /src/Installer.dsw Mon Dec 5 09:00:26 2005
+++ /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: "Installer"=.\Installer.dsp - Package Owner=<4>
-
-Package=<5>
-{{{
-}}}
-
-Package=<4>
-{{{
-}}}
-
-###############################################################################
-
-Global:
-
-Package=<5>
-{{{
-}}}
-
-Package=<3>
-{{{
-}}}
-
-###############################################################################
-
=======================================
--- /src/Installer.rc Sun Apr 18 13:54:42 2004
+++ /dev/null
@@ -1,132 +0,0 @@
-//Microsoft Developer Studio generated resource script.
-//
-#include "resource.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (U.K.) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
-#ifdef _WIN32
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
-#pragma code_page(1252)
-#endif //_WIN32
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE DISCARDABLE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE DISCARDABLE
-BEGIN
- "#include ""afxres.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE DISCARDABLE
-BEGIN
- "\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Dialog
-//
-
-dlgInstall DIALOG DISCARDABLE 0, 0, 308, 193
-STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
-CAPTION "Pingus Installer"
-FONT 8, "MS Sans Serif"
-BEGIN
- LTEXT "#",lblInstallTo,7,42,294,10,NOT WS_VISIBLE
- LTEXT "#",lblInstallFile,7,58,294,8,NOT WS_VISIBLE
- CONTROL "",barTop,"Static",SS_ETCHEDHORZ,0,33,313,1
- LTEXT "This will install Pingus on your computer\n\nPlease
select an installation directory.",
- lblWelcome,7,42,154,25
- EDITTEXT txtEdit,7,74,263,12,ES_AUTOHSCROLL
- PUSHBUTTON "...",cmdBrowse,277,74,24,12
- PUSHBUTTON "Cancel",IDCANCEL,191,172,50,14
- DEFPUSHBUTTON "Install",IDOK,251,172,50,14
- CONTROL "Run program after installation",chkExecute,"Button",
- BS_AUTOCHECKBOX | WS_TABSTOP,7,140,294,11
- CONTROL "Create shortcut on
Desktop",chkShortcutDesktop,"Button",
- BS_AUTOCHECKBOX | WS_TABSTOP,7,114,294,10
- CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,-1,164,311,1
- LTEXT "Windows Installer © Neil Mitchell
1999-2004",IDC_STATIC,
- 7,176,155,10,WS_DISABLED
- CONTROL "Progress2",prgBar,"msctls_progress32",NOT
WS_VISIBLE,7,
- 74,294,12
- CONTROL "Create shortcut in the Start Menu",chkShortcutStart,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,124,294,10
- LTEXT "#",lblSpace,7,89,294,9
-END
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// DESIGNINFO
-//
-
-#ifdef APSTUDIO_INVOKED
-GUIDELINES DESIGNINFO DISCARDABLE
-BEGIN
- dlgInstall, DIALOG
- BEGIN
- LEFTMARGIN, 7
- RIGHTMARGIN, 301
- TOPMARGIN, 7
- BOTTOMMARGIN, 186
- END
-END
-#endif // APSTUDIO_INVOKED
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Icon
-//
-
-// Icon with lowest ID value placed first to ensure application icon
-// remains consistent on all systems.
-IDI_ICON1 ICON DISCARDABLE "Setup.ico"
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// 24
-//
-
-1 24 DISCARDABLE "Pingus-Installer.manifest"
-#endif // English (U.K.) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
=======================================
--- /src/Parameters.h Fri Apr 16 12:25:47 2004
+++ /dev/null
@@ -1,24 +0,0 @@
-//These are configuration parameters
-
-
-//Default directory
-//The resulting value will be "C:\Program Files\" + Value
-#define InstallDir "Pingus"
-
-//Primary program
-//This is the first file that will be checked for overwrite access
-//If this is the main .exe it will allow them first refusal if they are
currently
-//running the program
-//Use NULL for no primary file
-#define PrimaryFile "Pingus.exe"
-
-//Program name
-//Text of what your program is called
-#define ProgramName "Pingus"
-
-
-#define Description "GPL multiplatform Lemmings(tm) clone"
-
-
-#define Copyright "Ingo Ruhnke 2000-2004"
-
=======================================
--- /src/Pingus-Installer.manifest Fri Apr 16 12:25:47 2004
+++ /dev/null
@@ -1,2 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<assembly xmlns="urn:schemas-microsoft-com:asm.v1"
manifestVersion="1.0"><assemblyIdentity version="1.0.0.0"
processorArchitecture="x86" name="Pingus Installer" type="win32"
/><dependency><dependentAssembly><assemblyIdentity type="win32"
name="Microsoft.Windows.Common-Controls" version="6.0.0.0"
processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*"
/></dependentAssembly></dependency></assembly>
=======================================
--- /src/Setup.ico Thu Apr 15 13:50:08 2004
+++ /dev/null
Binary file, no diff available.
=======================================
--- /src/ShellCode.cpp Sun Apr 18 13:54:42 2004
+++ /dev/null
@@ -1,165 +0,0 @@
-#include "Header.h"
-#include "Parameters.h"
-#include <shlobj.h>
-#include "FileCode.h"
-
-
-bool OleReady;
-
-void ShellInit()
-{
- HRESULT hres = OleInitialize(NULL);
- OleReady = ((hres == S_FALSE) || (hres == S_OK));
-}
-
-void ShellDest()
-{
- if (OleReady)
- OleUninitialize();
-}
-
-
-bool CreateShortcut(char* Destination, char* Target, char* StartIn, char*
Parameters, char* Desc)
-{
- if (!OleReady)
- return false;
-
- HRESULT hres;
- IShellLink* psl;
-
- // Get a pointer to the IShellLink interface.
- hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
- IID_IShellLink, (LPVOID*)&psl);
- if (SUCCEEDED(hres))
- {
- IPersistFile* ppf;
-
- // Set the path to the shortcut target and add the description.
- psl->SetPath(Target);
- if (Parameters != NULL) psl->SetArguments(Parameters);
- if (Desc != NULL) psl->SetDescription(Desc);
- if (StartIn != NULL) psl->SetWorkingDirectory(StartIn);
-
- // Query IShellLink for the IPersistFile interface for saving the
- // shortcut in persistent storage.
- hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf);
-
- if (SUCCEEDED(hres))
- {
- WCHAR wsz[MAX_PATH];
-
- // Ensure that the string is Unicode.
- MultiByteToWideChar(CP_ACP, 0, Destination, -1, wsz, MAX_PATH);
-
- // Save the link by calling IPersistFile::Save.
- hres = ppf->Save(wsz, TRUE);
- ppf->Release();
- }
- psl->Release();
- }
- return (SUCCEEDED(hres) ? true : false);
-}
-
-
-bool GetFolder(HWND hDlg, int nFolder, char* Buffer)
-{
- LPITEMIDLIST idl;
- SHGetSpecialFolderLocation(hDlg, nFolder, &idl);
- if (idl == 0) return false;
-
- BOOL res = SHGetPathFromIDList(idl, Buffer);
- CoTaskMemFree(idl);
- return (res != FALSE);
-}
-
-
-bool CreateDesktopShortcut(HWND hDlg, char* Folder)
-{
- char Destination[MyMaxPath];
- if (!GetFolder(hDlg, CSIDL_DESKTOP, Destination))
- return false;
-
- strcat(Destination, "\\" ProgramName ".lnk");
-
- char Target[MyMaxPath];
- strcpy(Target, Folder);
- strcat(Target, "\\" PrimaryFile);
-
- return CreateShortcut(Destination, Target, Folder, NULL, ProgramName "
- " Description);
-}
-
-bool CreateStartMenuShortcut(HWND hDlg, char* Folder)
-{
- char Destination[MyMaxPath];
- if (!GetFolder(hDlg, CSIDL_PROGRAMS, Destination))
- return false;
-
- strcat(Destination, "\\" ProgramName);
- if (!EnsureFolder(Destination))
- return false;
-
- strcat(Destination, "\\");
- char* i = &Destination[strlen(Destination)];
-
- char Target[MyMaxPath];
- strcpy(Target, Folder);
- strcat(Target, "\\" PrimaryFile);
-
- strcpy(i, ProgramName ".lnk");
- bool res = CreateShortcut(Destination, Target, Folder, NULL,
ProgramName " - " Description);
-
- strcpy(i, "Readme.lnk");
- strcpy(&Target[strlen(Folder)+1], "readme.htm");
- res &= CreateShortcut(Destination, Target, NULL, NULL, ProgramName " -
Read Me");
-
- return res;
-}
-
-
-void GetProgramFiles(HWND hDlg, char* Buffer)
-{
- char* s = getenv("PROGRAMFILES");
- strcpy(Buffer, (s != NULL ? s : "C:\\Program Files"));
-}
-
-
-
-int CALLBACK BrowseCallbackProc(HWND hWnd, UINT uMsg, LPARAM lParam,
LPARAM lpData)
-{
- switch(uMsg)
- {
- case BFFM_INITIALIZED:
- char Buffer[MyMaxPath];
- GetWindowText((HWND) lpData, Buffer, MyMaxPath);
- SendMessage(hWnd, BFFM_SETSELECTION, TRUE, (LPARAM) Buffer);
- break;
- }
-
- return 0;
-}
-
-
-void Browse(HWND hDlg, HWND hText)
-{
- const int bif_NEWDIALOGSTYLE = 0x40;
-
- BROWSEINFO bi;
- bi.hwndOwner = hDlg;
- bi.pidlRoot = NULL;
- bi.pszDisplayName = NULL;
- bi.lpszTitle = "Select the installation folder for " ProgramName;
- bi.ulFlags = BIF_RETURNONLYFSDIRS | bif_NEWDIALOGSTYLE;
- bi.lpfn = &BrowseCallbackProc;
- bi.lParam = (LPARAM) hText;
- bi.iImage = 0;
-
- LPITEMIDLIST idl = SHBrowseForFolder(&bi);
-
- if (idl != NULL)
- {
- char Buffer[MyMaxPath];
- SHGetPathFromIDList(idl, Buffer);
- SetWindowText(hText, Buffer);
- CoTaskMemFree(idl);
- }
-}
=======================================
***Additional files exist in this changeset.***
==============================================================================
Revision: e6d7b0105ff5
Author: Jimmy Salmon <address@hidden>
Date: Sun Aug 19 14:34:51 2007
Log: Removed old installer, don't include contrib dir
http://code.google.com/p/pingus/source/detail?r=e6d7b0105ff5&repo=windows-installer
Modified:
/release.sh
=======================================
--- /release.sh Sun Aug 19 14:20:27 2007
+++ /release.sh Sun Aug 19 14:34:51 2007
@@ -2,6 +2,7 @@
echo "Exporting svn"
svn export . pingus
+rm -rf pingus/contrib
rm -rf pingus/src
rm -f pingus/pingus.sln
rm -f pingus/pingus.vcproj
==============================================================================
Revision: f3f4bd009b38
Author: Jimmy Salmon <address@hidden>
Date: Sun Aug 19 14:41:10 2007
Log: Remove more files from installer
http://code.google.com/p/pingus/source/detail?r=f3f4bd009b38&repo=windows-installer
Modified:
/release.sh
=======================================
--- /release.sh Sun Aug 19 14:34:51 2007
+++ /release.sh Sun Aug 19 14:41:10 2007
@@ -3,10 +3,17 @@
echo "Exporting svn"
svn export . pingus
rm -rf pingus/contrib
+rm -rf pingus/doc
rm -rf pingus/src
rm -f pingus/pingus.sln
rm -f pingus/pingus.vcproj
rm -f pingus/SConstruct
+rm -f pingus/ChangeLog
+rm -f pingus/clanlib_2_sexpr.rb
+rm -f pingus/config.h
+rm -f pingus/INSTALL.unix
+rm -f pingus/INSTALL.Win32
+rm -f pingus/xml2sexpr.rb
cp Release/pingus.exe pingus
cp contrib/windows_installer/libiconv2.dll pingus
==============================================================================
Revision: 960aa95405bc
Author: Ingo Ruhnke <address@hidden>
Date: Thu Aug 23 11:42:59 2007
Log: - moved level_comment_tool/ and windows_installer/ to trunk
http://code.google.com/p/pingus/source/detail?r=960aa95405bc&repo=windows-installer
==============================================================================
Revision: ff339b90e926
Author: Jimmy Salmon <address@hidden>
Date: Fri Aug 24 19:40:38 2007
Log: Updated for new location
http://code.google.com/p/pingus/source/detail?r=ff339b90e926&repo=windows-installer
Modified:
/release.sh
=======================================
--- /release.sh Sun Aug 19 14:41:10 2007
+++ /release.sh Fri Aug 24 19:40:38 2007
@@ -16,19 +16,11 @@
rm -f pingus/xml2sexpr.rb
cp Release/pingus.exe pingus
-cp contrib/windows_installer/libiconv2.dll pingus
-cp contrib/windows_installer/msvcp80.dll pingus
-cp contrib/windows_installer/msvcr80.dll pingus
-cp contrib/windows_installer/ogg.dll pingus
-cp contrib/windows_installer/SDL.dll pingus
-cp contrib/windows_installer/SDL_mixer.dll pingus
-cp contrib/windows_installer/smpeg.dll pingus
-cp contrib/windows_installer/vorbis.dll pingus
-cp contrib/windows_installer/vorbisfile.dll pingus
-cp contrib/windows_installer/Microsoft.VC80.CRT.manifest pingus
+cp ../windows_installer/*.dll pingus
+cp ../windows_installer/Microsoft.VC80.CRT.manifest pingus
echo "Creating installer"
-"c:/Program Files/NSIS/makensis.exe" /NOCD
contrib/windows_installer/pingus.nsi
+"c:/Program Files/NSIS/makensis.exe" /NOCD ../windows_installer/pingus.nsi
echo "Cleaning up"
rm -rf pingus
==============================================================================
Revision: 3399f9cabe2f
Author: Jimmy Salmon <address@hidden>
Date: Fri Sep 21 21:38:03 2007
Log: Updated for 0.7.1
http://code.google.com/p/pingus/source/detail?r=3399f9cabe2f&repo=windows-installer
Modified:
/pingus.nsi
=======================================
--- /pingus.nsi Sun Aug 19 14:20:27 2007
+++ /pingus.nsi Fri Sep 21 21:38:03 2007
@@ -3,7 +3,7 @@
!define NAME "Pingus"
Name "${NAME}"
-OutFile "Pingus-0.7.exe"
+OutFile "Pingus-0.7.1.exe"
#!define MUI_ICON "src/win32/icon1.ico"
#!define MUI_UNICON "src/win32/icon1.ico"
==============================================================================
Revision: 7ca89d02bea1
Author: Jimmy Salmon <address@hidden>
Date: Sun Sep 23 07:59:28 2007
Log: Don't need lib dir
http://code.google.com/p/pingus/source/detail?r=7ca89d02bea1&repo=windows-installer
Modified:
/release.sh
=======================================
--- /release.sh Fri Aug 24 19:40:38 2007
+++ /release.sh Sun Sep 23 07:59:28 2007
@@ -4,6 +4,7 @@
svn export . pingus
rm -rf pingus/contrib
rm -rf pingus/doc
+rm -rf pingus/lib
rm -rf pingus/src
rm -f pingus/pingus.sln
rm -f pingus/pingus.vcproj
==============================================================================
Revision: 14c5781edd99
Author: Jimmy Salmon <address@hidden>
Date: Mon Sep 24 19:54:08 2007
Log: Added pingus.exe.config
http://code.google.com/p/pingus/source/detail?r=14c5781edd99&repo=windows-installer
Added:
/pingus.exe.config
Modified:
/release.sh
=======================================
--- /dev/null
+++ /pingus.exe.config Mon Sep 24 19:54:08 2007
@@ -0,0 +1,10 @@
+<configuration>
+ <windows>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity type="win32" name="Microsoft.VC80.CRT"
processorArchitecture="x86"
publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
+ <bindingRedirect oldVersion="8.0.41204.256-8.0.50727.762"
newVersion="8.0.50727.762"/>
+ </dependentAssembly>
+ </assemblyBinding>
+ </windows>
+</configuration>
=======================================
--- /release.sh Sun Sep 23 07:59:28 2007
+++ /release.sh Mon Sep 24 19:54:08 2007
@@ -19,6 +19,7 @@
cp Release/pingus.exe pingus
cp ../windows_installer/*.dll pingus
cp ../windows_installer/Microsoft.VC80.CRT.manifest pingus
+cp ../windows_installer/pingus.exe.config pingus
echo "Creating installer"
"c:/Program Files/NSIS/makensis.exe" /NOCD ../windows_installer/pingus.nsi
==============================================================================
Revision: 367829415509
Author: Jimmy Salmon <address@hidden>
Date: Sun Oct 28 22:32:53 2007
Log: Prepare for 0.7.2
http://code.google.com/p/pingus/source/detail?r=367829415509&repo=windows-installer
Modified:
/pingus.nsi
=======================================
--- /pingus.nsi Fri Sep 21 21:38:03 2007
+++ /pingus.nsi Sun Oct 28 22:32:53 2007
@@ -3,7 +3,7 @@
!define NAME "Pingus"
Name "${NAME}"
-OutFile "Pingus-0.7.1.exe"
+OutFile "Pingus-0.7.2.exe"
#!define MUI_ICON "src/win32/icon1.ico"
#!define MUI_UNICON "src/win32/icon1.ico"
==============================================================================
Revision: aed6563547ee
Author: Jimmy Salmon <address@hidden>
Date: Sun Oct 28 23:17:45 2007
Log: Add to Add/Remove Programs
http://code.google.com/p/pingus/source/detail?r=aed6563547ee&repo=windows-installer
Modified:
/pingus.nsi
=======================================
--- /pingus.nsi Sun Oct 28 22:32:53 2007
+++ /pingus.nsi Sun Oct 28 23:17:45 2007
@@ -1,9 +1,10 @@
!include "MUI.nsh"
!define NAME "Pingus"
+!define VERSION "0.7.2"
Name "${NAME}"
-OutFile "Pingus-0.7.2.exe"
+OutFile "${NAME}-${VERSION}.exe"
#!define MUI_ICON "src/win32/icon1.ico"
#!define MUI_UNICON "src/win32/icon1.ico"
@@ -42,6 +43,12 @@
SetOutPath "$INSTDIR"
File /r "pingus\*.*"
WriteRegStr HKCU "Software\${NAME}" "" $INSTDIR
+ WriteRegStr
HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "DisplayName" "${NAME}"
+ WriteRegStr
HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "DisplayVersion" "${VERSION}"
+ WriteRegStr
HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "InstallLocation"
$INSTDIR
+ WriteRegStr
HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "UninstallString" "$INSTDIR\Uninstall.exe"
+ WriteRegDWORD
HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "NoModify"
1
+ WriteRegDWORD
HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}" "NoRepair"
1
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\${NAME}.lnk" "$INSTDIR\pingus.exe"
@@ -61,5 +68,6 @@
RMDir "$SMPROGRAMS\$MUI_TEMP"
DeleteRegKey /ifempty HKCU "Software\${NAME}"
+ DeleteRegKey
HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${NAME}"
SectionEnd
==============================================================================
Revision: 1e653b54d568
Author: Jimmy Salmon <address@hidden>
Date: Sun Oct 28 23:36:57 2007
Log: Fix removing shortcuts from start menu in Vista
http://code.google.com/p/pingus/source/detail?r=1e653b54d568&repo=windows-installer
Modified:
/pingus.nsi
=======================================
--- /pingus.nsi Sun Oct 28 23:17:45 2007
+++ /pingus.nsi Sun Oct 28 23:36:57 2007
@@ -6,6 +6,8 @@
Name "${NAME}"
OutFile "${NAME}-${VERSION}.exe"
+RequestExecutionLevel admin
+
#!define MUI_ICON "src/win32/icon1.ico"
#!define MUI_UNICON "src/win32/icon1.ico"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] [windows-installer.pingus] 19 new revisions pushed by address@hidden on 2011-10-20 00:52 GMT,
pingus <=