zstdlib 0.1.1-x64-mingw32 → 0.1.2-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,4 @@
1
+ #include <zstd.h>
1
2
  /*
2
3
  * zlib.c - An interface for zlib.
3
4
  *
@@ -7,7 +8,7 @@
7
8
  */
8
9
 
9
10
  #include <ruby.h>
10
- #include <zlib.h>
11
+ #include <zstd_zlibwrapper.h>
11
12
  #include <time.h>
12
13
  #include <ruby/io.h>
13
14
  #include <ruby/thread.h>
@@ -250,48 +251,48 @@ static VALUE rb_gzreader_readlines(int, VALUE*, VALUE);
250
251
  * Using the wrapper to compress strings with default parameters is quite
251
252
  * simple:
252
253
  *
253
- * require "zlib"
254
+ * require "zstdlib"
254
255
  *
255
256
  * data_to_compress = File.read("don_quixote.txt")
256
257
  *
257
258
  * puts "Input size: #{data_to_compress.size}"
258
259
  * #=> Input size: 2347740
259
260
  *
260
- * data_compressed = Zlib::Deflate.deflate(data_to_compress)
261
+ * data_compressed = Zstdlib::Deflate.deflate(data_to_compress)
261
262
  *
262
263
  * puts "Compressed size: #{data_compressed.size}"
263
264
  * #=> Compressed size: 887238
264
265
  *
265
- * uncompressed_data = Zlib::Inflate.inflate(data_compressed)
266
+ * uncompressed_data = Zstdlib::Inflate.inflate(data_compressed)
266
267
  *
267
268
  * puts "Uncompressed data is: #{uncompressed_data}"
268
269
  * #=> Uncompressed data is: The Project Gutenberg EBook of Don Quixote...
269
270
  *
270
271
  * == Class tree
271
272
  *
272
- * - Zlib::Deflate
273
- * - Zlib::Inflate
274
- * - Zlib::ZStream
275
- * - Zlib::Error
276
- * - Zlib::StreamEnd
277
- * - Zlib::NeedDict
278
- * - Zlib::DataError
279
- * - Zlib::StreamError
280
- * - Zlib::MemError
281
- * - Zlib::BufError
282
- * - Zlib::VersionError
273
+ * - Zstdlib::Deflate
274
+ * - Zstdlib::Inflate
275
+ * - Zstdlib::ZStream
276
+ * - Zstdlib::Error
277
+ * - Zstdlib::StreamEnd
278
+ * - Zstdlib::NeedDict
279
+ * - Zstdlib::DataError
280
+ * - Zstdlib::StreamError
281
+ * - Zstdlib::MemError
282
+ * - Zstdlib::BufError
283
+ * - Zstdlib::VersionError
283
284
  *
284
285
  * (if you have GZIP_SUPPORT)
285
- * - Zlib::GzipReader
286
- * - Zlib::GzipWriter
287
- * - Zlib::GzipFile
288
- * - Zlib::GzipFile::Error
289
- * - Zlib::GzipFile::LengthError
290
- * - Zlib::GzipFile::CRCError
291
- * - Zlib::GzipFile::NoFooter
286
+ * - Zstdlib::GzipReader
287
+ * - Zstdlib::GzipWriter
288
+ * - Zstdlib::GzipFile
289
+ * - Zstdlib::GzipFile::Error
290
+ * - Zstdlib::GzipFile::LengthError
291
+ * - Zstdlib::GzipFile::CRCError
292
+ * - Zstdlib::GzipFile::NoFooter
292
293
  *
293
294
  */
294
- void Init_zlib(void);
295
+ void Init_zstdlib(void);
295
296
 
296
297
  /*--------- Exceptions --------*/
297
298
 
@@ -351,9 +352,22 @@ finalizer_warn(const char *msg)
351
352
 
352
353
 
353
354
  /*-------- module Zlib --------*/
355
+ /*
356
+ * Document-method: Zstdlib.zstd_version
357
+ *
358
+ * Returns the string which represents the version of zstd library.
359
+ */
360
+ static VALUE
361
+ rb_zstd_version(VALUE klass)
362
+ {
363
+ VALUE str;
364
+ str = rb_str_new2(ZSTD_versionString());
365
+ OBJ_TAINT(str);
366
+ return str;
367
+ }
354
368
 
355
369
  /*
356
- * Document-method: Zlib.zlib_version
370
+ * Document-method: Zstdlib.zlib_version
357
371
  *
358
372
  * Returns the string which represents the version of zlib library.
359
373
  */
@@ -414,9 +428,9 @@ do_checksum(int argc, VALUE *argv, uLong (*func)(uLong, const Bytef*, uInt))
414
428
  }
415
429
 
416
430
  /*
417
- * Document-method: Zlib.adler32
431
+ * Document-method: Zstdlib.adler32
418
432
  *
419
- * call-seq: Zlib.adler32(string, adler)
433
+ * call-seq: Zstdlib.adler32(string, adler)
420
434
  *
421
435
  * Calculates Adler-32 checksum for +string+, and returns updated value of
422
436
  * +adler+. If +string+ is omitted, it returns the Adler-32 initial value. If
@@ -424,10 +438,10 @@ do_checksum(int argc, VALUE *argv, uLong (*func)(uLong, const Bytef*, uInt))
424
438
  *
425
439
  * Example usage:
426
440
  *
427
- * require "zlib"
441
+ * require "zstdlib"
428
442
  *
429
443
  * data = "foo"
430
- * puts "Adler32 checksum: #{Zlib.adler32(data).to_s(16)}"
444
+ * puts "Adler32 checksum: #{Zstdlib.adler32(data).to_s(16)}"
431
445
  * #=> Adler32 checksum: 2820145
432
446
  *
433
447
  */
@@ -439,9 +453,9 @@ rb_zlib_adler32(int argc, VALUE *argv, VALUE klass)
439
453
 
440
454
  #ifdef HAVE_ADLER32_COMBINE
441
455
  /*
442
- * Document-method: Zlib.adler32_combine
456
+ * Document-method: Zstdlib.adler32_combine
443
457
  *
444
- * call-seq: Zlib.adler32_combine(adler1, adler2, len2)
458
+ * call-seq: Zstdlib.adler32_combine(adler1, adler2, len2)
445
459
  *
446
460
  * Combine two Adler-32 check values in to one. +alder1+ is the first Adler-32
447
461
  * value, +adler2+ is the second Adler-32 value. +len2+ is the length of the
@@ -459,9 +473,9 @@ rb_zlib_adler32_combine(VALUE klass, VALUE adler1, VALUE adler2, VALUE len2)
459
473
  #endif
460
474
 
461
475
  /*
462
- * Document-method: Zlib.crc32
476
+ * Document-method: Zstdlib.crc32
463
477
  *
464
- * call-seq: Zlib.crc32(string, crc)
478
+ * call-seq: Zstdlib.crc32(string, crc)
465
479
  *
466
480
  * Calculates CRC checksum for +string+, and returns updated value of +crc+. If
467
481
  * +string+ is omitted, it returns the CRC initial value. If +crc+ is omitted, it
@@ -477,9 +491,9 @@ rb_zlib_crc32(int argc, VALUE *argv, VALUE klass)
477
491
 
478
492
  #ifdef HAVE_CRC32_COMBINE
479
493
  /*
480
- * Document-method: Zlib.crc32_combine
494
+ * Document-method: Zstdlib.crc32_combine
481
495
  *
482
- * call-seq: Zlib.crc32_combine(crc1, crc2, len2)
496
+ * call-seq: Zstdlib.crc32_combine(crc1, crc2, len2)
483
497
  *
484
498
  * Combine two CRC-32 check values in to one. +crc1+ is the first CRC-32
485
499
  * value, +crc2+ is the second CRC-32 value. +len2+ is the length of the
@@ -497,7 +511,7 @@ rb_zlib_crc32_combine(VALUE klass, VALUE crc1, VALUE crc2, VALUE len2)
497
511
  #endif
498
512
 
499
513
  /*
500
- * Document-method: Zlib.crc_table
514
+ * Document-method: Zstdlib.crc_table
501
515
  *
502
516
  * Returns the table for calculating CRC checksum as an array.
503
517
  */
@@ -1171,19 +1185,19 @@ get_zstream(VALUE obj)
1171
1185
  /* ------------------------------------------------------------------------- */
1172
1186
 
1173
1187
  /*
1174
- * Document-class: Zlib::ZStream
1188
+ * Document-class: Zstdlib::ZStream
1175
1189
  *
1176
- * Zlib::ZStream is the abstract class for the stream which handles the
1190
+ * Zstdlib::ZStream is the abstract class for the stream which handles the
1177
1191
  * compressed data. The operations are defined in the subclasses:
1178
- * Zlib::Deflate for compression, and Zlib::Inflate for decompression.
1192
+ * Zstdlib::Deflate for compression, and Zstdlib::Inflate for decompression.
1179
1193
  *
1180
- * An instance of Zlib::ZStream has one stream (struct zstream in the source)
1194
+ * An instance of Zstdlib::ZStream has one stream (struct zstream in the source)
1181
1195
  * and two variable-length buffers which associated to the input (next_in) of
1182
1196
  * the stream and the output (next_out) of the stream. In this document,
1183
1197
  * "input buffer" means the buffer for input, and "output buffer" means the
1184
1198
  * buffer for output.
1185
1199
  *
1186
- * Data input into an instance of Zlib::ZStream are temporally stored into
1200
+ * Data input into an instance of Zstdlib::ZStream are temporally stored into
1187
1201
  * the end of input buffer, and then data in input buffer are processed from
1188
1202
  * the beginning of the buffer until no more output from the stream is
1189
1203
  * produced (i.e. until avail_out > 0 after processing). During processing,
@@ -1195,7 +1209,7 @@ get_zstream(VALUE obj)
1195
1209
  *
1196
1210
  * Here is an ascii art for describing above:
1197
1211
  *
1198
- * +================ an instance of Zlib::ZStream ================+
1212
+ * +================ an instance of Zstdlib::ZStream ================+
1199
1213
  * || ||
1200
1214
  * || +--------+ +-------+ +--------+ ||
1201
1215
  * || +--| output |<---------|zstream|<---------| input |<--+ ||
@@ -1208,15 +1222,15 @@ get_zstream(VALUE obj)
1208
1222
  * "output data" "input data"
1209
1223
  *
1210
1224
  * If an error occurs during processing input buffer, an exception which is a
1211
- * subclass of Zlib::Error is raised. At that time, both input and output
1225
+ * subclass of Zstdlib::Error is raised. At that time, both input and output
1212
1226
  * buffer keep their conditions at the time when the error occurs.
1213
1227
  *
1214
1228
  * == Method Catalogue
1215
1229
  *
1216
1230
  * Many of the methods in this class are fairly low-level and unlikely to be
1217
1231
  * of interest to users. In fact, users are unlikely to use this class
1218
- * directly; rather they will be interested in Zlib::Inflate and
1219
- * Zlib::Deflate.
1232
+ * directly; rather they will be interested in Zstdlib::Inflate and
1233
+ * Zstdlib::Deflate.
1220
1234
  *
1221
1235
  * The higher level methods are listed below.
1222
1236
  *
@@ -1408,9 +1422,9 @@ rb_zstream_closed_p(VALUE obj)
1408
1422
  /* ------------------------------------------------------------------------- */
1409
1423
 
1410
1424
  /*
1411
- * Document-class: Zlib::Deflate
1425
+ * Document-class: Zstdlib::Deflate
1412
1426
  *
1413
- * Zlib::Deflate is the class for compressing data. See Zlib::ZStream for more
1427
+ * Zstdlib::Deflate is the class for compressing data. See Zstdlib::ZStream for more
1414
1428
  * information.
1415
1429
  */
1416
1430
 
@@ -1418,7 +1432,7 @@ rb_zstream_closed_p(VALUE obj)
1418
1432
  (NIL_P((val)) ? (ifnil) \
1419
1433
  : (FIX2INT((val))))
1420
1434
 
1421
- #define ARG_LEVEL(val) FIXNUMARG((val), Z_DEFAULT_COMPRESSION)
1435
+ #define ARG_LEVEL(val) FIXNUMARG((val), ZSTD_CLEVEL_DEFAULT)
1422
1436
  #define ARG_WBITS(val) FIXNUMARG((val), MAX_WBITS)
1423
1437
  #define ARG_MEMLEVEL(val) FIXNUMARG((val), DEF_MEM_LEVEL)
1424
1438
  #define ARG_STRATEGY(val) FIXNUMARG((val), Z_DEFAULT_STRATEGY)
@@ -1432,10 +1446,10 @@ rb_deflate_s_allocate(VALUE klass)
1432
1446
  }
1433
1447
 
1434
1448
  /*
1435
- * Document-method: Zlib::Deflate.new
1449
+ * Document-method: Zstdlib::Deflate.new
1436
1450
  *
1437
1451
  * call-seq:
1438
- * Zlib::Deflate.new(level=DEFAULT_COMPRESSION, window_bits=MAX_WBITS, mem_level=DEF_MEM_LEVEL, strategy=DEFAULT_STRATEGY)
1452
+ * Zstdlib::Deflate.new(level=DEFAULT_COMPRESSION, window_bits=MAX_WBITS, mem_level=DEF_MEM_LEVEL, strategy=DEFAULT_STRATEGY)
1439
1453
  *
1440
1454
  * Creates a new deflate stream for compression. If a given argument is nil,
1441
1455
  * the default value of that argument is used.
@@ -1444,10 +1458,10 @@ rb_deflate_s_allocate(VALUE klass)
1444
1458
  * compression) and 9 (best compression). The following constants have been
1445
1459
  * defined to make code more readable:
1446
1460
  *
1447
- * * Zlib::DEFAULT_COMPRESSION
1448
- * * Zlib::NO_COMPRESSION
1449
- * * Zlib::BEST_SPEED
1450
- * * Zlib::BEST_COMPRESSION
1461
+ * * Zstdlib::DEFAULT_COMPRESSION
1462
+ * * Zstdlib::NO_COMPRESSION
1463
+ * * Zstdlib::BEST_SPEED
1464
+ * * Zstdlib::BEST_COMPRESSION
1451
1465
  *
1452
1466
  * See http://www.zlib.net/manual.html#Constants for further information.
1453
1467
  *
@@ -1460,17 +1474,17 @@ rb_deflate_s_allocate(VALUE klass)
1460
1474
  * compression ratio while 9 uses maximum memory for optimal speed. The
1461
1475
  * default value is 8. Two constants are defined:
1462
1476
  *
1463
- * * Zlib::DEF_MEM_LEVEL
1464
- * * Zlib::MAX_MEM_LEVEL
1477
+ * * Zstdlib::DEF_MEM_LEVEL
1478
+ * * Zstdlib::MAX_MEM_LEVEL
1465
1479
  *
1466
1480
  * The +strategy+ sets the deflate compression strategy. The following
1467
1481
  * strategies are available:
1468
1482
  *
1469
- * Zlib::DEFAULT_STRATEGY:: For normal data
1470
- * Zlib::FILTERED:: For data produced by a filter or predictor
1471
- * Zlib::FIXED:: Prevents dynamic Huffman codes
1472
- * Zlib::HUFFMAN_ONLY:: Prevents string matching
1473
- * Zlib::RLE:: Designed for better compression of PNG image data
1483
+ * Zstdlib::DEFAULT_STRATEGY:: For normal data
1484
+ * Zstdlib::FILTERED:: For data produced by a filter or predictor
1485
+ * Zstdlib::FIXED:: Prevents dynamic Huffman codes
1486
+ * Zstdlib::HUFFMAN_ONLY:: Prevents string matching
1487
+ * Zstdlib::RLE:: Designed for better compression of PNG image data
1474
1488
  *
1475
1489
  * See the constants for further description.
1476
1490
  *
@@ -1479,16 +1493,16 @@ rb_deflate_s_allocate(VALUE klass)
1479
1493
  * === Basic
1480
1494
  *
1481
1495
  * open "compressed.file", "w+" do |io|
1482
- * io << Zlib::Deflate.new.deflate(File.read("big.file"))
1496
+ * io << Zstdlib::Deflate.new.deflate(File.read("big.file"))
1483
1497
  * end
1484
1498
  *
1485
1499
  * === Custom compression
1486
1500
  *
1487
1501
  * open "compressed.file", "w+" do |compressed_io|
1488
- * deflate = Zlib::Deflate.new(Zlib::BEST_COMPRESSION,
1489
- * Zlib::MAX_WBITS,
1490
- * Zlib::MAX_MEM_LEVEL,
1491
- * Zlib::HUFFMAN_ONLY)
1502
+ * deflate = Zstdlib::Deflate.new(Zstdlib::BEST_COMPRESSION,
1503
+ * Zstdlib::MAX_WBITS,
1504
+ * Zstdlib::MAX_MEM_LEVEL,
1505
+ * Zstdlib::HUFFMAN_ONLY)
1492
1506
  *
1493
1507
  * begin
1494
1508
  * open "big.file" do |big_io|
@@ -1526,7 +1540,7 @@ rb_deflate_initialize(int argc, VALUE *argv, VALUE obj)
1526
1540
  }
1527
1541
 
1528
1542
  /*
1529
- * Document-method: Zlib::Deflate#initialize_copy
1543
+ * Document-method: Zstdlib::Deflate#initialize_copy
1530
1544
  *
1531
1545
  * Duplicates the deflate stream.
1532
1546
  */
@@ -1562,26 +1576,26 @@ deflate_run(VALUE args)
1562
1576
  }
1563
1577
 
1564
1578
  /*
1565
- * Document-method: Zlib::Deflate.deflate
1579
+ * Document-method: Zstdlib::Deflate.deflate
1566
1580
  *
1567
1581
  * call-seq:
1568
- * Zlib.deflate(string[, level])
1569
- * Zlib::Deflate.deflate(string[, level])
1582
+ * Zstdlib.deflate(string[, level])
1583
+ * Zstdlib::Deflate.deflate(string[, level])
1570
1584
  *
1571
1585
  * Compresses the given +string+. Valid values of level are
1572
- * Zlib::NO_COMPRESSION, Zlib::BEST_SPEED, Zlib::BEST_COMPRESSION,
1573
- * Zlib::DEFAULT_COMPRESSION, or an integer from 0 to 9.
1586
+ * Zstdlib::NO_COMPRESSION, Zstdlib::BEST_SPEED, Zstdlib::BEST_COMPRESSION,
1587
+ * Zstdlib::DEFAULT_COMPRESSION, or an integer from 0 to 9.
1574
1588
  *
1575
1589
  * This method is almost equivalent to the following code:
1576
1590
  *
1577
1591
  * def deflate(string, level)
1578
- * z = Zlib::Deflate.new(level)
1579
- * dst = z.deflate(string, Zlib::FINISH)
1592
+ * z = Zstdlib::Deflate.new(level)
1593
+ * dst = z.deflate(string, Zstdlib::FINISH)
1580
1594
  * z.close
1581
1595
  * dst
1582
1596
  * end
1583
1597
  *
1584
- * See also Zlib.inflate
1598
+ * See also Zstdlib.inflate
1585
1599
  *
1586
1600
  */
1587
1601
  static VALUE
@@ -1624,16 +1638,16 @@ do_deflate(struct zstream *z, VALUE src, int flush)
1624
1638
  }
1625
1639
 
1626
1640
  /*
1627
- * Document-method: Zlib::Deflate#deflate
1641
+ * Document-method: Zstdlib::Deflate#deflate
1628
1642
  *
1629
1643
  * call-seq:
1630
- * z.deflate(string, flush = Zlib::NO_FLUSH) -> String
1631
- * z.deflate(string, flush = Zlib::NO_FLUSH) { |chunk| ... } -> nil
1644
+ * z.deflate(string, flush = Zstdlib::NO_FLUSH) -> String
1645
+ * z.deflate(string, flush = Zstdlib::NO_FLUSH) { |chunk| ... } -> nil
1632
1646
  *
1633
1647
  * Inputs +string+ into the deflate stream and returns the output from the
1634
1648
  * stream. On calling this method, both the input and the output buffers of
1635
1649
  * the stream are flushed. If +string+ is nil, this method finishes the
1636
- * stream, just like Zlib::ZStream#finish.
1650
+ * stream, just like Zstdlib::ZStream#finish.
1637
1651
  *
1638
1652
  * If a block is given consecutive deflated chunks from the +string+ are
1639
1653
  * yielded to the block and +nil+ is returned.
@@ -1641,10 +1655,10 @@ do_deflate(struct zstream *z, VALUE src, int flush)
1641
1655
  * The +flush+ parameter specifies the flush mode. The following constants
1642
1656
  * may be used:
1643
1657
  *
1644
- * Zlib::NO_FLUSH:: The default
1645
- * Zlib::SYNC_FLUSH:: Flushes the output to a byte boundary
1646
- * Zlib::FULL_FLUSH:: SYNC_FLUSH + resets the compression state
1647
- * Zlib::FINISH:: Pending input is processed, pending output is flushed.
1658
+ * Zstdlib::NO_FLUSH:: The default
1659
+ * Zstdlib::SYNC_FLUSH:: Flushes the output to a byte boundary
1660
+ * Zstdlib::FULL_FLUSH:: SYNC_FLUSH + resets the compression state
1661
+ * Zstdlib::FINISH:: Pending input is processed, pending output is flushed.
1648
1662
  *
1649
1663
  * See the constants for further description.
1650
1664
  *
@@ -1663,12 +1677,12 @@ rb_deflate_deflate(int argc, VALUE *argv, VALUE obj)
1663
1677
  }
1664
1678
 
1665
1679
  /*
1666
- * Document-method: Zlib::Deflate#<<
1680
+ * Document-method: Zstdlib::Deflate#<<
1667
1681
  *
1668
1682
  * call-seq: << string
1669
1683
  *
1670
- * Inputs +string+ into the deflate stream just like Zlib::Deflate#deflate, but
1671
- * returns the Zlib::Deflate object itself. The output from the stream is
1684
+ * Inputs +string+ into the deflate stream just like Zstdlib::Deflate#deflate, but
1685
+ * returns the Zstdlib::Deflate object itself. The output from the stream is
1672
1686
  * preserved in output buffer.
1673
1687
  */
1674
1688
  static VALUE
@@ -1680,18 +1694,18 @@ rb_deflate_addstr(VALUE obj, VALUE src)
1680
1694
  }
1681
1695
 
1682
1696
  /*
1683
- * Document-method: Zlib::Deflate#flush
1697
+ * Document-method: Zstdlib::Deflate#flush
1684
1698
  *
1685
1699
  * call-seq:
1686
- * flush(flush = Zlib::SYNC_FLUSH) -> String
1687
- * flush(flush = Zlib::SYNC_FLUSH) { |chunk| ... } -> nil
1700
+ * flush(flush = Zstdlib::SYNC_FLUSH) -> String
1701
+ * flush(flush = Zstdlib::SYNC_FLUSH) { |chunk| ... } -> nil
1688
1702
  *
1689
1703
  * This method is equivalent to <tt>deflate('', flush)</tt>. This method is
1690
1704
  * just provided to improve the readability of your Ruby program. If a block
1691
1705
  * is given chunks of deflate output are yielded to the block until the buffer
1692
1706
  * is flushed.
1693
1707
  *
1694
- * See Zlib::Deflate#deflate for detail on the +flush+ constants NO_FLUSH,
1708
+ * See Zstdlib::Deflate#deflate for detail on the +flush+ constants NO_FLUSH,
1695
1709
  * SYNC_FLUSH, FULL_FLUSH and FINISH.
1696
1710
  */
1697
1711
  static VALUE
@@ -1711,7 +1725,7 @@ rb_deflate_flush(int argc, VALUE *argv, VALUE obj)
1711
1725
  }
1712
1726
 
1713
1727
  /*
1714
- * Document-method: Zlib::Deflate.params
1728
+ * Document-method: Zstdlib::Deflate.params
1715
1729
  *
1716
1730
  * call-seq: params(level, strategy)
1717
1731
  *
@@ -1719,7 +1733,7 @@ rb_deflate_flush(int argc, VALUE *argv, VALUE obj)
1719
1733
  * different types of data that require different types of compression. Any
1720
1734
  * unprocessed data is flushed before changing the params.
1721
1735
  *
1722
- * See Zlib::Deflate.new for a description of +level+ and +strategy+.
1736
+ * See Zstdlib::Deflate.new for a description of +level+ and +strategy+.
1723
1737
  *
1724
1738
  */
1725
1739
  static VALUE
@@ -1754,12 +1768,12 @@ rb_deflate_params(VALUE obj, VALUE v_level, VALUE v_strategy)
1754
1768
  }
1755
1769
 
1756
1770
  /*
1757
- * Document-method: Zlib::Deflate.set_dictionary
1771
+ * Document-method: Zstdlib::Deflate.set_dictionary
1758
1772
  *
1759
1773
  * call-seq: set_dictionary(string)
1760
1774
  *
1761
1775
  * Sets the preset dictionary and returns +string+. This method is available
1762
- * just only after Zlib::Deflate.new or Zlib::ZStream#reset method was called.
1776
+ * just only after Zstdlib::Deflate.new or Zstdlib::ZStream#reset method was called.
1763
1777
  * See zlib.h for details.
1764
1778
  *
1765
1779
  * Can raise errors of Z_STREAM_ERROR if a parameter is invalid (such as
@@ -1789,10 +1803,10 @@ rb_deflate_set_dictionary(VALUE obj, VALUE dic)
1789
1803
  /* ------------------------------------------------------------------------- */
1790
1804
 
1791
1805
  /*
1792
- * Document-class: Zlib::Inflate
1806
+ * Document-class: Zstdlib::Inflate
1793
1807
  *
1794
1808
  * Zlib:Inflate is the class for decompressing compressed data. Unlike
1795
- * Zlib::Deflate, an instance of this class is not able to duplicate (clone,
1809
+ * Zstdlib::Deflate, an instance of this class is not able to duplicate (clone,
1796
1810
  * dup) itself.
1797
1811
  */
1798
1812
 
@@ -1805,10 +1819,10 @@ rb_inflate_s_allocate(VALUE klass)
1805
1819
  }
1806
1820
 
1807
1821
  /*
1808
- * Document-method: Zlib::Inflate.new
1822
+ * Document-method: Zstdlib::Inflate.new
1809
1823
  *
1810
1824
  * call-seq:
1811
- * Zlib::Inflate.new(window_bits = Zlib::MAX_WBITS)
1825
+ * Zstdlib::Inflate.new(window_bits = Zstdlib::MAX_WBITS)
1812
1826
  *
1813
1827
  * Creates a new inflate stream for decompression. +window_bits+ sets the
1814
1828
  * size of the history buffer and can have the following values:
@@ -1825,7 +1839,7 @@ rb_inflate_s_allocate(VALUE klass)
1825
1839
  * Greater than 15::
1826
1840
  * Add 32 to window_bits to enable zlib and gzip decoding with automatic
1827
1841
  * header detection, or add 16 to decode only the gzip format (a
1828
- * Zlib::DataError will be raised for a non-gzip stream).
1842
+ * Zstdlib::DataError will be raised for a non-gzip stream).
1829
1843
  *
1830
1844
  * (-8..-15)::
1831
1845
  * Enables raw deflate mode which will not generate a check value, and will
@@ -1837,7 +1851,7 @@ rb_inflate_s_allocate(VALUE klass)
1837
1851
  * == Example
1838
1852
  *
1839
1853
  * open "compressed.file" do |compressed_io|
1840
- * zi = Zlib::Inflate.new(Zlib::MAX_WBITS + 32)
1854
+ * zi = Zstdlib::Inflate.new(Zstdlib::MAX_WBITS + 32)
1841
1855
  *
1842
1856
  * begin
1843
1857
  * open "uncompressed.file", "w+" do |uncompressed_io|
@@ -1880,26 +1894,26 @@ inflate_run(VALUE args)
1880
1894
  }
1881
1895
 
1882
1896
  /*
1883
- * Document-method: Zlib::inflate
1897
+ * Document-method: Zstdlib::inflate
1884
1898
  *
1885
1899
  * call-seq:
1886
- * Zlib.inflate(string)
1887
- * Zlib::Inflate.inflate(string)
1900
+ * Zstdlib.inflate(string)
1901
+ * Zstdlib::Inflate.inflate(string)
1888
1902
  *
1889
- * Decompresses +string+. Raises a Zlib::NeedDict exception if a preset
1903
+ * Decompresses +string+. Raises a Zstdlib::NeedDict exception if a preset
1890
1904
  * dictionary is needed for decompression.
1891
1905
  *
1892
1906
  * This method is almost equivalent to the following code:
1893
1907
  *
1894
1908
  * def inflate(string)
1895
- * zstream = Zlib::Inflate.new
1909
+ * zstream = Zstdlib::Inflate.new
1896
1910
  * buf = zstream.inflate(string)
1897
1911
  * zstream.finish
1898
1912
  * zstream.close
1899
1913
  * buf
1900
1914
  * end
1901
1915
  *
1902
- * See also Zlib.deflate
1916
+ * See also Zstdlib.deflate
1903
1917
  *
1904
1918
  */
1905
1919
  static VALUE
@@ -1938,7 +1952,7 @@ do_inflate(struct zstream *z, VALUE src)
1938
1952
  }
1939
1953
  }
1940
1954
 
1941
- /* Document-method: Zlib::Inflate#add_dictionary
1955
+ /* Document-method: Zstdlib::Inflate#add_dictionary
1942
1956
  *
1943
1957
  * call-seq: add_dictionary(string)
1944
1958
  *
@@ -1959,7 +1973,7 @@ rb_inflate_add_dictionary(VALUE obj, VALUE dictionary)
1959
1973
  }
1960
1974
 
1961
1975
  /*
1962
- * Document-method: Zlib::Inflate#inflate
1976
+ * Document-method: Zstdlib::Inflate#inflate
1963
1977
  *
1964
1978
  * call-seq:
1965
1979
  * inflate(deflate_string) -> String
@@ -1968,22 +1982,22 @@ rb_inflate_add_dictionary(VALUE obj, VALUE dictionary)
1968
1982
  * Inputs +deflate_string+ into the inflate stream and returns the output from
1969
1983
  * the stream. Calling this method, both the input and the output buffer of
1970
1984
  * the stream are flushed. If string is +nil+, this method finishes the
1971
- * stream, just like Zlib::ZStream#finish.
1985
+ * stream, just like Zstdlib::ZStream#finish.
1972
1986
  *
1973
1987
  * If a block is given consecutive inflated chunks from the +deflate_string+
1974
1988
  * are yielded to the block and +nil+ is returned.
1975
1989
  *
1976
- * Raises a Zlib::NeedDict exception if a preset dictionary is needed to
1977
- * decompress. Set the dictionary by Zlib::Inflate#set_dictionary and then
1990
+ * Raises a Zstdlib::NeedDict exception if a preset dictionary is needed to
1991
+ * decompress. Set the dictionary by Zstdlib::Inflate#set_dictionary and then
1978
1992
  * call this method again with an empty string to flush the stream:
1979
1993
  *
1980
- * inflater = Zlib::Inflate.new
1994
+ * inflater = Zstdlib::Inflate.new
1981
1995
  *
1982
1996
  * begin
1983
1997
  * out = inflater.inflate compressed
1984
- * rescue Zlib::NeedDict
1998
+ * rescue Zstdlib::NeedDict
1985
1999
  * # ensure the dictionary matches the stream's required dictionary
1986
- * raise unless inflater.adler == Zlib.adler32(dictionary)
2000
+ * raise unless inflater.adler == Zstdlib.adler32(dictionary)
1987
2001
  *
1988
2002
  * inflater.set_dictionary dictionary
1989
2003
  * inflater.inflate ''
@@ -1993,7 +2007,7 @@ rb_inflate_add_dictionary(VALUE obj, VALUE dictionary)
1993
2007
  *
1994
2008
  * inflater.close
1995
2009
  *
1996
- * See also Zlib::Inflate.new
2010
+ * See also Zstdlib::Inflate.new
1997
2011
  */
1998
2012
  static VALUE
1999
2013
  rb_inflate_inflate(VALUE obj, VALUE src)
@@ -2028,8 +2042,8 @@ rb_inflate_inflate(VALUE obj, VALUE src)
2028
2042
  /*
2029
2043
  * call-seq: << string
2030
2044
  *
2031
- * Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate, but
2032
- * returns the Zlib::Inflate object itself. The output from the stream is
2045
+ * Inputs +string+ into the inflate stream just like Zstdlib::Inflate#inflate, but
2046
+ * returns the Zstdlib::Inflate object itself. The output from the stream is
2033
2047
  * preserved in output buffer.
2034
2048
  */
2035
2049
  static VALUE
@@ -2097,10 +2111,10 @@ rb_inflate_sync_point_p(VALUE obj)
2097
2111
  }
2098
2112
 
2099
2113
  /*
2100
- * Document-method: Zlib::Inflate#set_dictionary
2114
+ * Document-method: Zstdlib::Inflate#set_dictionary
2101
2115
  *
2102
2116
  * Sets the preset dictionary and returns +string+. This method is available just
2103
- * only after a Zlib::NeedDict exception was raised. See zlib.h for details.
2117
+ * only after a Zstdlib::NeedDict exception was raised. See zlib.h for details.
2104
2118
  *
2105
2119
  */
2106
2120
  static VALUE
@@ -2227,7 +2241,7 @@ gzfile_free(void *p)
2227
2241
 
2228
2242
  if (ZSTREAM_IS_READY(z)) {
2229
2243
  if (z->func == &deflate_funcs) {
2230
- finalizer_warn("Zlib::GzipWriter object must be closed explicitly.");
2244
+ finalizer_warn("Zstdlib::GzipWriter object must be closed explicitly.");
2231
2245
  }
2232
2246
  zstream_finalize(z);
2233
2247
  }
@@ -2375,7 +2389,7 @@ gzfile_read_raw_ensure(struct gzfile *gz, long size)
2375
2389
  {
2376
2390
  VALUE str;
2377
2391
 
2378
- if (gz->io == Qundef) { /* Zlib.gunzip */
2392
+ if (gz->io == Qundef) { /* Zstdlib.gunzip */
2379
2393
  if (NIL_P(gz->z.input) || RSTRING_LEN(gz->z.input) < size)
2380
2394
  rb_raise(cGzError, "unexpected end of string");
2381
2395
  }
@@ -2447,7 +2461,7 @@ gzfile_raise(struct gzfile *gz, VALUE klass, const char *message)
2447
2461
  }
2448
2462
 
2449
2463
  /*
2450
- * Document-method: Zlib::GzipFile::Error#inspect
2464
+ * Document-method: Zstdlib::GzipFile::Error#inspect
2451
2465
  *
2452
2466
  * Constructs a String of the GzipFile Error
2453
2467
  */
@@ -2485,7 +2499,7 @@ gzfile_make_header(struct gzfile *gz)
2485
2499
  if (gz->level == Z_BEST_SPEED) {
2486
2500
  extraflags |= GZ_EXTRAFLAG_FAST;
2487
2501
  }
2488
- else if (gz->level == Z_BEST_COMPRESSION) {
2502
+ else if (gz->level == ZSTD_maxCLevel()) {
2489
2503
  extraflags |= GZ_EXTRAFLAG_SLOW;
2490
2504
  }
2491
2505
 
@@ -2556,10 +2570,10 @@ gzfile_read_header(struct gzfile *gz)
2556
2570
  gz->level = Z_BEST_SPEED;
2557
2571
  }
2558
2572
  else if (head[8] & GZ_EXTRAFLAG_SLOW) {
2559
- gz->level = Z_BEST_COMPRESSION;
2573
+ gz->level = ZSTD_maxCLevel();
2560
2574
  }
2561
2575
  else {
2562
- gz->level = Z_DEFAULT_COMPRESSION;
2576
+ gz->level = ZSTD_CLEVEL_DEFAULT;
2563
2577
  }
2564
2578
 
2565
2579
  gz->mtime = gzfile_get32(&head[4]);
@@ -2948,40 +2962,40 @@ get_gzfile(VALUE obj)
2948
2962
  /* ------------------------------------------------------------------------- */
2949
2963
 
2950
2964
  /*
2951
- * Document-class: Zlib::GzipFile
2965
+ * Document-class: Zstdlib::GzipFile
2952
2966
  *
2953
- * Zlib::GzipFile is an abstract class for handling a gzip formatted
2967
+ * Zstdlib::GzipFile is an abstract class for handling a gzip formatted
2954
2968
  * compressed file. The operations are defined in the subclasses,
2955
- * Zlib::GzipReader for reading, and Zlib::GzipWriter for writing.
2969
+ * Zstdlib::GzipReader for reading, and Zstdlib::GzipWriter for writing.
2956
2970
  *
2957
2971
  * GzipReader should be used by associating an IO, or IO-like, object.
2958
2972
  *
2959
2973
  * == Method Catalogue
2960
2974
  *
2961
2975
  * - ::wrap
2962
- * - ::open (Zlib::GzipReader::open and Zlib::GzipWriter::open)
2976
+ * - ::open (Zstdlib::GzipReader::open and Zstdlib::GzipWriter::open)
2963
2977
  * - #close
2964
2978
  * - #closed?
2965
2979
  * - #comment
2966
- * - comment= (Zlib::GzipWriter#comment=)
2980
+ * - comment= (Zstdlib::GzipWriter#comment=)
2967
2981
  * - #crc
2968
- * - eof? (Zlib::GzipReader#eof?)
2982
+ * - eof? (Zstdlib::GzipReader#eof?)
2969
2983
  * - #finish
2970
2984
  * - #level
2971
- * - lineno (Zlib::GzipReader#lineno)
2972
- * - lineno= (Zlib::GzipReader#lineno=)
2985
+ * - lineno (Zstdlib::GzipReader#lineno)
2986
+ * - lineno= (Zstdlib::GzipReader#lineno=)
2973
2987
  * - #mtime
2974
- * - mtime= (Zlib::GzipWriter#mtime=)
2988
+ * - mtime= (Zstdlib::GzipWriter#mtime=)
2975
2989
  * - #orig_name
2976
- * - orig_name (Zlib::GzipWriter#orig_name=)
2990
+ * - orig_name (Zstdlib::GzipWriter#orig_name=)
2977
2991
  * - #os_code
2978
2992
  * - path (when the underlying IO supports #path)
2979
2993
  * - #sync
2980
2994
  * - #sync=
2981
2995
  * - #to_io
2982
2996
  *
2983
- * (due to internal structure, documentation may appear under Zlib::GzipReader
2984
- * or Zlib::GzipWriter)
2997
+ * (due to internal structure, documentation may appear under Zstdlib::GzipReader
2998
+ * or Zstdlib::GzipWriter)
2985
2999
  */
2986
3000
 
2987
3001
 
@@ -3040,11 +3054,11 @@ gzfile_wrap(int argc, VALUE *argv, VALUE klass, int close_io_on_error)
3040
3054
  }
3041
3055
 
3042
3056
  /*
3043
- * Document-method: Zlib::GzipFile.wrap
3057
+ * Document-method: Zstdlib::GzipFile.wrap
3044
3058
  *
3045
3059
  * call-seq:
3046
- * Zlib::GzipReader.wrap(io, ...) { |gz| ... }
3047
- * Zlib::GzipWriter.wrap(io, ...) { |gz| ... }
3060
+ * Zstdlib::GzipReader.wrap(io, ...) { |gz| ... }
3061
+ * Zstdlib::GzipWriter.wrap(io, ...) { |gz| ... }
3048
3062
  *
3049
3063
  * Creates a GzipReader or GzipWriter associated with +io+, passing in any
3050
3064
  * necessary extra options, and executes the block with the newly created
@@ -3052,7 +3066,7 @@ gzfile_wrap(int argc, VALUE *argv, VALUE klass, int close_io_on_error)
3052
3066
  *
3053
3067
  * The GzipFile object will be closed automatically after executing the block.
3054
3068
  * If you want to keep the associated IO object open, you may call
3055
- * Zlib::GzipFile#finish method in the block.
3069
+ * Zstdlib::GzipFile#finish method in the block.
3056
3070
  */
3057
3071
  static VALUE
3058
3072
  rb_gzfile_s_wrap(int argc, VALUE *argv, VALUE klass)
@@ -3061,9 +3075,9 @@ rb_gzfile_s_wrap(int argc, VALUE *argv, VALUE klass)
3061
3075
  }
3062
3076
 
3063
3077
  /*
3064
- * Document-method: Zlib::GzipFile.open
3078
+ * Document-method: Zstdlib::GzipFile.open
3065
3079
  *
3066
- * See Zlib::GzipReader#open and Zlib::GzipWriter#open.
3080
+ * See Zstdlib::GzipReader#open and Zstdlib::GzipWriter#open.
3067
3081
  */
3068
3082
  static VALUE
3069
3083
  gzfile_s_open(int argc, VALUE *argv, VALUE klass, const char *mode)
@@ -3078,7 +3092,7 @@ gzfile_s_open(int argc, VALUE *argv, VALUE klass, const char *mode)
3078
3092
  }
3079
3093
 
3080
3094
  /*
3081
- * Document-method: Zlib::GzipFile#to_io
3095
+ * Document-method: Zstdlib::GzipFile#to_io
3082
3096
  *
3083
3097
  * Same as IO.
3084
3098
  */
@@ -3089,7 +3103,7 @@ rb_gzfile_to_io(VALUE obj)
3089
3103
  }
3090
3104
 
3091
3105
  /*
3092
- * Document-method: Zlib::GzipFile#crc
3106
+ * Document-method: Zstdlib::GzipFile#crc
3093
3107
  *
3094
3108
  * Returns CRC value of the uncompressed data.
3095
3109
  */
@@ -3100,7 +3114,7 @@ rb_gzfile_crc(VALUE obj)
3100
3114
  }
3101
3115
 
3102
3116
  /*
3103
- * Document-method: Zlib::GzipFile#mtime
3117
+ * Document-method: Zstdlib::GzipFile#mtime
3104
3118
  *
3105
3119
  * Returns last modification time recorded in the gzip file header.
3106
3120
  */
@@ -3111,7 +3125,7 @@ rb_gzfile_mtime(VALUE obj)
3111
3125
  }
3112
3126
 
3113
3127
  /*
3114
- * Document-method: Zlib::GzipFile#level
3128
+ * Document-method: Zstdlib::GzipFile#level
3115
3129
  *
3116
3130
  * Returns compression level.
3117
3131
  */
@@ -3122,7 +3136,7 @@ rb_gzfile_level(VALUE obj)
3122
3136
  }
3123
3137
 
3124
3138
  /*
3125
- * Document-method: Zlib::GzipFile#os_code
3139
+ * Document-method: Zstdlib::GzipFile#os_code
3126
3140
  *
3127
3141
  * Returns OS code number recorded in the gzip file header.
3128
3142
  */
@@ -3133,7 +3147,7 @@ rb_gzfile_os_code(VALUE obj)
3133
3147
  }
3134
3148
 
3135
3149
  /*
3136
- * Document-method: Zlib::GzipFile#orig_name
3150
+ * Document-method: Zstdlib::GzipFile#orig_name
3137
3151
  *
3138
3152
  * Returns original filename recorded in the gzip file header, or +nil+ if
3139
3153
  * original filename is not present.
@@ -3150,7 +3164,7 @@ rb_gzfile_orig_name(VALUE obj)
3150
3164
  }
3151
3165
 
3152
3166
  /*
3153
- * Document-method: Zlib::GzipFile#comment
3167
+ * Document-method: Zstdlib::GzipFile#comment
3154
3168
  *
3155
3169
  * Returns comments recorded in the gzip file header, or nil if the comments
3156
3170
  * is not present.
@@ -3167,7 +3181,7 @@ rb_gzfile_comment(VALUE obj)
3167
3181
  }
3168
3182
 
3169
3183
  /*
3170
- * Document-method: Zlib::GzipFile#lineno
3184
+ * Document-method: Zstdlib::GzipFile#lineno
3171
3185
  *
3172
3186
  * The line number of the last row read from this file.
3173
3187
  */
@@ -3178,7 +3192,7 @@ rb_gzfile_lineno(VALUE obj)
3178
3192
  }
3179
3193
 
3180
3194
  /*
3181
- * Document-method: Zlib::GzipReader#lineno=
3195
+ * Document-method: Zstdlib::GzipReader#lineno=
3182
3196
  *
3183
3197
  * Specify line number of the last row read from this file.
3184
3198
  */
@@ -3191,7 +3205,7 @@ rb_gzfile_set_lineno(VALUE obj, VALUE lineno)
3191
3205
  }
3192
3206
 
3193
3207
  /*
3194
- * Document-method: Zlib::GzipWriter#mtime=
3208
+ * Document-method: Zstdlib::GzipWriter#mtime=
3195
3209
  *
3196
3210
  * Specify the modification time (+mtime+) in the gzip header.
3197
3211
  * Using an Integer.
@@ -3226,7 +3240,7 @@ rb_gzfile_set_mtime(VALUE obj, VALUE mtime)
3226
3240
  }
3227
3241
 
3228
3242
  /*
3229
- * Document-method: Zlib::GzipFile#orig_name=
3243
+ * Document-method: Zstdlib::GzipFile#orig_name=
3230
3244
  *
3231
3245
  * Specify the original name (+str+) in the gzip header.
3232
3246
  */
@@ -3250,7 +3264,7 @@ rb_gzfile_set_orig_name(VALUE obj, VALUE str)
3250
3264
  }
3251
3265
 
3252
3266
  /*
3253
- * Document-method: Zlib::GzipFile#comment=
3267
+ * Document-method: Zstdlib::GzipFile#comment=
3254
3268
  *
3255
3269
  * Specify the comment (+str+) in the gzip header.
3256
3270
  */
@@ -3274,7 +3288,7 @@ rb_gzfile_set_comment(VALUE obj, VALUE str)
3274
3288
  }
3275
3289
 
3276
3290
  /*
3277
- * Document-method: Zlib::GzipFile#close
3291
+ * Document-method: Zstdlib::GzipFile#close
3278
3292
  *
3279
3293
  * Closes the GzipFile object. This method calls close method of the
3280
3294
  * associated IO object. Returns the associated IO object.
@@ -3295,9 +3309,9 @@ rb_gzfile_close(VALUE obj)
3295
3309
  }
3296
3310
 
3297
3311
  /*
3298
- * Document-method: Zlib::GzipFile#finish
3312
+ * Document-method: Zstdlib::GzipFile#finish
3299
3313
  *
3300
- * Closes the GzipFile object. Unlike Zlib::GzipFile#close, this method never
3314
+ * Closes the GzipFile object. Unlike Zstdlib::GzipFile#close, this method never
3301
3315
  * calls the close method of the associated IO object. Returns the associated IO
3302
3316
  * object.
3303
3317
  */
@@ -3313,7 +3327,7 @@ rb_gzfile_finish(VALUE obj)
3313
3327
  }
3314
3328
 
3315
3329
  /*
3316
- * Document-method: Zlib::GzipFile#closed?
3330
+ * Document-method: Zstdlib::GzipFile#closed?
3317
3331
  *
3318
3332
  * Same as IO#closed?
3319
3333
  *
@@ -3327,7 +3341,7 @@ rb_gzfile_closed_p(VALUE obj)
3327
3341
  }
3328
3342
 
3329
3343
  /*
3330
- * Document-method: Zlib::GzipFile#eof?
3344
+ * Document-method: Zstdlib::GzipFile#eof?
3331
3345
  *
3332
3346
  * Returns +true+ or +false+ whether the stream has reached the end.
3333
3347
  */
@@ -3339,7 +3353,7 @@ rb_gzfile_eof_p(VALUE obj)
3339
3353
  }
3340
3354
 
3341
3355
  /*
3342
- * Document-method: Zlib::GzipFile#sync
3356
+ * Document-method: Zstdlib::GzipFile#sync
3343
3357
  *
3344
3358
  * Same as IO#sync
3345
3359
  *
@@ -3351,7 +3365,7 @@ rb_gzfile_sync(VALUE obj)
3351
3365
  }
3352
3366
 
3353
3367
  /*
3354
- * Document-method: Zlib::GzipFile#sync=
3368
+ * Document-method: Zstdlib::GzipFile#sync=
3355
3369
  *
3356
3370
  * call-seq: sync = flag
3357
3371
  *
@@ -3374,7 +3388,7 @@ rb_gzfile_set_sync(VALUE obj, VALUE mode)
3374
3388
  }
3375
3389
 
3376
3390
  /*
3377
- * Document-method: Zlib::GzipFile#total_in
3391
+ * Document-method: Zstdlib::GzipFile#total_in
3378
3392
  *
3379
3393
  * Total number of input bytes read so far.
3380
3394
  */
@@ -3385,7 +3399,7 @@ rb_gzfile_total_in(VALUE obj)
3385
3399
  }
3386
3400
 
3387
3401
  /*
3388
- * Document-method: Zlib::GzipFile#total_out
3402
+ * Document-method: Zstdlib::GzipFile#total_out
3389
3403
  *
3390
3404
  * Total number of output bytes output so far.
3391
3405
  */
@@ -3404,7 +3418,7 @@ rb_gzfile_total_out(VALUE obj)
3404
3418
  }
3405
3419
 
3406
3420
  /*
3407
- * Document-method: Zlib::GzipFile#path
3421
+ * Document-method: Zstdlib::GzipFile#path
3408
3422
  *
3409
3423
  * call-seq: path
3410
3424
  *
@@ -3436,19 +3450,19 @@ rb_gzfile_ecopts(struct gzfile *gz, VALUE opts)
3436
3450
  /* ------------------------------------------------------------------------- */
3437
3451
 
3438
3452
  /*
3439
- * Document-class: Zlib::GzipWriter
3453
+ * Document-class: Zstdlib::GzipWriter
3440
3454
  *
3441
- * Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should
3455
+ * Zstdlib::GzipWriter is a class for writing gzipped files. GzipWriter should
3442
3456
  * be used with an instance of IO, or IO-like, object.
3443
3457
  *
3444
3458
  * Following two example generate the same result.
3445
3459
  *
3446
- * Zlib::GzipWriter.open('hoge.gz') do |gz|
3460
+ * Zstdlib::GzipWriter.open('hoge.gz') do |gz|
3447
3461
  * gz.write 'jugemu jugemu gokou no surikire...'
3448
3462
  * end
3449
3463
  *
3450
3464
  * File.open('hoge.gz', 'w') do |f|
3451
- * gz = Zlib::GzipWriter.new(f)
3465
+ * gz = Zstdlib::GzipWriter.new(f)
3452
3466
  * gz.write 'jugemu jugemu gokou no surikire...'
3453
3467
  * gz.close
3454
3468
  * end
@@ -3456,14 +3470,14 @@ rb_gzfile_ecopts(struct gzfile *gz, VALUE opts)
3456
3470
  * To make like gzip(1) does, run following:
3457
3471
  *
3458
3472
  * orig = 'hoge.txt'
3459
- * Zlib::GzipWriter.open('hoge.gz') do |gz|
3473
+ * Zstdlib::GzipWriter.open('hoge.gz') do |gz|
3460
3474
  * gz.mtime = File.mtime(orig)
3461
3475
  * gz.orig_name = orig
3462
3476
  * gz.write IO.binread(orig)
3463
3477
  * end
3464
3478
  *
3465
3479
  * NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close
3466
- * GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter
3480
+ * GzipWriter objects by Zstdlib::GzipWriter#close etc. Otherwise, GzipWriter
3467
3481
  * will be not able to write the gzip footer and will generate a broken gzip
3468
3482
  * file.
3469
3483
  */
@@ -3475,11 +3489,11 @@ rb_gzwriter_s_allocate(VALUE klass)
3475
3489
  }
3476
3490
 
3477
3491
  /*
3478
- * call-seq: Zlib::GzipWriter.open(filename, level=nil, strategy=nil) { |gz| ... }
3492
+ * call-seq: Zstdlib::GzipWriter.open(filename, level=nil, strategy=nil) { |gz| ... }
3479
3493
  *
3480
3494
  * Opens a file specified by +filename+ for writing gzip compressed data, and
3481
3495
  * returns a GzipWriter object associated with that file. Further details of
3482
- * this method are found in Zlib::GzipWriter.new and Zlib::GzipFile.wrap.
3496
+ * this method are found in Zstdlib::GzipWriter.new and Zstdlib::GzipFile.wrap.
3483
3497
  */
3484
3498
  static VALUE
3485
3499
  rb_gzwriter_s_open(int argc, VALUE *argv, VALUE klass)
@@ -3489,10 +3503,10 @@ rb_gzwriter_s_open(int argc, VALUE *argv, VALUE klass)
3489
3503
 
3490
3504
  /*
3491
3505
  * call-seq:
3492
- * Zlib::GzipWriter.new(io, level = nil, strategy = nil, options = {})
3506
+ * Zstdlib::GzipWriter.new(io, level = nil, strategy = nil, options = {})
3493
3507
  *
3494
3508
  * Creates a GzipWriter object associated with +io+. +level+ and +strategy+
3495
- * should be the same as the arguments of Zlib::Deflate.new. The GzipWriter
3509
+ * should be the same as the arguments of Zstdlib::Deflate.new. The GzipWriter
3496
3510
  * object writes gzipped data to +io+. +io+ must respond to the
3497
3511
  * +write+ method that behaves the same as IO#write.
3498
3512
  *
@@ -3538,8 +3552,8 @@ rb_gzwriter_initialize(int argc, VALUE *argv, VALUE obj)
3538
3552
  * call-seq: flush(flush=nil)
3539
3553
  *
3540
3554
  * Flushes all the internal buffers of the GzipWriter object. The meaning of
3541
- * +flush+ is same as in Zlib::Deflate#deflate. <tt>Zlib::SYNC_FLUSH</tt> is used if
3542
- * +flush+ is omitted. It is no use giving flush <tt>Zlib::NO_FLUSH</tt>.
3555
+ * +flush+ is same as in Zstdlib::Deflate#deflate. <tt>Zstdlib::SYNC_FLUSH</tt> is used if
3556
+ * +flush+ is omitted. It is no use giving flush <tt>Zstdlib::NO_FLUSH</tt>.
3543
3557
  */
3544
3558
  static VALUE
3545
3559
  rb_gzwriter_flush(int argc, VALUE *argv, VALUE obj)
@@ -3625,25 +3639,25 @@ rb_gzwriter_putc(VALUE obj, VALUE ch)
3625
3639
  /* ------------------------------------------------------------------------- */
3626
3640
 
3627
3641
  /*
3628
- * Document-class: Zlib::GzipReader
3642
+ * Document-class: Zstdlib::GzipReader
3629
3643
  *
3630
- * Zlib::GzipReader is the class for reading a gzipped file. GzipReader should
3644
+ * Zstdlib::GzipReader is the class for reading a gzipped file. GzipReader should
3631
3645
  * be used as an IO, or -IO-like, object.
3632
3646
  *
3633
- * Zlib::GzipReader.open('hoge.gz') {|gz|
3647
+ * Zstdlib::GzipReader.open('hoge.gz') {|gz|
3634
3648
  * print gz.read
3635
3649
  * }
3636
3650
  *
3637
3651
  * File.open('hoge.gz') do |f|
3638
- * gz = Zlib::GzipReader.new(f)
3652
+ * gz = Zstdlib::GzipReader.new(f)
3639
3653
  * print gz.read
3640
3654
  * gz.close
3641
3655
  * end
3642
3656
  *
3643
3657
  * == Method Catalogue
3644
3658
  *
3645
- * The following methods in Zlib::GzipReader are just like their counterparts
3646
- * in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an
3659
+ * The following methods in Zstdlib::GzipReader are just like their counterparts
3660
+ * in IO, but they raise Zstdlib::Error or Zstdlib::GzipFile::Error exception if an
3647
3661
  * error was found in the gzip file.
3648
3662
  * - #each
3649
3663
  * - #each_line
@@ -3661,15 +3675,15 @@ rb_gzwriter_putc(VALUE obj, VALUE ch)
3661
3675
  * Be careful of the footer of the gzip file. A gzip file has the checksum of
3662
3676
  * pre-compressed data in its footer. GzipReader checks all uncompressed data
3663
3677
  * against that checksum at the following cases, and if it fails, raises
3664
- * <tt>Zlib::GzipFile::NoFooter</tt>, <tt>Zlib::GzipFile::CRCError</tt>, or
3665
- * <tt>Zlib::GzipFile::LengthError</tt> exception.
3678
+ * <tt>Zstdlib::GzipFile::NoFooter</tt>, <tt>Zstdlib::GzipFile::CRCError</tt>, or
3679
+ * <tt>Zstdlib::GzipFile::LengthError</tt> exception.
3666
3680
  *
3667
3681
  * - When an reading request is received beyond the end of file (the end of
3668
- * compressed data). That is, when Zlib::GzipReader#read,
3669
- * Zlib::GzipReader#gets, or some other methods for reading returns nil.
3670
- * - When Zlib::GzipFile#close method is called after the object reaches the
3682
+ * compressed data). That is, when Zstdlib::GzipReader#read,
3683
+ * Zstdlib::GzipReader#gets, or some other methods for reading returns nil.
3684
+ * - When Zstdlib::GzipFile#close method is called after the object reaches the
3671
3685
  * end of file.
3672
- * - When Zlib::GzipReader#unused method is called after the object reaches
3686
+ * - When Zstdlib::GzipReader#unused method is called after the object reaches
3673
3687
  * the end of file.
3674
3688
  *
3675
3689
  * The rest of the methods are adequately described in their own
@@ -3683,13 +3697,13 @@ rb_gzreader_s_allocate(VALUE klass)
3683
3697
  }
3684
3698
 
3685
3699
  /*
3686
- * Document-method: Zlib::GzipReader.open
3700
+ * Document-method: Zstdlib::GzipReader.open
3687
3701
  *
3688
- * call-seq: Zlib::GzipReader.open(filename) {|gz| ... }
3702
+ * call-seq: Zstdlib::GzipReader.open(filename) {|gz| ... }
3689
3703
  *
3690
3704
  * Opens a file specified by +filename+ as a gzipped file, and returns a
3691
3705
  * GzipReader object associated with that file. Further details of this method
3692
- * are in Zlib::GzipReader.new and ZLib::GzipFile.wrap.
3706
+ * are in Zstdlib::GzipReader.new and ZLib::GzipFile.wrap.
3693
3707
  */
3694
3708
  static VALUE
3695
3709
  rb_gzreader_s_open(int argc, VALUE *argv, VALUE klass)
@@ -3698,10 +3712,10 @@ rb_gzreader_s_open(int argc, VALUE *argv, VALUE klass)
3698
3712
  }
3699
3713
 
3700
3714
  /*
3701
- * Document-method: Zlib::GzipReader.new
3715
+ * Document-method: Zstdlib::GzipReader.new
3702
3716
  *
3703
3717
  * call-seq:
3704
- * Zlib::GzipReader.new(io, options = {})
3718
+ * Zstdlib::GzipReader.new(io, options = {})
3705
3719
  *
3706
3720
  * Creates a GzipReader object associated with +io+. The GzipReader object reads
3707
3721
  * gzipped data from +io+, and parses/decompresses it. The +io+ must
@@ -3711,7 +3725,7 @@ rb_gzreader_s_open(int argc, VALUE *argv, VALUE klass)
3711
3725
  * +:external_encoding+, +:internal_encoding+ and +:encoding+ may be set as in
3712
3726
  * IO::new.
3713
3727
  *
3714
- * If the gzip file header is incorrect, raises an Zlib::GzipFile::Error
3728
+ * If the gzip file header is incorrect, raises an Zstdlib::GzipFile::Error
3715
3729
  * exception.
3716
3730
  */
3717
3731
  static VALUE
@@ -3743,7 +3757,7 @@ rb_gzreader_initialize(int argc, VALUE *argv, VALUE obj)
3743
3757
  }
3744
3758
 
3745
3759
  /*
3746
- * Document-method: Zlib::GzipReader#rewind
3760
+ * Document-method: Zstdlib::GzipReader#rewind
3747
3761
  *
3748
3762
  * Resets the position of the file pointer to the point created the GzipReader
3749
3763
  * object. The associated IO object needs to respond to the +seek+ method.
@@ -3757,7 +3771,7 @@ rb_gzreader_rewind(VALUE obj)
3757
3771
  }
3758
3772
 
3759
3773
  /*
3760
- * Document-method: Zlib::GzipReader#unused
3774
+ * Document-method: Zstdlib::GzipReader#unused
3761
3775
  *
3762
3776
  * Returns the rest of the data which had read for parsing gzip format, or
3763
3777
  * +nil+ if the whole gzip file is not parsed yet.
@@ -3771,9 +3785,9 @@ rb_gzreader_unused(VALUE obj)
3771
3785
  }
3772
3786
 
3773
3787
  /*
3774
- * Document-method: Zlib::GzipReader#read
3788
+ * Document-method: Zstdlib::GzipReader#read
3775
3789
  *
3776
- * See Zlib::GzipReader documentation for a description.
3790
+ * See Zstdlib::GzipReader documentation for a description.
3777
3791
  */
3778
3792
  static VALUE
3779
3793
  rb_gzreader_read(int argc, VALUE *argv, VALUE obj)
@@ -3795,7 +3809,7 @@ rb_gzreader_read(int argc, VALUE *argv, VALUE obj)
3795
3809
  }
3796
3810
 
3797
3811
  /*
3798
- * Document-method: Zlib::GzipReader#readpartial
3812
+ * Document-method: Zstdlib::GzipReader#readpartial
3799
3813
  *
3800
3814
  * call-seq:
3801
3815
  * gzipreader.readpartial(maxlen [, outbuf]) => string, outbuf
@@ -3825,9 +3839,9 @@ rb_gzreader_readpartial(int argc, VALUE *argv, VALUE obj)
3825
3839
  }
3826
3840
 
3827
3841
  /*
3828
- * Document-method: Zlib::GzipReader#getc
3842
+ * Document-method: Zstdlib::GzipReader#getc
3829
3843
  *
3830
- * See Zlib::GzipReader documentation for a description.
3844
+ * See Zstdlib::GzipReader documentation for a description.
3831
3845
  */
3832
3846
  static VALUE
3833
3847
  rb_gzreader_getc(VALUE obj)
@@ -3838,9 +3852,9 @@ rb_gzreader_getc(VALUE obj)
3838
3852
  }
3839
3853
 
3840
3854
  /*
3841
- * Document-method: Zlib::GzipReader#readchar
3855
+ * Document-method: Zstdlib::GzipReader#readchar
3842
3856
  *
3843
- * See Zlib::GzipReader documentation for a description.
3857
+ * See Zstdlib::GzipReader documentation for a description.
3844
3858
  */
3845
3859
  static VALUE
3846
3860
  rb_gzreader_readchar(VALUE obj)
@@ -3854,9 +3868,9 @@ rb_gzreader_readchar(VALUE obj)
3854
3868
  }
3855
3869
 
3856
3870
  /*
3857
- * Document-method: Zlib::GzipReader#getbyte
3871
+ * Document-method: Zstdlib::GzipReader#getbyte
3858
3872
  *
3859
- * See Zlib::GzipReader documentation for a description.
3873
+ * See Zstdlib::GzipReader documentation for a description.
3860
3874
  */
3861
3875
  static VALUE
3862
3876
  rb_gzreader_getbyte(VALUE obj)
@@ -3872,9 +3886,9 @@ rb_gzreader_getbyte(VALUE obj)
3872
3886
  }
3873
3887
 
3874
3888
  /*
3875
- * Document-method: Zlib::GzipReader#readbyte
3889
+ * Document-method: Zstdlib::GzipReader#readbyte
3876
3890
  *
3877
- * See Zlib::GzipReader documentation for a description.
3891
+ * See Zstdlib::GzipReader documentation for a description.
3878
3892
  */
3879
3893
  static VALUE
3880
3894
  rb_gzreader_readbyte(VALUE obj)
@@ -3888,9 +3902,9 @@ rb_gzreader_readbyte(VALUE obj)
3888
3902
  }
3889
3903
 
3890
3904
  /*
3891
- * Document-method: Zlib::GzipReader#each_char
3905
+ * Document-method: Zstdlib::GzipReader#each_char
3892
3906
  *
3893
- * See Zlib::GzipReader documentation for a description.
3907
+ * See Zstdlib::GzipReader documentation for a description.
3894
3908
  */
3895
3909
  static VALUE
3896
3910
  rb_gzreader_each_char(VALUE obj)
@@ -3906,9 +3920,9 @@ rb_gzreader_each_char(VALUE obj)
3906
3920
  }
3907
3921
 
3908
3922
  /*
3909
- * Document-method: Zlib::GzipReader#each_byte
3923
+ * Document-method: Zstdlib::GzipReader#each_byte
3910
3924
  *
3911
- * See Zlib::GzipReader documentation for a description.
3925
+ * See Zstdlib::GzipReader documentation for a description.
3912
3926
  */
3913
3927
  static VALUE
3914
3928
  rb_gzreader_each_byte(VALUE obj)
@@ -3924,23 +3938,23 @@ rb_gzreader_each_byte(VALUE obj)
3924
3938
  }
3925
3939
 
3926
3940
  /*
3927
- * Document-method: Zlib::GzipReader#bytes
3941
+ * Document-method: Zstdlib::GzipReader#bytes
3928
3942
  *
3929
3943
  * This is a deprecated alias for <code>each_byte</code>.
3930
3944
  */
3931
3945
  static VALUE
3932
3946
  rb_gzreader_bytes(VALUE obj)
3933
3947
  {
3934
- rb_warn("Zlib::GzipReader#bytes is deprecated; use #each_byte instead");
3948
+ rb_warn("Zstdlib::GzipReader#bytes is deprecated; use #each_byte instead");
3935
3949
  if (!rb_block_given_p())
3936
3950
  return rb_enumeratorize(obj, ID2SYM(rb_intern("each_byte")), 0, 0);
3937
3951
  return rb_gzreader_each_byte(obj);
3938
3952
  }
3939
3953
 
3940
3954
  /*
3941
- * Document-method: Zlib::GzipReader#ungetc
3955
+ * Document-method: Zstdlib::GzipReader#ungetc
3942
3956
  *
3943
- * See Zlib::GzipReader documentation for a description.
3957
+ * See Zstdlib::GzipReader documentation for a description.
3944
3958
  */
3945
3959
  static VALUE
3946
3960
  rb_gzreader_ungetc(VALUE obj, VALUE s)
@@ -3960,9 +3974,9 @@ rb_gzreader_ungetc(VALUE obj, VALUE s)
3960
3974
  }
3961
3975
 
3962
3976
  /*
3963
- * Document-method: Zlib::GzipReader#ungetbyte
3977
+ * Document-method: Zstdlib::GzipReader#ungetbyte
3964
3978
  *
3965
- * See Zlib::GzipReader documentation for a description.
3979
+ * See Zstdlib::GzipReader documentation for a description.
3966
3980
  */
3967
3981
  static VALUE
3968
3982
  rb_gzreader_ungetbyte(VALUE obj, VALUE ch)
@@ -4160,9 +4174,9 @@ gzreader_gets(int argc, VALUE *argv, VALUE obj)
4160
4174
  }
4161
4175
 
4162
4176
  /*
4163
- * Document-method: Zlib::GzipReader#gets
4177
+ * Document-method: Zstdlib::GzipReader#gets
4164
4178
  *
4165
- * See Zlib::GzipReader documentation for a description.
4179
+ * See Zstdlib::GzipReader documentation for a description.
4166
4180
  */
4167
4181
  static VALUE
4168
4182
  rb_gzreader_gets(int argc, VALUE *argv, VALUE obj)
@@ -4176,9 +4190,9 @@ rb_gzreader_gets(int argc, VALUE *argv, VALUE obj)
4176
4190
  }
4177
4191
 
4178
4192
  /*
4179
- * Document-method: Zlib::GzipReader#readline
4193
+ * Document-method: Zstdlib::GzipReader#readline
4180
4194
  *
4181
- * See Zlib::GzipReader documentation for a description.
4195
+ * See Zstdlib::GzipReader documentation for a description.
4182
4196
  */
4183
4197
  static VALUE
4184
4198
  rb_gzreader_readline(int argc, VALUE *argv, VALUE obj)
@@ -4192,9 +4206,9 @@ rb_gzreader_readline(int argc, VALUE *argv, VALUE obj)
4192
4206
  }
4193
4207
 
4194
4208
  /*
4195
- * Document-method: Zlib::GzipReader#each
4209
+ * Document-method: Zstdlib::GzipReader#each
4196
4210
  *
4197
- * See Zlib::GzipReader documentation for a description.
4211
+ * See Zstdlib::GzipReader documentation for a description.
4198
4212
  */
4199
4213
  static VALUE
4200
4214
  rb_gzreader_each(int argc, VALUE *argv, VALUE obj)
@@ -4210,23 +4224,23 @@ rb_gzreader_each(int argc, VALUE *argv, VALUE obj)
4210
4224
  }
4211
4225
 
4212
4226
  /*
4213
- * Document-method: Zlib::GzipReader#lines
4227
+ * Document-method: Zstdlib::GzipReader#lines
4214
4228
  *
4215
4229
  * This is a deprecated alias for <code>each_line</code>.
4216
4230
  */
4217
4231
  static VALUE
4218
4232
  rb_gzreader_lines(int argc, VALUE *argv, VALUE obj)
4219
4233
  {
4220
- rb_warn("Zlib::GzipReader#lines is deprecated; use #each_line instead");
4234
+ rb_warn("Zstdlib::GzipReader#lines is deprecated; use #each_line instead");
4221
4235
  if (!rb_block_given_p())
4222
4236
  return rb_enumeratorize(obj, ID2SYM(rb_intern("each_line")), argc, argv);
4223
4237
  return rb_gzreader_each(argc, argv, obj);
4224
4238
  }
4225
4239
 
4226
4240
  /*
4227
- * Document-method: Zlib::GzipReader#readlines
4241
+ * Document-method: Zstdlib::GzipReader#readlines
4228
4242
  *
4229
- * See Zlib::GzipReader documentation for a description.
4243
+ * See Zstdlib::GzipReader documentation for a description.
4230
4244
  */
4231
4245
  static VALUE
4232
4246
  rb_gzreader_readlines(int argc, VALUE *argv, VALUE obj)
@@ -4240,9 +4254,9 @@ rb_gzreader_readlines(int argc, VALUE *argv, VALUE obj)
4240
4254
  }
4241
4255
 
4242
4256
  /*
4243
- * Document-method: Zlib::GzipReader#external_encoding
4257
+ * Document-method: Zstdlib::GzipReader#external_encoding
4244
4258
  *
4245
- * See Zlib::GzipReader documentation for a description.
4259
+ * See Zstdlib::GzipReader documentation for a description.
4246
4260
  */
4247
4261
  static VALUE
4248
4262
  rb_gzreader_external_encoding(VALUE self)
@@ -4274,24 +4288,24 @@ static VALUE zlib_gzip_run(VALUE arg);
4274
4288
 
4275
4289
  /*
4276
4290
  * call-seq:
4277
- * Zlib.gzip(src, level: nil, strategy: nil) -> String
4291
+ * Zstdlib.gzip(src, level: nil, strategy: nil) -> String
4278
4292
  *
4279
4293
  * Gzip the given +string+. Valid values of level are
4280
- * Zlib::NO_COMPRESSION, Zlib::BEST_SPEED, Zlib::BEST_COMPRESSION,
4281
- * Zlib::DEFAULT_COMPRESSION (default), or an integer from 0 to 9.
4294
+ * Zstdlib::NO_COMPRESSION, Zstdlib::BEST_SPEED, Zstdlib::BEST_COMPRESSION,
4295
+ * Zstdlib::DEFAULT_COMPRESSION (default), or an integer from 0 to 9.
4282
4296
  *
4283
4297
  * This method is almost equivalent to the following code:
4284
4298
  *
4285
4299
  * def gzip(string, level: nil, strategy: nil)
4286
4300
  * sio = StringIO.new
4287
4301
  * sio.binmode
4288
- * gz = Zlib::GzipWriter.new(sio, level, strategy)
4302
+ * gz = Zstdlib::GzipWriter.new(sio, level, strategy)
4289
4303
  * gz.write(string)
4290
4304
  * gz.close
4291
4305
  * sio.string
4292
4306
  * end
4293
4307
  *
4294
- * See also Zlib.gunzip
4308
+ * See also Zstdlib.gunzip
4295
4309
  *
4296
4310
  */
4297
4311
  static VALUE
@@ -4361,7 +4375,7 @@ static VALUE zlib_gunzip_run(VALUE arg);
4361
4375
 
4362
4376
  /*
4363
4377
  * call-seq:
4364
- * Zlib.gunzip(src) -> String
4378
+ * Zstdlib.gunzip(src) -> String
4365
4379
  *
4366
4380
  * Decode the given gzipped +string+.
4367
4381
  *
@@ -4369,13 +4383,13 @@ static VALUE zlib_gunzip_run(VALUE arg);
4369
4383
  *
4370
4384
  * def gunzip(string)
4371
4385
  * sio = StringIO.new(string)
4372
- * gz = Zlib::GzipReader.new(sio, encoding: Encoding::ASCII_8BIT)
4386
+ * gz = Zstdlib::GzipReader.new(sio, encoding: Encoding::ASCII_8BIT)
4373
4387
  * gz.read
4374
4388
  * ensure
4375
4389
  * gz&.close
4376
4390
  * end
4377
4391
  *
4378
- * See also Zlib.gzip
4392
+ * See also Zstdlib.gzip
4379
4393
  */
4380
4394
  static VALUE
4381
4395
  zlib_gunzip(VALUE klass, VALUE src)
@@ -4419,14 +4433,14 @@ zlib_gunzip_run(VALUE arg)
4419
4433
  #endif /* GZIP_SUPPORT */
4420
4434
 
4421
4435
  void
4422
- Init_zlib(void)
4436
+ Init_zstdlib(void)
4423
4437
  {
4424
4438
  VALUE mZlib, cZStream, cDeflate, cInflate;
4425
4439
  #if GZIP_SUPPORT
4426
4440
  VALUE cGzipFile, cGzipWriter, cGzipReader;
4427
4441
  #endif
4428
4442
 
4429
- mZlib = rb_define_module("Zlib");
4443
+ mZlib = rb_define_module("Zstdlib");
4430
4444
 
4431
4445
  id_dictionaries = rb_intern("@dictionaries");
4432
4446
 
@@ -4450,6 +4464,8 @@ Init_zlib(void)
4450
4464
  rb_define_const(mZlib, "VERSION", rb_str_new2(RUBY_ZLIB_VERSION));
4451
4465
  /* The string which represents the version of zlib.h */
4452
4466
  rb_define_const(mZlib, "ZLIB_VERSION", rb_str_new2(ZLIB_VERSION));
4467
+ rb_define_const(mZlib, "ZSTD_VERSION", rb_str_new2(ZSTD_versionString()));
4468
+ rb_define_module_function(mZlib, "zstd_version", rb_zstd_version, 0);
4453
4469
 
4454
4470
  cZStream = rb_define_class_under(mZlib, "ZStream", rb_cObject);
4455
4471
  rb_undef_alloc_func(cZStream);
@@ -4473,7 +4489,7 @@ Init_zlib(void)
4473
4489
 
4474
4490
  /* Represents binary data as guessed by deflate.
4475
4491
  *
4476
- * See Zlib::Deflate#data_type. */
4492
+ * See Zstdlib::Deflate#data_type. */
4477
4493
  rb_define_const(mZlib, "BINARY", INT2FIX(Z_BINARY));
4478
4494
 
4479
4495
  /* Represents text data as guessed by deflate.
@@ -4481,19 +4497,19 @@ Init_zlib(void)
4481
4497
  * NOTE: The underlying constant Z_ASCII was deprecated in favor of Z_TEXT
4482
4498
  * in zlib 1.2.2. New applications should not use this constant.
4483
4499
  *
4484
- * See Zlib::Deflate#data_type. */
4500
+ * See Zstdlib::Deflate#data_type. */
4485
4501
  rb_define_const(mZlib, "ASCII", INT2FIX(Z_ASCII));
4486
4502
 
4487
4503
  #ifdef Z_TEXT
4488
4504
  /* Represents text data as guessed by deflate.
4489
4505
  *
4490
- * See Zlib::Deflate#data_type. */
4506
+ * See Zstdlib::Deflate#data_type. */
4491
4507
  rb_define_const(mZlib, "TEXT", INT2FIX(Z_TEXT));
4492
4508
  #endif
4493
4509
 
4494
4510
  /* Represents an unknown data type as guessed by deflate.
4495
4511
  *
4496
- * See Zlib::Deflate#data_type. */
4512
+ * See Zstdlib::Deflate#data_type. */
4497
4513
  rb_define_const(mZlib, "UNKNOWN", INT2FIX(Z_UNKNOWN));
4498
4514
 
4499
4515
  cDeflate = rb_define_class_under(mZlib, "Deflate", cZStream);
@@ -4527,12 +4543,12 @@ Init_zlib(void)
4527
4543
  /* Fastest compression level, but with the lowest space savings. */
4528
4544
  rb_define_const(mZlib, "BEST_SPEED", INT2FIX(Z_BEST_SPEED));
4529
4545
  /* Slowest compression level, but with the best space savings. */
4530
- rb_define_const(mZlib, "BEST_COMPRESSION", INT2FIX(Z_BEST_COMPRESSION));
4546
+ rb_define_const(mZlib, "BEST_COMPRESSION", INT2FIX(ZSTD_maxCLevel()));
4531
4547
  /* Default compression level which is a good trade-off between space and
4532
4548
  * time
4533
4549
  */
4534
4550
  rb_define_const(mZlib, "DEFAULT_COMPRESSION",
4535
- INT2FIX(Z_DEFAULT_COMPRESSION));
4551
+ INT2FIX(ZSTD_CLEVEL_DEFAULT));
4536
4552
 
4537
4553
  /* Deflate strategy for data produced by a filter (or predictor). The
4538
4554
  * effect of FILTERED is to force more Huffman codes and less string
@@ -4563,7 +4579,7 @@ Init_zlib(void)
4563
4579
  rb_define_const(mZlib, "DEFAULT_STRATEGY", INT2FIX(Z_DEFAULT_STRATEGY));
4564
4580
 
4565
4581
  /* The maximum size of the zlib history buffer. Note that zlib allows
4566
- * larger values to enable different inflate modes. See Zlib::Inflate.new
4582
+ * larger values to enable different inflate modes. See Zstdlib::Inflate.new
4567
4583
  * for details.
4568
4584
  */
4569
4585
  rb_define_const(mZlib, "MAX_WBITS", INT2FIX(MAX_WBITS));
@@ -4730,28 +4746,28 @@ Init_zlib(void)
4730
4746
  /* Document error classes. */
4731
4747
 
4732
4748
  /*
4733
- * Document-class: Zlib::Error
4749
+ * Document-class: Zstdlib::Error
4734
4750
  *
4735
4751
  * The superclass for all exceptions raised by Ruby/zlib.
4736
4752
  *
4737
- * The following exceptions are defined as subclasses of Zlib::Error. These
4753
+ * The following exceptions are defined as subclasses of Zstdlib::Error. These
4738
4754
  * exceptions are raised when zlib library functions return with an error
4739
4755
  * status.
4740
4756
  *
4741
- * - Zlib::StreamEnd
4742
- * - Zlib::NeedDict
4743
- * - Zlib::DataError
4744
- * - Zlib::StreamError
4745
- * - Zlib::MemError
4746
- * - Zlib::BufError
4747
- * - Zlib::VersionError
4757
+ * - Zstdlib::StreamEnd
4758
+ * - Zstdlib::NeedDict
4759
+ * - Zstdlib::DataError
4760
+ * - Zstdlib::StreamError
4761
+ * - Zstdlib::MemError
4762
+ * - Zstdlib::BufError
4763
+ * - Zstdlib::VersionError
4748
4764
  *
4749
4765
  */
4750
4766
 
4751
4767
  /*
4752
- * Document-class: Zlib::StreamEnd
4768
+ * Document-class: Zstdlib::StreamEnd
4753
4769
  *
4754
- * Subclass of Zlib::Error
4770
+ * Subclass of Zstdlib::Error
4755
4771
  *
4756
4772
  * When zlib returns a Z_STREAM_END
4757
4773
  * is return if the end of the compressed data has been reached
@@ -4760,20 +4776,20 @@ Init_zlib(void)
4760
4776
  */
4761
4777
 
4762
4778
  /*
4763
- * Document-class: Zlib::NeedDict
4779
+ * Document-class: Zstdlib::NeedDict
4764
4780
  *
4765
- * Subclass of Zlib::Error
4781
+ * Subclass of Zstdlib::Error
4766
4782
  *
4767
4783
  * When zlib returns a Z_NEED_DICT
4768
4784
  * if a preset dictionary is needed at this point.
4769
4785
  *
4770
- * Used by Zlib::Inflate.inflate and <tt>Zlib.inflate</tt>
4786
+ * Used by Zstdlib::Inflate.inflate and <tt>Zstdlib.inflate</tt>
4771
4787
  */
4772
4788
 
4773
4789
  /*
4774
- * Document-class: Zlib::VersionError
4790
+ * Document-class: Zstdlib::VersionError
4775
4791
  *
4776
- * Subclass of Zlib::Error
4792
+ * Subclass of Zstdlib::Error
4777
4793
  *
4778
4794
  * When zlib returns a Z_VERSION_ERROR,
4779
4795
  * usually if the zlib library version is incompatible with the
@@ -4782,9 +4798,9 @@ Init_zlib(void)
4782
4798
  */
4783
4799
 
4784
4800
  /*
4785
- * Document-class: Zlib::MemError
4801
+ * Document-class: Zstdlib::MemError
4786
4802
  *
4787
- * Subclass of Zlib::Error
4803
+ * Subclass of Zstdlib::Error
4788
4804
  *
4789
4805
  * When zlib returns a Z_MEM_ERROR,
4790
4806
  * usually if there was not enough memory.
@@ -4792,9 +4808,9 @@ Init_zlib(void)
4792
4808
  */
4793
4809
 
4794
4810
  /*
4795
- * Document-class: Zlib::StreamError
4811
+ * Document-class: Zstdlib::StreamError
4796
4812
  *
4797
- * Subclass of Zlib::Error
4813
+ * Subclass of Zstdlib::Error
4798
4814
  *
4799
4815
  * When zlib returns a Z_STREAM_ERROR,
4800
4816
  * usually if the stream state was inconsistent.
@@ -4802,44 +4818,44 @@ Init_zlib(void)
4802
4818
  */
4803
4819
 
4804
4820
  /*
4805
- * Document-class: Zlib::BufError
4821
+ * Document-class: Zstdlib::BufError
4806
4822
  *
4807
- * Subclass of Zlib::Error when zlib returns a Z_BUF_ERROR.
4823
+ * Subclass of Zstdlib::Error when zlib returns a Z_BUF_ERROR.
4808
4824
  *
4809
4825
  * Usually if no progress is possible.
4810
4826
  *
4811
4827
  */
4812
4828
 
4813
4829
  /*
4814
- * Document-class: Zlib::DataError
4830
+ * Document-class: Zstdlib::DataError
4815
4831
  *
4816
- * Subclass of Zlib::Error when zlib returns a Z_DATA_ERROR.
4832
+ * Subclass of Zstdlib::Error when zlib returns a Z_DATA_ERROR.
4817
4833
  *
4818
4834
  * Usually if a stream was prematurely freed.
4819
4835
  *
4820
4836
  */
4821
4837
 
4822
4838
  /*
4823
- * Document-class: Zlib::GzipFile::Error
4839
+ * Document-class: Zstdlib::GzipFile::Error
4824
4840
  *
4825
4841
  * Base class of errors that occur when processing GZIP files.
4826
4842
  */
4827
4843
 
4828
4844
  /*
4829
- * Document-class: Zlib::GzipFile::NoFooter
4845
+ * Document-class: Zstdlib::GzipFile::NoFooter
4830
4846
  *
4831
4847
  * Raised when gzip file footer is not found.
4832
4848
  */
4833
4849
 
4834
4850
  /*
4835
- * Document-class: Zlib::GzipFile::CRCError
4851
+ * Document-class: Zstdlib::GzipFile::CRCError
4836
4852
  *
4837
4853
  * Raised when the CRC checksum recorded in gzip file footer is not equivalent
4838
4854
  * to the CRC checksum of the actual uncompressed data.
4839
4855
  */
4840
4856
 
4841
4857
  /*
4842
- * Document-class: Zlib::GzipFile::LengthError
4858
+ * Document-class: Zstdlib::GzipFile::LengthError
4843
4859
  *
4844
4860
  * Raised when the data length recorded in the gzip file footer is not equivalent
4845
4861
  * to the length of the actual uncompressed data.