libmspack 0.0.5 → 0.10.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/rake.yml +37 -0
  3. data/.gitignore +2 -0
  4. data/.yardopts +1 -1
  5. data/README.md +1 -1
  6. data/Rakefile +11 -5
  7. data/ext/Rakefile +1 -1
  8. data/ext/libmspack/AUTHORS +1 -0
  9. data/ext/libmspack/ChangeLog +321 -4
  10. data/ext/libmspack/INSTALL +368 -0
  11. data/ext/libmspack/Makefile.am +86 -95
  12. data/ext/libmspack/Makefile.in +1729 -0
  13. data/ext/libmspack/README +30 -30
  14. data/ext/libmspack/acinclude.m4 +99 -0
  15. data/ext/libmspack/aclocal.m4 +1218 -0
  16. data/ext/libmspack/ar-lib +270 -0
  17. data/ext/libmspack/compile +347 -0
  18. data/ext/libmspack/config.guess +1480 -0
  19. data/ext/libmspack/config.h.in +129 -0
  20. data/ext/libmspack/config.sub +1801 -0
  21. data/ext/libmspack/configure +15487 -0
  22. data/ext/libmspack/configure.ac +11 -13
  23. data/ext/libmspack/depcomp +791 -0
  24. data/ext/libmspack/install-sh +508 -0
  25. data/ext/libmspack/libmscabd.la +41 -0
  26. data/ext/libmspack/libmschmd.la +41 -0
  27. data/ext/libmspack/libmspack.la +41 -0
  28. data/ext/libmspack/ltmain.sh +11156 -0
  29. data/ext/libmspack/m4/libtool.m4 +8387 -0
  30. data/ext/libmspack/m4/ltoptions.m4 +437 -0
  31. data/ext/libmspack/m4/ltsugar.m4 +124 -0
  32. data/ext/libmspack/m4/ltversion.m4 +23 -0
  33. data/ext/libmspack/m4/lt~obsolete.m4 +99 -0
  34. data/ext/libmspack/missing +215 -0
  35. data/ext/libmspack/mspack/cab.h +20 -7
  36. data/ext/libmspack/mspack/cabd.c +301 -236
  37. data/ext/libmspack/mspack/chmd.c +304 -319
  38. data/ext/libmspack/mspack/crc32.c +52 -52
  39. data/ext/libmspack/mspack/crc32.h +1 -1
  40. data/ext/libmspack/mspack/kwajd.c +178 -172
  41. data/ext/libmspack/mspack/lzss.h +4 -4
  42. data/ext/libmspack/mspack/lzssd.c +42 -42
  43. data/ext/libmspack/mspack/lzx.h +11 -11
  44. data/ext/libmspack/mspack/lzxd.c +370 -361
  45. data/ext/libmspack/mspack/mspack.h +109 -77
  46. data/ext/libmspack/mspack/mszip.h +6 -6
  47. data/ext/libmspack/mspack/mszipd.c +140 -139
  48. data/ext/libmspack/mspack/oab.h +1 -0
  49. data/ext/libmspack/mspack/oabd.c +71 -73
  50. data/ext/libmspack/mspack/qtm.h +4 -4
  51. data/ext/libmspack/mspack/qtmd.c +118 -117
  52. data/ext/libmspack/mspack/readbits.h +52 -52
  53. data/ext/libmspack/mspack/readhuff.h +61 -61
  54. data/ext/libmspack/mspack/system.c +15 -9
  55. data/ext/libmspack/mspack/system.h +38 -50
  56. data/ext/libmspack/mspack/szddd.c +35 -35
  57. data/ext/libmspack/test-driver +148 -0
  58. data/ext/x86_64-linux/libmspack.so +0 -0
  59. data/ext/x86_64-windows/mspack.dll +0 -0
  60. data/lib/libmspack/version.rb +2 -1
  61. data/lib/libmspack.rb +1 -1
  62. data/libmspack.gemspec +4 -4
  63. data/spec/libmspack_spec.rb +5 -4
  64. metadata +38 -105
  65. data/.travis.yml +0 -5
  66. data/ext/i386-windows/libmspack.dll +0 -0
  67. data/ext/libmspack/cleanup.sh +0 -9
  68. data/ext/libmspack/debian/changelog +0 -6
  69. data/ext/libmspack/debian/control +0 -14
  70. data/ext/libmspack/debian/rules +0 -101
  71. data/ext/libmspack/doc/Doxyfile.in +0 -22
  72. data/ext/libmspack/doc/Makefile.in +0 -14
  73. data/ext/libmspack/doc/szdd_kwaj_format.html +0 -331
  74. data/ext/libmspack/mspack/mspack.def +0 -28
  75. data/ext/libmspack/mspack/qtmc.c +0 -18
  76. data/ext/libmspack/rebuild.sh +0 -8
  77. data/ext/libmspack/test/cabd_c10 +0 -19
  78. data/ext/libmspack/test/cabd_compare +0 -34
  79. data/ext/libmspack/test/cabd_md5.c +0 -161
  80. data/ext/libmspack/test/cabd_memory.c +0 -179
  81. data/ext/libmspack/test/cabd_test.c +0 -386
  82. data/ext/libmspack/test/cabrip.c +0 -81
  83. data/ext/libmspack/test/chmd_compare +0 -38
  84. data/ext/libmspack/test/chmd_find.c +0 -95
  85. data/ext/libmspack/test/chmd_md5.c +0 -67
  86. data/ext/libmspack/test/chmd_order.c +0 -144
  87. data/ext/libmspack/test/chminfo.c +0 -284
  88. data/ext/libmspack/test/chmx.c +0 -216
  89. data/ext/libmspack/test/error.h +0 -22
  90. data/ext/libmspack/test/expand.c +0 -79
  91. data/ext/libmspack/test/md5.c +0 -457
  92. data/ext/libmspack/test/md5.h +0 -165
  93. data/ext/libmspack/test/md5_fh.h +0 -123
  94. data/ext/libmspack/test/msdecompile_md5 +0 -24
  95. data/ext/libmspack/test/msexpand_md5 +0 -39
  96. data/ext/libmspack/test/multifh.c +0 -435
  97. data/ext/libmspack/test/oabx.c +0 -41
  98. data/ext/libmspack/test/test_files/cabd/1.pl +0 -84
  99. data/ext/libmspack/test/test_files/cabd/2.pl +0 -75
  100. data/ext/libmspack/test/test_files/cabd/bad_folderindex.cab +0 -0
  101. data/ext/libmspack/test/test_files/cabd/bad_nofiles.cab +0 -0
  102. data/ext/libmspack/test/test_files/cabd/bad_nofolders.cab +0 -0
  103. data/ext/libmspack/test/test_files/cabd/bad_signature.cab +0 -0
  104. data/ext/libmspack/test/test_files/cabd/multi_basic_pt1.cab +0 -0
  105. data/ext/libmspack/test/test_files/cabd/multi_basic_pt2.cab +0 -0
  106. data/ext/libmspack/test/test_files/cabd/multi_basic_pt3.cab +0 -0
  107. data/ext/libmspack/test/test_files/cabd/multi_basic_pt4.cab +0 -0
  108. data/ext/libmspack/test/test_files/cabd/multi_basic_pt5.cab +0 -0
  109. data/ext/libmspack/test/test_files/cabd/normal_255c_filename.cab +0 -0
  110. data/ext/libmspack/test/test_files/cabd/normal_2files_1folder.cab +0 -0
  111. data/ext/libmspack/test/test_files/cabd/partial_nodata.cab +0 -0
  112. data/ext/libmspack/test/test_files/cabd/partial_nofiles.cab +0 -0
  113. data/ext/libmspack/test/test_files/cabd/partial_nofolder.cab +0 -0
  114. data/ext/libmspack/test/test_files/cabd/partial_shortextheader.cab +0 -0
  115. data/ext/libmspack/test/test_files/cabd/partial_shortfile1.cab +0 -0
  116. data/ext/libmspack/test/test_files/cabd/partial_shortfile2.cab +0 -0
  117. data/ext/libmspack/test/test_files/cabd/partial_shortfolder.cab +0 -0
  118. data/ext/libmspack/test/test_files/cabd/partial_shortheader.cab +0 -0
  119. data/ext/libmspack/test/test_files/cabd/partial_str_nofname.cab +0 -0
  120. data/ext/libmspack/test/test_files/cabd/partial_str_noninfo.cab +0 -0
  121. data/ext/libmspack/test/test_files/cabd/partial_str_nonname.cab +0 -0
  122. data/ext/libmspack/test/test_files/cabd/partial_str_nopinfo.cab +0 -0
  123. data/ext/libmspack/test/test_files/cabd/partial_str_nopname.cab +0 -0
  124. data/ext/libmspack/test/test_files/cabd/partial_str_shortfname.cab +0 -0
  125. data/ext/libmspack/test/test_files/cabd/partial_str_shortninfo.cab +0 -0
  126. data/ext/libmspack/test/test_files/cabd/partial_str_shortnname.cab +0 -0
  127. data/ext/libmspack/test/test_files/cabd/partial_str_shortpinfo.cab +0 -0
  128. data/ext/libmspack/test/test_files/cabd/partial_str_shortpname.cab +0 -0
  129. data/ext/libmspack/test/test_files/cabd/reserve_---.cab +0 -0
  130. data/ext/libmspack/test/test_files/cabd/reserve_--D.cab +0 -0
  131. data/ext/libmspack/test/test_files/cabd/reserve_-F-.cab +0 -0
  132. data/ext/libmspack/test/test_files/cabd/reserve_-FD.cab +0 -0
  133. data/ext/libmspack/test/test_files/cabd/reserve_H--.cab +0 -0
  134. data/ext/libmspack/test/test_files/cabd/reserve_H-D.cab +0 -0
  135. data/ext/libmspack/test/test_files/cabd/reserve_HF-.cab +0 -0
  136. data/ext/libmspack/test/test_files/cabd/reserve_HFD.cab +0 -0
  137. data/ext/libmspack/test/test_files/cabd/search_basic.cab +0 -0
  138. data/ext/libmspack/test/test_files/cabd/search_tricky1.cab +0 -0
  139. data/ext/libmspack/winbuild.sh +0 -26
  140. data/ext/libmspack.h +0 -259
  141. data/ext/x86_64-windows/libmspack.dll +0 -0
@@ -1,331 +0,0 @@
1
- <?xml version="1.0" encoding="iso-8859-1"?>
2
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="eng">
5
- <head>
6
- <style type="text/css">
7
- dt {
8
- font-weight:bold;
9
- }
10
- pre {
11
- background-color:#F9F9F9;
12
- border:1px dashed #2F6FAB;
13
- color:black;
14
- padding:1em;
15
- }
16
- table.wikitable {
17
- background:none repeat scroll 0 0 #F9F9F9;
18
- border:1px solid #AAAAAA;
19
- border-collapse:collapse;
20
- margin:1em 1em 1em 0;
21
- }
22
- .wikitable th, .wikitable td {
23
- border:1px solid #AAAAAA;
24
- padding:0.2em;
25
- }
26
- .wikitable th {
27
- background:none repeat scroll 0 0 #F2F2F2;
28
- text-align:center;
29
- }
30
- .wikitable caption {
31
- font-weight:bold;
32
- }
33
- .c.source-c .de1, .c.source-c .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
34
- .c.source-c {font-family:monospace;}
35
- .c.source-c .imp {font-weight: bold; color: red;}
36
- .c.source-c li, .c.source-c .li1 {font-weight: normal; vertical-align:top;}
37
- .c.source-c .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
38
- .c.source-c .li2 {font-weight: bold; vertical-align:top;}
39
- .c.source-c .kw1 {color: #b1b100;}
40
- .c.source-c .kw2 {color: #000000; font-weight: bold;}
41
- .c.source-c .kw3 {color: #000066;}
42
- .c.source-c .kw4 {color: #993333;}
43
- .c.source-c .co1 {color: #666666; font-style: italic;}
44
- .c.source-c .co2 {color: #339933;}
45
- .c.source-c .coMULTI {color: #808080; font-style: italic;}
46
- .c.source-c .es0 {color: #000099; font-weight: bold;}
47
- .c.source-c .es1 {color: #000099; font-weight: bold;}
48
- .c.source-c .es2 {color: #660099; font-weight: bold;}
49
- .c.source-c .es3 {color: #660099; font-weight: bold;}
50
- .c.source-c .es4 {color: #660099; font-weight: bold;}
51
- .c.source-c .es5 {color: #006699; font-weight: bold;}
52
- .c.source-c .br0 {color: #009900;}
53
- .c.source-c .sy0 {color: #339933;}
54
- .c.source-c .st0 {color: #ff0000;}
55
- .c.source-c .nu0 {color: #0000dd;}
56
- .c.source-c .nu6 {color: #208080;}
57
- .c.source-c .nu8 {color: #208080;}
58
- .c.source-c .nu12 {color: #208080;}
59
- .c.source-c .nu16 {color:#800080;}
60
- .c.source-c .nu17 {color:#800080;}
61
- .c.source-c .nu18 {color:#800080;}
62
- .c.source-c .nu19 {color:#800080;}
63
- .c.source-c .me1 {color: #202020;}
64
- .c.source-c .me2 {color: #202020;}
65
- .c.source-c .ln-xtra, .c.source-c li.ln-xtra, .c.source-c div.ln-xtra {background-color: #ffc;}
66
- .c.source-c span.xtra { display:block; }
67
- </style>
68
- <meta name="author" content="Stuart Caie" />
69
- <title>COMPRESS.EXE file formats: SZDD and KWAJ</title>
70
- </head>
71
- <body>
72
- <h1>COMPRESS.EXE file formats: SZDD and KWAJ</h1>
73
-
74
- <p>This document describes the <b>SZDD</b> and <b>KWAJ</b> file
75
- formats which are implemented in the MS-DOS commands
76
- <tt>COMPRESS.EXE</tt> and <tt>EXPAND.EXE</tt>.</p>
77
-
78
- <p>Both formats compress a single file to another single file,
79
- replacing the last character in the filename with an underscore or
80
- dollar character, e.g. <tt>README.TXT</tt> becomes <tt>README.TX_</tt>
81
- or <tt>README.TX$</tt>.</p>
82
-
83
- <a name="SZDD_file_format"><h2>SZDD file format</h2></a>
84
-
85
- <p>An SZDD file begins with this fixed header:</p>
86
-
87
- <table class="wikitable">
88
- <caption>SZDD header format</caption>
89
- <tr><th>Offset</th><th>Length</th><th>Description</th></tr>
90
- <tr><td>0x00</td><td>8</td><td>"SZDD" signature: 0x53,0x5A,0x44,0x44,0x88,0xF0,0x27,0x33</td></tr>
91
- <tr><td>0x08</td><td>1</td><td>Compression mode: only "A" (0x41) is valid here</td></tr>
92
- <tr><td>0x09</td><td>1</td><td>The character missing from the end of the filename (0=unknown)</td></tr>
93
- <tr><td>0x0A</td><td>4</td><td>The integer length of the file when unpacked</td></tr>
94
- </table>
95
-
96
- <p>The header is immediately followed by the compressed data. The
97
- following pseudocode explains how to unpack this data; it's a form of
98
- the LZSS algorithm.</p>
99
-
100
- <table class="wikitable">
101
- <caption>SZDD decompression pseudocode</caption>
102
- <tr><td>
103
- <div dir="ltr" style="text-align: left;"><div class="c source-c" style="font-family:monospace;"><pre class="de1"><span class="kw4">char</span> window<span class="br0">&#91;</span><span class="nu0">4096</span><span class="br0">&#93;</span><span class="sy0">;</span>
104
- <span class="kw4">int</span> pos <span class="sy0">=</span> <span class="nu0">4096</span> <span class="sy0">-</span> <span class="nu0">16</span><span class="sy0">;</span>
105
- memset<span class="br0">&#40;</span>window<span class="sy0">,</span> <span class="nu12">0x20</span><span class="sy0">,</span> <span class="nu0">4096</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="coMULTI">/* window initially full of spaces */</span>
106
- <span class="kw1">for</span> <span class="br0">&#40;</span><span class="sy0">;;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
107
- <span class="kw4">int</span> control <span class="sy0">=</span> GETBYTE<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
108
- <span class="kw1">if</span> <span class="br0">&#40;</span>control <span class="sy0">==</span> EOF<span class="br0">&#41;</span> <span class="kw2">break</span><span class="sy0">;</span> <span class="coMULTI">/* exit if no more to read */</span>
109
- <span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw4">int</span> cbit <span class="sy0">=</span> <span class="nu12">0x01</span><span class="sy0">;</span> cbit <span class="sy0">&amp;</span> <span class="nu12">0xFF</span><span class="sy0">;</span> cbit <span class="sy0">&lt;&lt;=</span> <span class="nu0">1</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
110
- <span class="kw1">if</span> <span class="br0">&#40;</span>control <span class="sy0">&amp;</span> cbit<span class="br0">&#41;</span> <span class="br0">&#123;</span>
111
- <span class="coMULTI">/* literal */</span>
112
- PUTBYTE<span class="br0">&#40;</span>window<span class="br0">&#91;</span>pos<span class="sy0">++</span><span class="br0">&#93;</span> <span class="sy0">=</span> GETBYTE<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span>
113
- <span class="br0">&#125;</span>
114
- <span class="kw1">else</span> <span class="br0">&#123;</span>
115
- <span class="coMULTI">/* match */</span>
116
- <span class="kw4">int</span> matchpos <span class="sy0">=</span> GETBYTE<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
117
- <span class="kw4">int</span> matchlen <span class="sy0">=</span> GETBYTE<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
118
- matchpos <span class="sy0">|=</span> <span class="br0">&#40;</span>matchlen <span class="sy0">&amp;</span> <span class="nu12">0xF0</span><span class="br0">&#41;</span> <span class="sy0">&lt;&lt;</span> <span class="nu0">4</span><span class="sy0">;</span>
119
- matchlen <span class="sy0">=</span> <span class="br0">&#40;</span>matchlen <span class="sy0">&amp;</span> <span class="nu12">0x0F</span><span class="br0">&#41;</span> <span class="sy0">+</span> <span class="nu0">3</span><span class="sy0">;</span>
120
- <span class="kw1">while</span> <span class="br0">&#40;</span>matchlen<span class="sy0">--</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
121
- PUTBYTE<span class="br0">&#40;</span>window<span class="br0">&#91;</span>pos<span class="sy0">++</span><span class="br0">&#93;</span> <span class="sy0">=</span> window<span class="br0">&#91;</span>matchpos<span class="sy0">++</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span>
122
- pos <span class="sy0">&amp;=</span> <span class="nu0">4095</span><span class="sy0">;</span> matchpos <span class="sy0">&amp;=</span> <span class="nu0">4095</span><span class="sy0">;</span>
123
- <span class="br0">&#125;</span>
124
- <span class="br0">&#125;</span>
125
- <span class="br0">&#125;</span>
126
- <span class="br0">&#125;</span></pre></div></div>
127
- </td></tr></table>
128
-
129
- <p>There is also a variant SZDD format seen in the installation
130
- package for QBasic 4.5, so I call it the QBasic variant. It has a
131
- different header and the <tt>pos</tt> variable in the pseudocode above
132
- is set to <tt>4096-18</tt> instead of <tt>4096-16</tt>.</p>
133
-
134
- <table class="wikitable">
135
- <caption>QBasic SZDD variant header format</caption>
136
- <tr><th>Offset</th><th>Length</th><th>Description</th></tr>
137
- <tr><td>0x00</td><td>8</td><td>"SZ" signature: 0x53,0x5A,0x20,0x88,0xF0,0x27,0x33,0xD1</td></tr>
138
- <tr><td>0x08</td><td>4</td><td>The integer length of the file when unpacked</td></tr></table>
139
-
140
- <a name="KWAJ_file_format"><h2>KWAJ file format</h2></a>
141
-
142
- <p>A KWAJ file begins with this fixed header:</p>
143
-
144
- <table class="wikitable">
145
- <caption>KWAJ header format</caption>
146
- <tr><th>Offset</th><th>Length</th><th>Description</th></tr>
147
- <tr><td>0x00</td><td>8</td><td>"KWAJ" signature: 0x4B,0x57,0x41,0x4A,0x88,0xF0,0x27,0xD1</td></tr>
148
- <tr><td>0x08</td><td>2</td><td>compression method (0-4)</td></tr>
149
- <tr><td>0x0A</td><td>2</td><td>file offset of compressed data</td></tr>
150
- <tr><td>0x0C</td><td>2</td><td>header flags to mark header extensions</td></tr>
151
- </table>
152
-
153
- <a name="Compression_methods"><h3>Compression methods</h3></a>
154
-
155
- <p>The "compression method" field indicates the type of data
156
- compression used:</p>
157
-
158
- <ol start="0">
159
- <li>No compression</li>
160
- <li>No compression, data is XORed with byte 0xFF</li>
161
- <li>The same compression method as regular SZDD</li>
162
- <li>LZ + Huffman "Jeff Johnson" compression</li>
163
- <li>MS-ZIP</li>
164
- </ol>
165
-
166
- <a name="Header_extensions"><h3>Header extensions</h3></a>
167
-
168
- <p>Header extensions immediately follow the header.</p>
169
-
170
- <p>If you don't care about the header extensions, use the file offset
171
- to skip to the compressed data.</p>
172
-
173
- <p>The header extensions appear in this order:</p>
174
-
175
- <dl>
176
- <dt>When header flags bit 0 is set</dt><dd>4 bytes: decompressed length of file</dd>
177
- <dt>When header flags bit 1 is set</dt><dd>2 bytes: unknown purpose</dd>
178
- <dt>When header flags bit 2 is set</dt><dd>2 bytes: length of data, followed by that many bytes of (unknown purpose) data</dd>
179
- <dt>When header flags bit 3 is set</dt><dd>1-9 bytes: null-terminated string with max length 8: file name</dd>
180
- <dt>When header flags bit 4 is set</dt><dd>1-4 bytes: null-terminated string with max length 3: file extension</dd>
181
- <dt>When header flags bit 5 is set</dt><dd>2 bytes: length of data, followed by that many bytes of (arbitrary text) data</dd>
182
- </dl>
183
-
184
- <a name="KWAJ_compression_method_3"><h3>KWAJ compression method 3</h3></a>
185
-
186
- <p>Compression method 3 is unique to the KWAJ format. It's an
187
- LZ+Huffman algorithm created by Jeff Johnson.</p>
188
-
189
- <p>Bits are always read from MSB to LSB, one byte at a time.</p>
190
-
191
- <p>There are three parts:</p>
192
-
193
- <ol>
194
- <li>The data starts off with 6 nybbles; 4 bits each. Each nybble is
195
- between 0-3 and is the encoding type of the 5 huffman length lists to
196
- follow. The 6th nybble is just padding.</li>
197
- <li>Then follow 5 huffman code length lists.</li>
198
- <li>Then follows the compressed data, which is a mix of huffman
199
- symbols and raw bits.</li>
200
- </ol>
201
-
202
- <a name="Huffman_code_length_lists"><h4>Huffman code length lists</h4></a>
203
-
204
- <p>KWAJ uses 5 huffman trees. They always have the same number of
205
- symbols in them. They are, in order:</p>
206
-
207
- <ol>
208
- <li>16 symbol tree (0-15) to store match run lengths (MATCHLEN)</li>
209
- <li>16 symbol tree (0-15) to store match run lengths immediately following a short literal run (MATCHLEN2)</li>
210
- <li>32 symbol tree (0-31) to store literal run lengths (LITLEN)</li>
211
- <li>64 symbol tree (0-63) to store the upper 6 bits of match distances (OFFSET)</li>
212
- <li>256 symbol tree (0-255) to store literals (LITERAL)</li>
213
- </ol>
214
-
215
- <p>Canonical huffman codes are used, which means you simply need to
216
- know how many symbols in each huffman tree (given above), and how long
217
- each huffman symbol is</p>
218
-
219
- <p>How the symbol lengths are encoded depends on the encoding type, as
220
- given by the 6 nybbles at the start of the compressed data.</p>
221
-
222
- <p>Symbol lengths are read in ascending order, and the number of
223
- symbols to read is implied by which tree you're defining.</p>
224
-
225
- <dl>
226
- <dt>Huffman code length list, encoding type 0</dt>
227
- <dd>All symbol have the same length, implied by the number of symbols in the tree:
228
- <ul>
229
- <li>16 symbols -&gt; all symbols are length 4</li>
230
- <li>32 symbols -&gt; all symbols are length 5</li>
231
- <li>64 symbols -&gt; all symbols are length 6</li>
232
- <li>256 symbols -&gt; all symbols are length 8</li>
233
- </ul>
234
- </dd>
235
- <dd>You don't need to read anything.</dd>
236
- </dl>
237
-
238
- <dl>
239
- <dt>Huffman code length list, encoding type 1</dt>
240
- <dd>A run-length encoding is used:
241
- <ul>
242
- <li>read 4 bits for the first symbol length (0-15)</li>
243
- <li>LOOP:
244
- <ul>
245
- <li>read 1 bit == 0 if symbol length is the same as the previous, OTHERWISE:</li>
246
- <li>read 1 bit == 0 if symbol length is previous + 1, OTHERWISE:</li>
247
- <li>read 4 bits for symbol length (0-15)</li>
248
- </ul>
249
- </li>
250
- </ul>
251
- </dd>
252
- </dl>
253
-
254
- <dl>
255
- <dt>Huffman code length list, encoding type 2</dt>
256
- <dd>Another run-length encoding is used:
257
- <ul>
258
- <li>read 4 bits for the first symbol length (0-15)</li>
259
- <li>LOOP:
260
- <ul>
261
- <li> read 2 bits as selector (0-3):
262
- <ul>
263
- <li> selector == 3: read 4 bits for symbol length, OTHERWISE:</li>
264
- <li> symbol length is previous symbol + (selector-1), i.e. -1, 0 or +1</li>
265
- </ul>
266
- </li>
267
- </ul>
268
- </li>
269
- </ul>
270
- </dd>
271
- </dl>
272
-
273
- <dl>
274
- <dt>Huffman code length list, encoding type 3</dt>
275
- <dd>There is no compression. Read 4 bits per symbol (0-15).</dd>
276
- </dl>
277
-
278
- <a name="Compressed_data"><h4>Compressed data</h4></a>
279
-
280
- <p>At this point, the compressed data begins.</p>
281
-
282
- <p>We have a 4096 byte ring buffer, initially filled with byte 0x20
283
- (ASCII space). Unlike the SZDD format, the starting position in the
284
- buffer is irrelevant, as match positions are stored relative to the
285
- current position in the window, not as absolute positions in the
286
- window.</p>
287
-
288
- <p>Pseudo-code:</p>
289
- <pre>
290
- ring buffer position = 4096-17
291
- selected table = MATCHLEN
292
- LOOP:
293
- code = read huffman code using selected table (MATCHLEN or MATCHLEN2)
294
- if EOF reached, exit loop
295
- if code &gt; 0, this is a match:
296
- match length = code + 2
297
- x = read huffman code using OFFSET table
298
- y = read 6 bits
299
- match offset = current ring buffer position - (x&lt;&lt;6 | y)
300
- copy match as output and into the ring buffer
301
- selected table = MATCHLEN
302
- if code == 0, this is a run of literals:
303
- x = read huffman code using LITLEN table
304
- if x != 31, selected table = MATCHLEN2
305
- read {x+1} literals using LITERAL huffman table, copy as output and into the ring buffer
306
- </pre>
307
-
308
- <a name="MSZIP"><h2>MS-ZIP</h2></a>
309
-
310
- KWAJ type 4 compression is called MS-ZIP, because it is almost
311
- identical to the MS-ZIP compression found in Microsoft Cabinet files.
312
-
313
- Each 32768 bytes of data is compressed independently using Phil
314
- Katz's DEFLATE algorithm. However, the history window is shared
315
- between blocks, so they must be unpacked in order.
316
- The format of each block is as follows:
317
-
318
- <table class="wikitable">
319
- <caption>KWAJ MS-ZIP block format</caption>
320
- <tr><th>Offset</th><th>Length</th><th>Description</th></tr>
321
- <tr><td>0</td><td>2</td><td>Compressed length of this block (n).
322
- Stored in Intel byte order.
323
- Doesn't include these two bytes.</td></tr>
324
- <tr><td>2</td><td>2</td><td>"CK" in ASCII (0x43, 0x4B)</td></tr>
325
- <tr><td>4</td><td>n-2</td><td>Data compressed in DEFLATE format</td></tr>
326
- </table>
327
-
328
- The final block will unpack to 1-32768 bytes. It will be followed by two
329
- zero bytes.
330
-
331
- </body></html>
@@ -1,28 +0,0 @@
1
- LIBRARY mspack
2
- EXPORTS
3
- mspack_create_cab_compressor
4
- mspack_create_cab_decompressor
5
- mspack_create_chm_compressor
6
- mspack_create_chm_decompressor
7
- mspack_create_hlp_compressor
8
- mspack_create_hlp_decompressor
9
- mspack_create_kwaj_compressor
10
- mspack_create_kwaj_decompressor
11
- mspack_create_lit_compressor
12
- mspack_create_lit_decompressor
13
- mspack_create_szdd_compressor
14
- mspack_create_szdd_decompressor
15
- mspack_destroy_cab_compressor
16
- mspack_destroy_cab_decompressor
17
- mspack_destroy_chm_compressor
18
- mspack_destroy_chm_decompressor
19
- mspack_destroy_hlp_compressor
20
- mspack_destroy_hlp_decompressor
21
- mspack_destroy_kwaj_compressor
22
- mspack_destroy_kwaj_decompressor
23
- mspack_destroy_lit_compressor
24
- mspack_destroy_lit_decompressor
25
- mspack_destroy_szdd_compressor
26
- mspack_destroy_szdd_decompressor
27
- mspack_sys_selftest_internal
28
- mspack_version
@@ -1,18 +0,0 @@
1
- /* This file is part of libmspack.
2
- * (C) 2003-2004 Stuart Caie.
3
- *
4
- * The Quantum method was created by David Stafford, adapted by Microsoft
5
- * Corporation.
6
- *
7
- * libmspack is free software; you can redistribute it and/or modify it under
8
- * the terms of the GNU Lesser General Public License (LGPL) version 2.1
9
- *
10
- * For further details, see the file COPYING.LIB distributed with libmspack
11
- */
12
-
13
- /* Quantum compression implementation */
14
-
15
- #include <system.h>
16
- #include <qtm.h>
17
-
18
- /* todo */
@@ -1,8 +0,0 @@
1
- #!/bin/sh
2
- ./cleanup.sh
3
- mkdir m4
4
- autoreconf -i -W all
5
- ./configure
6
- make
7
- make -C doc
8
- make distcheck
@@ -1,19 +0,0 @@
1
- #!/bin/sh
2
- # Expand all cabs from the C10 collection; none are intentionally valid.
3
- # See https://www.ee.oulu.fi/research/ouspg/PROTOS_Test-Suite_c10-archive
4
-
5
- # I downloaded the .iso, unpacked cab_tar.bz2 and moved the cab files into
6
- # 256 directories (00 to ff) under C10/unpacked. This makes it possible to
7
- # invoke cabd_md5 just 256 times to test the entire collection.
8
-
9
- for dir in `find C10/unpacked -maxdepth 1 -type d`
10
- do
11
- echo "testing $dir"
12
- ./cabd_md5 $dir/*.cab >/dev/null 2>.err
13
- result=$?
14
- if [ $result -ne 0 ]; then
15
- echo "FAIL $dir $result" >&2
16
- cat .err >&2
17
- fi
18
- done
19
- rm .err
@@ -1,34 +0,0 @@
1
- #!/bin/sh
2
- # Test if cabd_md5 expands cab files identically to Microsoft's EXPAND.EXE
3
-
4
- [ -d .cache ] || mkdir .cache
5
-
6
- for cab in "$@"
7
- do
8
- echo "test $cab"
9
- cached=`echo $cab | sed -e 's/\//-/g' -e 's/^/.cache\//'`
10
- if [ ! -s $cached ]; then
11
- ./msexpand_md5 $cab >.orig.out 2>.orig.err
12
- if [ -s .orig.err ]; then
13
- echo "FAIL $cab: MS errors" >&2
14
- cat .orig.err >&2
15
- else
16
- mv .orig.out $cached
17
- fi
18
- fi
19
-
20
- ./cabd_md5 $cab >.test.out 2>.test.err
21
- perl -pi -e 'if($.>1){s{\\}{/}g;s{ /}{ }}' .test.out
22
- if [ -s .test.err ]; then
23
- echo "FAIL $cab: errors" >&2
24
- cat .test.err >&2
25
- fi
26
-
27
- if cmp $cached .test.out >/dev/null; then
28
- echo "OK $cab"
29
- else
30
- echo "FAIL $cab: differences" >&2
31
- diff -u $cached .test.out >&2
32
- fi
33
- done
34
- rm -f .orig.out .orig.err .test.out .test.err
@@ -1,161 +0,0 @@
1
- #ifdef HAVE_CONFIG_H
2
- #include <config.h>
3
- #endif
4
-
5
- #include <stdio.h>
6
- #include <stdlib.h>
7
- #include <string.h>
8
- #include <mspack.h>
9
- #include <sys/stat.h>
10
- #include <dirent.h>
11
-
12
- #include <md5_fh.h>
13
- #include <error.h>
14
-
15
- /**
16
- * Matches a cabinet's filename case-insensitively in the filesystem and
17
- * returns the case-correct form.
18
- *
19
- * @param origcab if this is non-NULL, the pathname part of this filename
20
- * will be extracted, and the search will be conducted in
21
- * that directory.
22
- * @param cabname the internal CAB filename to search for.
23
- * @return a copy of the full, case-correct filename of the given cabinet
24
- * filename, or NULL if the specified filename does not exist on disk.
25
- */
26
- static char *find_cabinet_file(char *origcab, char *cabname) {
27
- struct dirent *entry;
28
- struct stat st_buf;
29
- int found = 0, len;
30
- char *tail, *cab;
31
- DIR *dir;
32
-
33
- /* ensure we have a cabinet name at all */
34
- if (!cabname || !cabname[0]) return NULL;
35
-
36
- /* find if there's a directory path in the origcab */
37
- tail = origcab ? strrchr(origcab, '/') : NULL;
38
- len = (tail - origcab) + 1;
39
-
40
- /* allocate memory for our copy */
41
- if (!(cab = (char *) malloc((tail ? len : 2) + strlen(cabname) + 1))) return NULL;
42
-
43
- /* add the directory path from the original cabinet name, or "." */
44
- if (tail) memcpy(cab, origcab, (size_t) len);
45
- else cab[0]='.', cab[1]='/', len=2;
46
- cab[len] = '\0';
47
-
48
- /* try accessing the cabinet with its current name (case-sensitive) */
49
- strcpy(&cab[len], cabname);
50
- if (stat(cab, &st_buf) == 0) {
51
- found = 1;
52
- }
53
- else {
54
- /* cabinet was not found, look for it in the current dir */
55
- cab[len] = '\0';
56
- if ((dir = opendir(cab))) {
57
- while ((entry = readdir(dir))) {
58
- if (strcasecmp(cabname, entry->d_name) == 0) {
59
- strcat(cab, entry->d_name);
60
- found = (stat(cab, &st_buf) == 0);
61
- break;
62
- }
63
- }
64
- closedir(dir);
65
- }
66
- }
67
-
68
- if (!found || !S_ISREG(st_buf.st_mode)) {
69
- /* cabinet not found, or not a regular file */
70
- free(cab);
71
- cab = NULL;
72
- }
73
-
74
- return cab;
75
- }
76
-
77
-
78
- int main(int argc, char *argv[]) {
79
- struct mscab_decompressor *cabd;
80
- struct mscabd_cabinet *cab, *c, *c2;
81
- struct mscabd_file *file;
82
- char *cabname, *newname;
83
- int err;
84
-
85
- setbuf(stdout, NULL);
86
- setbuf(stderr, NULL);
87
-
88
- /* if self-test reveals an error */
89
- MSPACK_SYS_SELFTEST(err);
90
- if (err) return 1;
91
-
92
- if (!(cabd = mspack_create_cab_decompressor(&read_files_write_md5))) {
93
- fprintf(stderr, "can't make decompressor\n");
94
- return 1;
95
- }
96
-
97
- for (argv++; (cabname = *argv); argv++) {
98
- printf("*** %s\n", cabname);
99
-
100
- if (!(cab = cabd->open(cabd, cabname))) {
101
- fprintf(stderr, "cab open error: %s\n", ERROR(cabd));
102
- continue;
103
- }
104
-
105
- /* prepend any spanning cabinets */
106
- for (c = cab; c && (c->flags & MSCAB_HDR_PREVCAB); c = c->prevcab) {
107
- if (!(newname = find_cabinet_file(cabname, c->prevname))) {
108
- fprintf(stderr, "%s: can't find \"%s\" to prepend\n",
109
- cabname, c->prevname);
110
- break;
111
- }
112
- if (!(c2 = cabd->open(cabd, newname))) {
113
- fprintf(stderr, "%s: error opening \"%s\" for prepend: %s\n",
114
- cabname, newname, ERROR(cabd));
115
- break;
116
- }
117
- if (cabd->prepend(cabd, c, c2) != MSPACK_ERR_OK) {
118
- fprintf(stderr, "%s: error prepending \"%s\": %s\n",
119
- cabname, newname, ERROR(cabd));
120
- break;
121
- }
122
- }
123
-
124
- /* append any spanning cabinets */
125
- for (c = cab; c && (c->flags & MSCAB_HDR_NEXTCAB); c = c->nextcab) {
126
- if (!(newname = find_cabinet_file(cabname, c->nextname))) {
127
- fprintf(stderr, "%s: can't find \"%s\" to append\n",
128
- cabname, c->nextname);
129
- break;
130
- }
131
- if (!(c2 = cabd->open(cabd, newname))) {
132
- fprintf(stderr, "%s: error opening \"%s\" for append: %s\n",
133
- cabname, newname, ERROR(cabd));
134
- break;
135
- }
136
- if (cabd->append(cabd, c, c2) != MSPACK_ERR_OK) {
137
- fprintf(stderr, "%s: error appending \"%s\": %s\n",
138
- cabname, newname, ERROR(cabd));
139
- break;
140
- }
141
- }
142
-
143
- /* extract files */
144
- for (file = cab->files; file; file = file->next ) {
145
- if (cabd->extract(cabd, file, NULL) == MSPACK_ERR_OK) {
146
- printf("%s %s\n", md5_string, file->filename);
147
- }
148
- else {
149
- fprintf(stderr, "%s: error extracting \"%s\": %s\n",
150
- cabname, file->filename, ERROR(cabd));
151
- }
152
- }
153
-
154
- /* free all resources */
155
- for (c2 = cab->prevcab; c2; c2 = c2->prevcab) free((void*)c2->filename);
156
- for (c2 = cab->nextcab; c2; c2 = c2->nextcab) free((void*)c2->filename);
157
- cabd->close(cabd, cab);
158
- }
159
- mspack_destroy_cab_decompressor(cabd);
160
- return 0;
161
- }