UrgentcareCLI 0.1.1 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/UrgentCare/CLI.rb +1 -2
- data/lib/UrgentCare/Scraper.rb +65 -0
- data/lib/UrgentCare/version.rb +2 -2
- data/lib/UrgentCare.rb +1 -0
- metadata +3 -313
- data/.gitignore +0 -11
- data/.rspec +0 -3
- data/.travis.yml +0 -5
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -12
- data/Gemfile.lock +0 -84
- data/LICENSE.txt +0 -21
- data/Notes +0 -41
- data/README.md +0 -41
- data/Rakefile +0 -8
- data/UrgentCare.gemspec +0 -39
- data/background.jpg +0 -0
- data/data.txt +0 -4
- data/lib/Urgentcare/Scraper.rb +0 -78
- data/node_modules/.bin/rimraf +0 -1
- data/node_modules/.package-lock.json +0 -250
- data/node_modules/balanced-match/.github/FUNDING.yml +0 -2
- data/node_modules/balanced-match/LICENSE.md +0 -21
- data/node_modules/balanced-match/README.md +0 -97
- data/node_modules/balanced-match/index.js +0 -62
- data/node_modules/balanced-match/package.json +0 -48
- data/node_modules/brace-expansion/LICENSE +0 -21
- data/node_modules/brace-expansion/README.md +0 -129
- data/node_modules/brace-expansion/index.js +0 -201
- data/node_modules/brace-expansion/package.json +0 -47
- data/node_modules/concat-map/.travis.yml +0 -4
- data/node_modules/concat-map/LICENSE +0 -18
- data/node_modules/concat-map/README.markdown +0 -62
- data/node_modules/concat-map/example/map.js +0 -6
- data/node_modules/concat-map/index.js +0 -13
- data/node_modules/concat-map/package.json +0 -43
- data/node_modules/concat-map/test/map.js +0 -39
- data/node_modules/core-util-is/LICENSE +0 -19
- data/node_modules/core-util-is/README.md +0 -3
- data/node_modules/core-util-is/float.patch +0 -604
- data/node_modules/core-util-is/lib/util.js +0 -107
- data/node_modules/core-util-is/package.json +0 -32
- data/node_modules/core-util-is/test.js +0 -68
- data/node_modules/fs.realpath/LICENSE +0 -43
- data/node_modules/fs.realpath/README.md +0 -33
- data/node_modules/fs.realpath/index.js +0 -66
- data/node_modules/fs.realpath/old.js +0 -303
- data/node_modules/fs.realpath/package.json +0 -26
- data/node_modules/glob/LICENSE +0 -21
- data/node_modules/glob/README.md +0 -375
- data/node_modules/glob/changelog.md +0 -67
- data/node_modules/glob/common.js +0 -234
- data/node_modules/glob/glob.js +0 -788
- data/node_modules/glob/package.json +0 -51
- data/node_modules/glob/sync.js +0 -484
- data/node_modules/immediate/LICENSE.txt +0 -20
- data/node_modules/immediate/README.md +0 -93
- data/node_modules/immediate/dist/immediate.js +0 -75
- data/node_modules/immediate/dist/immediate.min.js +0 -1
- data/node_modules/immediate/lib/browser.js +0 -69
- data/node_modules/immediate/lib/index.js +0 -73
- data/node_modules/immediate/package.json +0 -42
- data/node_modules/inflight/LICENSE +0 -15
- data/node_modules/inflight/README.md +0 -37
- data/node_modules/inflight/inflight.js +0 -54
- data/node_modules/inflight/package.json +0 -29
- data/node_modules/inherits/LICENSE +0 -16
- data/node_modules/inherits/README.md +0 -42
- data/node_modules/inherits/inherits.js +0 -9
- data/node_modules/inherits/inherits_browser.js +0 -27
- data/node_modules/inherits/package.json +0 -29
- data/node_modules/isarray/.npmignore +0 -1
- data/node_modules/isarray/.travis.yml +0 -4
- data/node_modules/isarray/Makefile +0 -6
- data/node_modules/isarray/README.md +0 -60
- data/node_modules/isarray/component.json +0 -19
- data/node_modules/isarray/index.js +0 -5
- data/node_modules/isarray/package.json +0 -45
- data/node_modules/isarray/test.js +0 -20
- data/node_modules/jszip/.codeclimate.yml +0 -16
- data/node_modules/jszip/.editorconfig +0 -8
- data/node_modules/jszip/.jshintignore +0 -1
- data/node_modules/jszip/.jshintrc +0 -21
- data/node_modules/jszip/.travis.yml +0 -17
- data/node_modules/jszip/CHANGES.md +0 -163
- data/node_modules/jszip/LICENSE.markdown +0 -651
- data/node_modules/jszip/README.markdown +0 -35
- data/node_modules/jszip/dist/jszip.js +0 -30
- data/node_modules/jszip/dist/jszip.min.js +0 -13
- data/node_modules/jszip/index.d.ts +0 -270
- data/node_modules/jszip/lib/base64.js +0 -106
- data/node_modules/jszip/lib/compressedObject.js +0 -74
- data/node_modules/jszip/lib/compressions.js +0 -14
- data/node_modules/jszip/lib/crc32.js +0 -77
- data/node_modules/jszip/lib/defaults.js +0 -11
- data/node_modules/jszip/lib/external.js +0 -19
- data/node_modules/jszip/lib/flate.js +0 -85
- data/node_modules/jszip/lib/generate/ZipFileWorker.js +0 -540
- data/node_modules/jszip/lib/generate/index.js +0 -57
- data/node_modules/jszip/lib/index.js +0 -52
- data/node_modules/jszip/lib/license_header.js +0 -11
- data/node_modules/jszip/lib/load.js +0 -81
- data/node_modules/jszip/lib/nodejs/NodejsStreamInputAdapter.js +0 -74
- data/node_modules/jszip/lib/nodejs/NodejsStreamOutputAdapter.js +0 -42
- data/node_modules/jszip/lib/nodejsUtils.js +0 -57
- data/node_modules/jszip/lib/object.js +0 -389
- data/node_modules/jszip/lib/readable-stream-browser.js +0 -9
- data/node_modules/jszip/lib/reader/ArrayReader.js +0 -57
- data/node_modules/jszip/lib/reader/DataReader.js +0 -116
- data/node_modules/jszip/lib/reader/NodeBufferReader.js +0 -19
- data/node_modules/jszip/lib/reader/StringReader.js +0 -38
- data/node_modules/jszip/lib/reader/Uint8ArrayReader.js +0 -22
- data/node_modules/jszip/lib/reader/readerFor.js +0 -28
- data/node_modules/jszip/lib/signature.js +0 -7
- data/node_modules/jszip/lib/stream/ConvertWorker.js +0 -26
- data/node_modules/jszip/lib/stream/Crc32Probe.js +0 -24
- data/node_modules/jszip/lib/stream/DataLengthProbe.js +0 -29
- data/node_modules/jszip/lib/stream/DataWorker.js +0 -116
- data/node_modules/jszip/lib/stream/GenericWorker.js +0 -263
- data/node_modules/jszip/lib/stream/StreamHelper.js +0 -212
- data/node_modules/jszip/lib/support.js +0 -38
- data/node_modules/jszip/lib/utf8.js +0 -275
- data/node_modules/jszip/lib/utils.js +0 -476
- data/node_modules/jszip/lib/zipEntries.js +0 -262
- data/node_modules/jszip/lib/zipEntry.js +0 -294
- data/node_modules/jszip/lib/zipObject.js +0 -133
- data/node_modules/jszip/package.json +0 -63
- data/node_modules/jszip/vendor/FileSaver.js +0 -247
- data/node_modules/lie/README.md +0 -62
- data/node_modules/lie/dist/lie.js +0 -350
- data/node_modules/lie/dist/lie.min.js +0 -1
- data/node_modules/lie/dist/lie.polyfill.js +0 -358
- data/node_modules/lie/dist/lie.polyfill.min.js +0 -1
- data/node_modules/lie/lib/browser.js +0 -273
- data/node_modules/lie/lib/index.js +0 -298
- data/node_modules/lie/license.md +0 -7
- data/node_modules/lie/lie.d.ts +0 -244
- data/node_modules/lie/package.json +0 -69
- data/node_modules/lie/polyfill.js +0 -4
- data/node_modules/minimatch/LICENSE +0 -15
- data/node_modules/minimatch/README.md +0 -209
- data/node_modules/minimatch/minimatch.js +0 -923
- data/node_modules/minimatch/package.json +0 -30
- data/node_modules/once/LICENSE +0 -15
- data/node_modules/once/README.md +0 -79
- data/node_modules/once/once.js +0 -42
- data/node_modules/once/package.json +0 -33
- data/node_modules/pako/CHANGELOG.md +0 -164
- data/node_modules/pako/LICENSE +0 -21
- data/node_modules/pako/README.md +0 -191
- data/node_modules/pako/dist/pako.js +0 -6818
- data/node_modules/pako/dist/pako.min.js +0 -1
- data/node_modules/pako/dist/pako_deflate.js +0 -3997
- data/node_modules/pako/dist/pako_deflate.min.js +0 -1
- data/node_modules/pako/dist/pako_inflate.js +0 -3300
- data/node_modules/pako/dist/pako_inflate.min.js +0 -1
- data/node_modules/pako/index.js +0 -14
- data/node_modules/pako/lib/deflate.js +0 -400
- data/node_modules/pako/lib/inflate.js +0 -423
- data/node_modules/pako/lib/utils/common.js +0 -105
- data/node_modules/pako/lib/utils/strings.js +0 -187
- data/node_modules/pako/lib/zlib/README +0 -59
- data/node_modules/pako/lib/zlib/adler32.js +0 -51
- data/node_modules/pako/lib/zlib/constants.js +0 -68
- data/node_modules/pako/lib/zlib/crc32.js +0 -59
- data/node_modules/pako/lib/zlib/deflate.js +0 -1874
- data/node_modules/pako/lib/zlib/gzheader.js +0 -58
- data/node_modules/pako/lib/zlib/inffast.js +0 -345
- data/node_modules/pako/lib/zlib/inflate.js +0 -1556
- data/node_modules/pako/lib/zlib/inftrees.js +0 -343
- data/node_modules/pako/lib/zlib/messages.js +0 -32
- data/node_modules/pako/lib/zlib/trees.js +0 -1222
- data/node_modules/pako/lib/zlib/zstream.js +0 -47
- data/node_modules/pako/package.json +0 -44
- data/node_modules/path-is-absolute/index.js +0 -20
- data/node_modules/path-is-absolute/license +0 -21
- data/node_modules/path-is-absolute/package.json +0 -43
- data/node_modules/path-is-absolute/readme.md +0 -59
- data/node_modules/process-nextick-args/index.js +0 -45
- data/node_modules/process-nextick-args/license.md +0 -19
- data/node_modules/process-nextick-args/package.json +0 -25
- data/node_modules/process-nextick-args/readme.md +0 -18
- data/node_modules/readable-stream/.travis.yml +0 -34
- data/node_modules/readable-stream/CONTRIBUTING.md +0 -38
- data/node_modules/readable-stream/GOVERNANCE.md +0 -136
- data/node_modules/readable-stream/LICENSE +0 -47
- data/node_modules/readable-stream/README.md +0 -58
- data/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +0 -60
- data/node_modules/readable-stream/duplex-browser.js +0 -1
- data/node_modules/readable-stream/duplex.js +0 -1
- data/node_modules/readable-stream/lib/_stream_duplex.js +0 -131
- data/node_modules/readable-stream/lib/_stream_passthrough.js +0 -47
- data/node_modules/readable-stream/lib/_stream_readable.js +0 -1019
- data/node_modules/readable-stream/lib/_stream_transform.js +0 -214
- data/node_modules/readable-stream/lib/_stream_writable.js +0 -687
- data/node_modules/readable-stream/lib/internal/streams/BufferList.js +0 -79
- data/node_modules/readable-stream/lib/internal/streams/destroy.js +0 -74
- data/node_modules/readable-stream/lib/internal/streams/stream-browser.js +0 -1
- data/node_modules/readable-stream/lib/internal/streams/stream.js +0 -1
- data/node_modules/readable-stream/package.json +0 -52
- data/node_modules/readable-stream/passthrough.js +0 -1
- data/node_modules/readable-stream/readable-browser.js +0 -7
- data/node_modules/readable-stream/readable.js +0 -19
- data/node_modules/readable-stream/transform.js +0 -1
- data/node_modules/readable-stream/writable-browser.js +0 -1
- data/node_modules/readable-stream/writable.js +0 -8
- data/node_modules/rimraf/LICENSE +0 -15
- data/node_modules/rimraf/README.md +0 -101
- data/node_modules/rimraf/bin.js +0 -50
- data/node_modules/rimraf/package.json +0 -29
- data/node_modules/rimraf/rimraf.js +0 -372
- data/node_modules/safe-buffer/LICENSE +0 -21
- data/node_modules/safe-buffer/README.md +0 -584
- data/node_modules/safe-buffer/index.d.ts +0 -187
- data/node_modules/safe-buffer/index.js +0 -62
- data/node_modules/safe-buffer/package.json +0 -37
- data/node_modules/selenium-webdriver/CHANGES.md +0 -1114
- data/node_modules/selenium-webdriver/LICENSE +0 -202
- data/node_modules/selenium-webdriver/NOTICE +0 -2
- data/node_modules/selenium-webdriver/README.md +0 -229
- data/node_modules/selenium-webdriver/chrome.js +0 -295
- data/node_modules/selenium-webdriver/chromium.js +0 -829
- data/node_modules/selenium-webdriver/devtools/CDPConnection.js +0 -35
- data/node_modules/selenium-webdriver/edge.js +0 -224
- data/node_modules/selenium-webdriver/example/chrome_android.js +0 -45
- data/node_modules/selenium-webdriver/example/chrome_mobile_emulation.js +0 -46
- data/node_modules/selenium-webdriver/example/firefox_channels.js +0 -84
- data/node_modules/selenium-webdriver/example/google_search.js +0 -50
- data/node_modules/selenium-webdriver/example/google_search_test.js +0 -70
- data/node_modules/selenium-webdriver/example/headless.js +0 -63
- data/node_modules/selenium-webdriver/example/logging.js +0 -64
- data/node_modules/selenium-webdriver/firefox.js +0 -789
- data/node_modules/selenium-webdriver/http/index.js +0 -324
- data/node_modules/selenium-webdriver/http/util.js +0 -172
- data/node_modules/selenium-webdriver/ie.js +0 -503
- data/node_modules/selenium-webdriver/index.js +0 -825
- data/node_modules/selenium-webdriver/io/exec.js +0 -162
- data/node_modules/selenium-webdriver/io/index.js +0 -348
- data/node_modules/selenium-webdriver/io/zip.js +0 -223
- data/node_modules/selenium-webdriver/lib/atoms/find-elements.js +0 -123
- data/node_modules/selenium-webdriver/lib/atoms/get-attribute.js +0 -101
- data/node_modules/selenium-webdriver/lib/atoms/is-displayed.js +0 -101
- data/node_modules/selenium-webdriver/lib/atoms/mutation-listener.js +0 -55
- data/node_modules/selenium-webdriver/lib/by.js +0 -415
- data/node_modules/selenium-webdriver/lib/capabilities.js +0 -553
- data/node_modules/selenium-webdriver/lib/command.js +0 -206
- data/node_modules/selenium-webdriver/lib/error.js +0 -605
- data/node_modules/selenium-webdriver/lib/http.js +0 -704
- data/node_modules/selenium-webdriver/lib/input.js +0 -946
- data/node_modules/selenium-webdriver/lib/logging.js +0 -661
- data/node_modules/selenium-webdriver/lib/promise.js +0 -285
- data/node_modules/selenium-webdriver/lib/proxy.js +0 -212
- data/node_modules/selenium-webdriver/lib/session.js +0 -77
- data/node_modules/selenium-webdriver/lib/symbols.js +0 -37
- data/node_modules/selenium-webdriver/lib/until.js +0 -429
- data/node_modules/selenium-webdriver/lib/webdriver.js +0 -2919
- data/node_modules/selenium-webdriver/net/index.js +0 -107
- data/node_modules/selenium-webdriver/net/portprober.js +0 -75
- data/node_modules/selenium-webdriver/opera.js +0 -406
- data/node_modules/selenium-webdriver/package.json +0 -54
- data/node_modules/selenium-webdriver/proxy.js +0 -32
- data/node_modules/selenium-webdriver/remote/index.js +0 -624
- data/node_modules/selenium-webdriver/safari.js +0 -168
- data/node_modules/selenium-webdriver/testing/index.js +0 -504
- data/node_modules/set-immediate-shim/index.js +0 -7
- data/node_modules/set-immediate-shim/package.json +0 -34
- data/node_modules/set-immediate-shim/readme.md +0 -31
- data/node_modules/string_decoder/.travis.yml +0 -50
- data/node_modules/string_decoder/LICENSE +0 -48
- data/node_modules/string_decoder/README.md +0 -47
- data/node_modules/string_decoder/lib/string_decoder.js +0 -296
- data/node_modules/string_decoder/package.json +0 -31
- data/node_modules/tmp/CHANGELOG.md +0 -288
- data/node_modules/tmp/LICENSE +0 -21
- data/node_modules/tmp/README.md +0 -365
- data/node_modules/tmp/lib/tmp.js +0 -780
- data/node_modules/tmp/node_modules/.bin/rimraf +0 -1
- data/node_modules/tmp/node_modules/rimraf/CHANGELOG.md +0 -65
- data/node_modules/tmp/node_modules/rimraf/LICENSE +0 -15
- data/node_modules/tmp/node_modules/rimraf/README.md +0 -101
- data/node_modules/tmp/node_modules/rimraf/bin.js +0 -68
- data/node_modules/tmp/node_modules/rimraf/package.json +0 -32
- data/node_modules/tmp/node_modules/rimraf/rimraf.js +0 -360
- data/node_modules/tmp/package.json +0 -58
- data/node_modules/util-deprecate/History.md +0 -16
- data/node_modules/util-deprecate/LICENSE +0 -24
- data/node_modules/util-deprecate/README.md +0 -53
- data/node_modules/util-deprecate/browser.js +0 -67
- data/node_modules/util-deprecate/node.js +0 -6
- data/node_modules/util-deprecate/package.json +0 -27
- data/node_modules/wrappy/LICENSE +0 -15
- data/node_modules/wrappy/README.md +0 -36
- data/node_modules/wrappy/package.json +0 -29
- data/node_modules/wrappy/wrappy.js +0 -33
- data/node_modules/ws/LICENSE +0 -21
- data/node_modules/ws/README.md +0 -496
- data/node_modules/ws/browser.js +0 -8
- data/node_modules/ws/index.js +0 -10
- data/node_modules/ws/lib/buffer-util.js +0 -129
- data/node_modules/ws/lib/constants.js +0 -10
- data/node_modules/ws/lib/event-target.js +0 -184
- data/node_modules/ws/lib/extension.js +0 -223
- data/node_modules/ws/lib/limiter.js +0 -55
- data/node_modules/ws/lib/permessage-deflate.js +0 -517
- data/node_modules/ws/lib/receiver.js +0 -507
- data/node_modules/ws/lib/sender.js +0 -405
- data/node_modules/ws/lib/stream.js +0 -165
- data/node_modules/ws/lib/validation.js +0 -104
- data/node_modules/ws/lib/websocket-server.js +0 -418
- data/node_modules/ws/lib/websocket.js +0 -942
- data/node_modules/ws/package.json +0 -56
- data/package-lock.json +0 -458
- data/package.json +0 -5
- data/selenium.log +0 -1
- data/spec.md +0 -6
- data/test.data +0 -2110
@@ -1,58 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
// (C) 1995-2013 Jean-loup Gailly and Mark Adler
|
4
|
-
// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
|
5
|
-
//
|
6
|
-
// This software is provided 'as-is', without any express or implied
|
7
|
-
// warranty. In no event will the authors be held liable for any damages
|
8
|
-
// arising from the use of this software.
|
9
|
-
//
|
10
|
-
// Permission is granted to anyone to use this software for any purpose,
|
11
|
-
// including commercial applications, and to alter it and redistribute it
|
12
|
-
// freely, subject to the following restrictions:
|
13
|
-
//
|
14
|
-
// 1. The origin of this software must not be misrepresented; you must not
|
15
|
-
// claim that you wrote the original software. If you use this software
|
16
|
-
// in a product, an acknowledgment in the product documentation would be
|
17
|
-
// appreciated but is not required.
|
18
|
-
// 2. Altered source versions must be plainly marked as such, and must not be
|
19
|
-
// misrepresented as being the original software.
|
20
|
-
// 3. This notice may not be removed or altered from any source distribution.
|
21
|
-
|
22
|
-
function GZheader() {
|
23
|
-
/* true if compressed data believed to be text */
|
24
|
-
this.text = 0;
|
25
|
-
/* modification time */
|
26
|
-
this.time = 0;
|
27
|
-
/* extra flags (not used when writing a gzip file) */
|
28
|
-
this.xflags = 0;
|
29
|
-
/* operating system */
|
30
|
-
this.os = 0;
|
31
|
-
/* pointer to extra field or Z_NULL if none */
|
32
|
-
this.extra = null;
|
33
|
-
/* extra field length (valid if extra != Z_NULL) */
|
34
|
-
this.extra_len = 0; // Actually, we don't need it in JS,
|
35
|
-
// but leave for few code modifications
|
36
|
-
|
37
|
-
//
|
38
|
-
// Setup limits is not necessary because in js we should not preallocate memory
|
39
|
-
// for inflate use constant limit in 65536 bytes
|
40
|
-
//
|
41
|
-
|
42
|
-
/* space at extra (only when reading header) */
|
43
|
-
// this.extra_max = 0;
|
44
|
-
/* pointer to zero-terminated file name or Z_NULL */
|
45
|
-
this.name = '';
|
46
|
-
/* space at name (only when reading header) */
|
47
|
-
// this.name_max = 0;
|
48
|
-
/* pointer to zero-terminated comment or Z_NULL */
|
49
|
-
this.comment = '';
|
50
|
-
/* space at comment (only when reading header) */
|
51
|
-
// this.comm_max = 0;
|
52
|
-
/* true if there was or will be a header crc */
|
53
|
-
this.hcrc = 0;
|
54
|
-
/* true when done reading gzip header (not used when writing a gzip file) */
|
55
|
-
this.done = false;
|
56
|
-
}
|
57
|
-
|
58
|
-
module.exports = GZheader;
|
@@ -1,345 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
// (C) 1995-2013 Jean-loup Gailly and Mark Adler
|
4
|
-
// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
|
5
|
-
//
|
6
|
-
// This software is provided 'as-is', without any express or implied
|
7
|
-
// warranty. In no event will the authors be held liable for any damages
|
8
|
-
// arising from the use of this software.
|
9
|
-
//
|
10
|
-
// Permission is granted to anyone to use this software for any purpose,
|
11
|
-
// including commercial applications, and to alter it and redistribute it
|
12
|
-
// freely, subject to the following restrictions:
|
13
|
-
//
|
14
|
-
// 1. The origin of this software must not be misrepresented; you must not
|
15
|
-
// claim that you wrote the original software. If you use this software
|
16
|
-
// in a product, an acknowledgment in the product documentation would be
|
17
|
-
// appreciated but is not required.
|
18
|
-
// 2. Altered source versions must be plainly marked as such, and must not be
|
19
|
-
// misrepresented as being the original software.
|
20
|
-
// 3. This notice may not be removed or altered from any source distribution.
|
21
|
-
|
22
|
-
// See state defs from inflate.js
|
23
|
-
var BAD = 30; /* got a data error -- remain here until reset */
|
24
|
-
var TYPE = 12; /* i: waiting for type bits, including last-flag bit */
|
25
|
-
|
26
|
-
/*
|
27
|
-
Decode literal, length, and distance codes and write out the resulting
|
28
|
-
literal and match bytes until either not enough input or output is
|
29
|
-
available, an end-of-block is encountered, or a data error is encountered.
|
30
|
-
When large enough input and output buffers are supplied to inflate(), for
|
31
|
-
example, a 16K input buffer and a 64K output buffer, more than 95% of the
|
32
|
-
inflate execution time is spent in this routine.
|
33
|
-
|
34
|
-
Entry assumptions:
|
35
|
-
|
36
|
-
state.mode === LEN
|
37
|
-
strm.avail_in >= 6
|
38
|
-
strm.avail_out >= 258
|
39
|
-
start >= strm.avail_out
|
40
|
-
state.bits < 8
|
41
|
-
|
42
|
-
On return, state.mode is one of:
|
43
|
-
|
44
|
-
LEN -- ran out of enough output space or enough available input
|
45
|
-
TYPE -- reached end of block code, inflate() to interpret next block
|
46
|
-
BAD -- error in block data
|
47
|
-
|
48
|
-
Notes:
|
49
|
-
|
50
|
-
- The maximum input bits used by a length/distance pair is 15 bits for the
|
51
|
-
length code, 5 bits for the length extra, 15 bits for the distance code,
|
52
|
-
and 13 bits for the distance extra. This totals 48 bits, or six bytes.
|
53
|
-
Therefore if strm.avail_in >= 6, then there is enough input to avoid
|
54
|
-
checking for available input while decoding.
|
55
|
-
|
56
|
-
- The maximum bytes that a single length/distance pair can output is 258
|
57
|
-
bytes, which is the maximum length that can be coded. inflate_fast()
|
58
|
-
requires strm.avail_out >= 258 for each loop to avoid checking for
|
59
|
-
output space.
|
60
|
-
*/
|
61
|
-
module.exports = function inflate_fast(strm, start) {
|
62
|
-
var state;
|
63
|
-
var _in; /* local strm.input */
|
64
|
-
var last; /* have enough input while in < last */
|
65
|
-
var _out; /* local strm.output */
|
66
|
-
var beg; /* inflate()'s initial strm.output */
|
67
|
-
var end; /* while out < end, enough space available */
|
68
|
-
//#ifdef INFLATE_STRICT
|
69
|
-
var dmax; /* maximum distance from zlib header */
|
70
|
-
//#endif
|
71
|
-
var wsize; /* window size or zero if not using window */
|
72
|
-
var whave; /* valid bytes in the window */
|
73
|
-
var wnext; /* window write index */
|
74
|
-
// Use `s_window` instead `window`, avoid conflict with instrumentation tools
|
75
|
-
var s_window; /* allocated sliding window, if wsize != 0 */
|
76
|
-
var hold; /* local strm.hold */
|
77
|
-
var bits; /* local strm.bits */
|
78
|
-
var lcode; /* local strm.lencode */
|
79
|
-
var dcode; /* local strm.distcode */
|
80
|
-
var lmask; /* mask for first level of length codes */
|
81
|
-
var dmask; /* mask for first level of distance codes */
|
82
|
-
var here; /* retrieved table entry */
|
83
|
-
var op; /* code bits, operation, extra bits, or */
|
84
|
-
/* window position, window bytes to copy */
|
85
|
-
var len; /* match length, unused bytes */
|
86
|
-
var dist; /* match distance */
|
87
|
-
var from; /* where to copy match from */
|
88
|
-
var from_source;
|
89
|
-
|
90
|
-
|
91
|
-
var input, output; // JS specific, because we have no pointers
|
92
|
-
|
93
|
-
/* copy state to local variables */
|
94
|
-
state = strm.state;
|
95
|
-
//here = state.here;
|
96
|
-
_in = strm.next_in;
|
97
|
-
input = strm.input;
|
98
|
-
last = _in + (strm.avail_in - 5);
|
99
|
-
_out = strm.next_out;
|
100
|
-
output = strm.output;
|
101
|
-
beg = _out - (start - strm.avail_out);
|
102
|
-
end = _out + (strm.avail_out - 257);
|
103
|
-
//#ifdef INFLATE_STRICT
|
104
|
-
dmax = state.dmax;
|
105
|
-
//#endif
|
106
|
-
wsize = state.wsize;
|
107
|
-
whave = state.whave;
|
108
|
-
wnext = state.wnext;
|
109
|
-
s_window = state.window;
|
110
|
-
hold = state.hold;
|
111
|
-
bits = state.bits;
|
112
|
-
lcode = state.lencode;
|
113
|
-
dcode = state.distcode;
|
114
|
-
lmask = (1 << state.lenbits) - 1;
|
115
|
-
dmask = (1 << state.distbits) - 1;
|
116
|
-
|
117
|
-
|
118
|
-
/* decode literals and length/distances until end-of-block or not enough
|
119
|
-
input data or output space */
|
120
|
-
|
121
|
-
top:
|
122
|
-
do {
|
123
|
-
if (bits < 15) {
|
124
|
-
hold += input[_in++] << bits;
|
125
|
-
bits += 8;
|
126
|
-
hold += input[_in++] << bits;
|
127
|
-
bits += 8;
|
128
|
-
}
|
129
|
-
|
130
|
-
here = lcode[hold & lmask];
|
131
|
-
|
132
|
-
dolen:
|
133
|
-
for (;;) { // Goto emulation
|
134
|
-
op = here >>> 24/*here.bits*/;
|
135
|
-
hold >>>= op;
|
136
|
-
bits -= op;
|
137
|
-
op = (here >>> 16) & 0xff/*here.op*/;
|
138
|
-
if (op === 0) { /* literal */
|
139
|
-
//Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
|
140
|
-
// "inflate: literal '%c'\n" :
|
141
|
-
// "inflate: literal 0x%02x\n", here.val));
|
142
|
-
output[_out++] = here & 0xffff/*here.val*/;
|
143
|
-
}
|
144
|
-
else if (op & 16) { /* length base */
|
145
|
-
len = here & 0xffff/*here.val*/;
|
146
|
-
op &= 15; /* number of extra bits */
|
147
|
-
if (op) {
|
148
|
-
if (bits < op) {
|
149
|
-
hold += input[_in++] << bits;
|
150
|
-
bits += 8;
|
151
|
-
}
|
152
|
-
len += hold & ((1 << op) - 1);
|
153
|
-
hold >>>= op;
|
154
|
-
bits -= op;
|
155
|
-
}
|
156
|
-
//Tracevv((stderr, "inflate: length %u\n", len));
|
157
|
-
if (bits < 15) {
|
158
|
-
hold += input[_in++] << bits;
|
159
|
-
bits += 8;
|
160
|
-
hold += input[_in++] << bits;
|
161
|
-
bits += 8;
|
162
|
-
}
|
163
|
-
here = dcode[hold & dmask];
|
164
|
-
|
165
|
-
dodist:
|
166
|
-
for (;;) { // goto emulation
|
167
|
-
op = here >>> 24/*here.bits*/;
|
168
|
-
hold >>>= op;
|
169
|
-
bits -= op;
|
170
|
-
op = (here >>> 16) & 0xff/*here.op*/;
|
171
|
-
|
172
|
-
if (op & 16) { /* distance base */
|
173
|
-
dist = here & 0xffff/*here.val*/;
|
174
|
-
op &= 15; /* number of extra bits */
|
175
|
-
if (bits < op) {
|
176
|
-
hold += input[_in++] << bits;
|
177
|
-
bits += 8;
|
178
|
-
if (bits < op) {
|
179
|
-
hold += input[_in++] << bits;
|
180
|
-
bits += 8;
|
181
|
-
}
|
182
|
-
}
|
183
|
-
dist += hold & ((1 << op) - 1);
|
184
|
-
//#ifdef INFLATE_STRICT
|
185
|
-
if (dist > dmax) {
|
186
|
-
strm.msg = 'invalid distance too far back';
|
187
|
-
state.mode = BAD;
|
188
|
-
break top;
|
189
|
-
}
|
190
|
-
//#endif
|
191
|
-
hold >>>= op;
|
192
|
-
bits -= op;
|
193
|
-
//Tracevv((stderr, "inflate: distance %u\n", dist));
|
194
|
-
op = _out - beg; /* max distance in output */
|
195
|
-
if (dist > op) { /* see if copy from window */
|
196
|
-
op = dist - op; /* distance back in window */
|
197
|
-
if (op > whave) {
|
198
|
-
if (state.sane) {
|
199
|
-
strm.msg = 'invalid distance too far back';
|
200
|
-
state.mode = BAD;
|
201
|
-
break top;
|
202
|
-
}
|
203
|
-
|
204
|
-
// (!) This block is disabled in zlib defaults,
|
205
|
-
// don't enable it for binary compatibility
|
206
|
-
//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
|
207
|
-
// if (len <= op - whave) {
|
208
|
-
// do {
|
209
|
-
// output[_out++] = 0;
|
210
|
-
// } while (--len);
|
211
|
-
// continue top;
|
212
|
-
// }
|
213
|
-
// len -= op - whave;
|
214
|
-
// do {
|
215
|
-
// output[_out++] = 0;
|
216
|
-
// } while (--op > whave);
|
217
|
-
// if (op === 0) {
|
218
|
-
// from = _out - dist;
|
219
|
-
// do {
|
220
|
-
// output[_out++] = output[from++];
|
221
|
-
// } while (--len);
|
222
|
-
// continue top;
|
223
|
-
// }
|
224
|
-
//#endif
|
225
|
-
}
|
226
|
-
from = 0; // window index
|
227
|
-
from_source = s_window;
|
228
|
-
if (wnext === 0) { /* very common case */
|
229
|
-
from += wsize - op;
|
230
|
-
if (op < len) { /* some from window */
|
231
|
-
len -= op;
|
232
|
-
do {
|
233
|
-
output[_out++] = s_window[from++];
|
234
|
-
} while (--op);
|
235
|
-
from = _out - dist; /* rest from output */
|
236
|
-
from_source = output;
|
237
|
-
}
|
238
|
-
}
|
239
|
-
else if (wnext < op) { /* wrap around window */
|
240
|
-
from += wsize + wnext - op;
|
241
|
-
op -= wnext;
|
242
|
-
if (op < len) { /* some from end of window */
|
243
|
-
len -= op;
|
244
|
-
do {
|
245
|
-
output[_out++] = s_window[from++];
|
246
|
-
} while (--op);
|
247
|
-
from = 0;
|
248
|
-
if (wnext < len) { /* some from start of window */
|
249
|
-
op = wnext;
|
250
|
-
len -= op;
|
251
|
-
do {
|
252
|
-
output[_out++] = s_window[from++];
|
253
|
-
} while (--op);
|
254
|
-
from = _out - dist; /* rest from output */
|
255
|
-
from_source = output;
|
256
|
-
}
|
257
|
-
}
|
258
|
-
}
|
259
|
-
else { /* contiguous in window */
|
260
|
-
from += wnext - op;
|
261
|
-
if (op < len) { /* some from window */
|
262
|
-
len -= op;
|
263
|
-
do {
|
264
|
-
output[_out++] = s_window[from++];
|
265
|
-
} while (--op);
|
266
|
-
from = _out - dist; /* rest from output */
|
267
|
-
from_source = output;
|
268
|
-
}
|
269
|
-
}
|
270
|
-
while (len > 2) {
|
271
|
-
output[_out++] = from_source[from++];
|
272
|
-
output[_out++] = from_source[from++];
|
273
|
-
output[_out++] = from_source[from++];
|
274
|
-
len -= 3;
|
275
|
-
}
|
276
|
-
if (len) {
|
277
|
-
output[_out++] = from_source[from++];
|
278
|
-
if (len > 1) {
|
279
|
-
output[_out++] = from_source[from++];
|
280
|
-
}
|
281
|
-
}
|
282
|
-
}
|
283
|
-
else {
|
284
|
-
from = _out - dist; /* copy direct from output */
|
285
|
-
do { /* minimum length is three */
|
286
|
-
output[_out++] = output[from++];
|
287
|
-
output[_out++] = output[from++];
|
288
|
-
output[_out++] = output[from++];
|
289
|
-
len -= 3;
|
290
|
-
} while (len > 2);
|
291
|
-
if (len) {
|
292
|
-
output[_out++] = output[from++];
|
293
|
-
if (len > 1) {
|
294
|
-
output[_out++] = output[from++];
|
295
|
-
}
|
296
|
-
}
|
297
|
-
}
|
298
|
-
}
|
299
|
-
else if ((op & 64) === 0) { /* 2nd level distance code */
|
300
|
-
here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];
|
301
|
-
continue dodist;
|
302
|
-
}
|
303
|
-
else {
|
304
|
-
strm.msg = 'invalid distance code';
|
305
|
-
state.mode = BAD;
|
306
|
-
break top;
|
307
|
-
}
|
308
|
-
|
309
|
-
break; // need to emulate goto via "continue"
|
310
|
-
}
|
311
|
-
}
|
312
|
-
else if ((op & 64) === 0) { /* 2nd level length code */
|
313
|
-
here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];
|
314
|
-
continue dolen;
|
315
|
-
}
|
316
|
-
else if (op & 32) { /* end-of-block */
|
317
|
-
//Tracevv((stderr, "inflate: end of block\n"));
|
318
|
-
state.mode = TYPE;
|
319
|
-
break top;
|
320
|
-
}
|
321
|
-
else {
|
322
|
-
strm.msg = 'invalid literal/length code';
|
323
|
-
state.mode = BAD;
|
324
|
-
break top;
|
325
|
-
}
|
326
|
-
|
327
|
-
break; // need to emulate goto via "continue"
|
328
|
-
}
|
329
|
-
} while (_in < last && _out < end);
|
330
|
-
|
331
|
-
/* return unused bytes (on entry, bits < 8, so in won't go too far back) */
|
332
|
-
len = bits >> 3;
|
333
|
-
_in -= len;
|
334
|
-
bits -= len << 3;
|
335
|
-
hold &= (1 << bits) - 1;
|
336
|
-
|
337
|
-
/* update state and return */
|
338
|
-
strm.next_in = _in;
|
339
|
-
strm.next_out = _out;
|
340
|
-
strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));
|
341
|
-
strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));
|
342
|
-
state.hold = hold;
|
343
|
-
state.bits = bits;
|
344
|
-
return;
|
345
|
-
};
|
@@ -1,1556 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
// (C) 1995-2013 Jean-loup Gailly and Mark Adler
|
4
|
-
// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
|
5
|
-
//
|
6
|
-
// This software is provided 'as-is', without any express or implied
|
7
|
-
// warranty. In no event will the authors be held liable for any damages
|
8
|
-
// arising from the use of this software.
|
9
|
-
//
|
10
|
-
// Permission is granted to anyone to use this software for any purpose,
|
11
|
-
// including commercial applications, and to alter it and redistribute it
|
12
|
-
// freely, subject to the following restrictions:
|
13
|
-
//
|
14
|
-
// 1. The origin of this software must not be misrepresented; you must not
|
15
|
-
// claim that you wrote the original software. If you use this software
|
16
|
-
// in a product, an acknowledgment in the product documentation would be
|
17
|
-
// appreciated but is not required.
|
18
|
-
// 2. Altered source versions must be plainly marked as such, and must not be
|
19
|
-
// misrepresented as being the original software.
|
20
|
-
// 3. This notice may not be removed or altered from any source distribution.
|
21
|
-
|
22
|
-
var utils = require('../utils/common');
|
23
|
-
var adler32 = require('./adler32');
|
24
|
-
var crc32 = require('./crc32');
|
25
|
-
var inflate_fast = require('./inffast');
|
26
|
-
var inflate_table = require('./inftrees');
|
27
|
-
|
28
|
-
var CODES = 0;
|
29
|
-
var LENS = 1;
|
30
|
-
var DISTS = 2;
|
31
|
-
|
32
|
-
/* Public constants ==========================================================*/
|
33
|
-
/* ===========================================================================*/
|
34
|
-
|
35
|
-
|
36
|
-
/* Allowed flush values; see deflate() and inflate() below for details */
|
37
|
-
//var Z_NO_FLUSH = 0;
|
38
|
-
//var Z_PARTIAL_FLUSH = 1;
|
39
|
-
//var Z_SYNC_FLUSH = 2;
|
40
|
-
//var Z_FULL_FLUSH = 3;
|
41
|
-
var Z_FINISH = 4;
|
42
|
-
var Z_BLOCK = 5;
|
43
|
-
var Z_TREES = 6;
|
44
|
-
|
45
|
-
|
46
|
-
/* Return codes for the compression/decompression functions. Negative values
|
47
|
-
* are errors, positive values are used for special but normal events.
|
48
|
-
*/
|
49
|
-
var Z_OK = 0;
|
50
|
-
var Z_STREAM_END = 1;
|
51
|
-
var Z_NEED_DICT = 2;
|
52
|
-
//var Z_ERRNO = -1;
|
53
|
-
var Z_STREAM_ERROR = -2;
|
54
|
-
var Z_DATA_ERROR = -3;
|
55
|
-
var Z_MEM_ERROR = -4;
|
56
|
-
var Z_BUF_ERROR = -5;
|
57
|
-
//var Z_VERSION_ERROR = -6;
|
58
|
-
|
59
|
-
/* The deflate compression method */
|
60
|
-
var Z_DEFLATED = 8;
|
61
|
-
|
62
|
-
|
63
|
-
/* STATES ====================================================================*/
|
64
|
-
/* ===========================================================================*/
|
65
|
-
|
66
|
-
|
67
|
-
var HEAD = 1; /* i: waiting for magic header */
|
68
|
-
var FLAGS = 2; /* i: waiting for method and flags (gzip) */
|
69
|
-
var TIME = 3; /* i: waiting for modification time (gzip) */
|
70
|
-
var OS = 4; /* i: waiting for extra flags and operating system (gzip) */
|
71
|
-
var EXLEN = 5; /* i: waiting for extra length (gzip) */
|
72
|
-
var EXTRA = 6; /* i: waiting for extra bytes (gzip) */
|
73
|
-
var NAME = 7; /* i: waiting for end of file name (gzip) */
|
74
|
-
var COMMENT = 8; /* i: waiting for end of comment (gzip) */
|
75
|
-
var HCRC = 9; /* i: waiting for header crc (gzip) */
|
76
|
-
var DICTID = 10; /* i: waiting for dictionary check value */
|
77
|
-
var DICT = 11; /* waiting for inflateSetDictionary() call */
|
78
|
-
var TYPE = 12; /* i: waiting for type bits, including last-flag bit */
|
79
|
-
var TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */
|
80
|
-
var STORED = 14; /* i: waiting for stored size (length and complement) */
|
81
|
-
var COPY_ = 15; /* i/o: same as COPY below, but only first time in */
|
82
|
-
var COPY = 16; /* i/o: waiting for input or output to copy stored block */
|
83
|
-
var TABLE = 17; /* i: waiting for dynamic block table lengths */
|
84
|
-
var LENLENS = 18; /* i: waiting for code length code lengths */
|
85
|
-
var CODELENS = 19; /* i: waiting for length/lit and distance code lengths */
|
86
|
-
var LEN_ = 20; /* i: same as LEN below, but only first time in */
|
87
|
-
var LEN = 21; /* i: waiting for length/lit/eob code */
|
88
|
-
var LENEXT = 22; /* i: waiting for length extra bits */
|
89
|
-
var DIST = 23; /* i: waiting for distance code */
|
90
|
-
var DISTEXT = 24; /* i: waiting for distance extra bits */
|
91
|
-
var MATCH = 25; /* o: waiting for output space to copy string */
|
92
|
-
var LIT = 26; /* o: waiting for output space to write literal */
|
93
|
-
var CHECK = 27; /* i: waiting for 32-bit check value */
|
94
|
-
var LENGTH = 28; /* i: waiting for 32-bit length (gzip) */
|
95
|
-
var DONE = 29; /* finished check, done -- remain here until reset */
|
96
|
-
var BAD = 30; /* got a data error -- remain here until reset */
|
97
|
-
var MEM = 31; /* got an inflate() memory error -- remain here until reset */
|
98
|
-
var SYNC = 32; /* looking for synchronization bytes to restart inflate() */
|
99
|
-
|
100
|
-
/* ===========================================================================*/
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
var ENOUGH_LENS = 852;
|
105
|
-
var ENOUGH_DISTS = 592;
|
106
|
-
//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);
|
107
|
-
|
108
|
-
var MAX_WBITS = 15;
|
109
|
-
/* 32K LZ77 window */
|
110
|
-
var DEF_WBITS = MAX_WBITS;
|
111
|
-
|
112
|
-
|
113
|
-
function zswap32(q) {
|
114
|
-
return (((q >>> 24) & 0xff) +
|
115
|
-
((q >>> 8) & 0xff00) +
|
116
|
-
((q & 0xff00) << 8) +
|
117
|
-
((q & 0xff) << 24));
|
118
|
-
}
|
119
|
-
|
120
|
-
|
121
|
-
function InflateState() {
|
122
|
-
this.mode = 0; /* current inflate mode */
|
123
|
-
this.last = false; /* true if processing last block */
|
124
|
-
this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */
|
125
|
-
this.havedict = false; /* true if dictionary provided */
|
126
|
-
this.flags = 0; /* gzip header method and flags (0 if zlib) */
|
127
|
-
this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */
|
128
|
-
this.check = 0; /* protected copy of check value */
|
129
|
-
this.total = 0; /* protected copy of output count */
|
130
|
-
// TODO: may be {}
|
131
|
-
this.head = null; /* where to save gzip header information */
|
132
|
-
|
133
|
-
/* sliding window */
|
134
|
-
this.wbits = 0; /* log base 2 of requested window size */
|
135
|
-
this.wsize = 0; /* window size or zero if not using window */
|
136
|
-
this.whave = 0; /* valid bytes in the window */
|
137
|
-
this.wnext = 0; /* window write index */
|
138
|
-
this.window = null; /* allocated sliding window, if needed */
|
139
|
-
|
140
|
-
/* bit accumulator */
|
141
|
-
this.hold = 0; /* input bit accumulator */
|
142
|
-
this.bits = 0; /* number of bits in "in" */
|
143
|
-
|
144
|
-
/* for string and stored block copying */
|
145
|
-
this.length = 0; /* literal or length of data to copy */
|
146
|
-
this.offset = 0; /* distance back to copy string from */
|
147
|
-
|
148
|
-
/* for table and code decoding */
|
149
|
-
this.extra = 0; /* extra bits needed */
|
150
|
-
|
151
|
-
/* fixed and dynamic code tables */
|
152
|
-
this.lencode = null; /* starting table for length/literal codes */
|
153
|
-
this.distcode = null; /* starting table for distance codes */
|
154
|
-
this.lenbits = 0; /* index bits for lencode */
|
155
|
-
this.distbits = 0; /* index bits for distcode */
|
156
|
-
|
157
|
-
/* dynamic table building */
|
158
|
-
this.ncode = 0; /* number of code length code lengths */
|
159
|
-
this.nlen = 0; /* number of length code lengths */
|
160
|
-
this.ndist = 0; /* number of distance code lengths */
|
161
|
-
this.have = 0; /* number of code lengths in lens[] */
|
162
|
-
this.next = null; /* next available space in codes[] */
|
163
|
-
|
164
|
-
this.lens = new utils.Buf16(320); /* temporary storage for code lengths */
|
165
|
-
this.work = new utils.Buf16(288); /* work area for code table building */
|
166
|
-
|
167
|
-
/*
|
168
|
-
because we don't have pointers in js, we use lencode and distcode directly
|
169
|
-
as buffers so we don't need codes
|
170
|
-
*/
|
171
|
-
//this.codes = new utils.Buf32(ENOUGH); /* space for code tables */
|
172
|
-
this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */
|
173
|
-
this.distdyn = null; /* dynamic table for distance codes (JS specific) */
|
174
|
-
this.sane = 0; /* if false, allow invalid distance too far */
|
175
|
-
this.back = 0; /* bits back of last unprocessed length/lit */
|
176
|
-
this.was = 0; /* initial length of match */
|
177
|
-
}
|
178
|
-
|
179
|
-
function inflateResetKeep(strm) {
|
180
|
-
var state;
|
181
|
-
|
182
|
-
if (!strm || !strm.state) { return Z_STREAM_ERROR; }
|
183
|
-
state = strm.state;
|
184
|
-
strm.total_in = strm.total_out = state.total = 0;
|
185
|
-
strm.msg = ''; /*Z_NULL*/
|
186
|
-
if (state.wrap) { /* to support ill-conceived Java test suite */
|
187
|
-
strm.adler = state.wrap & 1;
|
188
|
-
}
|
189
|
-
state.mode = HEAD;
|
190
|
-
state.last = 0;
|
191
|
-
state.havedict = 0;
|
192
|
-
state.dmax = 32768;
|
193
|
-
state.head = null/*Z_NULL*/;
|
194
|
-
state.hold = 0;
|
195
|
-
state.bits = 0;
|
196
|
-
//state.lencode = state.distcode = state.next = state.codes;
|
197
|
-
state.lencode = state.lendyn = new utils.Buf32(ENOUGH_LENS);
|
198
|
-
state.distcode = state.distdyn = new utils.Buf32(ENOUGH_DISTS);
|
199
|
-
|
200
|
-
state.sane = 1;
|
201
|
-
state.back = -1;
|
202
|
-
//Tracev((stderr, "inflate: reset\n"));
|
203
|
-
return Z_OK;
|
204
|
-
}
|
205
|
-
|
206
|
-
function inflateReset(strm) {
|
207
|
-
var state;
|
208
|
-
|
209
|
-
if (!strm || !strm.state) { return Z_STREAM_ERROR; }
|
210
|
-
state = strm.state;
|
211
|
-
state.wsize = 0;
|
212
|
-
state.whave = 0;
|
213
|
-
state.wnext = 0;
|
214
|
-
return inflateResetKeep(strm);
|
215
|
-
|
216
|
-
}
|
217
|
-
|
218
|
-
function inflateReset2(strm, windowBits) {
|
219
|
-
var wrap;
|
220
|
-
var state;
|
221
|
-
|
222
|
-
/* get the state */
|
223
|
-
if (!strm || !strm.state) { return Z_STREAM_ERROR; }
|
224
|
-
state = strm.state;
|
225
|
-
|
226
|
-
/* extract wrap request from windowBits parameter */
|
227
|
-
if (windowBits < 0) {
|
228
|
-
wrap = 0;
|
229
|
-
windowBits = -windowBits;
|
230
|
-
}
|
231
|
-
else {
|
232
|
-
wrap = (windowBits >> 4) + 1;
|
233
|
-
if (windowBits < 48) {
|
234
|
-
windowBits &= 15;
|
235
|
-
}
|
236
|
-
}
|
237
|
-
|
238
|
-
/* set number of window bits, free window if different */
|
239
|
-
if (windowBits && (windowBits < 8 || windowBits > 15)) {
|
240
|
-
return Z_STREAM_ERROR;
|
241
|
-
}
|
242
|
-
if (state.window !== null && state.wbits !== windowBits) {
|
243
|
-
state.window = null;
|
244
|
-
}
|
245
|
-
|
246
|
-
/* update state and reset the rest of it */
|
247
|
-
state.wrap = wrap;
|
248
|
-
state.wbits = windowBits;
|
249
|
-
return inflateReset(strm);
|
250
|
-
}
|
251
|
-
|
252
|
-
function inflateInit2(strm, windowBits) {
|
253
|
-
var ret;
|
254
|
-
var state;
|
255
|
-
|
256
|
-
if (!strm) { return Z_STREAM_ERROR; }
|
257
|
-
//strm.msg = Z_NULL; /* in case we return an error */
|
258
|
-
|
259
|
-
state = new InflateState();
|
260
|
-
|
261
|
-
//if (state === Z_NULL) return Z_MEM_ERROR;
|
262
|
-
//Tracev((stderr, "inflate: allocated\n"));
|
263
|
-
strm.state = state;
|
264
|
-
state.window = null/*Z_NULL*/;
|
265
|
-
ret = inflateReset2(strm, windowBits);
|
266
|
-
if (ret !== Z_OK) {
|
267
|
-
strm.state = null/*Z_NULL*/;
|
268
|
-
}
|
269
|
-
return ret;
|
270
|
-
}
|
271
|
-
|
272
|
-
function inflateInit(strm) {
|
273
|
-
return inflateInit2(strm, DEF_WBITS);
|
274
|
-
}
|
275
|
-
|
276
|
-
|
277
|
-
/*
|
278
|
-
Return state with length and distance decoding tables and index sizes set to
|
279
|
-
fixed code decoding. Normally this returns fixed tables from inffixed.h.
|
280
|
-
If BUILDFIXED is defined, then instead this routine builds the tables the
|
281
|
-
first time it's called, and returns those tables the first time and
|
282
|
-
thereafter. This reduces the size of the code by about 2K bytes, in
|
283
|
-
exchange for a little execution time. However, BUILDFIXED should not be
|
284
|
-
used for threaded applications, since the rewriting of the tables and virgin
|
285
|
-
may not be thread-safe.
|
286
|
-
*/
|
287
|
-
var virgin = true;
|
288
|
-
|
289
|
-
var lenfix, distfix; // We have no pointers in JS, so keep tables separate
|
290
|
-
|
291
|
-
function fixedtables(state) {
|
292
|
-
/* build fixed huffman tables if first call (may not be thread safe) */
|
293
|
-
if (virgin) {
|
294
|
-
var sym;
|
295
|
-
|
296
|
-
lenfix = new utils.Buf32(512);
|
297
|
-
distfix = new utils.Buf32(32);
|
298
|
-
|
299
|
-
/* literal/length table */
|
300
|
-
sym = 0;
|
301
|
-
while (sym < 144) { state.lens[sym++] = 8; }
|
302
|
-
while (sym < 256) { state.lens[sym++] = 9; }
|
303
|
-
while (sym < 280) { state.lens[sym++] = 7; }
|
304
|
-
while (sym < 288) { state.lens[sym++] = 8; }
|
305
|
-
|
306
|
-
inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });
|
307
|
-
|
308
|
-
/* distance table */
|
309
|
-
sym = 0;
|
310
|
-
while (sym < 32) { state.lens[sym++] = 5; }
|
311
|
-
|
312
|
-
inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });
|
313
|
-
|
314
|
-
/* do this just once */
|
315
|
-
virgin = false;
|
316
|
-
}
|
317
|
-
|
318
|
-
state.lencode = lenfix;
|
319
|
-
state.lenbits = 9;
|
320
|
-
state.distcode = distfix;
|
321
|
-
state.distbits = 5;
|
322
|
-
}
|
323
|
-
|
324
|
-
|
325
|
-
/*
|
326
|
-
Update the window with the last wsize (normally 32K) bytes written before
|
327
|
-
returning. If window does not exist yet, create it. This is only called
|
328
|
-
when a window is already in use, or when output has been written during this
|
329
|
-
inflate call, but the end of the deflate stream has not been reached yet.
|
330
|
-
It is also called to create a window for dictionary data when a dictionary
|
331
|
-
is loaded.
|
332
|
-
|
333
|
-
Providing output buffers larger than 32K to inflate() should provide a speed
|
334
|
-
advantage, since only the last 32K of output is copied to the sliding window
|
335
|
-
upon return from inflate(), and since all distances after the first 32K of
|
336
|
-
output will fall in the output data, making match copies simpler and faster.
|
337
|
-
The advantage may be dependent on the size of the processor's data caches.
|
338
|
-
*/
|
339
|
-
function updatewindow(strm, src, end, copy) {
|
340
|
-
var dist;
|
341
|
-
var state = strm.state;
|
342
|
-
|
343
|
-
/* if it hasn't been done already, allocate space for the window */
|
344
|
-
if (state.window === null) {
|
345
|
-
state.wsize = 1 << state.wbits;
|
346
|
-
state.wnext = 0;
|
347
|
-
state.whave = 0;
|
348
|
-
|
349
|
-
state.window = new utils.Buf8(state.wsize);
|
350
|
-
}
|
351
|
-
|
352
|
-
/* copy state->wsize or less output bytes into the circular window */
|
353
|
-
if (copy >= state.wsize) {
|
354
|
-
utils.arraySet(state.window, src, end - state.wsize, state.wsize, 0);
|
355
|
-
state.wnext = 0;
|
356
|
-
state.whave = state.wsize;
|
357
|
-
}
|
358
|
-
else {
|
359
|
-
dist = state.wsize - state.wnext;
|
360
|
-
if (dist > copy) {
|
361
|
-
dist = copy;
|
362
|
-
}
|
363
|
-
//zmemcpy(state->window + state->wnext, end - copy, dist);
|
364
|
-
utils.arraySet(state.window, src, end - copy, dist, state.wnext);
|
365
|
-
copy -= dist;
|
366
|
-
if (copy) {
|
367
|
-
//zmemcpy(state->window, end - copy, copy);
|
368
|
-
utils.arraySet(state.window, src, end - copy, copy, 0);
|
369
|
-
state.wnext = copy;
|
370
|
-
state.whave = state.wsize;
|
371
|
-
}
|
372
|
-
else {
|
373
|
-
state.wnext += dist;
|
374
|
-
if (state.wnext === state.wsize) { state.wnext = 0; }
|
375
|
-
if (state.whave < state.wsize) { state.whave += dist; }
|
376
|
-
}
|
377
|
-
}
|
378
|
-
return 0;
|
379
|
-
}
|
380
|
-
|
381
|
-
function inflate(strm, flush) {
|
382
|
-
var state;
|
383
|
-
var input, output; // input/output buffers
|
384
|
-
var next; /* next input INDEX */
|
385
|
-
var put; /* next output INDEX */
|
386
|
-
var have, left; /* available input and output */
|
387
|
-
var hold; /* bit buffer */
|
388
|
-
var bits; /* bits in bit buffer */
|
389
|
-
var _in, _out; /* save starting available input and output */
|
390
|
-
var copy; /* number of stored or match bytes to copy */
|
391
|
-
var from; /* where to copy match bytes from */
|
392
|
-
var from_source;
|
393
|
-
var here = 0; /* current decoding table entry */
|
394
|
-
var here_bits, here_op, here_val; // paked "here" denormalized (JS specific)
|
395
|
-
//var last; /* parent table entry */
|
396
|
-
var last_bits, last_op, last_val; // paked "last" denormalized (JS specific)
|
397
|
-
var len; /* length to copy for repeats, bits to drop */
|
398
|
-
var ret; /* return code */
|
399
|
-
var hbuf = new utils.Buf8(4); /* buffer for gzip header crc calculation */
|
400
|
-
var opts;
|
401
|
-
|
402
|
-
var n; // temporary var for NEED_BITS
|
403
|
-
|
404
|
-
var order = /* permutation of code lengths */
|
405
|
-
[ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ];
|
406
|
-
|
407
|
-
|
408
|
-
if (!strm || !strm.state || !strm.output ||
|
409
|
-
(!strm.input && strm.avail_in !== 0)) {
|
410
|
-
return Z_STREAM_ERROR;
|
411
|
-
}
|
412
|
-
|
413
|
-
state = strm.state;
|
414
|
-
if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */
|
415
|
-
|
416
|
-
|
417
|
-
//--- LOAD() ---
|
418
|
-
put = strm.next_out;
|
419
|
-
output = strm.output;
|
420
|
-
left = strm.avail_out;
|
421
|
-
next = strm.next_in;
|
422
|
-
input = strm.input;
|
423
|
-
have = strm.avail_in;
|
424
|
-
hold = state.hold;
|
425
|
-
bits = state.bits;
|
426
|
-
//---
|
427
|
-
|
428
|
-
_in = have;
|
429
|
-
_out = left;
|
430
|
-
ret = Z_OK;
|
431
|
-
|
432
|
-
inf_leave: // goto emulation
|
433
|
-
for (;;) {
|
434
|
-
switch (state.mode) {
|
435
|
-
case HEAD:
|
436
|
-
if (state.wrap === 0) {
|
437
|
-
state.mode = TYPEDO;
|
438
|
-
break;
|
439
|
-
}
|
440
|
-
//=== NEEDBITS(16);
|
441
|
-
while (bits < 16) {
|
442
|
-
if (have === 0) { break inf_leave; }
|
443
|
-
have--;
|
444
|
-
hold += input[next++] << bits;
|
445
|
-
bits += 8;
|
446
|
-
}
|
447
|
-
//===//
|
448
|
-
if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */
|
449
|
-
state.check = 0/*crc32(0L, Z_NULL, 0)*/;
|
450
|
-
//=== CRC2(state.check, hold);
|
451
|
-
hbuf[0] = hold & 0xff;
|
452
|
-
hbuf[1] = (hold >>> 8) & 0xff;
|
453
|
-
state.check = crc32(state.check, hbuf, 2, 0);
|
454
|
-
//===//
|
455
|
-
|
456
|
-
//=== INITBITS();
|
457
|
-
hold = 0;
|
458
|
-
bits = 0;
|
459
|
-
//===//
|
460
|
-
state.mode = FLAGS;
|
461
|
-
break;
|
462
|
-
}
|
463
|
-
state.flags = 0; /* expect zlib header */
|
464
|
-
if (state.head) {
|
465
|
-
state.head.done = false;
|
466
|
-
}
|
467
|
-
if (!(state.wrap & 1) || /* check if zlib header allowed */
|
468
|
-
(((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {
|
469
|
-
strm.msg = 'incorrect header check';
|
470
|
-
state.mode = BAD;
|
471
|
-
break;
|
472
|
-
}
|
473
|
-
if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {
|
474
|
-
strm.msg = 'unknown compression method';
|
475
|
-
state.mode = BAD;
|
476
|
-
break;
|
477
|
-
}
|
478
|
-
//--- DROPBITS(4) ---//
|
479
|
-
hold >>>= 4;
|
480
|
-
bits -= 4;
|
481
|
-
//---//
|
482
|
-
len = (hold & 0x0f)/*BITS(4)*/ + 8;
|
483
|
-
if (state.wbits === 0) {
|
484
|
-
state.wbits = len;
|
485
|
-
}
|
486
|
-
else if (len > state.wbits) {
|
487
|
-
strm.msg = 'invalid window size';
|
488
|
-
state.mode = BAD;
|
489
|
-
break;
|
490
|
-
}
|
491
|
-
state.dmax = 1 << len;
|
492
|
-
//Tracev((stderr, "inflate: zlib header ok\n"));
|
493
|
-
strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;
|
494
|
-
state.mode = hold & 0x200 ? DICTID : TYPE;
|
495
|
-
//=== INITBITS();
|
496
|
-
hold = 0;
|
497
|
-
bits = 0;
|
498
|
-
//===//
|
499
|
-
break;
|
500
|
-
case FLAGS:
|
501
|
-
//=== NEEDBITS(16); */
|
502
|
-
while (bits < 16) {
|
503
|
-
if (have === 0) { break inf_leave; }
|
504
|
-
have--;
|
505
|
-
hold += input[next++] << bits;
|
506
|
-
bits += 8;
|
507
|
-
}
|
508
|
-
//===//
|
509
|
-
state.flags = hold;
|
510
|
-
if ((state.flags & 0xff) !== Z_DEFLATED) {
|
511
|
-
strm.msg = 'unknown compression method';
|
512
|
-
state.mode = BAD;
|
513
|
-
break;
|
514
|
-
}
|
515
|
-
if (state.flags & 0xe000) {
|
516
|
-
strm.msg = 'unknown header flags set';
|
517
|
-
state.mode = BAD;
|
518
|
-
break;
|
519
|
-
}
|
520
|
-
if (state.head) {
|
521
|
-
state.head.text = ((hold >> 8) & 1);
|
522
|
-
}
|
523
|
-
if (state.flags & 0x0200) {
|
524
|
-
//=== CRC2(state.check, hold);
|
525
|
-
hbuf[0] = hold & 0xff;
|
526
|
-
hbuf[1] = (hold >>> 8) & 0xff;
|
527
|
-
state.check = crc32(state.check, hbuf, 2, 0);
|
528
|
-
//===//
|
529
|
-
}
|
530
|
-
//=== INITBITS();
|
531
|
-
hold = 0;
|
532
|
-
bits = 0;
|
533
|
-
//===//
|
534
|
-
state.mode = TIME;
|
535
|
-
/* falls through */
|
536
|
-
case TIME:
|
537
|
-
//=== NEEDBITS(32); */
|
538
|
-
while (bits < 32) {
|
539
|
-
if (have === 0) { break inf_leave; }
|
540
|
-
have--;
|
541
|
-
hold += input[next++] << bits;
|
542
|
-
bits += 8;
|
543
|
-
}
|
544
|
-
//===//
|
545
|
-
if (state.head) {
|
546
|
-
state.head.time = hold;
|
547
|
-
}
|
548
|
-
if (state.flags & 0x0200) {
|
549
|
-
//=== CRC4(state.check, hold)
|
550
|
-
hbuf[0] = hold & 0xff;
|
551
|
-
hbuf[1] = (hold >>> 8) & 0xff;
|
552
|
-
hbuf[2] = (hold >>> 16) & 0xff;
|
553
|
-
hbuf[3] = (hold >>> 24) & 0xff;
|
554
|
-
state.check = crc32(state.check, hbuf, 4, 0);
|
555
|
-
//===
|
556
|
-
}
|
557
|
-
//=== INITBITS();
|
558
|
-
hold = 0;
|
559
|
-
bits = 0;
|
560
|
-
//===//
|
561
|
-
state.mode = OS;
|
562
|
-
/* falls through */
|
563
|
-
case OS:
|
564
|
-
//=== NEEDBITS(16); */
|
565
|
-
while (bits < 16) {
|
566
|
-
if (have === 0) { break inf_leave; }
|
567
|
-
have--;
|
568
|
-
hold += input[next++] << bits;
|
569
|
-
bits += 8;
|
570
|
-
}
|
571
|
-
//===//
|
572
|
-
if (state.head) {
|
573
|
-
state.head.xflags = (hold & 0xff);
|
574
|
-
state.head.os = (hold >> 8);
|
575
|
-
}
|
576
|
-
if (state.flags & 0x0200) {
|
577
|
-
//=== CRC2(state.check, hold);
|
578
|
-
hbuf[0] = hold & 0xff;
|
579
|
-
hbuf[1] = (hold >>> 8) & 0xff;
|
580
|
-
state.check = crc32(state.check, hbuf, 2, 0);
|
581
|
-
//===//
|
582
|
-
}
|
583
|
-
//=== INITBITS();
|
584
|
-
hold = 0;
|
585
|
-
bits = 0;
|
586
|
-
//===//
|
587
|
-
state.mode = EXLEN;
|
588
|
-
/* falls through */
|
589
|
-
case EXLEN:
|
590
|
-
if (state.flags & 0x0400) {
|
591
|
-
//=== NEEDBITS(16); */
|
592
|
-
while (bits < 16) {
|
593
|
-
if (have === 0) { break inf_leave; }
|
594
|
-
have--;
|
595
|
-
hold += input[next++] << bits;
|
596
|
-
bits += 8;
|
597
|
-
}
|
598
|
-
//===//
|
599
|
-
state.length = hold;
|
600
|
-
if (state.head) {
|
601
|
-
state.head.extra_len = hold;
|
602
|
-
}
|
603
|
-
if (state.flags & 0x0200) {
|
604
|
-
//=== CRC2(state.check, hold);
|
605
|
-
hbuf[0] = hold & 0xff;
|
606
|
-
hbuf[1] = (hold >>> 8) & 0xff;
|
607
|
-
state.check = crc32(state.check, hbuf, 2, 0);
|
608
|
-
//===//
|
609
|
-
}
|
610
|
-
//=== INITBITS();
|
611
|
-
hold = 0;
|
612
|
-
bits = 0;
|
613
|
-
//===//
|
614
|
-
}
|
615
|
-
else if (state.head) {
|
616
|
-
state.head.extra = null/*Z_NULL*/;
|
617
|
-
}
|
618
|
-
state.mode = EXTRA;
|
619
|
-
/* falls through */
|
620
|
-
case EXTRA:
|
621
|
-
if (state.flags & 0x0400) {
|
622
|
-
copy = state.length;
|
623
|
-
if (copy > have) { copy = have; }
|
624
|
-
if (copy) {
|
625
|
-
if (state.head) {
|
626
|
-
len = state.head.extra_len - state.length;
|
627
|
-
if (!state.head.extra) {
|
628
|
-
// Use untyped array for more convenient processing later
|
629
|
-
state.head.extra = new Array(state.head.extra_len);
|
630
|
-
}
|
631
|
-
utils.arraySet(
|
632
|
-
state.head.extra,
|
633
|
-
input,
|
634
|
-
next,
|
635
|
-
// extra field is limited to 65536 bytes
|
636
|
-
// - no need for additional size check
|
637
|
-
copy,
|
638
|
-
/*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/
|
639
|
-
len
|
640
|
-
);
|
641
|
-
//zmemcpy(state.head.extra + len, next,
|
642
|
-
// len + copy > state.head.extra_max ?
|
643
|
-
// state.head.extra_max - len : copy);
|
644
|
-
}
|
645
|
-
if (state.flags & 0x0200) {
|
646
|
-
state.check = crc32(state.check, input, copy, next);
|
647
|
-
}
|
648
|
-
have -= copy;
|
649
|
-
next += copy;
|
650
|
-
state.length -= copy;
|
651
|
-
}
|
652
|
-
if (state.length) { break inf_leave; }
|
653
|
-
}
|
654
|
-
state.length = 0;
|
655
|
-
state.mode = NAME;
|
656
|
-
/* falls through */
|
657
|
-
case NAME:
|
658
|
-
if (state.flags & 0x0800) {
|
659
|
-
if (have === 0) { break inf_leave; }
|
660
|
-
copy = 0;
|
661
|
-
do {
|
662
|
-
// TODO: 2 or 1 bytes?
|
663
|
-
len = input[next + copy++];
|
664
|
-
/* use constant limit because in js we should not preallocate memory */
|
665
|
-
if (state.head && len &&
|
666
|
-
(state.length < 65536 /*state.head.name_max*/)) {
|
667
|
-
state.head.name += String.fromCharCode(len);
|
668
|
-
}
|
669
|
-
} while (len && copy < have);
|
670
|
-
|
671
|
-
if (state.flags & 0x0200) {
|
672
|
-
state.check = crc32(state.check, input, copy, next);
|
673
|
-
}
|
674
|
-
have -= copy;
|
675
|
-
next += copy;
|
676
|
-
if (len) { break inf_leave; }
|
677
|
-
}
|
678
|
-
else if (state.head) {
|
679
|
-
state.head.name = null;
|
680
|
-
}
|
681
|
-
state.length = 0;
|
682
|
-
state.mode = COMMENT;
|
683
|
-
/* falls through */
|
684
|
-
case COMMENT:
|
685
|
-
if (state.flags & 0x1000) {
|
686
|
-
if (have === 0) { break inf_leave; }
|
687
|
-
copy = 0;
|
688
|
-
do {
|
689
|
-
len = input[next + copy++];
|
690
|
-
/* use constant limit because in js we should not preallocate memory */
|
691
|
-
if (state.head && len &&
|
692
|
-
(state.length < 65536 /*state.head.comm_max*/)) {
|
693
|
-
state.head.comment += String.fromCharCode(len);
|
694
|
-
}
|
695
|
-
} while (len && copy < have);
|
696
|
-
if (state.flags & 0x0200) {
|
697
|
-
state.check = crc32(state.check, input, copy, next);
|
698
|
-
}
|
699
|
-
have -= copy;
|
700
|
-
next += copy;
|
701
|
-
if (len) { break inf_leave; }
|
702
|
-
}
|
703
|
-
else if (state.head) {
|
704
|
-
state.head.comment = null;
|
705
|
-
}
|
706
|
-
state.mode = HCRC;
|
707
|
-
/* falls through */
|
708
|
-
case HCRC:
|
709
|
-
if (state.flags & 0x0200) {
|
710
|
-
//=== NEEDBITS(16); */
|
711
|
-
while (bits < 16) {
|
712
|
-
if (have === 0) { break inf_leave; }
|
713
|
-
have--;
|
714
|
-
hold += input[next++] << bits;
|
715
|
-
bits += 8;
|
716
|
-
}
|
717
|
-
//===//
|
718
|
-
if (hold !== (state.check & 0xffff)) {
|
719
|
-
strm.msg = 'header crc mismatch';
|
720
|
-
state.mode = BAD;
|
721
|
-
break;
|
722
|
-
}
|
723
|
-
//=== INITBITS();
|
724
|
-
hold = 0;
|
725
|
-
bits = 0;
|
726
|
-
//===//
|
727
|
-
}
|
728
|
-
if (state.head) {
|
729
|
-
state.head.hcrc = ((state.flags >> 9) & 1);
|
730
|
-
state.head.done = true;
|
731
|
-
}
|
732
|
-
strm.adler = state.check = 0;
|
733
|
-
state.mode = TYPE;
|
734
|
-
break;
|
735
|
-
case DICTID:
|
736
|
-
//=== NEEDBITS(32); */
|
737
|
-
while (bits < 32) {
|
738
|
-
if (have === 0) { break inf_leave; }
|
739
|
-
have--;
|
740
|
-
hold += input[next++] << bits;
|
741
|
-
bits += 8;
|
742
|
-
}
|
743
|
-
//===//
|
744
|
-
strm.adler = state.check = zswap32(hold);
|
745
|
-
//=== INITBITS();
|
746
|
-
hold = 0;
|
747
|
-
bits = 0;
|
748
|
-
//===//
|
749
|
-
state.mode = DICT;
|
750
|
-
/* falls through */
|
751
|
-
case DICT:
|
752
|
-
if (state.havedict === 0) {
|
753
|
-
//--- RESTORE() ---
|
754
|
-
strm.next_out = put;
|
755
|
-
strm.avail_out = left;
|
756
|
-
strm.next_in = next;
|
757
|
-
strm.avail_in = have;
|
758
|
-
state.hold = hold;
|
759
|
-
state.bits = bits;
|
760
|
-
//---
|
761
|
-
return Z_NEED_DICT;
|
762
|
-
}
|
763
|
-
strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;
|
764
|
-
state.mode = TYPE;
|
765
|
-
/* falls through */
|
766
|
-
case TYPE:
|
767
|
-
if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }
|
768
|
-
/* falls through */
|
769
|
-
case TYPEDO:
|
770
|
-
if (state.last) {
|
771
|
-
//--- BYTEBITS() ---//
|
772
|
-
hold >>>= bits & 7;
|
773
|
-
bits -= bits & 7;
|
774
|
-
//---//
|
775
|
-
state.mode = CHECK;
|
776
|
-
break;
|
777
|
-
}
|
778
|
-
//=== NEEDBITS(3); */
|
779
|
-
while (bits < 3) {
|
780
|
-
if (have === 0) { break inf_leave; }
|
781
|
-
have--;
|
782
|
-
hold += input[next++] << bits;
|
783
|
-
bits += 8;
|
784
|
-
}
|
785
|
-
//===//
|
786
|
-
state.last = (hold & 0x01)/*BITS(1)*/;
|
787
|
-
//--- DROPBITS(1) ---//
|
788
|
-
hold >>>= 1;
|
789
|
-
bits -= 1;
|
790
|
-
//---//
|
791
|
-
|
792
|
-
switch ((hold & 0x03)/*BITS(2)*/) {
|
793
|
-
case 0: /* stored block */
|
794
|
-
//Tracev((stderr, "inflate: stored block%s\n",
|
795
|
-
// state.last ? " (last)" : ""));
|
796
|
-
state.mode = STORED;
|
797
|
-
break;
|
798
|
-
case 1: /* fixed block */
|
799
|
-
fixedtables(state);
|
800
|
-
//Tracev((stderr, "inflate: fixed codes block%s\n",
|
801
|
-
// state.last ? " (last)" : ""));
|
802
|
-
state.mode = LEN_; /* decode codes */
|
803
|
-
if (flush === Z_TREES) {
|
804
|
-
//--- DROPBITS(2) ---//
|
805
|
-
hold >>>= 2;
|
806
|
-
bits -= 2;
|
807
|
-
//---//
|
808
|
-
break inf_leave;
|
809
|
-
}
|
810
|
-
break;
|
811
|
-
case 2: /* dynamic block */
|
812
|
-
//Tracev((stderr, "inflate: dynamic codes block%s\n",
|
813
|
-
// state.last ? " (last)" : ""));
|
814
|
-
state.mode = TABLE;
|
815
|
-
break;
|
816
|
-
case 3:
|
817
|
-
strm.msg = 'invalid block type';
|
818
|
-
state.mode = BAD;
|
819
|
-
}
|
820
|
-
//--- DROPBITS(2) ---//
|
821
|
-
hold >>>= 2;
|
822
|
-
bits -= 2;
|
823
|
-
//---//
|
824
|
-
break;
|
825
|
-
case STORED:
|
826
|
-
//--- BYTEBITS() ---// /* go to byte boundary */
|
827
|
-
hold >>>= bits & 7;
|
828
|
-
bits -= bits & 7;
|
829
|
-
//---//
|
830
|
-
//=== NEEDBITS(32); */
|
831
|
-
while (bits < 32) {
|
832
|
-
if (have === 0) { break inf_leave; }
|
833
|
-
have--;
|
834
|
-
hold += input[next++] << bits;
|
835
|
-
bits += 8;
|
836
|
-
}
|
837
|
-
//===//
|
838
|
-
if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {
|
839
|
-
strm.msg = 'invalid stored block lengths';
|
840
|
-
state.mode = BAD;
|
841
|
-
break;
|
842
|
-
}
|
843
|
-
state.length = hold & 0xffff;
|
844
|
-
//Tracev((stderr, "inflate: stored length %u\n",
|
845
|
-
// state.length));
|
846
|
-
//=== INITBITS();
|
847
|
-
hold = 0;
|
848
|
-
bits = 0;
|
849
|
-
//===//
|
850
|
-
state.mode = COPY_;
|
851
|
-
if (flush === Z_TREES) { break inf_leave; }
|
852
|
-
/* falls through */
|
853
|
-
case COPY_:
|
854
|
-
state.mode = COPY;
|
855
|
-
/* falls through */
|
856
|
-
case COPY:
|
857
|
-
copy = state.length;
|
858
|
-
if (copy) {
|
859
|
-
if (copy > have) { copy = have; }
|
860
|
-
if (copy > left) { copy = left; }
|
861
|
-
if (copy === 0) { break inf_leave; }
|
862
|
-
//--- zmemcpy(put, next, copy); ---
|
863
|
-
utils.arraySet(output, input, next, copy, put);
|
864
|
-
//---//
|
865
|
-
have -= copy;
|
866
|
-
next += copy;
|
867
|
-
left -= copy;
|
868
|
-
put += copy;
|
869
|
-
state.length -= copy;
|
870
|
-
break;
|
871
|
-
}
|
872
|
-
//Tracev((stderr, "inflate: stored end\n"));
|
873
|
-
state.mode = TYPE;
|
874
|
-
break;
|
875
|
-
case TABLE:
|
876
|
-
//=== NEEDBITS(14); */
|
877
|
-
while (bits < 14) {
|
878
|
-
if (have === 0) { break inf_leave; }
|
879
|
-
have--;
|
880
|
-
hold += input[next++] << bits;
|
881
|
-
bits += 8;
|
882
|
-
}
|
883
|
-
//===//
|
884
|
-
state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;
|
885
|
-
//--- DROPBITS(5) ---//
|
886
|
-
hold >>>= 5;
|
887
|
-
bits -= 5;
|
888
|
-
//---//
|
889
|
-
state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;
|
890
|
-
//--- DROPBITS(5) ---//
|
891
|
-
hold >>>= 5;
|
892
|
-
bits -= 5;
|
893
|
-
//---//
|
894
|
-
state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;
|
895
|
-
//--- DROPBITS(4) ---//
|
896
|
-
hold >>>= 4;
|
897
|
-
bits -= 4;
|
898
|
-
//---//
|
899
|
-
//#ifndef PKZIP_BUG_WORKAROUND
|
900
|
-
if (state.nlen > 286 || state.ndist > 30) {
|
901
|
-
strm.msg = 'too many length or distance symbols';
|
902
|
-
state.mode = BAD;
|
903
|
-
break;
|
904
|
-
}
|
905
|
-
//#endif
|
906
|
-
//Tracev((stderr, "inflate: table sizes ok\n"));
|
907
|
-
state.have = 0;
|
908
|
-
state.mode = LENLENS;
|
909
|
-
/* falls through */
|
910
|
-
case LENLENS:
|
911
|
-
while (state.have < state.ncode) {
|
912
|
-
//=== NEEDBITS(3);
|
913
|
-
while (bits < 3) {
|
914
|
-
if (have === 0) { break inf_leave; }
|
915
|
-
have--;
|
916
|
-
hold += input[next++] << bits;
|
917
|
-
bits += 8;
|
918
|
-
}
|
919
|
-
//===//
|
920
|
-
state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);
|
921
|
-
//--- DROPBITS(3) ---//
|
922
|
-
hold >>>= 3;
|
923
|
-
bits -= 3;
|
924
|
-
//---//
|
925
|
-
}
|
926
|
-
while (state.have < 19) {
|
927
|
-
state.lens[order[state.have++]] = 0;
|
928
|
-
}
|
929
|
-
// We have separate tables & no pointers. 2 commented lines below not needed.
|
930
|
-
//state.next = state.codes;
|
931
|
-
//state.lencode = state.next;
|
932
|
-
// Switch to use dynamic table
|
933
|
-
state.lencode = state.lendyn;
|
934
|
-
state.lenbits = 7;
|
935
|
-
|
936
|
-
opts = { bits: state.lenbits };
|
937
|
-
ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);
|
938
|
-
state.lenbits = opts.bits;
|
939
|
-
|
940
|
-
if (ret) {
|
941
|
-
strm.msg = 'invalid code lengths set';
|
942
|
-
state.mode = BAD;
|
943
|
-
break;
|
944
|
-
}
|
945
|
-
//Tracev((stderr, "inflate: code lengths ok\n"));
|
946
|
-
state.have = 0;
|
947
|
-
state.mode = CODELENS;
|
948
|
-
/* falls through */
|
949
|
-
case CODELENS:
|
950
|
-
while (state.have < state.nlen + state.ndist) {
|
951
|
-
for (;;) {
|
952
|
-
here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/
|
953
|
-
here_bits = here >>> 24;
|
954
|
-
here_op = (here >>> 16) & 0xff;
|
955
|
-
here_val = here & 0xffff;
|
956
|
-
|
957
|
-
if ((here_bits) <= bits) { break; }
|
958
|
-
//--- PULLBYTE() ---//
|
959
|
-
if (have === 0) { break inf_leave; }
|
960
|
-
have--;
|
961
|
-
hold += input[next++] << bits;
|
962
|
-
bits += 8;
|
963
|
-
//---//
|
964
|
-
}
|
965
|
-
if (here_val < 16) {
|
966
|
-
//--- DROPBITS(here.bits) ---//
|
967
|
-
hold >>>= here_bits;
|
968
|
-
bits -= here_bits;
|
969
|
-
//---//
|
970
|
-
state.lens[state.have++] = here_val;
|
971
|
-
}
|
972
|
-
else {
|
973
|
-
if (here_val === 16) {
|
974
|
-
//=== NEEDBITS(here.bits + 2);
|
975
|
-
n = here_bits + 2;
|
976
|
-
while (bits < n) {
|
977
|
-
if (have === 0) { break inf_leave; }
|
978
|
-
have--;
|
979
|
-
hold += input[next++] << bits;
|
980
|
-
bits += 8;
|
981
|
-
}
|
982
|
-
//===//
|
983
|
-
//--- DROPBITS(here.bits) ---//
|
984
|
-
hold >>>= here_bits;
|
985
|
-
bits -= here_bits;
|
986
|
-
//---//
|
987
|
-
if (state.have === 0) {
|
988
|
-
strm.msg = 'invalid bit length repeat';
|
989
|
-
state.mode = BAD;
|
990
|
-
break;
|
991
|
-
}
|
992
|
-
len = state.lens[state.have - 1];
|
993
|
-
copy = 3 + (hold & 0x03);//BITS(2);
|
994
|
-
//--- DROPBITS(2) ---//
|
995
|
-
hold >>>= 2;
|
996
|
-
bits -= 2;
|
997
|
-
//---//
|
998
|
-
}
|
999
|
-
else if (here_val === 17) {
|
1000
|
-
//=== NEEDBITS(here.bits + 3);
|
1001
|
-
n = here_bits + 3;
|
1002
|
-
while (bits < n) {
|
1003
|
-
if (have === 0) { break inf_leave; }
|
1004
|
-
have--;
|
1005
|
-
hold += input[next++] << bits;
|
1006
|
-
bits += 8;
|
1007
|
-
}
|
1008
|
-
//===//
|
1009
|
-
//--- DROPBITS(here.bits) ---//
|
1010
|
-
hold >>>= here_bits;
|
1011
|
-
bits -= here_bits;
|
1012
|
-
//---//
|
1013
|
-
len = 0;
|
1014
|
-
copy = 3 + (hold & 0x07);//BITS(3);
|
1015
|
-
//--- DROPBITS(3) ---//
|
1016
|
-
hold >>>= 3;
|
1017
|
-
bits -= 3;
|
1018
|
-
//---//
|
1019
|
-
}
|
1020
|
-
else {
|
1021
|
-
//=== NEEDBITS(here.bits + 7);
|
1022
|
-
n = here_bits + 7;
|
1023
|
-
while (bits < n) {
|
1024
|
-
if (have === 0) { break inf_leave; }
|
1025
|
-
have--;
|
1026
|
-
hold += input[next++] << bits;
|
1027
|
-
bits += 8;
|
1028
|
-
}
|
1029
|
-
//===//
|
1030
|
-
//--- DROPBITS(here.bits) ---//
|
1031
|
-
hold >>>= here_bits;
|
1032
|
-
bits -= here_bits;
|
1033
|
-
//---//
|
1034
|
-
len = 0;
|
1035
|
-
copy = 11 + (hold & 0x7f);//BITS(7);
|
1036
|
-
//--- DROPBITS(7) ---//
|
1037
|
-
hold >>>= 7;
|
1038
|
-
bits -= 7;
|
1039
|
-
//---//
|
1040
|
-
}
|
1041
|
-
if (state.have + copy > state.nlen + state.ndist) {
|
1042
|
-
strm.msg = 'invalid bit length repeat';
|
1043
|
-
state.mode = BAD;
|
1044
|
-
break;
|
1045
|
-
}
|
1046
|
-
while (copy--) {
|
1047
|
-
state.lens[state.have++] = len;
|
1048
|
-
}
|
1049
|
-
}
|
1050
|
-
}
|
1051
|
-
|
1052
|
-
/* handle error breaks in while */
|
1053
|
-
if (state.mode === BAD) { break; }
|
1054
|
-
|
1055
|
-
/* check for end-of-block code (better have one) */
|
1056
|
-
if (state.lens[256] === 0) {
|
1057
|
-
strm.msg = 'invalid code -- missing end-of-block';
|
1058
|
-
state.mode = BAD;
|
1059
|
-
break;
|
1060
|
-
}
|
1061
|
-
|
1062
|
-
/* build code tables -- note: do not change the lenbits or distbits
|
1063
|
-
values here (9 and 6) without reading the comments in inftrees.h
|
1064
|
-
concerning the ENOUGH constants, which depend on those values */
|
1065
|
-
state.lenbits = 9;
|
1066
|
-
|
1067
|
-
opts = { bits: state.lenbits };
|
1068
|
-
ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);
|
1069
|
-
// We have separate tables & no pointers. 2 commented lines below not needed.
|
1070
|
-
// state.next_index = opts.table_index;
|
1071
|
-
state.lenbits = opts.bits;
|
1072
|
-
// state.lencode = state.next;
|
1073
|
-
|
1074
|
-
if (ret) {
|
1075
|
-
strm.msg = 'invalid literal/lengths set';
|
1076
|
-
state.mode = BAD;
|
1077
|
-
break;
|
1078
|
-
}
|
1079
|
-
|
1080
|
-
state.distbits = 6;
|
1081
|
-
//state.distcode.copy(state.codes);
|
1082
|
-
// Switch to use dynamic table
|
1083
|
-
state.distcode = state.distdyn;
|
1084
|
-
opts = { bits: state.distbits };
|
1085
|
-
ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);
|
1086
|
-
// We have separate tables & no pointers. 2 commented lines below not needed.
|
1087
|
-
// state.next_index = opts.table_index;
|
1088
|
-
state.distbits = opts.bits;
|
1089
|
-
// state.distcode = state.next;
|
1090
|
-
|
1091
|
-
if (ret) {
|
1092
|
-
strm.msg = 'invalid distances set';
|
1093
|
-
state.mode = BAD;
|
1094
|
-
break;
|
1095
|
-
}
|
1096
|
-
//Tracev((stderr, 'inflate: codes ok\n'));
|
1097
|
-
state.mode = LEN_;
|
1098
|
-
if (flush === Z_TREES) { break inf_leave; }
|
1099
|
-
/* falls through */
|
1100
|
-
case LEN_:
|
1101
|
-
state.mode = LEN;
|
1102
|
-
/* falls through */
|
1103
|
-
case LEN:
|
1104
|
-
if (have >= 6 && left >= 258) {
|
1105
|
-
//--- RESTORE() ---
|
1106
|
-
strm.next_out = put;
|
1107
|
-
strm.avail_out = left;
|
1108
|
-
strm.next_in = next;
|
1109
|
-
strm.avail_in = have;
|
1110
|
-
state.hold = hold;
|
1111
|
-
state.bits = bits;
|
1112
|
-
//---
|
1113
|
-
inflate_fast(strm, _out);
|
1114
|
-
//--- LOAD() ---
|
1115
|
-
put = strm.next_out;
|
1116
|
-
output = strm.output;
|
1117
|
-
left = strm.avail_out;
|
1118
|
-
next = strm.next_in;
|
1119
|
-
input = strm.input;
|
1120
|
-
have = strm.avail_in;
|
1121
|
-
hold = state.hold;
|
1122
|
-
bits = state.bits;
|
1123
|
-
//---
|
1124
|
-
|
1125
|
-
if (state.mode === TYPE) {
|
1126
|
-
state.back = -1;
|
1127
|
-
}
|
1128
|
-
break;
|
1129
|
-
}
|
1130
|
-
state.back = 0;
|
1131
|
-
for (;;) {
|
1132
|
-
here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/
|
1133
|
-
here_bits = here >>> 24;
|
1134
|
-
here_op = (here >>> 16) & 0xff;
|
1135
|
-
here_val = here & 0xffff;
|
1136
|
-
|
1137
|
-
if (here_bits <= bits) { break; }
|
1138
|
-
//--- PULLBYTE() ---//
|
1139
|
-
if (have === 0) { break inf_leave; }
|
1140
|
-
have--;
|
1141
|
-
hold += input[next++] << bits;
|
1142
|
-
bits += 8;
|
1143
|
-
//---//
|
1144
|
-
}
|
1145
|
-
if (here_op && (here_op & 0xf0) === 0) {
|
1146
|
-
last_bits = here_bits;
|
1147
|
-
last_op = here_op;
|
1148
|
-
last_val = here_val;
|
1149
|
-
for (;;) {
|
1150
|
-
here = state.lencode[last_val +
|
1151
|
-
((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];
|
1152
|
-
here_bits = here >>> 24;
|
1153
|
-
here_op = (here >>> 16) & 0xff;
|
1154
|
-
here_val = here & 0xffff;
|
1155
|
-
|
1156
|
-
if ((last_bits + here_bits) <= bits) { break; }
|
1157
|
-
//--- PULLBYTE() ---//
|
1158
|
-
if (have === 0) { break inf_leave; }
|
1159
|
-
have--;
|
1160
|
-
hold += input[next++] << bits;
|
1161
|
-
bits += 8;
|
1162
|
-
//---//
|
1163
|
-
}
|
1164
|
-
//--- DROPBITS(last.bits) ---//
|
1165
|
-
hold >>>= last_bits;
|
1166
|
-
bits -= last_bits;
|
1167
|
-
//---//
|
1168
|
-
state.back += last_bits;
|
1169
|
-
}
|
1170
|
-
//--- DROPBITS(here.bits) ---//
|
1171
|
-
hold >>>= here_bits;
|
1172
|
-
bits -= here_bits;
|
1173
|
-
//---//
|
1174
|
-
state.back += here_bits;
|
1175
|
-
state.length = here_val;
|
1176
|
-
if (here_op === 0) {
|
1177
|
-
//Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
|
1178
|
-
// "inflate: literal '%c'\n" :
|
1179
|
-
// "inflate: literal 0x%02x\n", here.val));
|
1180
|
-
state.mode = LIT;
|
1181
|
-
break;
|
1182
|
-
}
|
1183
|
-
if (here_op & 32) {
|
1184
|
-
//Tracevv((stderr, "inflate: end of block\n"));
|
1185
|
-
state.back = -1;
|
1186
|
-
state.mode = TYPE;
|
1187
|
-
break;
|
1188
|
-
}
|
1189
|
-
if (here_op & 64) {
|
1190
|
-
strm.msg = 'invalid literal/length code';
|
1191
|
-
state.mode = BAD;
|
1192
|
-
break;
|
1193
|
-
}
|
1194
|
-
state.extra = here_op & 15;
|
1195
|
-
state.mode = LENEXT;
|
1196
|
-
/* falls through */
|
1197
|
-
case LENEXT:
|
1198
|
-
if (state.extra) {
|
1199
|
-
//=== NEEDBITS(state.extra);
|
1200
|
-
n = state.extra;
|
1201
|
-
while (bits < n) {
|
1202
|
-
if (have === 0) { break inf_leave; }
|
1203
|
-
have--;
|
1204
|
-
hold += input[next++] << bits;
|
1205
|
-
bits += 8;
|
1206
|
-
}
|
1207
|
-
//===//
|
1208
|
-
state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;
|
1209
|
-
//--- DROPBITS(state.extra) ---//
|
1210
|
-
hold >>>= state.extra;
|
1211
|
-
bits -= state.extra;
|
1212
|
-
//---//
|
1213
|
-
state.back += state.extra;
|
1214
|
-
}
|
1215
|
-
//Tracevv((stderr, "inflate: length %u\n", state.length));
|
1216
|
-
state.was = state.length;
|
1217
|
-
state.mode = DIST;
|
1218
|
-
/* falls through */
|
1219
|
-
case DIST:
|
1220
|
-
for (;;) {
|
1221
|
-
here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/
|
1222
|
-
here_bits = here >>> 24;
|
1223
|
-
here_op = (here >>> 16) & 0xff;
|
1224
|
-
here_val = here & 0xffff;
|
1225
|
-
|
1226
|
-
if ((here_bits) <= bits) { break; }
|
1227
|
-
//--- PULLBYTE() ---//
|
1228
|
-
if (have === 0) { break inf_leave; }
|
1229
|
-
have--;
|
1230
|
-
hold += input[next++] << bits;
|
1231
|
-
bits += 8;
|
1232
|
-
//---//
|
1233
|
-
}
|
1234
|
-
if ((here_op & 0xf0) === 0) {
|
1235
|
-
last_bits = here_bits;
|
1236
|
-
last_op = here_op;
|
1237
|
-
last_val = here_val;
|
1238
|
-
for (;;) {
|
1239
|
-
here = state.distcode[last_val +
|
1240
|
-
((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];
|
1241
|
-
here_bits = here >>> 24;
|
1242
|
-
here_op = (here >>> 16) & 0xff;
|
1243
|
-
here_val = here & 0xffff;
|
1244
|
-
|
1245
|
-
if ((last_bits + here_bits) <= bits) { break; }
|
1246
|
-
//--- PULLBYTE() ---//
|
1247
|
-
if (have === 0) { break inf_leave; }
|
1248
|
-
have--;
|
1249
|
-
hold += input[next++] << bits;
|
1250
|
-
bits += 8;
|
1251
|
-
//---//
|
1252
|
-
}
|
1253
|
-
//--- DROPBITS(last.bits) ---//
|
1254
|
-
hold >>>= last_bits;
|
1255
|
-
bits -= last_bits;
|
1256
|
-
//---//
|
1257
|
-
state.back += last_bits;
|
1258
|
-
}
|
1259
|
-
//--- DROPBITS(here.bits) ---//
|
1260
|
-
hold >>>= here_bits;
|
1261
|
-
bits -= here_bits;
|
1262
|
-
//---//
|
1263
|
-
state.back += here_bits;
|
1264
|
-
if (here_op & 64) {
|
1265
|
-
strm.msg = 'invalid distance code';
|
1266
|
-
state.mode = BAD;
|
1267
|
-
break;
|
1268
|
-
}
|
1269
|
-
state.offset = here_val;
|
1270
|
-
state.extra = (here_op) & 15;
|
1271
|
-
state.mode = DISTEXT;
|
1272
|
-
/* falls through */
|
1273
|
-
case DISTEXT:
|
1274
|
-
if (state.extra) {
|
1275
|
-
//=== NEEDBITS(state.extra);
|
1276
|
-
n = state.extra;
|
1277
|
-
while (bits < n) {
|
1278
|
-
if (have === 0) { break inf_leave; }
|
1279
|
-
have--;
|
1280
|
-
hold += input[next++] << bits;
|
1281
|
-
bits += 8;
|
1282
|
-
}
|
1283
|
-
//===//
|
1284
|
-
state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;
|
1285
|
-
//--- DROPBITS(state.extra) ---//
|
1286
|
-
hold >>>= state.extra;
|
1287
|
-
bits -= state.extra;
|
1288
|
-
//---//
|
1289
|
-
state.back += state.extra;
|
1290
|
-
}
|
1291
|
-
//#ifdef INFLATE_STRICT
|
1292
|
-
if (state.offset > state.dmax) {
|
1293
|
-
strm.msg = 'invalid distance too far back';
|
1294
|
-
state.mode = BAD;
|
1295
|
-
break;
|
1296
|
-
}
|
1297
|
-
//#endif
|
1298
|
-
//Tracevv((stderr, "inflate: distance %u\n", state.offset));
|
1299
|
-
state.mode = MATCH;
|
1300
|
-
/* falls through */
|
1301
|
-
case MATCH:
|
1302
|
-
if (left === 0) { break inf_leave; }
|
1303
|
-
copy = _out - left;
|
1304
|
-
if (state.offset > copy) { /* copy from window */
|
1305
|
-
copy = state.offset - copy;
|
1306
|
-
if (copy > state.whave) {
|
1307
|
-
if (state.sane) {
|
1308
|
-
strm.msg = 'invalid distance too far back';
|
1309
|
-
state.mode = BAD;
|
1310
|
-
break;
|
1311
|
-
}
|
1312
|
-
// (!) This block is disabled in zlib defaults,
|
1313
|
-
// don't enable it for binary compatibility
|
1314
|
-
//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
|
1315
|
-
// Trace((stderr, "inflate.c too far\n"));
|
1316
|
-
// copy -= state.whave;
|
1317
|
-
// if (copy > state.length) { copy = state.length; }
|
1318
|
-
// if (copy > left) { copy = left; }
|
1319
|
-
// left -= copy;
|
1320
|
-
// state.length -= copy;
|
1321
|
-
// do {
|
1322
|
-
// output[put++] = 0;
|
1323
|
-
// } while (--copy);
|
1324
|
-
// if (state.length === 0) { state.mode = LEN; }
|
1325
|
-
// break;
|
1326
|
-
//#endif
|
1327
|
-
}
|
1328
|
-
if (copy > state.wnext) {
|
1329
|
-
copy -= state.wnext;
|
1330
|
-
from = state.wsize - copy;
|
1331
|
-
}
|
1332
|
-
else {
|
1333
|
-
from = state.wnext - copy;
|
1334
|
-
}
|
1335
|
-
if (copy > state.length) { copy = state.length; }
|
1336
|
-
from_source = state.window;
|
1337
|
-
}
|
1338
|
-
else { /* copy from output */
|
1339
|
-
from_source = output;
|
1340
|
-
from = put - state.offset;
|
1341
|
-
copy = state.length;
|
1342
|
-
}
|
1343
|
-
if (copy > left) { copy = left; }
|
1344
|
-
left -= copy;
|
1345
|
-
state.length -= copy;
|
1346
|
-
do {
|
1347
|
-
output[put++] = from_source[from++];
|
1348
|
-
} while (--copy);
|
1349
|
-
if (state.length === 0) { state.mode = LEN; }
|
1350
|
-
break;
|
1351
|
-
case LIT:
|
1352
|
-
if (left === 0) { break inf_leave; }
|
1353
|
-
output[put++] = state.length;
|
1354
|
-
left--;
|
1355
|
-
state.mode = LEN;
|
1356
|
-
break;
|
1357
|
-
case CHECK:
|
1358
|
-
if (state.wrap) {
|
1359
|
-
//=== NEEDBITS(32);
|
1360
|
-
while (bits < 32) {
|
1361
|
-
if (have === 0) { break inf_leave; }
|
1362
|
-
have--;
|
1363
|
-
// Use '|' instead of '+' to make sure that result is signed
|
1364
|
-
hold |= input[next++] << bits;
|
1365
|
-
bits += 8;
|
1366
|
-
}
|
1367
|
-
//===//
|
1368
|
-
_out -= left;
|
1369
|
-
strm.total_out += _out;
|
1370
|
-
state.total += _out;
|
1371
|
-
if (_out) {
|
1372
|
-
strm.adler = state.check =
|
1373
|
-
/*UPDATE(state.check, put - _out, _out);*/
|
1374
|
-
(state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out));
|
1375
|
-
|
1376
|
-
}
|
1377
|
-
_out = left;
|
1378
|
-
// NB: crc32 stored as signed 32-bit int, zswap32 returns signed too
|
1379
|
-
if ((state.flags ? hold : zswap32(hold)) !== state.check) {
|
1380
|
-
strm.msg = 'incorrect data check';
|
1381
|
-
state.mode = BAD;
|
1382
|
-
break;
|
1383
|
-
}
|
1384
|
-
//=== INITBITS();
|
1385
|
-
hold = 0;
|
1386
|
-
bits = 0;
|
1387
|
-
//===//
|
1388
|
-
//Tracev((stderr, "inflate: check matches trailer\n"));
|
1389
|
-
}
|
1390
|
-
state.mode = LENGTH;
|
1391
|
-
/* falls through */
|
1392
|
-
case LENGTH:
|
1393
|
-
if (state.wrap && state.flags) {
|
1394
|
-
//=== NEEDBITS(32);
|
1395
|
-
while (bits < 32) {
|
1396
|
-
if (have === 0) { break inf_leave; }
|
1397
|
-
have--;
|
1398
|
-
hold += input[next++] << bits;
|
1399
|
-
bits += 8;
|
1400
|
-
}
|
1401
|
-
//===//
|
1402
|
-
if (hold !== (state.total & 0xffffffff)) {
|
1403
|
-
strm.msg = 'incorrect length check';
|
1404
|
-
state.mode = BAD;
|
1405
|
-
break;
|
1406
|
-
}
|
1407
|
-
//=== INITBITS();
|
1408
|
-
hold = 0;
|
1409
|
-
bits = 0;
|
1410
|
-
//===//
|
1411
|
-
//Tracev((stderr, "inflate: length matches trailer\n"));
|
1412
|
-
}
|
1413
|
-
state.mode = DONE;
|
1414
|
-
/* falls through */
|
1415
|
-
case DONE:
|
1416
|
-
ret = Z_STREAM_END;
|
1417
|
-
break inf_leave;
|
1418
|
-
case BAD:
|
1419
|
-
ret = Z_DATA_ERROR;
|
1420
|
-
break inf_leave;
|
1421
|
-
case MEM:
|
1422
|
-
return Z_MEM_ERROR;
|
1423
|
-
case SYNC:
|
1424
|
-
/* falls through */
|
1425
|
-
default:
|
1426
|
-
return Z_STREAM_ERROR;
|
1427
|
-
}
|
1428
|
-
}
|
1429
|
-
|
1430
|
-
// inf_leave <- here is real place for "goto inf_leave", emulated via "break inf_leave"
|
1431
|
-
|
1432
|
-
/*
|
1433
|
-
Return from inflate(), updating the total counts and the check value.
|
1434
|
-
If there was no progress during the inflate() call, return a buffer
|
1435
|
-
error. Call updatewindow() to create and/or update the window state.
|
1436
|
-
Note: a memory error from inflate() is non-recoverable.
|
1437
|
-
*/
|
1438
|
-
|
1439
|
-
//--- RESTORE() ---
|
1440
|
-
strm.next_out = put;
|
1441
|
-
strm.avail_out = left;
|
1442
|
-
strm.next_in = next;
|
1443
|
-
strm.avail_in = have;
|
1444
|
-
state.hold = hold;
|
1445
|
-
state.bits = bits;
|
1446
|
-
//---
|
1447
|
-
|
1448
|
-
if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&
|
1449
|
-
(state.mode < CHECK || flush !== Z_FINISH))) {
|
1450
|
-
if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {
|
1451
|
-
state.mode = MEM;
|
1452
|
-
return Z_MEM_ERROR;
|
1453
|
-
}
|
1454
|
-
}
|
1455
|
-
_in -= strm.avail_in;
|
1456
|
-
_out -= strm.avail_out;
|
1457
|
-
strm.total_in += _in;
|
1458
|
-
strm.total_out += _out;
|
1459
|
-
state.total += _out;
|
1460
|
-
if (state.wrap && _out) {
|
1461
|
-
strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/
|
1462
|
-
(state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out));
|
1463
|
-
}
|
1464
|
-
strm.data_type = state.bits + (state.last ? 64 : 0) +
|
1465
|
-
(state.mode === TYPE ? 128 : 0) +
|
1466
|
-
(state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);
|
1467
|
-
if (((_in === 0 && _out === 0) || flush === Z_FINISH) && ret === Z_OK) {
|
1468
|
-
ret = Z_BUF_ERROR;
|
1469
|
-
}
|
1470
|
-
return ret;
|
1471
|
-
}
|
1472
|
-
|
1473
|
-
function inflateEnd(strm) {
|
1474
|
-
|
1475
|
-
if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {
|
1476
|
-
return Z_STREAM_ERROR;
|
1477
|
-
}
|
1478
|
-
|
1479
|
-
var state = strm.state;
|
1480
|
-
if (state.window) {
|
1481
|
-
state.window = null;
|
1482
|
-
}
|
1483
|
-
strm.state = null;
|
1484
|
-
return Z_OK;
|
1485
|
-
}
|
1486
|
-
|
1487
|
-
function inflateGetHeader(strm, head) {
|
1488
|
-
var state;
|
1489
|
-
|
1490
|
-
/* check state */
|
1491
|
-
if (!strm || !strm.state) { return Z_STREAM_ERROR; }
|
1492
|
-
state = strm.state;
|
1493
|
-
if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR; }
|
1494
|
-
|
1495
|
-
/* save header structure */
|
1496
|
-
state.head = head;
|
1497
|
-
head.done = false;
|
1498
|
-
return Z_OK;
|
1499
|
-
}
|
1500
|
-
|
1501
|
-
function inflateSetDictionary(strm, dictionary) {
|
1502
|
-
var dictLength = dictionary.length;
|
1503
|
-
|
1504
|
-
var state;
|
1505
|
-
var dictid;
|
1506
|
-
var ret;
|
1507
|
-
|
1508
|
-
/* check state */
|
1509
|
-
if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; }
|
1510
|
-
state = strm.state;
|
1511
|
-
|
1512
|
-
if (state.wrap !== 0 && state.mode !== DICT) {
|
1513
|
-
return Z_STREAM_ERROR;
|
1514
|
-
}
|
1515
|
-
|
1516
|
-
/* check for correct dictionary identifier */
|
1517
|
-
if (state.mode === DICT) {
|
1518
|
-
dictid = 1; /* adler32(0, null, 0)*/
|
1519
|
-
/* dictid = adler32(dictid, dictionary, dictLength); */
|
1520
|
-
dictid = adler32(dictid, dictionary, dictLength, 0);
|
1521
|
-
if (dictid !== state.check) {
|
1522
|
-
return Z_DATA_ERROR;
|
1523
|
-
}
|
1524
|
-
}
|
1525
|
-
/* copy dictionary to window using updatewindow(), which will amend the
|
1526
|
-
existing dictionary if appropriate */
|
1527
|
-
ret = updatewindow(strm, dictionary, dictLength, dictLength);
|
1528
|
-
if (ret) {
|
1529
|
-
state.mode = MEM;
|
1530
|
-
return Z_MEM_ERROR;
|
1531
|
-
}
|
1532
|
-
state.havedict = 1;
|
1533
|
-
// Tracev((stderr, "inflate: dictionary set\n"));
|
1534
|
-
return Z_OK;
|
1535
|
-
}
|
1536
|
-
|
1537
|
-
exports.inflateReset = inflateReset;
|
1538
|
-
exports.inflateReset2 = inflateReset2;
|
1539
|
-
exports.inflateResetKeep = inflateResetKeep;
|
1540
|
-
exports.inflateInit = inflateInit;
|
1541
|
-
exports.inflateInit2 = inflateInit2;
|
1542
|
-
exports.inflate = inflate;
|
1543
|
-
exports.inflateEnd = inflateEnd;
|
1544
|
-
exports.inflateGetHeader = inflateGetHeader;
|
1545
|
-
exports.inflateSetDictionary = inflateSetDictionary;
|
1546
|
-
exports.inflateInfo = 'pako inflate (from Nodeca project)';
|
1547
|
-
|
1548
|
-
/* Not implemented
|
1549
|
-
exports.inflateCopy = inflateCopy;
|
1550
|
-
exports.inflateGetDictionary = inflateGetDictionary;
|
1551
|
-
exports.inflateMark = inflateMark;
|
1552
|
-
exports.inflatePrime = inflatePrime;
|
1553
|
-
exports.inflateSync = inflateSync;
|
1554
|
-
exports.inflateSyncPoint = inflateSyncPoint;
|
1555
|
-
exports.inflateUndermine = inflateUndermine;
|
1556
|
-
*/
|