@mtkruto/node 0.0.6

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 (167) hide show
  1. package/LICENSE +165 -0
  2. package/README.md +1 -0
  3. package/esm/_dnt.shims.js +68 -0
  4. package/esm/client/client.js +169 -0
  5. package/esm/client/client_abstract.js +51 -0
  6. package/esm/client/client_plain.js +112 -0
  7. package/esm/connection/connection.js +2 -0
  8. package/esm/connection/connection_web_socket.js +90 -0
  9. package/esm/constants.js +60 -0
  10. package/esm/deps/deno.land/std@0.186.0/fmt/colors.js +474 -0
  11. package/esm/deps/deno.land/std@0.186.0/testing/_diff.js +311 -0
  12. package/esm/deps/deno.land/std@0.186.0/testing/_format.js +23 -0
  13. package/esm/deps/deno.land/std@0.186.0/testing/asserts.js +633 -0
  14. package/esm/deps/deno.land/x/crc32@v0.2.0/mod.js +105 -0
  15. package/esm/deps/deno.land/x/tgcrypto@0.1.1/mod.js +68 -0
  16. package/esm/deps/deno.land/x/tgcrypto@0.1.1/tgcrypto.js +1127 -0
  17. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/gzip/gzip.js +239 -0
  18. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/utils/uint8.js +10 -0
  19. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/deflate.js +139 -0
  20. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/inflate.js +176 -0
  21. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/mod.js +2 -0
  22. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/adler32.js +19 -0
  23. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/crc32.js +25 -0
  24. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/deflate.js +1941 -0
  25. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/gzheader.js +85 -0
  26. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inffast.js +321 -0
  27. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inflate.js +1658 -0
  28. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inftrees.js +355 -0
  29. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/messages.js +11 -0
  30. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/status.js +42 -0
  31. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/trees.js +1107 -0
  32. package/esm/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/zstream.js +86 -0
  33. package/esm/deps.js +4 -0
  34. package/esm/mod.js +4 -0
  35. package/esm/package.json +3 -0
  36. package/esm/tl/0_tl_raw_reader.js +62 -0
  37. package/esm/tl/0_tl_raw_writer.js +60 -0
  38. package/esm/tl/1_tl_object.js +149 -0
  39. package/esm/tl/2_types.js +48220 -0
  40. package/esm/tl/3_functions.js +19856 -0
  41. package/esm/tl/3_tl_object_deserializer.js +72 -0
  42. package/esm/tl/3_tl_reader.js +16 -0
  43. package/esm/tl/3_tl_writer.js +7 -0
  44. package/esm/tl/4_rpc_result.js +27 -0
  45. package/esm/tl/5_message.js +54 -0
  46. package/esm/tl/6_message_container.js +35 -0
  47. package/esm/transport/transport.js +32 -0
  48. package/esm/transport/transport_intermediate.js +56 -0
  49. package/esm/transport/transport_provider.js +23 -0
  50. package/esm/types.js +1 -0
  51. package/esm/utilities/0_bigint.js +37 -0
  52. package/esm/utilities/0_buffer.js +33 -0
  53. package/esm/utilities/0_crypto.js +35 -0
  54. package/esm/utilities/0_hash.js +7 -0
  55. package/esm/utilities/1_auth.js +29 -0
  56. package/esm/utilities/1_message.js +94 -0
  57. package/esm/utilities/1_obfuscation.js +33 -0
  58. package/package.json +40 -0
  59. package/script/_dnt.shims.js +77 -0
  60. package/script/client/client.js +173 -0
  61. package/script/client/client_abstract.js +55 -0
  62. package/script/client/client_plain.js +116 -0
  63. package/script/connection/connection.js +6 -0
  64. package/script/connection/connection_web_socket.js +117 -0
  65. package/script/constants.js +63 -0
  66. package/script/deps/deno.land/std@0.186.0/fmt/colors.js +548 -0
  67. package/script/deps/deno.land/std@0.186.0/testing/_diff.js +317 -0
  68. package/script/deps/deno.land/std@0.186.0/testing/_format.js +50 -0
  69. package/script/deps/deno.land/std@0.186.0/testing/asserts.js +659 -0
  70. package/script/deps/deno.land/x/crc32@v0.2.0/mod.js +113 -0
  71. package/script/deps/deno.land/x/tgcrypto@0.1.1/mod.js +82 -0
  72. package/script/deps/deno.land/x/tgcrypto@0.1.1/tgcrypto.js +1152 -0
  73. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/gzip/gzip.js +271 -0
  74. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/utils/uint8.js +14 -0
  75. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/deflate.js +172 -0
  76. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/inflate.js +208 -0
  77. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/mod.js +18 -0
  78. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/adler32.js +22 -0
  79. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/crc32.js +30 -0
  80. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/deflate.js +1976 -0
  81. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/gzheader.js +88 -0
  82. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inffast.js +324 -0
  83. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inflate.js +1674 -0
  84. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inftrees.js +358 -0
  85. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/messages.js +14 -0
  86. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/status.js +44 -0
  87. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/trees.js +1115 -0
  88. package/script/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/zstream.js +89 -0
  89. package/script/deps.js +30 -0
  90. package/script/mod.js +32 -0
  91. package/script/package.json +3 -0
  92. package/script/tl/0_tl_raw_reader.js +66 -0
  93. package/script/tl/0_tl_raw_writer.js +64 -0
  94. package/script/tl/1_tl_object.js +156 -0
  95. package/script/tl/2_types.js +49824 -0
  96. package/script/tl/3_functions.js +20413 -0
  97. package/script/tl/3_tl_object_deserializer.js +76 -0
  98. package/script/tl/3_tl_reader.js +20 -0
  99. package/script/tl/3_tl_writer.js +11 -0
  100. package/script/tl/4_rpc_result.js +31 -0
  101. package/script/tl/5_message.js +58 -0
  102. package/script/tl/6_message_container.js +39 -0
  103. package/script/transport/transport.js +36 -0
  104. package/script/transport/transport_intermediate.js +60 -0
  105. package/script/transport/transport_provider.js +27 -0
  106. package/script/types.js +2 -0
  107. package/script/utilities/0_bigint.js +67 -0
  108. package/script/utilities/0_buffer.js +38 -0
  109. package/script/utilities/0_crypto.js +39 -0
  110. package/script/utilities/0_hash.js +35 -0
  111. package/script/utilities/1_auth.js +56 -0
  112. package/script/utilities/1_message.js +102 -0
  113. package/script/utilities/1_obfuscation.js +60 -0
  114. package/types/_dnt.shims.d.ts +10 -0
  115. package/types/client/client.d.ts +19 -0
  116. package/types/client/client_abstract.d.ts +20 -0
  117. package/types/client/client_plain.d.ts +10 -0
  118. package/types/connection/connection.d.ts +7 -0
  119. package/types/connection/connection_web_socket.d.ts +13 -0
  120. package/types/constants.d.ts +2 -0
  121. package/types/deps/deno.land/std@0.186.0/fmt/colors.d.ts +270 -0
  122. package/types/deps/deno.land/std@0.186.0/testing/_diff.d.ts +26 -0
  123. package/types/deps/deno.land/std@0.186.0/testing/_format.d.ts +1 -0
  124. package/types/deps/deno.land/std@0.186.0/testing/asserts.d.ts +284 -0
  125. package/types/deps/deno.land/x/crc32@v0.2.0/mod.d.ts +15 -0
  126. package/types/deps/deno.land/x/tgcrypto@0.1.1/mod.d.ts +47 -0
  127. package/types/deps/deno.land/x/tgcrypto@0.1.1/tgcrypto.d.ts +2 -0
  128. package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/gzip/gzip.d.ts +16 -0
  129. package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/utils/uint8.d.ts +1 -0
  130. package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/deflate.d.ts +29 -0
  131. package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/inflate.d.ts +23 -0
  132. package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/mod.d.ts +2 -0
  133. package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/adler32.d.ts +1 -0
  134. package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/crc32.d.ts +2 -0
  135. package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/deflate.d.ts +78 -0
  136. package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/gzheader.d.ts +12 -0
  137. package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inffast.d.ts +1 -0
  138. package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inflate.d.ts +47 -0
  139. package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/inftrees.d.ts +1 -0
  140. package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/messages.d.ts +12 -0
  141. package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/status.d.ts +30 -0
  142. package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/trees.d.ts +5 -0
  143. package/types/deps/raw.githubusercontent.com/MTKruto/compress/master/zlib/zlib/zstream.d.ts +14 -0
  144. package/types/deps.d.ts +4 -0
  145. package/types/mod.d.ts +4 -0
  146. package/types/tl/0_tl_raw_reader.d.ts +13 -0
  147. package/types/tl/0_tl_raw_writer.d.ts +13 -0
  148. package/types/tl/1_tl_object.d.ts +36 -0
  149. package/types/tl/2_types.d.ts +14815 -0
  150. package/types/tl/3_functions.d.ts +6122 -0
  151. package/types/tl/3_tl_object_deserializer.d.ts +3 -0
  152. package/types/tl/3_tl_reader.d.ts +4 -0
  153. package/types/tl/3_tl_writer.d.ts +5 -0
  154. package/types/tl/4_rpc_result.d.ts +8 -0
  155. package/types/tl/5_message.d.ts +11 -0
  156. package/types/tl/6_message_container.d.ts +9 -0
  157. package/types/transport/transport.d.ts +15 -0
  158. package/types/transport/transport_intermediate.d.ts +11 -0
  159. package/types/transport/transport_provider.d.ts +12 -0
  160. package/types/types.d.ts +1 -0
  161. package/types/utilities/0_bigint.d.ts +4 -0
  162. package/types/utilities/0_buffer.d.ts +2 -0
  163. package/types/utilities/0_crypto.d.ts +8 -0
  164. package/types/utilities/0_hash.d.ts +2 -0
  165. package/types/utilities/1_auth.d.ts +1 -0
  166. package/types/utilities/1_message.d.ts +10 -0
  167. package/types/utilities/1_obfuscation.d.ts +6 -0
@@ -0,0 +1,85 @@
1
+ export default class GZheader {
2
+ constructor() {
3
+ /* true if compressed data believed to be text */
4
+ Object.defineProperty(this, "text", {
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true,
8
+ value: 0
9
+ });
10
+ /* modification time */
11
+ Object.defineProperty(this, "time", {
12
+ enumerable: true,
13
+ configurable: true,
14
+ writable: true,
15
+ value: 0
16
+ });
17
+ /* extra flags (not used when writing a gzip file) */
18
+ Object.defineProperty(this, "xflags", {
19
+ enumerable: true,
20
+ configurable: true,
21
+ writable: true,
22
+ value: 0
23
+ });
24
+ /* operating system */
25
+ Object.defineProperty(this, "os", {
26
+ enumerable: true,
27
+ configurable: true,
28
+ writable: true,
29
+ value: 0
30
+ });
31
+ /* pointer to extra field or Z_NULL if none */
32
+ Object.defineProperty(this, "extra", {
33
+ enumerable: true,
34
+ configurable: true,
35
+ writable: true,
36
+ value: null
37
+ });
38
+ /* extra field length (valid if extra != Z_NULL) */
39
+ Object.defineProperty(this, "extra_len", {
40
+ enumerable: true,
41
+ configurable: true,
42
+ writable: true,
43
+ value: 0
44
+ }); // Actually, we don't need it in JS,
45
+ // but leave for few code modifications
46
+ //
47
+ // Setup limits is not necessary because in js we should not preallocate memory
48
+ // for inflate use constant limit in 65536 bytes
49
+ //
50
+ /* space at extra (only when reading header) */
51
+ // extra_max = 0;
52
+ /* pointer to zero-terminated file name or Z_NULL */
53
+ Object.defineProperty(this, "name", {
54
+ enumerable: true,
55
+ configurable: true,
56
+ writable: true,
57
+ value: ""
58
+ });
59
+ /* space at name (only when reading header) */
60
+ // name_max = 0;
61
+ /* pointer to zero-terminated comment or Z_NULL */
62
+ Object.defineProperty(this, "comment", {
63
+ enumerable: true,
64
+ configurable: true,
65
+ writable: true,
66
+ value: ""
67
+ });
68
+ /* space at comment (only when reading header) */
69
+ // comm_max = 0;
70
+ /* true if there was or will be a header crc */
71
+ Object.defineProperty(this, "hcrc", {
72
+ enumerable: true,
73
+ configurable: true,
74
+ writable: true,
75
+ value: 0
76
+ });
77
+ /* true when done reading gzip header (not used when writing a gzip file) */
78
+ Object.defineProperty(this, "done", {
79
+ enumerable: true,
80
+ configurable: true,
81
+ writable: true,
82
+ value: false
83
+ });
84
+ }
85
+ }
@@ -0,0 +1,321 @@
1
+ // See state defs from inflate.js
2
+ const BAD = 30; /* got a data error -- remain here until reset */
3
+ const TYPE = 12; /* i: waiting for type bits, including last-flag bit */
4
+ /*
5
+ Decode literal, length, and distance codes and write out the resulting
6
+ literal and match bytes until either not enough input or output is
7
+ available, an end-of-block is encountered, or a data error is encountered.
8
+ When large enough input and output buffers are supplied to inflate(), for
9
+ example, a 16K input buffer and a 64K output buffer, more than 95% of the
10
+ inflate execution time is spent in this routine.
11
+
12
+ Entry assumptions:
13
+
14
+ state.mode === LEN
15
+ strm.avail_in >= 6
16
+ strm.avail_out >= 258
17
+ start >= strm.avail_out
18
+ state.bits < 8
19
+
20
+ On return, state.mode is one of:
21
+
22
+ LEN -- ran out of enough output space or enough available input
23
+ TYPE -- reached end of block code, inflate() to interpret next block
24
+ BAD -- error in block data
25
+
26
+ Notes:
27
+
28
+ - The maximum input bits used by a length/distance pair is 15 bits for the
29
+ length code, 5 bits for the length extra, 15 bits for the distance code,
30
+ and 13 bits for the distance extra. This totals 48 bits, or six bytes.
31
+ Therefore if strm.avail_in >= 6, then there is enough input to avoid
32
+ checking for available input while decoding.
33
+
34
+ - The maximum bytes that a single length/distance pair can output is 258
35
+ bytes, which is the maximum length that can be coded. inflate_fast()
36
+ requires strm.avail_out >= 258 for each loop to avoid checking for
37
+ output space.
38
+ */
39
+ export default function inflate_fast(strm, start) {
40
+ let state;
41
+ let _in; /* local strm.input */
42
+ let last; /* have enough input while in < last */
43
+ let _out; /* local strm.output */
44
+ let beg; /* inflate()'s initial strm.output */
45
+ let end; /* while out < end, enough space available */
46
+ //#ifdef INFLATE_STRICT
47
+ let dmax; /* maximum distance from zlib header */
48
+ //#endif
49
+ let wsize; /* window size or zero if not using window */
50
+ let whave; /* valid bytes in the window */
51
+ let wnext; /* window write index */
52
+ // Use `s_window` instead `window`, avoid conflict with instrumentation tools
53
+ let s_window; /* allocated sliding window, if wsize != 0 */
54
+ let hold; /* local strm.hold */
55
+ let bits; /* local strm.bits */
56
+ let lcode; /* local strm.lencode */
57
+ let dcode; /* local strm.distcode */
58
+ let lmask; /* mask for first level of length codes */
59
+ let dmask; /* mask for first level of distance codes */
60
+ let here; /* retrieved table entry */
61
+ let op; /* code bits, operation, extra bits, or */
62
+ /* window position, window bytes to copy */
63
+ let len; /* match length, unused bytes */
64
+ let dist; /* match distance */
65
+ let from; /* where to copy match from */
66
+ let from_source;
67
+ let input, output; // JS specific, because we have no pointers
68
+ /* copy state to local variables */
69
+ state = strm.state;
70
+ //here = state.here;
71
+ _in = strm.next_in;
72
+ input = strm.input;
73
+ last = _in + (strm.avail_in - 5);
74
+ _out = strm.next_out;
75
+ output = strm.output;
76
+ beg = _out - (start - strm.avail_out);
77
+ end = _out + (strm.avail_out - 257);
78
+ //#ifdef INFLATE_STRICT
79
+ dmax = state.dmax;
80
+ //#endif
81
+ wsize = state.wsize;
82
+ whave = state.whave;
83
+ wnext = state.wnext;
84
+ s_window = state.window;
85
+ hold = state.hold;
86
+ bits = state.bits;
87
+ lcode = state.lencode;
88
+ dcode = state.distcode;
89
+ lmask = (1 << state.lenbits) - 1;
90
+ dmask = (1 << state.distbits) - 1;
91
+ /* decode literals and length/distances until end-of-block or not enough
92
+ input data or output space */
93
+ top: do {
94
+ if (bits < 15) {
95
+ hold += input[_in++] << bits;
96
+ bits += 8;
97
+ hold += input[_in++] << bits;
98
+ bits += 8;
99
+ }
100
+ here = lcode[hold & lmask];
101
+ dolen: for (;;) { // Goto emulation
102
+ op = here >>> 24 /*here.bits*/;
103
+ hold >>>= op;
104
+ bits -= op;
105
+ op = (here >>> 16) & 0xff /*here.op*/;
106
+ if (op === 0) {
107
+ /* literal */
108
+ //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
109
+ // "inflate: literal '%c'\n" :
110
+ // "inflate: literal 0x%02x\n", here.val));
111
+ output[_out++] = here & 0xffff /*here.val*/;
112
+ }
113
+ else if (op & 16) {
114
+ /* length base */
115
+ len = here & 0xffff /*here.val*/;
116
+ op &= 15; /* number of extra bits */
117
+ if (op) {
118
+ if (bits < op) {
119
+ hold += input[_in++] << bits;
120
+ bits += 8;
121
+ }
122
+ len += hold & ((1 << op) - 1);
123
+ hold >>>= op;
124
+ bits -= op;
125
+ }
126
+ //Tracevv((stderr, "inflate: length %u\n", len));
127
+ if (bits < 15) {
128
+ hold += input[_in++] << bits;
129
+ bits += 8;
130
+ hold += input[_in++] << bits;
131
+ bits += 8;
132
+ }
133
+ here = dcode[hold & dmask];
134
+ dodist: for (;;) { // goto emulation
135
+ op = here >>> 24 /*here.bits*/;
136
+ hold >>>= op;
137
+ bits -= op;
138
+ op = (here >>> 16) & 0xff /*here.op*/;
139
+ if (op & 16) {
140
+ /* distance base */
141
+ dist = here & 0xffff /*here.val*/;
142
+ op &= 15; /* number of extra bits */
143
+ if (bits < op) {
144
+ hold += input[_in++] << bits;
145
+ bits += 8;
146
+ if (bits < op) {
147
+ hold += input[_in++] << bits;
148
+ bits += 8;
149
+ }
150
+ }
151
+ dist += hold & ((1 << op) - 1);
152
+ //#ifdef INFLATE_STRICT
153
+ if (dist > dmax) {
154
+ strm.msg = "invalid distance too far back";
155
+ state.mode = BAD;
156
+ break top;
157
+ }
158
+ //#endif
159
+ hold >>>= op;
160
+ bits -= op;
161
+ //Tracevv((stderr, "inflate: distance %u\n", dist));
162
+ op = _out - beg; /* max distance in output */
163
+ if (dist > op) {
164
+ /* see if copy from window */
165
+ op = dist - op; /* distance back in window */
166
+ if (op > whave) {
167
+ if (state.sane) {
168
+ strm.msg = "invalid distance too far back";
169
+ state.mode = BAD;
170
+ break top;
171
+ }
172
+ // (!) This block is disabled in zlib defaults,
173
+ // don't enable it for binary compatibility
174
+ //#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
175
+ // if (len <= op - whave) {
176
+ // do {
177
+ // output[_out++] = 0;
178
+ // } while (--len);
179
+ // continue top;
180
+ // }
181
+ // len -= op - whave;
182
+ // do {
183
+ // output[_out++] = 0;
184
+ // } while (--op > whave);
185
+ // if (op === 0) {
186
+ // from = _out - dist;
187
+ // do {
188
+ // output[_out++] = output[from++];
189
+ // } while (--len);
190
+ // continue top;
191
+ // }
192
+ //#endif
193
+ }
194
+ from = 0; // window index
195
+ from_source = s_window;
196
+ if (wnext === 0) {
197
+ /* very common case */
198
+ from += wsize - op;
199
+ if (op < len) {
200
+ /* some from window */
201
+ len -= op;
202
+ do {
203
+ output[_out++] = s_window[from++];
204
+ } while (--op);
205
+ from = _out - dist; /* rest from output */
206
+ from_source = output;
207
+ }
208
+ }
209
+ else if (wnext < op) {
210
+ /* wrap around window */
211
+ from += wsize + wnext - op;
212
+ op -= wnext;
213
+ if (op < len) {
214
+ /* some from end of window */
215
+ len -= op;
216
+ do {
217
+ output[_out++] = s_window[from++];
218
+ } while (--op);
219
+ from = 0;
220
+ if (wnext < len) {
221
+ /* some from start of window */
222
+ op = wnext;
223
+ len -= op;
224
+ do {
225
+ output[_out++] = s_window[from++];
226
+ } while (--op);
227
+ from = _out - dist; /* rest from output */
228
+ from_source = output;
229
+ }
230
+ }
231
+ }
232
+ else {
233
+ /* contiguous in window */
234
+ from += wnext - op;
235
+ if (op < len) {
236
+ /* some from window */
237
+ len -= op;
238
+ do {
239
+ output[_out++] = s_window[from++];
240
+ } while (--op);
241
+ from = _out - dist; /* rest from output */
242
+ from_source = output;
243
+ }
244
+ }
245
+ while (len > 2) {
246
+ output[_out++] = from_source[from++];
247
+ output[_out++] = from_source[from++];
248
+ output[_out++] = from_source[from++];
249
+ len -= 3;
250
+ }
251
+ if (len) {
252
+ output[_out++] = from_source[from++];
253
+ if (len > 1) {
254
+ output[_out++] = from_source[from++];
255
+ }
256
+ }
257
+ }
258
+ else {
259
+ from = _out - dist; /* copy direct from output */
260
+ do {
261
+ /* minimum length is three */
262
+ output[_out++] = output[from++];
263
+ output[_out++] = output[from++];
264
+ output[_out++] = output[from++];
265
+ len -= 3;
266
+ } while (len > 2);
267
+ if (len) {
268
+ output[_out++] = output[from++];
269
+ if (len > 1) {
270
+ output[_out++] = output[from++];
271
+ }
272
+ }
273
+ }
274
+ }
275
+ else if ((op & 64) === 0) {
276
+ /* 2nd level distance code */
277
+ here =
278
+ dcode[(here & 0xffff) /*here.val*/ + (hold & ((1 << op) - 1))];
279
+ continue dodist;
280
+ }
281
+ else {
282
+ strm.msg = "invalid distance code";
283
+ state.mode = BAD;
284
+ break top;
285
+ }
286
+ break; // need to emulate goto via "continue"
287
+ }
288
+ }
289
+ else if ((op & 64) === 0) {
290
+ /* 2nd level length code */
291
+ here = lcode[(here & 0xffff) /*here.val*/ + (hold & ((1 << op) - 1))];
292
+ continue dolen;
293
+ }
294
+ else if (op & 32) {
295
+ /* end-of-block */
296
+ //Tracevv((stderr, "inflate: end of block\n"));
297
+ state.mode = TYPE;
298
+ break top;
299
+ }
300
+ else {
301
+ strm.msg = "invalid literal/length code";
302
+ state.mode = BAD;
303
+ break top;
304
+ }
305
+ break; // need to emulate goto via "continue"
306
+ }
307
+ } while (_in < last && _out < end);
308
+ /* return unused bytes (on entry, bits < 8, so in won't go too far back) */
309
+ len = bits >> 3;
310
+ _in -= len;
311
+ bits -= len << 3;
312
+ hold &= (1 << bits) - 1;
313
+ /* update state and return */
314
+ strm.next_in = _in;
315
+ strm.next_out = _out;
316
+ strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));
317
+ strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));
318
+ state.hold = hold;
319
+ state.bits = bits;
320
+ return;
321
+ }