ruby-brs 1.1.0 → 1.1.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 76cee1124501f374a5f27ca52ecd1b632058bfb3136e2fa3c1f447ae292d9f23
4
- data.tar.gz: 4436a321a655174132a371e8140a892f18fcd365efbd4fd3da4ee2f1683d2c19
3
+ metadata.gz: a66abcbdc6c29138075e622a75c3af830c333b3534429d97c57d08f568e0c6ae
4
+ data.tar.gz: 1326fc334ec25dcfef28777cbe9defa15ffde9d84df48773bfd5199d140510a1
5
5
  SHA512:
6
- metadata.gz: 1b9d0d1bead338ba24ee95dad6c6387a8ab31bb1e037147d4c15955176eaf1314120b1c0ced1bc68dc6c7c498ade16b22be90f0d89b76eaf31542c48c562ac09
7
- data.tar.gz: 470a2e6fab1f66d787d92dc352094f2c34e9c0f788545bc08a3643e3cc4faa6369804c24ec5499666894b130600630e9455b70f5c0b2c9b38148eb979111f188
6
+ metadata.gz: 690e7ac3f938f10028ea88d50933a5f6b59f7ad8040966356655760bc5dc3deaaa27a89fc3b98e85565edf373015075ca1424a6c894557c6d6dc7c52bee83a9f
7
+ data.tar.gz: 2daa6c5c07566869cdb1f5826a8ab9584ff7c1371140edfba33dcd1bdbaf1ea02dcbebb2c0ee405c44692658bdbbaad326482c4069d761d05e86a4dfc8dcdb9d
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Ruby bindings for brotli library
2
2
 
3
- | Travis | AppVeyor | Cirrus | Circle |
4
- | :---: | :---: | :---: | :---: |
5
- | [![Travis test status](https://travis-ci.com/andrew-aladev/ruby-brs.svg?branch=master)](https://travis-ci.com/andrew-aladev/ruby-brs) | [![AppVeyor test status](https://ci.appveyor.com/api/projects/status/github/andrew-aladev/ruby-brs?branch=master&svg=true)](https://ci.appveyor.com/project/andrew-aladev/ruby-brs/branch/master) | [![Cirrus test status](https://api.cirrus-ci.com/github/andrew-aladev/ruby-brs.svg?branch=master)](https://cirrus-ci.com/github/andrew-aladev/ruby-brs) | [![Circle test status](https://circleci.com/gh/andrew-aladev/ruby-brs/tree/master.svg?style=shield)](https://circleci.com/gh/andrew-aladev/ruby-brs/tree/master) |
3
+ | Travis | AppVeyor | Circle | Codecov |
4
+ | :---: | :---: | :---: | :---: |
5
+ | [![Travis test status](https://travis-ci.com/andrew-aladev/ruby-brs.svg?branch=master)](https://travis-ci.com/andrew-aladev/ruby-brs) | [![AppVeyor test status](https://ci.appveyor.com/api/projects/status/github/andrew-aladev/ruby-brs?branch=master&svg=true)](https://ci.appveyor.com/project/andrew-aladev/ruby-brs/branch/master) | [![Circle test status](https://circleci.com/gh/andrew-aladev/ruby-brs/tree/master.svg?style=shield)](https://circleci.com/gh/andrew-aladev/ruby-brs/tree/master) | [![Codecov](https://codecov.io/gh/andrew-aladev/ruby-brs/branch/master/graph/badge.svg)](https://codecov.io/gh/andrew-aladev/ruby-brs) |
6
6
 
7
7
  See [brotli library](https://github.com/google/brotli).
8
8
 
@@ -21,6 +21,8 @@ rake gem
21
21
  gem install pkg/ruby-brs-*.gem
22
22
  ```
23
23
 
24
+ You can also use [overlay](https://github.com/andrew-aladev/overlay) for gentoo.
25
+
24
26
  ## Usage
25
27
 
26
28
  There are simple APIs: `String` and `File`. Also you can use generic streaming API: `Stream::Writer` and `Stream::Reader`.
@@ -36,6 +38,27 @@ BRS::File.decompress "file.txt.br", "file.txt"
36
38
 
37
39
  BRS::Stream::Writer.open("file.txt.br") { |writer| writer << "sample string" }
38
40
  puts BRS::Stream::Reader.open("file.txt.br") { |reader| reader.read }
41
+
42
+ writer = BRS::Stream::Writer.new output_socket
43
+ begin
44
+ bytes_written = writer.write_nonblock "sample string"
45
+ # handle "bytes_written"
46
+ rescue IO::WaitWritable
47
+ # handle wait
48
+ ensure
49
+ writer.close
50
+ end
51
+
52
+ reader = BRS::Stream::Reader.new input_socket
53
+ begin
54
+ puts reader.read_nonblock(512)
55
+ rescue IO::WaitReadable
56
+ # handle wait
57
+ rescue ::EOFError
58
+ # handle eof
59
+ ensure
60
+ reader.close
61
+ end
39
62
  ```
40
63
 
41
64
  You can create and read `tar.br` archives with `minitar` for example.
@@ -62,74 +85,38 @@ end
62
85
 
63
86
  ## Options
64
87
 
65
- Each API supports several options:
66
-
67
- ```
68
- :source_buffer_length
69
- :destination_buffer_length
70
- ```
88
+ | Option | Values | Default | Description |
89
+ |------------------------------------|------------|------------|-------------|
90
+ | `source_buffer_length` | 0 - inf | 0 (auto) | internal buffer length for source data |
91
+ | `destination_buffer_length` | 0 - inf | 0 (auto) | internal buffer length for description data |
92
+ | `mode` | `MODES` | `:generic` | compressor mode |
93
+ | `quality` | 0 - 11 | 11 | compression level |
94
+ | `lgwin` | 10 - 24 | 22 | compressor window size |
95
+ | `lgblock` | 16 - 24 | nil (auto) | compressor input block size |
96
+ | `disable_literal_context_modeling` | true/false | false | disables literal context modeling format |
97
+ | `disable_ring_buffer_reallocation` | true/false | false | disables ring buffer reallocation |
98
+ | `size_hint` | 0 - inf | 0 (auto) | size of input (if known) |
99
+ | `large_window` | true/false | false | enables large window |
71
100
 
72
101
  There are internal buffers for compressed and decompressed data.
73
- For example you want to use 1 KB as source buffer length for compressor - please use 256 B as destination buffer length.
74
- You want to use 256 B as source buffer length for decompressor - please use 1 KB as destination buffer length.
75
-
76
- Values: 0 - infinity, default value: 0.
77
- 0 means automatic buffer length selection.
102
+ For example you want to use 1 KB as `source_buffer_length` for compressor - please use 256 B as `destination_buffer_length`.
103
+ You want to use 256 B as `source_buffer_length` for decompressor - please use 1 KB as `destination_buffer_length`.
78
104
 
79
- ```
80
- :mode
81
- ```
82
-
83
- Values: `BRS::Option::MODES`, default value: `:generic`.
84
-
85
- ```
86
- :quality
87
- ```
88
-
89
- Values: `BRS::Option::MIN_QUALITY` - `BRS::Option::MAX_QUALITY`, default value: `BRS::Option::MAX_QUALITY`.
90
-
91
- ```
92
- :lgwin
93
- ```
94
-
95
- Values: `BRS::Option::MIN_LGWIN` - `BRS::Option::MAX_LGWIN`, default value: `22`.
96
-
97
- ```
98
- :lgblock
99
- ```
100
-
101
- Values: `BRS::Option::MIN_LGBLOCK` - `BRS::Option::MAX_LGBLOCK`, default value: none.
102
-
103
- ```
104
- :disable_literal_context_modeling
105
- ```
106
-
107
- Values: true/false, default value: false.
108
-
109
- ```
110
- :disable_ring_buffer_reallocation
111
- ```
112
-
113
- Values: true/false, default value: false.
114
-
115
- ```
116
- :size_hint
117
- ```
118
-
119
- Values: 0 - infinity, default value: 0.
120
- It is reasonable to provide size of input (if known) for streaming api.
121
105
  `String` and `File` will set `:size_hint` automaticaly.
122
106
 
123
- ```
124
- :large_window
125
- ```
126
-
127
- Values: true/false, default value: false.
107
+ You can also read brotli docs for more info about options.
128
108
 
129
- Please read brotli docs for more info about options.
109
+ | Option | Related constants |
110
+ |-----------|-------------------|
111
+ | `mode` | `BRS::Option::MODES` = `%i[text font generic]` |
112
+ | `quality` | `BRS::Option::MIN_QUALITY` = 0, `BRS::Option::MAX_QUALITY` = 11 |
113
+ | `lgwin` | `BRS::Option::MIN_LGWIN` = 10, `BRS::Option::MAX_LGWIN` = 24 |
114
+ | `lgblock` | `BRS::Option::MIN_LGBLOCK` = 16, `BRS::Option::MAX_LGBLOCK` = 24 |
130
115
 
131
116
  Possible compressor options:
132
117
  ```
118
+ :source_buffer_length
119
+ :destination_buffer_length
133
120
  :mode
134
121
  :quality
135
122
  :lgwin
@@ -141,6 +128,8 @@ Possible compressor options:
141
128
 
142
129
  Possible decompressor options:
143
130
  ```
131
+ :source_buffer_length
132
+ :destination_buffer_length
144
133
  :disable_ring_buffer_reallocation
145
134
  :large_window
146
135
  ```
@@ -190,7 +179,7 @@ File maintains both source and destination buffers, it accepts both `source_buff
190
179
 
191
180
  ## Stream::Writer
192
181
 
193
- Its behaviour is similar to builtin [`Zlib::GzipWriter`](https://ruby-doc.org/stdlib-2.6.1/libdoc/zlib/rdoc/Zlib/GzipWriter.html).
182
+ Its behaviour is similar to builtin [`Zlib::GzipWriter`](https://ruby-doc.org/stdlib-2.7.0/libdoc/zlib/rdoc/Zlib/GzipWriter.html).
194
183
 
195
184
  Writer maintains destination buffer only, so it accepts `destination_buffer_length` option only.
196
185
 
@@ -228,7 +217,7 @@ Set another encodings, `nil` is just for compatibility with `IO`.
228
217
  #tell
229
218
  ```
230
219
 
231
- See [`IO`](https://ruby-doc.org/core-2.6.1/IO.html) docs.
220
+ See [`IO`](https://ruby-doc.org/core-2.7.0/IO.html) docs.
232
221
 
233
222
  ```
234
223
  #write(*objects)
@@ -238,7 +227,7 @@ See [`IO`](https://ruby-doc.org/core-2.6.1/IO.html) docs.
238
227
  #closed?
239
228
  ```
240
229
 
241
- See [`Zlib::GzipWriter`](https://ruby-doc.org/stdlib-2.6.1/libdoc/zlib/rdoc/Zlib/GzipWriter.html) docs.
230
+ See [`Zlib::GzipWriter`](https://ruby-doc.org/stdlib-2.7.0/libdoc/zlib/rdoc/Zlib/GzipWriter.html) docs.
242
231
 
243
232
  ```
244
233
  #write_nonblock(object, *options)
@@ -260,11 +249,11 @@ Behaviour is the same as `IO#write_nonblock` method.
260
249
  #puts(*objects)
261
250
  ```
262
251
 
263
- Typical helpers, see [`Zlib::GzipWriter`](https://ruby-doc.org/stdlib-2.6.1/libdoc/zlib/rdoc/Zlib/GzipWriter.html) docs.
252
+ Typical helpers, see [`Zlib::GzipWriter`](https://ruby-doc.org/stdlib-2.7.0/libdoc/zlib/rdoc/Zlib/GzipWriter.html) docs.
264
253
 
265
254
  ## Stream::Reader
266
255
 
267
- Its behaviour is similar to builtin [`Zlib::GzipReader`](https://ruby-doc.org/stdlib-2.6.1/libdoc/zlib/rdoc/Zlib/GzipReader.html).
256
+ Its behaviour is similar to builtin [`Zlib::GzipReader`](https://ruby-doc.org/stdlib-2.7.0/libdoc/zlib/rdoc/Zlib/GzipReader.html).
268
257
 
269
258
  Reader maintains both source and destination buffers, it accepts both `source_buffer_length` and `destination_buffer_length` options.
270
259
 
@@ -299,7 +288,7 @@ Set another encodings.
299
288
  #tell
300
289
  ```
301
290
 
302
- See [`IO`](https://ruby-doc.org/core-2.6.1/IO.html) docs.
291
+ See [`IO`](https://ruby-doc.org/core-2.7.0/IO.html) docs.
303
292
 
304
293
  ```
305
294
  #read(bytes_to_read = nil, out_buffer = nil)
@@ -309,14 +298,14 @@ See [`IO`](https://ruby-doc.org/core-2.6.1/IO.html) docs.
309
298
  #closed?
310
299
  ```
311
300
 
312
- See [`Zlib::GzipReader`](https://ruby-doc.org/stdlib-2.6.1/libdoc/zlib/rdoc/Zlib/GzipReader.html) docs.
301
+ See [`Zlib::GzipReader`](https://ruby-doc.org/stdlib-2.7.0/libdoc/zlib/rdoc/Zlib/GzipReader.html) docs.
313
302
 
314
303
  ```
315
304
  #readpartial(bytes_to_read = nil, out_buffer = nil)
316
305
  #read_nonblock(bytes_to_read, out_buffer = nil, *options)
317
306
  ```
318
307
 
319
- See [`IO`](https://ruby-doc.org/core-2.6.1/IO.html) docs.
308
+ See [`IO`](https://ruby-doc.org/core-2.7.0/IO.html) docs.
320
309
 
321
310
  ```
322
311
  #getbyte
@@ -339,13 +328,13 @@ See [`IO`](https://ruby-doc.org/core-2.6.1/IO.html) docs.
339
328
  #ungetline(line)
340
329
  ```
341
330
 
342
- Typical helpers, see [`Zlib::GzipReader`](https://ruby-doc.org/stdlib-2.6.1/libdoc/zlib/rdoc/Zlib/GzipReader.html) docs.
331
+ Typical helpers, see [`Zlib::GzipReader`](https://ruby-doc.org/stdlib-2.7.0/libdoc/zlib/rdoc/Zlib/GzipReader.html) docs.
343
332
 
344
333
  ## CI
345
334
 
346
- Travis and Appveyor CI uses [scripts/ci_test.sh](scripts/ci_test.sh) directly.
347
- Cirrus and Circle CI uses prebuilt [scripts/test-images](scripts/test-images).
348
- Cirrus CI uses amd64 image, Circle CI - i686.
335
+ See universal test script [scripts/ci_test.sh](scripts/ci_test.sh) for CI.
336
+ Please visit [scripts/test-images](scripts/test-images).
337
+ You can run this test script using many native and cross images.
349
338
 
350
339
  ## License
351
340
 
@@ -10,4 +10,7 @@
10
10
 
11
11
  typedef uint_fast8_t brs_ext_result_t;
12
12
 
13
+ typedef uint8_t brs_ext_byte_t;
14
+ typedef uint_fast8_t brs_ext_byte_fast_t;
15
+
13
16
  #endif // BRS_EXT_COMMON_H
@@ -5,7 +5,6 @@
5
5
 
6
6
  #include <brotli/decode.h>
7
7
 
8
- #include "brs_ext/common.h"
9
8
  #include "ruby.h"
10
9
 
11
10
  brs_ext_result_t brs_ext_get_decompressor_error(BrotliDecoderErrorCode error_code)
@@ -6,13 +6,11 @@
6
6
  #include <brotli/decode.h>
7
7
  #include <brotli/encode.h>
8
8
  #include <brotli/types.h>
9
- #include <stdint.h>
10
9
  #include <stdio.h>
11
10
  #include <stdlib.h>
12
11
  #include <string.h>
13
12
 
14
13
  #include "brs_ext/buffer.h"
15
- #include "brs_ext/common.h"
16
14
  #include "brs_ext/error.h"
17
15
  #include "brs_ext/io.h"
18
16
  #include "brs_ext/macro.h"
@@ -26,7 +24,7 @@ enum {
26
24
 
27
25
  // -- file --
28
26
 
29
- static inline brs_ext_result_t read_file(FILE* source_file, uint8_t* source_buffer, size_t* source_length_ptr, size_t source_buffer_length)
27
+ static inline brs_ext_result_t read_file(FILE* source_file, brs_ext_byte_t* source_buffer, size_t* source_length_ptr, size_t source_buffer_length)
30
28
  {
31
29
  size_t read_length = fread(source_buffer, 1, source_buffer_length, source_file);
32
30
  if (read_length == 0 && feof(source_file)) {
@@ -42,7 +40,7 @@ static inline brs_ext_result_t read_file(FILE* source_file, uint8_t* source_buff
42
40
  return 0;
43
41
  }
44
42
 
45
- static inline brs_ext_result_t write_file(FILE* destination_file, uint8_t* destination_buffer, size_t destination_length)
43
+ static inline brs_ext_result_t write_file(FILE* destination_file, brs_ext_byte_t* destination_buffer, size_t destination_length)
46
44
  {
47
45
  size_t written_length = fwrite(destination_buffer, 1, destination_length, destination_file);
48
46
  if (written_length != destination_length) {
@@ -55,15 +53,15 @@ static inline brs_ext_result_t write_file(FILE* destination_file, uint8_t* desti
55
53
  // -- buffer --
56
54
 
57
55
  static inline brs_ext_result_t create_buffers(
58
- uint8_t** source_buffer_ptr, size_t source_buffer_length,
59
- uint8_t** destination_buffer_ptr, size_t destination_buffer_length)
56
+ brs_ext_byte_t** source_buffer_ptr, size_t source_buffer_length,
57
+ brs_ext_byte_t** destination_buffer_ptr, size_t destination_buffer_length)
60
58
  {
61
- uint8_t* source_buffer = malloc(source_buffer_length);
59
+ brs_ext_byte_t* source_buffer = malloc(source_buffer_length);
62
60
  if (source_buffer == NULL) {
63
61
  return BRS_EXT_ERROR_ALLOCATE_FAILED;
64
62
  }
65
63
 
66
- uint8_t* destination_buffer = malloc(destination_buffer_length);
64
+ brs_ext_byte_t* destination_buffer = malloc(destination_buffer_length);
67
65
  if (destination_buffer == NULL) {
68
66
  free(source_buffer);
69
67
  return BRS_EXT_ERROR_ALLOCATE_FAILED;
@@ -82,12 +80,12 @@ static inline brs_ext_result_t create_buffers(
82
80
  // Algorithm can use same buffer again.
83
81
 
84
82
  static inline brs_ext_result_t read_more_source(
85
- FILE* source_file,
86
- const uint8_t** source_ptr, size_t* source_length_ptr,
87
- uint8_t* source_buffer, size_t source_buffer_length)
83
+ FILE* source_file,
84
+ const brs_ext_byte_t** source_ptr, size_t* source_length_ptr,
85
+ brs_ext_byte_t* source_buffer, size_t source_buffer_length)
88
86
  {
89
- const uint8_t* source = *source_ptr;
90
- size_t source_length = *source_length_ptr;
87
+ const brs_ext_byte_t* source = *source_ptr;
88
+ size_t source_length = *source_length_ptr;
91
89
 
92
90
  if (source != source_buffer) {
93
91
  if (source_length != 0) {
@@ -104,8 +102,8 @@ static inline brs_ext_result_t read_more_source(
104
102
  return BRS_EXT_ERROR_NOT_ENOUGH_SOURCE_BUFFER;
105
103
  }
106
104
 
107
- uint8_t* remaining_source_buffer = source_buffer + source_length;
108
- size_t new_source_length;
105
+ brs_ext_byte_t* remaining_source_buffer = source_buffer + source_length;
106
+ size_t new_source_length;
109
107
 
110
108
  brs_ext_result_t ext_result = read_file(source_file, remaining_source_buffer, &new_source_length, remaining_source_buffer_length);
111
109
  if (ext_result != 0) {
@@ -160,8 +158,8 @@ static inline brs_ext_result_t read_more_source(
160
158
  // Than algorithm can use same buffer again.
161
159
 
162
160
  static inline brs_ext_result_t flush_destination_buffer(
163
- FILE* destination_file,
164
- uint8_t* destination_buffer, size_t* destination_length_ptr, size_t destination_buffer_length)
161
+ FILE* destination_file,
162
+ brs_ext_byte_t* destination_buffer, size_t* destination_length_ptr, size_t destination_buffer_length)
165
163
  {
166
164
  if (*destination_length_ptr == 0) {
167
165
  // We want to write more data at once, than buffer has.
@@ -178,7 +176,7 @@ static inline brs_ext_result_t flush_destination_buffer(
178
176
  return 0;
179
177
  }
180
178
 
181
- static inline brs_ext_result_t write_remaining_destination(FILE* destination_file, uint8_t* destination_buffer, size_t destination_length)
179
+ static inline brs_ext_result_t write_remaining_destination(FILE* destination_file, brs_ext_byte_t* destination_buffer, size_t destination_length)
182
180
  {
183
181
  if (destination_length == 0) {
184
182
  return 0;
@@ -203,17 +201,17 @@ static inline brs_ext_result_t write_remaining_destination(FILE* destination_fil
203
201
  // -- compress --
204
202
 
205
203
  static inline brs_ext_result_t buffered_compress(
206
- BrotliEncoderState* state_ptr,
207
- const uint8_t** source_ptr, size_t* source_length_ptr,
208
- FILE* destination_file, uint8_t* destination_buffer, size_t* destination_length_ptr, size_t destination_buffer_length)
204
+ BrotliEncoderState* state_ptr,
205
+ const brs_ext_byte_t** source_ptr, size_t* source_length_ptr,
206
+ FILE* destination_file, brs_ext_byte_t* destination_buffer, size_t* destination_length_ptr, size_t destination_buffer_length)
209
207
  {
210
208
  BROTLI_BOOL result;
211
209
  brs_ext_result_t ext_result;
212
210
 
213
211
  while (true) {
214
- uint8_t* remaining_destination_buffer = destination_buffer + *destination_length_ptr;
215
- size_t remaining_destination_buffer_length = destination_buffer_length - *destination_length_ptr;
216
- size_t prev_remaining_destination_buffer_length = remaining_destination_buffer_length;
212
+ brs_ext_byte_t* remaining_destination_buffer = destination_buffer + *destination_length_ptr;
213
+ size_t remaining_destination_buffer_length = destination_buffer_length - *destination_length_ptr;
214
+ size_t prev_remaining_destination_buffer_length = remaining_destination_buffer_length;
217
215
 
218
216
  result = BrotliEncoderCompressStream(
219
217
  state_ptr,
@@ -248,18 +246,18 @@ static inline brs_ext_result_t buffered_compress(
248
246
 
249
247
  static inline brs_ext_result_t buffered_compressor_finish(
250
248
  BrotliEncoderState* state_ptr,
251
- FILE* destination_file, uint8_t* destination_buffer, size_t* destination_length_ptr, size_t destination_buffer_length)
249
+ FILE* destination_file, brs_ext_byte_t* destination_buffer, size_t* destination_length_ptr, size_t destination_buffer_length)
252
250
  {
253
251
  BROTLI_BOOL result;
254
252
  brs_ext_result_t ext_result;
255
253
 
256
- const uint8_t* source = NULL;
257
- size_t source_length = 0;
254
+ const brs_ext_byte_t* source = NULL;
255
+ size_t source_length = 0;
258
256
 
259
257
  while (true) {
260
- uint8_t* remaining_destination_buffer = destination_buffer + *destination_length_ptr;
261
- size_t remaining_destination_buffer_length = destination_buffer_length - *destination_length_ptr;
262
- size_t prev_remaining_destination_buffer_length = remaining_destination_buffer_length;
258
+ brs_ext_byte_t* remaining_destination_buffer = destination_buffer + *destination_length_ptr;
259
+ size_t remaining_destination_buffer_length = destination_buffer_length - *destination_length_ptr;
260
+ size_t prev_remaining_destination_buffer_length = remaining_destination_buffer_length;
263
261
 
264
262
  result = BrotliEncoderCompressStream(
265
263
  state_ptr,
@@ -294,14 +292,14 @@ static inline brs_ext_result_t buffered_compressor_finish(
294
292
 
295
293
  static inline brs_ext_result_t compress(
296
294
  BrotliEncoderState* state_ptr,
297
- FILE* source_file, uint8_t* source_buffer, size_t source_buffer_length,
298
- FILE* destination_file, uint8_t* destination_buffer, size_t destination_buffer_length)
295
+ FILE* source_file, brs_ext_byte_t* source_buffer, size_t source_buffer_length,
296
+ FILE* destination_file, brs_ext_byte_t* destination_buffer, size_t destination_buffer_length)
299
297
  {
300
298
  brs_ext_result_t ext_result;
301
299
 
302
- const uint8_t* source = source_buffer;
303
- size_t source_length = 0;
304
- size_t destination_length = 0;
300
+ const brs_ext_byte_t* source = source_buffer;
301
+ size_t source_length = 0;
302
+ size_t destination_length = 0;
305
303
 
306
304
  BUFFERED_READ_SOURCE(
307
305
  buffered_compress,
@@ -347,8 +345,8 @@ VALUE brs_ext_compress_io(VALUE BRS_EXT_UNUSED(self), VALUE source, VALUE destin
347
345
  destination_buffer_length = BRS_DEFAULT_DESTINATION_BUFFER_LENGTH_FOR_COMPRESSOR;
348
346
  }
349
347
 
350
- uint8_t* source_buffer;
351
- uint8_t* destination_buffer;
348
+ brs_ext_byte_t* source_buffer;
349
+ brs_ext_byte_t* destination_buffer;
352
350
 
353
351
  ext_result = create_buffers(
354
352
  &source_buffer, source_buffer_length,
@@ -381,17 +379,17 @@ VALUE brs_ext_compress_io(VALUE BRS_EXT_UNUSED(self), VALUE source, VALUE destin
381
379
  // -- decompress --
382
380
 
383
381
  static inline brs_ext_result_t buffered_decompress(
384
- BrotliDecoderState* state_ptr,
385
- const uint8_t** source_ptr, size_t* source_length_ptr,
386
- FILE* destination_file, uint8_t* destination_buffer, size_t* destination_length_ptr, size_t destination_buffer_length)
382
+ BrotliDecoderState* state_ptr,
383
+ const brs_ext_byte_t** source_ptr, size_t* source_length_ptr,
384
+ FILE* destination_file, brs_ext_byte_t* destination_buffer, size_t* destination_length_ptr, size_t destination_buffer_length)
387
385
  {
388
386
  BrotliDecoderResult result;
389
387
  brs_ext_result_t ext_result;
390
388
 
391
389
  while (true) {
392
- uint8_t* remaining_destination_buffer = destination_buffer + *destination_length_ptr;
393
- size_t remaining_destination_buffer_length = destination_buffer_length - *destination_length_ptr;
394
- size_t prev_remaining_destination_buffer_length = remaining_destination_buffer_length;
390
+ brs_ext_byte_t* remaining_destination_buffer = destination_buffer + *destination_length_ptr;
391
+ size_t remaining_destination_buffer_length = destination_buffer_length - *destination_length_ptr;
392
+ size_t prev_remaining_destination_buffer_length = remaining_destination_buffer_length;
395
393
 
396
394
  result = BrotliDecoderDecompressStream(
397
395
  state_ptr,
@@ -429,14 +427,14 @@ static inline brs_ext_result_t buffered_decompress(
429
427
 
430
428
  static inline brs_ext_result_t decompress(
431
429
  BrotliDecoderState* state_ptr,
432
- FILE* source_file, uint8_t* source_buffer, size_t source_buffer_length,
433
- FILE* destination_file, uint8_t* destination_buffer, size_t destination_buffer_length)
430
+ FILE* source_file, brs_ext_byte_t* source_buffer, size_t source_buffer_length,
431
+ FILE* destination_file, brs_ext_byte_t* destination_buffer, size_t destination_buffer_length)
434
432
  {
435
433
  brs_ext_result_t ext_result;
436
434
 
437
- const uint8_t* source = source_buffer;
438
- size_t source_length = 0;
439
- size_t destination_length = 0;
435
+ const brs_ext_byte_t* source = source_buffer;
436
+ size_t source_length = 0;
437
+ size_t destination_length = 0;
440
438
 
441
439
  BUFFERED_READ_SOURCE(
442
440
  buffered_decompress,
@@ -474,8 +472,8 @@ VALUE brs_ext_decompress_io(VALUE BRS_EXT_UNUSED(self), VALUE source, VALUE dest
474
472
  destination_buffer_length = BRS_DEFAULT_DESTINATION_BUFFER_LENGTH_FOR_DECOMPRESSOR;
475
473
  }
476
474
 
477
- uint8_t* source_buffer;
478
- uint8_t* destination_buffer;
475
+ brs_ext_byte_t* source_buffer;
476
+ brs_ext_byte_t* destination_buffer;
479
477
 
480
478
  ext_result = create_buffers(
481
479
  &source_buffer, source_buffer_length,