zstdlib 0.1.1-x86-mingw32 → 0.1.2-x86-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>
@@ -251,48 +252,48 @@ static VALUE rb_gzreader_readlines(int, VALUE*, VALUE);
251
252
  * Using the wrapper to compress strings with default parameters is quite
252
253
  * simple:
253
254
  *
254
- * require "zlib"
255
+ * require "zstdlib"
255
256
  *
256
257
  * data_to_compress = File.read("don_quixote.txt")
257
258
  *
258
259
  * puts "Input size: #{data_to_compress.size}"
259
260
  * #=> Input size: 2347740
260
261
  *
261
- * data_compressed = Zlib::Deflate.deflate(data_to_compress)
262
+ * data_compressed = Zstdlib::Deflate.deflate(data_to_compress)
262
263
  *
263
264
  * puts "Compressed size: #{data_compressed.size}"
264
265
  * #=> Compressed size: 887238
265
266
  *
266
- * uncompressed_data = Zlib::Inflate.inflate(data_compressed)
267
+ * uncompressed_data = Zstdlib::Inflate.inflate(data_compressed)
267
268
  *
268
269
  * puts "Uncompressed data is: #{uncompressed_data}"
269
270
  * #=> Uncompressed data is: The Project Gutenberg EBook of Don Quixote...
270
271
  *
271
272
  * == Class tree
272
273
  *
273
- * - Zlib::Deflate
274
- * - Zlib::Inflate
275
- * - Zlib::ZStream
276
- * - Zlib::Error
277
- * - Zlib::StreamEnd
278
- * - Zlib::NeedDict
279
- * - Zlib::DataError
280
- * - Zlib::StreamError
281
- * - Zlib::MemError
282
- * - Zlib::BufError
283
- * - Zlib::VersionError
274
+ * - Zstdlib::Deflate
275
+ * - Zstdlib::Inflate
276
+ * - Zstdlib::ZStream
277
+ * - Zstdlib::Error
278
+ * - Zstdlib::StreamEnd
279
+ * - Zstdlib::NeedDict
280
+ * - Zstdlib::DataError
281
+ * - Zstdlib::StreamError
282
+ * - Zstdlib::MemError
283
+ * - Zstdlib::BufError
284
+ * - Zstdlib::VersionError
284
285
  *
285
286
  * (if you have GZIP_SUPPORT)
286
- * - Zlib::GzipReader
287
- * - Zlib::GzipWriter
288
- * - Zlib::GzipFile
289
- * - Zlib::GzipFile::Error
290
- * - Zlib::GzipFile::LengthError
291
- * - Zlib::GzipFile::CRCError
292
- * - Zlib::GzipFile::NoFooter
287
+ * - Zstdlib::GzipReader
288
+ * - Zstdlib::GzipWriter
289
+ * - Zstdlib::GzipFile
290
+ * - Zstdlib::GzipFile::Error
291
+ * - Zstdlib::GzipFile::LengthError
292
+ * - Zstdlib::GzipFile::CRCError
293
+ * - Zstdlib::GzipFile::NoFooter
293
294
  *
294
295
  */
295
- void Init_zlib(void);
296
+ void Init_zstdlib(void);
296
297
 
297
298
  /*--------- Exceptions --------*/
298
299
 
@@ -352,9 +353,22 @@ finalizer_warn(const char *msg)
352
353
 
353
354
 
354
355
  /*-------- module Zlib --------*/
356
+ /*
357
+ * Document-method: Zstdlib.zstd_version
358
+ *
359
+ * Returns the string which represents the version of zstd library.
360
+ */
361
+ static VALUE
362
+ rb_zstd_version(VALUE klass)
363
+ {
364
+ VALUE str;
365
+ str = rb_str_new2(ZSTD_versionString());
366
+ OBJ_TAINT(str);
367
+ return str;
368
+ }
355
369
 
356
370
  /*
357
- * Document-method: Zlib.zlib_version
371
+ * Document-method: Zstdlib.zlib_version
358
372
  *
359
373
  * Returns the string which represents the version of zlib library.
360
374
  */
@@ -415,9 +429,9 @@ do_checksum(int argc, VALUE *argv, uLong (*func)(uLong, const Bytef*, uInt))
415
429
  }
416
430
 
417
431
  /*
418
- * Document-method: Zlib.adler32
432
+ * Document-method: Zstdlib.adler32
419
433
  *
420
- * call-seq: Zlib.adler32(string, adler)
434
+ * call-seq: Zstdlib.adler32(string, adler)
421
435
  *
422
436
  * Calculates Adler-32 checksum for +string+, and returns updated value of
423
437
  * +adler+. If +string+ is omitted, it returns the Adler-32 initial value. If
@@ -425,10 +439,10 @@ do_checksum(int argc, VALUE *argv, uLong (*func)(uLong, const Bytef*, uInt))
425
439
  *
426
440
  * Example usage:
427
441
  *
428
- * require "zlib"
442
+ * require "zstdlib"
429
443
  *
430
444
  * data = "foo"
431
- * puts "Adler32 checksum: #{Zlib.adler32(data).to_s(16)}"
445
+ * puts "Adler32 checksum: #{Zstdlib.adler32(data).to_s(16)}"
432
446
  * #=> Adler32 checksum: 2820145
433
447
  *
434
448
  */
@@ -440,9 +454,9 @@ rb_zlib_adler32(int argc, VALUE *argv, VALUE klass)
440
454
 
441
455
  #ifdef HAVE_ADLER32_COMBINE
442
456
  /*
443
- * Document-method: Zlib.adler32_combine
457
+ * Document-method: Zstdlib.adler32_combine
444
458
  *
445
- * call-seq: Zlib.adler32_combine(adler1, adler2, len2)
459
+ * call-seq: Zstdlib.adler32_combine(adler1, adler2, len2)
446
460
  *
447
461
  * Combine two Adler-32 check values in to one. +alder1+ is the first Adler-32
448
462
  * value, +adler2+ is the second Adler-32 value. +len2+ is the length of the
@@ -460,9 +474,9 @@ rb_zlib_adler32_combine(VALUE klass, VALUE adler1, VALUE adler2, VALUE len2)
460
474
  #endif
461
475
 
462
476
  /*
463
- * Document-method: Zlib.crc32
477
+ * Document-method: Zstdlib.crc32
464
478
  *
465
- * call-seq: Zlib.crc32(string, crc)
479
+ * call-seq: Zstdlib.crc32(string, crc)
466
480
  *
467
481
  * Calculates CRC checksum for +string+, and returns updated value of +crc+. If
468
482
  * +string+ is omitted, it returns the CRC initial value. If +crc+ is omitted, it
@@ -478,9 +492,9 @@ rb_zlib_crc32(int argc, VALUE *argv, VALUE klass)
478
492
 
479
493
  #ifdef HAVE_CRC32_COMBINE
480
494
  /*
481
- * Document-method: Zlib.crc32_combine
495
+ * Document-method: Zstdlib.crc32_combine
482
496
  *
483
- * call-seq: Zlib.crc32_combine(crc1, crc2, len2)
497
+ * call-seq: Zstdlib.crc32_combine(crc1, crc2, len2)
484
498
  *
485
499
  * Combine two CRC-32 check values in to one. +crc1+ is the first CRC-32
486
500
  * value, +crc2+ is the second CRC-32 value. +len2+ is the length of the
@@ -498,7 +512,7 @@ rb_zlib_crc32_combine(VALUE klass, VALUE crc1, VALUE crc2, VALUE len2)
498
512
  #endif
499
513
 
500
514
  /*
501
- * Document-method: Zlib.crc_table
515
+ * Document-method: Zstdlib.crc_table
502
516
  *
503
517
  * Returns the table for calculating CRC checksum as an array.
504
518
  */
@@ -1205,19 +1219,19 @@ get_zstream(VALUE obj)
1205
1219
  /* ------------------------------------------------------------------------- */
1206
1220
 
1207
1221
  /*
1208
- * Document-class: Zlib::ZStream
1222
+ * Document-class: Zstdlib::ZStream
1209
1223
  *
1210
- * Zlib::ZStream is the abstract class for the stream which handles the
1224
+ * Zstdlib::ZStream is the abstract class for the stream which handles the
1211
1225
  * compressed data. The operations are defined in the subclasses:
1212
- * Zlib::Deflate for compression, and Zlib::Inflate for decompression.
1226
+ * Zstdlib::Deflate for compression, and Zstdlib::Inflate for decompression.
1213
1227
  *
1214
- * An instance of Zlib::ZStream has one stream (struct zstream in the source)
1228
+ * An instance of Zstdlib::ZStream has one stream (struct zstream in the source)
1215
1229
  * and two variable-length buffers which associated to the input (next_in) of
1216
1230
  * the stream and the output (next_out) of the stream. In this document,
1217
1231
  * "input buffer" means the buffer for input, and "output buffer" means the
1218
1232
  * buffer for output.
1219
1233
  *
1220
- * Data input into an instance of Zlib::ZStream are temporally stored into
1234
+ * Data input into an instance of Zstdlib::ZStream are temporally stored into
1221
1235
  * the end of input buffer, and then data in input buffer are processed from
1222
1236
  * the beginning of the buffer until no more output from the stream is
1223
1237
  * produced (i.e. until avail_out > 0 after processing). During processing,
@@ -1229,7 +1243,7 @@ get_zstream(VALUE obj)
1229
1243
  *
1230
1244
  * Here is an ascii art for describing above:
1231
1245
  *
1232
- * +================ an instance of Zlib::ZStream ================+
1246
+ * +================ an instance of Zstdlib::ZStream ================+
1233
1247
  * || ||
1234
1248
  * || +--------+ +-------+ +--------+ ||
1235
1249
  * || +--| output |<---------|zstream|<---------| input |<--+ ||
@@ -1242,15 +1256,15 @@ get_zstream(VALUE obj)
1242
1256
  * "output data" "input data"
1243
1257
  *
1244
1258
  * If an error occurs during processing input buffer, an exception which is a
1245
- * subclass of Zlib::Error is raised. At that time, both input and output
1259
+ * subclass of Zstdlib::Error is raised. At that time, both input and output
1246
1260
  * buffer keep their conditions at the time when the error occurs.
1247
1261
  *
1248
1262
  * == Method Catalogue
1249
1263
  *
1250
1264
  * Many of the methods in this class are fairly low-level and unlikely to be
1251
1265
  * of interest to users. In fact, users are unlikely to use this class
1252
- * directly; rather they will be interested in Zlib::Inflate and
1253
- * Zlib::Deflate.
1266
+ * directly; rather they will be interested in Zstdlib::Inflate and
1267
+ * Zstdlib::Deflate.
1254
1268
  *
1255
1269
  * The higher level methods are listed below.
1256
1270
  *
@@ -1443,9 +1457,9 @@ rb_zstream_closed_p(VALUE obj)
1443
1457
  /* ------------------------------------------------------------------------- */
1444
1458
 
1445
1459
  /*
1446
- * Document-class: Zlib::Deflate
1460
+ * Document-class: Zstdlib::Deflate
1447
1461
  *
1448
- * Zlib::Deflate is the class for compressing data. See Zlib::ZStream for more
1462
+ * Zstdlib::Deflate is the class for compressing data. See Zstdlib::ZStream for more
1449
1463
  * information.
1450
1464
  */
1451
1465
 
@@ -1453,7 +1467,7 @@ rb_zstream_closed_p(VALUE obj)
1453
1467
  (NIL_P((val)) ? (ifnil) \
1454
1468
  : ((void)Check_Type((val), T_FIXNUM), FIX2INT((val))))
1455
1469
 
1456
- #define ARG_LEVEL(val) FIXNUMARG((val), Z_DEFAULT_COMPRESSION)
1470
+ #define ARG_LEVEL(val) FIXNUMARG((val), ZSTD_CLEVEL_DEFAULT)
1457
1471
  #define ARG_WBITS(val) FIXNUMARG((val), MAX_WBITS)
1458
1472
  #define ARG_MEMLEVEL(val) FIXNUMARG((val), DEF_MEM_LEVEL)
1459
1473
  #define ARG_STRATEGY(val) FIXNUMARG((val), Z_DEFAULT_STRATEGY)
@@ -1467,10 +1481,10 @@ rb_deflate_s_allocate(VALUE klass)
1467
1481
  }
1468
1482
 
1469
1483
  /*
1470
- * Document-method: Zlib::Deflate.new
1484
+ * Document-method: Zstdlib::Deflate.new
1471
1485
  *
1472
1486
  * call-seq:
1473
- * Zlib::Deflate.new(level=DEFAULT_COMPRESSION, window_bits=MAX_WBITS, mem_level=DEF_MEM_LEVEL, strategy=DEFAULT_STRATEGY)
1487
+ * Zstdlib::Deflate.new(level=DEFAULT_COMPRESSION, window_bits=MAX_WBITS, mem_level=DEF_MEM_LEVEL, strategy=DEFAULT_STRATEGY)
1474
1488
  *
1475
1489
  * Creates a new deflate stream for compression. If a given argument is nil,
1476
1490
  * the default value of that argument is used.
@@ -1479,10 +1493,10 @@ rb_deflate_s_allocate(VALUE klass)
1479
1493
  * compression) and 9 (best compression). The following constants have been
1480
1494
  * defined to make code more readable:
1481
1495
  *
1482
- * * Zlib::DEFAULT_COMPRESSION
1483
- * * Zlib::NO_COMPRESSION
1484
- * * Zlib::BEST_SPEED
1485
- * * Zlib::BEST_COMPRESSION
1496
+ * * Zstdlib::DEFAULT_COMPRESSION
1497
+ * * Zstdlib::NO_COMPRESSION
1498
+ * * Zstdlib::BEST_SPEED
1499
+ * * Zstdlib::BEST_COMPRESSION
1486
1500
  *
1487
1501
  * See http://www.zlib.net/manual.html#Constants for further information.
1488
1502
  *
@@ -1495,17 +1509,17 @@ rb_deflate_s_allocate(VALUE klass)
1495
1509
  * compression ratio while 9 uses maximum memory for optimal speed. The
1496
1510
  * default value is 8. Two constants are defined:
1497
1511
  *
1498
- * * Zlib::DEF_MEM_LEVEL
1499
- * * Zlib::MAX_MEM_LEVEL
1512
+ * * Zstdlib::DEF_MEM_LEVEL
1513
+ * * Zstdlib::MAX_MEM_LEVEL
1500
1514
  *
1501
1515
  * The +strategy+ sets the deflate compression strategy. The following
1502
1516
  * strategies are available:
1503
1517
  *
1504
- * Zlib::DEFAULT_STRATEGY:: For normal data
1505
- * Zlib::FILTERED:: For data produced by a filter or predictor
1506
- * Zlib::FIXED:: Prevents dynamic Huffman codes
1507
- * Zlib::HUFFMAN_ONLY:: Prevents string matching
1508
- * Zlib::RLE:: Designed for better compression of PNG image data
1518
+ * Zstdlib::DEFAULT_STRATEGY:: For normal data
1519
+ * Zstdlib::FILTERED:: For data produced by a filter or predictor
1520
+ * Zstdlib::FIXED:: Prevents dynamic Huffman codes
1521
+ * Zstdlib::HUFFMAN_ONLY:: Prevents string matching
1522
+ * Zstdlib::RLE:: Designed for better compression of PNG image data
1509
1523
  *
1510
1524
  * See the constants for further description.
1511
1525
  *
@@ -1514,16 +1528,16 @@ rb_deflate_s_allocate(VALUE klass)
1514
1528
  * === Basic
1515
1529
  *
1516
1530
  * open "compressed.file", "w+" do |io|
1517
- * io << Zlib::Deflate.new.deflate(File.read("big.file"))
1531
+ * io << Zstdlib::Deflate.new.deflate(File.read("big.file"))
1518
1532
  * end
1519
1533
  *
1520
1534
  * === Custom compression
1521
1535
  *
1522
1536
  * open "compressed.file", "w+" do |compressed_io|
1523
- * deflate = Zlib::Deflate.new(Zlib::BEST_COMPRESSION,
1524
- * Zlib::MAX_WBITS,
1525
- * Zlib::MAX_MEM_LEVEL,
1526
- * Zlib::HUFFMAN_ONLY)
1537
+ * deflate = Zstdlib::Deflate.new(Zstdlib::BEST_COMPRESSION,
1538
+ * Zstdlib::MAX_WBITS,
1539
+ * Zstdlib::MAX_MEM_LEVEL,
1540
+ * Zstdlib::HUFFMAN_ONLY)
1527
1541
  *
1528
1542
  * begin
1529
1543
  * open "big.file" do |big_io|
@@ -1561,7 +1575,7 @@ rb_deflate_initialize(int argc, VALUE *argv, VALUE obj)
1561
1575
  }
1562
1576
 
1563
1577
  /*
1564
- * Document-method: Zlib::Deflate#initialize_copy
1578
+ * Document-method: Zstdlib::Deflate#initialize_copy
1565
1579
  *
1566
1580
  * Duplicates the deflate stream.
1567
1581
  */
@@ -1598,26 +1612,26 @@ deflate_run(VALUE args)
1598
1612
  }
1599
1613
 
1600
1614
  /*
1601
- * Document-method: Zlib::Deflate.deflate
1615
+ * Document-method: Zstdlib::Deflate.deflate
1602
1616
  *
1603
1617
  * call-seq:
1604
- * Zlib.deflate(string[, level])
1605
- * Zlib::Deflate.deflate(string[, level])
1618
+ * Zstdlib.deflate(string[, level])
1619
+ * Zstdlib::Deflate.deflate(string[, level])
1606
1620
  *
1607
1621
  * Compresses the given +string+. Valid values of level are
1608
- * Zlib::NO_COMPRESSION, Zlib::BEST_SPEED, Zlib::BEST_COMPRESSION,
1609
- * Zlib::DEFAULT_COMPRESSION, or an integer from 0 to 9.
1622
+ * Zstdlib::NO_COMPRESSION, Zstdlib::BEST_SPEED, Zstdlib::BEST_COMPRESSION,
1623
+ * Zstdlib::DEFAULT_COMPRESSION, or an integer from 0 to 9.
1610
1624
  *
1611
1625
  * This method is almost equivalent to the following code:
1612
1626
  *
1613
1627
  * def deflate(string, level)
1614
- * z = Zlib::Deflate.new(level)
1615
- * dst = z.deflate(string, Zlib::FINISH)
1628
+ * z = Zstdlib::Deflate.new(level)
1629
+ * dst = z.deflate(string, Zstdlib::FINISH)
1616
1630
  * z.close
1617
1631
  * dst
1618
1632
  * end
1619
1633
  *
1620
- * See also Zlib.inflate
1634
+ * See also Zstdlib.inflate
1621
1635
  *
1622
1636
  */
1623
1637
  static VALUE
@@ -1660,16 +1674,16 @@ do_deflate(struct zstream *z, VALUE src, int flush)
1660
1674
  }
1661
1675
 
1662
1676
  /*
1663
- * Document-method: Zlib::Deflate#deflate
1677
+ * Document-method: Zstdlib::Deflate#deflate
1664
1678
  *
1665
1679
  * call-seq:
1666
- * z.deflate(string, flush = Zlib::NO_FLUSH) -> String
1667
- * z.deflate(string, flush = Zlib::NO_FLUSH) { |chunk| ... } -> nil
1680
+ * z.deflate(string, flush = Zstdlib::NO_FLUSH) -> String
1681
+ * z.deflate(string, flush = Zstdlib::NO_FLUSH) { |chunk| ... } -> nil
1668
1682
  *
1669
1683
  * Inputs +string+ into the deflate stream and returns the output from the
1670
1684
  * stream. On calling this method, both the input and the output buffers of
1671
1685
  * the stream are flushed. If +string+ is nil, this method finishes the
1672
- * stream, just like Zlib::ZStream#finish.
1686
+ * stream, just like Zstdlib::ZStream#finish.
1673
1687
  *
1674
1688
  * If a block is given consecutive deflated chunks from the +string+ are
1675
1689
  * yielded to the block and +nil+ is returned.
@@ -1677,10 +1691,10 @@ do_deflate(struct zstream *z, VALUE src, int flush)
1677
1691
  * The +flush+ parameter specifies the flush mode. The following constants
1678
1692
  * may be used:
1679
1693
  *
1680
- * Zlib::NO_FLUSH:: The default
1681
- * Zlib::SYNC_FLUSH:: Flushes the output to a byte boundary
1682
- * Zlib::FULL_FLUSH:: SYNC_FLUSH + resets the compression state
1683
- * Zlib::FINISH:: Pending input is processed, pending output is flushed.
1694
+ * Zstdlib::NO_FLUSH:: The default
1695
+ * Zstdlib::SYNC_FLUSH:: Flushes the output to a byte boundary
1696
+ * Zstdlib::FULL_FLUSH:: SYNC_FLUSH + resets the compression state
1697
+ * Zstdlib::FINISH:: Pending input is processed, pending output is flushed.
1684
1698
  *
1685
1699
  * See the constants for further description.
1686
1700
  *
@@ -1699,12 +1713,12 @@ rb_deflate_deflate(int argc, VALUE *argv, VALUE obj)
1699
1713
  }
1700
1714
 
1701
1715
  /*
1702
- * Document-method: Zlib::Deflate#<<
1716
+ * Document-method: Zstdlib::Deflate#<<
1703
1717
  *
1704
1718
  * call-seq: << string
1705
1719
  *
1706
- * Inputs +string+ into the deflate stream just like Zlib::Deflate#deflate, but
1707
- * returns the Zlib::Deflate object itself. The output from the stream is
1720
+ * Inputs +string+ into the deflate stream just like Zstdlib::Deflate#deflate, but
1721
+ * returns the Zstdlib::Deflate object itself. The output from the stream is
1708
1722
  * preserved in output buffer.
1709
1723
  */
1710
1724
  static VALUE
@@ -1716,18 +1730,18 @@ rb_deflate_addstr(VALUE obj, VALUE src)
1716
1730
  }
1717
1731
 
1718
1732
  /*
1719
- * Document-method: Zlib::Deflate#flush
1733
+ * Document-method: Zstdlib::Deflate#flush
1720
1734
  *
1721
1735
  * call-seq:
1722
- * flush(flush = Zlib::SYNC_FLUSH) -> String
1723
- * flush(flush = Zlib::SYNC_FLUSH) { |chunk| ... } -> nil
1736
+ * flush(flush = Zstdlib::SYNC_FLUSH) -> String
1737
+ * flush(flush = Zstdlib::SYNC_FLUSH) { |chunk| ... } -> nil
1724
1738
  *
1725
1739
  * This method is equivalent to <tt>deflate('', flush)</tt>. This method is
1726
1740
  * just provided to improve the readability of your Ruby program. If a block
1727
1741
  * is given chunks of deflate output are yielded to the block until the buffer
1728
1742
  * is flushed.
1729
1743
  *
1730
- * See Zlib::Deflate#deflate for detail on the +flush+ constants NO_FLUSH,
1744
+ * See Zstdlib::Deflate#deflate for detail on the +flush+ constants NO_FLUSH,
1731
1745
  * SYNC_FLUSH, FULL_FLUSH and FINISH.
1732
1746
  */
1733
1747
  static VALUE
@@ -1747,7 +1761,7 @@ rb_deflate_flush(int argc, VALUE *argv, VALUE obj)
1747
1761
  }
1748
1762
 
1749
1763
  /*
1750
- * Document-method: Zlib::Deflate.params
1764
+ * Document-method: Zstdlib::Deflate.params
1751
1765
  *
1752
1766
  * call-seq: params(level, strategy)
1753
1767
  *
@@ -1755,7 +1769,7 @@ rb_deflate_flush(int argc, VALUE *argv, VALUE obj)
1755
1769
  * different types of data that require different types of compression. Any
1756
1770
  * unprocessed data is flushed before changing the params.
1757
1771
  *
1758
- * See Zlib::Deflate.new for a description of +level+ and +strategy+.
1772
+ * See Zstdlib::Deflate.new for a description of +level+ and +strategy+.
1759
1773
  *
1760
1774
  */
1761
1775
  static VALUE
@@ -1787,12 +1801,12 @@ rb_deflate_params(VALUE obj, VALUE v_level, VALUE v_strategy)
1787
1801
  }
1788
1802
 
1789
1803
  /*
1790
- * Document-method: Zlib::Deflate.set_dictionary
1804
+ * Document-method: Zstdlib::Deflate.set_dictionary
1791
1805
  *
1792
1806
  * call-seq: set_dictionary(string)
1793
1807
  *
1794
1808
  * Sets the preset dictionary and returns +string+. This method is available
1795
- * just only after Zlib::Deflate.new or Zlib::ZStream#reset method was called.
1809
+ * just only after Zstdlib::Deflate.new or Zstdlib::ZStream#reset method was called.
1796
1810
  * See zlib.h for details.
1797
1811
  *
1798
1812
  * Can raise errors of Z_STREAM_ERROR if a parameter is invalid (such as
@@ -1822,10 +1836,10 @@ rb_deflate_set_dictionary(VALUE obj, VALUE dic)
1822
1836
  /* ------------------------------------------------------------------------- */
1823
1837
 
1824
1838
  /*
1825
- * Document-class: Zlib::Inflate
1839
+ * Document-class: Zstdlib::Inflate
1826
1840
  *
1827
1841
  * Zlib:Inflate is the class for decompressing compressed data. Unlike
1828
- * Zlib::Deflate, an instance of this class is not able to duplicate (clone,
1842
+ * Zstdlib::Deflate, an instance of this class is not able to duplicate (clone,
1829
1843
  * dup) itself.
1830
1844
  */
1831
1845
 
@@ -1838,10 +1852,10 @@ rb_inflate_s_allocate(VALUE klass)
1838
1852
  }
1839
1853
 
1840
1854
  /*
1841
- * Document-method: Zlib::Inflate.new
1855
+ * Document-method: Zstdlib::Inflate.new
1842
1856
  *
1843
1857
  * call-seq:
1844
- * Zlib::Inflate.new(window_bits = Zlib::MAX_WBITS)
1858
+ * Zstdlib::Inflate.new(window_bits = Zstdlib::MAX_WBITS)
1845
1859
  *
1846
1860
  * Creates a new inflate stream for decompression. +window_bits+ sets the
1847
1861
  * size of the history buffer and can have the following values:
@@ -1858,7 +1872,7 @@ rb_inflate_s_allocate(VALUE klass)
1858
1872
  * Greater than 15::
1859
1873
  * Add 32 to window_bits to enable zlib and gzip decoding with automatic
1860
1874
  * header detection, or add 16 to decode only the gzip format (a
1861
- * Zlib::DataError will be raised for a non-gzip stream).
1875
+ * Zstdlib::DataError will be raised for a non-gzip stream).
1862
1876
  *
1863
1877
  * (-8..-15)::
1864
1878
  * Enables raw deflate mode which will not generate a check value, and will
@@ -1870,7 +1884,7 @@ rb_inflate_s_allocate(VALUE klass)
1870
1884
  * == Example
1871
1885
  *
1872
1886
  * open "compressed.file" do |compressed_io|
1873
- * zi = Zlib::Inflate.new(Zlib::MAX_WBITS + 32)
1887
+ * zi = Zstdlib::Inflate.new(Zstdlib::MAX_WBITS + 32)
1874
1888
  *
1875
1889
  * begin
1876
1890
  * open "uncompressed.file", "w+" do |uncompressed_io|
@@ -1913,26 +1927,26 @@ inflate_run(VALUE args)
1913
1927
  }
1914
1928
 
1915
1929
  /*
1916
- * Document-method: Zlib::inflate
1930
+ * Document-method: Zstdlib::inflate
1917
1931
  *
1918
1932
  * call-seq:
1919
- * Zlib.inflate(string)
1920
- * Zlib::Inflate.inflate(string)
1933
+ * Zstdlib.inflate(string)
1934
+ * Zstdlib::Inflate.inflate(string)
1921
1935
  *
1922
- * Decompresses +string+. Raises a Zlib::NeedDict exception if a preset
1936
+ * Decompresses +string+. Raises a Zstdlib::NeedDict exception if a preset
1923
1937
  * dictionary is needed for decompression.
1924
1938
  *
1925
1939
  * This method is almost equivalent to the following code:
1926
1940
  *
1927
1941
  * def inflate(string)
1928
- * zstream = Zlib::Inflate.new
1942
+ * zstream = Zstdlib::Inflate.new
1929
1943
  * buf = zstream.inflate(string)
1930
1944
  * zstream.finish
1931
1945
  * zstream.close
1932
1946
  * buf
1933
1947
  * end
1934
1948
  *
1935
- * See also Zlib.deflate
1949
+ * See also Zstdlib.deflate
1936
1950
  *
1937
1951
  */
1938
1952
  static VALUE
@@ -1971,7 +1985,7 @@ do_inflate(struct zstream *z, VALUE src)
1971
1985
  }
1972
1986
  }
1973
1987
 
1974
- /* Document-method: Zlib::Inflate#add_dictionary
1988
+ /* Document-method: Zstdlib::Inflate#add_dictionary
1975
1989
  *
1976
1990
  * call-seq: add_dictionary(string)
1977
1991
  *
@@ -1992,7 +2006,7 @@ rb_inflate_add_dictionary(VALUE obj, VALUE dictionary)
1992
2006
  }
1993
2007
 
1994
2008
  /*
1995
- * Document-method: Zlib::Inflate#inflate
2009
+ * Document-method: Zstdlib::Inflate#inflate
1996
2010
  *
1997
2011
  * call-seq:
1998
2012
  * inflate(deflate_string) -> String
@@ -2001,22 +2015,22 @@ rb_inflate_add_dictionary(VALUE obj, VALUE dictionary)
2001
2015
  * Inputs +deflate_string+ into the inflate stream and returns the output from
2002
2016
  * the stream. Calling this method, both the input and the output buffer of
2003
2017
  * the stream are flushed. If string is +nil+, this method finishes the
2004
- * stream, just like Zlib::ZStream#finish.
2018
+ * stream, just like Zstdlib::ZStream#finish.
2005
2019
  *
2006
2020
  * If a block is given consecutive inflated chunks from the +deflate_string+
2007
2021
  * are yielded to the block and +nil+ is returned.
2008
2022
  *
2009
- * Raises a Zlib::NeedDict exception if a preset dictionary is needed to
2010
- * decompress. Set the dictionary by Zlib::Inflate#set_dictionary and then
2023
+ * Raises a Zstdlib::NeedDict exception if a preset dictionary is needed to
2024
+ * decompress. Set the dictionary by Zstdlib::Inflate#set_dictionary and then
2011
2025
  * call this method again with an empty string to flush the stream:
2012
2026
  *
2013
- * inflater = Zlib::Inflate.new
2027
+ * inflater = Zstdlib::Inflate.new
2014
2028
  *
2015
2029
  * begin
2016
2030
  * out = inflater.inflate compressed
2017
- * rescue Zlib::NeedDict
2031
+ * rescue Zstdlib::NeedDict
2018
2032
  * # ensure the dictionary matches the stream's required dictionary
2019
- * raise unless inflater.adler == Zlib.adler32(dictionary)
2033
+ * raise unless inflater.adler == Zstdlib.adler32(dictionary)
2020
2034
  *
2021
2035
  * inflater.set_dictionary dictionary
2022
2036
  * inflater.inflate ''
@@ -2026,7 +2040,7 @@ rb_inflate_add_dictionary(VALUE obj, VALUE dictionary)
2026
2040
  *
2027
2041
  * inflater.close
2028
2042
  *
2029
- * See also Zlib::Inflate.new
2043
+ * See also Zstdlib::Inflate.new
2030
2044
  */
2031
2045
  static VALUE
2032
2046
  rb_inflate_inflate(VALUE obj, VALUE src)
@@ -2061,8 +2075,8 @@ rb_inflate_inflate(VALUE obj, VALUE src)
2061
2075
  /*
2062
2076
  * call-seq: << string
2063
2077
  *
2064
- * Inputs +string+ into the inflate stream just like Zlib::Inflate#inflate, but
2065
- * returns the Zlib::Inflate object itself. The output from the stream is
2078
+ * Inputs +string+ into the inflate stream just like Zstdlib::Inflate#inflate, but
2079
+ * returns the Zstdlib::Inflate object itself. The output from the stream is
2066
2080
  * preserved in output buffer.
2067
2081
  */
2068
2082
  static VALUE
@@ -2130,10 +2144,10 @@ rb_inflate_sync_point_p(VALUE obj)
2130
2144
  }
2131
2145
 
2132
2146
  /*
2133
- * Document-method: Zlib::Inflate#set_dictionary
2147
+ * Document-method: Zstdlib::Inflate#set_dictionary
2134
2148
  *
2135
2149
  * Sets the preset dictionary and returns +string+. This method is available just
2136
- * only after a Zlib::NeedDict exception was raised. See zlib.h for details.
2150
+ * only after a Zstdlib::NeedDict exception was raised. See zlib.h for details.
2137
2151
  *
2138
2152
  */
2139
2153
  static VALUE
@@ -2260,7 +2274,7 @@ gzfile_free(void *p)
2260
2274
 
2261
2275
  if (ZSTREAM_IS_READY(z)) {
2262
2276
  if (z->func == &deflate_funcs) {
2263
- finalizer_warn("Zlib::GzipWriter object must be closed explicitly.");
2277
+ finalizer_warn("Zstdlib::GzipWriter object must be closed explicitly.");
2264
2278
  }
2265
2279
  zstream_finalize(z);
2266
2280
  }
@@ -2474,7 +2488,7 @@ gzfile_raise(struct gzfile *gz, VALUE klass, const char *message)
2474
2488
  }
2475
2489
 
2476
2490
  /*
2477
- * Document-method: Zlib::GzipFile::Error#inspect
2491
+ * Document-method: Zstdlib::GzipFile::Error#inspect
2478
2492
  *
2479
2493
  * Constructs a String of the GzipFile Error
2480
2494
  */
@@ -2512,7 +2526,7 @@ gzfile_make_header(struct gzfile *gz)
2512
2526
  if (gz->level == Z_BEST_SPEED) {
2513
2527
  extraflags |= GZ_EXTRAFLAG_FAST;
2514
2528
  }
2515
- else if (gz->level == Z_BEST_COMPRESSION) {
2529
+ else if (gz->level == ZSTD_maxCLevel()) {
2516
2530
  extraflags |= GZ_EXTRAFLAG_SLOW;
2517
2531
  }
2518
2532
 
@@ -2583,10 +2597,10 @@ gzfile_read_header(struct gzfile *gz)
2583
2597
  gz->level = Z_BEST_SPEED;
2584
2598
  }
2585
2599
  else if (head[8] & GZ_EXTRAFLAG_SLOW) {
2586
- gz->level = Z_BEST_COMPRESSION;
2600
+ gz->level = ZSTD_maxCLevel();
2587
2601
  }
2588
2602
  else {
2589
- gz->level = Z_DEFAULT_COMPRESSION;
2603
+ gz->level = ZSTD_CLEVEL_DEFAULT;
2590
2604
  }
2591
2605
 
2592
2606
  gz->mtime = gzfile_get32(&head[4]);
@@ -2975,40 +2989,40 @@ get_gzfile(VALUE obj)
2975
2989
  /* ------------------------------------------------------------------------- */
2976
2990
 
2977
2991
  /*
2978
- * Document-class: Zlib::GzipFile
2992
+ * Document-class: Zstdlib::GzipFile
2979
2993
  *
2980
- * Zlib::GzipFile is an abstract class for handling a gzip formatted
2994
+ * Zstdlib::GzipFile is an abstract class for handling a gzip formatted
2981
2995
  * compressed file. The operations are defined in the subclasses,
2982
- * Zlib::GzipReader for reading, and Zlib::GzipWriter for writing.
2996
+ * Zstdlib::GzipReader for reading, and Zstdlib::GzipWriter for writing.
2983
2997
  *
2984
2998
  * GzipReader should be used by associating an IO, or IO-like, object.
2985
2999
  *
2986
3000
  * == Method Catalogue
2987
3001
  *
2988
3002
  * - ::wrap
2989
- * - ::open (Zlib::GzipReader::open and Zlib::GzipWriter::open)
3003
+ * - ::open (Zstdlib::GzipReader::open and Zstdlib::GzipWriter::open)
2990
3004
  * - #close
2991
3005
  * - #closed?
2992
3006
  * - #comment
2993
- * - comment= (Zlib::GzipWriter#comment=)
3007
+ * - comment= (Zstdlib::GzipWriter#comment=)
2994
3008
  * - #crc
2995
- * - eof? (Zlib::GzipReader#eof?)
3009
+ * - eof? (Zstdlib::GzipReader#eof?)
2996
3010
  * - #finish
2997
3011
  * - #level
2998
- * - lineno (Zlib::GzipReader#lineno)
2999
- * - lineno= (Zlib::GzipReader#lineno=)
3012
+ * - lineno (Zstdlib::GzipReader#lineno)
3013
+ * - lineno= (Zstdlib::GzipReader#lineno=)
3000
3014
  * - #mtime
3001
- * - mtime= (Zlib::GzipWriter#mtime=)
3015
+ * - mtime= (Zstdlib::GzipWriter#mtime=)
3002
3016
  * - #orig_name
3003
- * - orig_name (Zlib::GzipWriter#orig_name=)
3017
+ * - orig_name (Zstdlib::GzipWriter#orig_name=)
3004
3018
  * - #os_code
3005
3019
  * - path (when the underlying IO supports #path)
3006
3020
  * - #sync
3007
3021
  * - #sync=
3008
3022
  * - #to_io
3009
3023
  *
3010
- * (due to internal structure, documentation may appear under Zlib::GzipReader
3011
- * or Zlib::GzipWriter)
3024
+ * (due to internal structure, documentation may appear under Zstdlib::GzipReader
3025
+ * or Zstdlib::GzipWriter)
3012
3026
  */
3013
3027
 
3014
3028
 
@@ -3067,11 +3081,11 @@ gzfile_wrap(int argc, VALUE *argv, VALUE klass, int close_io_on_error)
3067
3081
  }
3068
3082
 
3069
3083
  /*
3070
- * Document-method: Zlib::GzipFile.wrap
3084
+ * Document-method: Zstdlib::GzipFile.wrap
3071
3085
  *
3072
3086
  * call-seq:
3073
- * Zlib::GzipReader.wrap(io, ...) { |gz| ... }
3074
- * Zlib::GzipWriter.wrap(io, ...) { |gz| ... }
3087
+ * Zstdlib::GzipReader.wrap(io, ...) { |gz| ... }
3088
+ * Zstdlib::GzipWriter.wrap(io, ...) { |gz| ... }
3075
3089
  *
3076
3090
  * Creates a GzipReader or GzipWriter associated with +io+, passing in any
3077
3091
  * necessary extra options, and executes the block with the newly created
@@ -3079,7 +3093,7 @@ gzfile_wrap(int argc, VALUE *argv, VALUE klass, int close_io_on_error)
3079
3093
  *
3080
3094
  * The GzipFile object will be closed automatically after executing the block.
3081
3095
  * If you want to keep the associated IO object open, you may call
3082
- * Zlib::GzipFile#finish method in the block.
3096
+ * Zstdlib::GzipFile#finish method in the block.
3083
3097
  */
3084
3098
  static VALUE
3085
3099
  rb_gzfile_s_wrap(int argc, VALUE *argv, VALUE klass)
@@ -3088,9 +3102,9 @@ rb_gzfile_s_wrap(int argc, VALUE *argv, VALUE klass)
3088
3102
  }
3089
3103
 
3090
3104
  /*
3091
- * Document-method: Zlib::GzipFile.open
3105
+ * Document-method: Zstdlib::GzipFile.open
3092
3106
  *
3093
- * See Zlib::GzipReader#open and Zlib::GzipWriter#open.
3107
+ * See Zstdlib::GzipReader#open and Zstdlib::GzipWriter#open.
3094
3108
  */
3095
3109
  static VALUE
3096
3110
  gzfile_s_open(int argc, VALUE *argv, VALUE klass, const char *mode)
@@ -3105,7 +3119,7 @@ gzfile_s_open(int argc, VALUE *argv, VALUE klass, const char *mode)
3105
3119
  }
3106
3120
 
3107
3121
  /*
3108
- * Document-method: Zlib::GzipFile#to_io
3122
+ * Document-method: Zstdlib::GzipFile#to_io
3109
3123
  *
3110
3124
  * Same as IO.
3111
3125
  */
@@ -3116,7 +3130,7 @@ rb_gzfile_to_io(VALUE obj)
3116
3130
  }
3117
3131
 
3118
3132
  /*
3119
- * Document-method: Zlib::GzipFile#crc
3133
+ * Document-method: Zstdlib::GzipFile#crc
3120
3134
  *
3121
3135
  * Returns CRC value of the uncompressed data.
3122
3136
  */
@@ -3127,7 +3141,7 @@ rb_gzfile_crc(VALUE obj)
3127
3141
  }
3128
3142
 
3129
3143
  /*
3130
- * Document-method: Zlib::GzipFile#mtime
3144
+ * Document-method: Zstdlib::GzipFile#mtime
3131
3145
  *
3132
3146
  * Returns last modification time recorded in the gzip file header.
3133
3147
  */
@@ -3138,7 +3152,7 @@ rb_gzfile_mtime(VALUE obj)
3138
3152
  }
3139
3153
 
3140
3154
  /*
3141
- * Document-method: Zlib::GzipFile#level
3155
+ * Document-method: Zstdlib::GzipFile#level
3142
3156
  *
3143
3157
  * Returns compression level.
3144
3158
  */
@@ -3149,7 +3163,7 @@ rb_gzfile_level(VALUE obj)
3149
3163
  }
3150
3164
 
3151
3165
  /*
3152
- * Document-method: Zlib::GzipFile#os_code
3166
+ * Document-method: Zstdlib::GzipFile#os_code
3153
3167
  *
3154
3168
  * Returns OS code number recorded in the gzip file header.
3155
3169
  */
@@ -3160,7 +3174,7 @@ rb_gzfile_os_code(VALUE obj)
3160
3174
  }
3161
3175
 
3162
3176
  /*
3163
- * Document-method: Zlib::GzipFile#orig_name
3177
+ * Document-method: Zstdlib::GzipFile#orig_name
3164
3178
  *
3165
3179
  * Returns original filename recorded in the gzip file header, or +nil+ if
3166
3180
  * original filename is not present.
@@ -3177,7 +3191,7 @@ rb_gzfile_orig_name(VALUE obj)
3177
3191
  }
3178
3192
 
3179
3193
  /*
3180
- * Document-method: Zlib::GzipFile#comment
3194
+ * Document-method: Zstdlib::GzipFile#comment
3181
3195
  *
3182
3196
  * Returns comments recorded in the gzip file header, or nil if the comments
3183
3197
  * is not present.
@@ -3194,7 +3208,7 @@ rb_gzfile_comment(VALUE obj)
3194
3208
  }
3195
3209
 
3196
3210
  /*
3197
- * Document-method: Zlib::GzipFile#lineno
3211
+ * Document-method: Zstdlib::GzipFile#lineno
3198
3212
  *
3199
3213
  * The line number of the last row read from this file.
3200
3214
  */
@@ -3205,7 +3219,7 @@ rb_gzfile_lineno(VALUE obj)
3205
3219
  }
3206
3220
 
3207
3221
  /*
3208
- * Document-method: Zlib::GzipReader#lineno=
3222
+ * Document-method: Zstdlib::GzipReader#lineno=
3209
3223
  *
3210
3224
  * Specify line number of the last row read from this file.
3211
3225
  */
@@ -3218,7 +3232,7 @@ rb_gzfile_set_lineno(VALUE obj, VALUE lineno)
3218
3232
  }
3219
3233
 
3220
3234
  /*
3221
- * Document-method: Zlib::GzipWriter#mtime=
3235
+ * Document-method: Zstdlib::GzipWriter#mtime=
3222
3236
  *
3223
3237
  * Specify the modification time (+mtime+) in the gzip header.
3224
3238
  * Using a Fixnum or Integer
@@ -3240,7 +3254,7 @@ rb_gzfile_set_mtime(VALUE obj, VALUE mtime)
3240
3254
  }
3241
3255
 
3242
3256
  /*
3243
- * Document-method: Zlib::GzipFile#orig_name=
3257
+ * Document-method: Zstdlib::GzipFile#orig_name=
3244
3258
  *
3245
3259
  * Specify the original name (+str+) in the gzip header.
3246
3260
  */
@@ -3264,7 +3278,7 @@ rb_gzfile_set_orig_name(VALUE obj, VALUE str)
3264
3278
  }
3265
3279
 
3266
3280
  /*
3267
- * Document-method: Zlib::GzipFile#comment=
3281
+ * Document-method: Zstdlib::GzipFile#comment=
3268
3282
  *
3269
3283
  * Specify the comment (+str+) in the gzip header.
3270
3284
  */
@@ -3288,7 +3302,7 @@ rb_gzfile_set_comment(VALUE obj, VALUE str)
3288
3302
  }
3289
3303
 
3290
3304
  /*
3291
- * Document-method: Zlib::GzipFile#close
3305
+ * Document-method: Zstdlib::GzipFile#close
3292
3306
  *
3293
3307
  * Closes the GzipFile object. This method calls close method of the
3294
3308
  * associated IO object. Returns the associated IO object.
@@ -3309,9 +3323,9 @@ rb_gzfile_close(VALUE obj)
3309
3323
  }
3310
3324
 
3311
3325
  /*
3312
- * Document-method: Zlib::GzipFile#finish
3326
+ * Document-method: Zstdlib::GzipFile#finish
3313
3327
  *
3314
- * Closes the GzipFile object. Unlike Zlib::GzipFile#close, this method never
3328
+ * Closes the GzipFile object. Unlike Zstdlib::GzipFile#close, this method never
3315
3329
  * calls the close method of the associated IO object. Returns the associated IO
3316
3330
  * object.
3317
3331
  */
@@ -3327,7 +3341,7 @@ rb_gzfile_finish(VALUE obj)
3327
3341
  }
3328
3342
 
3329
3343
  /*
3330
- * Document-method: Zlib::GzipFile#closed?
3344
+ * Document-method: Zstdlib::GzipFile#closed?
3331
3345
  *
3332
3346
  * Same as IO#closed?
3333
3347
  *
@@ -3341,7 +3355,7 @@ rb_gzfile_closed_p(VALUE obj)
3341
3355
  }
3342
3356
 
3343
3357
  /*
3344
- * Document-method: Zlib::GzipFile#eof?
3358
+ * Document-method: Zstdlib::GzipFile#eof?
3345
3359
  *
3346
3360
  * Returns +true+ or +false+ whether the stream has reached the end.
3347
3361
  */
@@ -3353,7 +3367,7 @@ rb_gzfile_eof_p(VALUE obj)
3353
3367
  }
3354
3368
 
3355
3369
  /*
3356
- * Document-method: Zlib::GzipFile#sync
3370
+ * Document-method: Zstdlib::GzipFile#sync
3357
3371
  *
3358
3372
  * Same as IO#sync
3359
3373
  *
@@ -3365,7 +3379,7 @@ rb_gzfile_sync(VALUE obj)
3365
3379
  }
3366
3380
 
3367
3381
  /*
3368
- * Document-method: Zlib::GzipFile#sync=
3382
+ * Document-method: Zstdlib::GzipFile#sync=
3369
3383
  *
3370
3384
  * call-seq: sync = flag
3371
3385
  *
@@ -3388,7 +3402,7 @@ rb_gzfile_set_sync(VALUE obj, VALUE mode)
3388
3402
  }
3389
3403
 
3390
3404
  /*
3391
- * Document-method: Zlib::GzipFile#total_in
3405
+ * Document-method: Zstdlib::GzipFile#total_in
3392
3406
  *
3393
3407
  * Total number of input bytes read so far.
3394
3408
  */
@@ -3399,7 +3413,7 @@ rb_gzfile_total_in(VALUE obj)
3399
3413
  }
3400
3414
 
3401
3415
  /*
3402
- * Document-method: Zlib::GzipFile#total_out
3416
+ * Document-method: Zstdlib::GzipFile#total_out
3403
3417
  *
3404
3418
  * Total number of output bytes output so far.
3405
3419
  */
@@ -3418,7 +3432,7 @@ rb_gzfile_total_out(VALUE obj)
3418
3432
  }
3419
3433
 
3420
3434
  /*
3421
- * Document-method: Zlib::GzipFile#path
3435
+ * Document-method: Zstdlib::GzipFile#path
3422
3436
  *
3423
3437
  * call-seq: path
3424
3438
  *
@@ -3450,19 +3464,19 @@ rb_gzfile_ecopts(struct gzfile *gz, VALUE opts)
3450
3464
  /* ------------------------------------------------------------------------- */
3451
3465
 
3452
3466
  /*
3453
- * Document-class: Zlib::GzipWriter
3467
+ * Document-class: Zstdlib::GzipWriter
3454
3468
  *
3455
- * Zlib::GzipWriter is a class for writing gzipped files. GzipWriter should
3469
+ * Zstdlib::GzipWriter is a class for writing gzipped files. GzipWriter should
3456
3470
  * be used with an instance of IO, or IO-like, object.
3457
3471
  *
3458
3472
  * Following two example generate the same result.
3459
3473
  *
3460
- * Zlib::GzipWriter.open('hoge.gz') do |gz|
3474
+ * Zstdlib::GzipWriter.open('hoge.gz') do |gz|
3461
3475
  * gz.write 'jugemu jugemu gokou no surikire...'
3462
3476
  * end
3463
3477
  *
3464
3478
  * File.open('hoge.gz', 'w') do |f|
3465
- * gz = Zlib::GzipWriter.new(f)
3479
+ * gz = Zstdlib::GzipWriter.new(f)
3466
3480
  * gz.write 'jugemu jugemu gokou no surikire...'
3467
3481
  * gz.close
3468
3482
  * end
@@ -3470,14 +3484,14 @@ rb_gzfile_ecopts(struct gzfile *gz, VALUE opts)
3470
3484
  * To make like gzip(1) does, run following:
3471
3485
  *
3472
3486
  * orig = 'hoge.txt'
3473
- * Zlib::GzipWriter.open('hoge.gz') do |gz|
3487
+ * Zstdlib::GzipWriter.open('hoge.gz') do |gz|
3474
3488
  * gz.mtime = File.mtime(orig)
3475
3489
  * gz.orig_name = orig
3476
3490
  * gz.write IO.binread(orig)
3477
3491
  * end
3478
3492
  *
3479
3493
  * NOTE: Due to the limitation of Ruby's finalizer, you must explicitly close
3480
- * GzipWriter objects by Zlib::GzipWriter#close etc. Otherwise, GzipWriter
3494
+ * GzipWriter objects by Zstdlib::GzipWriter#close etc. Otherwise, GzipWriter
3481
3495
  * will be not able to write the gzip footer and will generate a broken gzip
3482
3496
  * file.
3483
3497
  */
@@ -3489,11 +3503,11 @@ rb_gzwriter_s_allocate(VALUE klass)
3489
3503
  }
3490
3504
 
3491
3505
  /*
3492
- * call-seq: Zlib::GzipWriter.open(filename, level=nil, strategy=nil) { |gz| ... }
3506
+ * call-seq: Zstdlib::GzipWriter.open(filename, level=nil, strategy=nil) { |gz| ... }
3493
3507
  *
3494
3508
  * Opens a file specified by +filename+ for writing gzip compressed data, and
3495
3509
  * returns a GzipWriter object associated with that file. Further details of
3496
- * this method are found in Zlib::GzipWriter.new and Zlib::GzipFile.wrap.
3510
+ * this method are found in Zstdlib::GzipWriter.new and Zstdlib::GzipFile.wrap.
3497
3511
  */
3498
3512
  static VALUE
3499
3513
  rb_gzwriter_s_open(int argc, VALUE *argv, VALUE klass)
@@ -3503,10 +3517,10 @@ rb_gzwriter_s_open(int argc, VALUE *argv, VALUE klass)
3503
3517
 
3504
3518
  /*
3505
3519
  * call-seq:
3506
- * Zlib::GzipWriter.new(io, level = nil, strategy = nil, options = {})
3520
+ * Zstdlib::GzipWriter.new(io, level = nil, strategy = nil, options = {})
3507
3521
  *
3508
3522
  * Creates a GzipWriter object associated with +io+. +level+ and +strategy+
3509
- * should be the same as the arguments of Zlib::Deflate.new. The GzipWriter
3523
+ * should be the same as the arguments of Zstdlib::Deflate.new. The GzipWriter
3510
3524
  * object writes gzipped data to +io+. +io+ must respond to the
3511
3525
  * +write+ method that behaves the same as IO#write.
3512
3526
  *
@@ -3552,8 +3566,8 @@ rb_gzwriter_initialize(int argc, VALUE *argv, VALUE obj)
3552
3566
  * call-seq: flush(flush=nil)
3553
3567
  *
3554
3568
  * Flushes all the internal buffers of the GzipWriter object. The meaning of
3555
- * +flush+ is same as in Zlib::Deflate#deflate. <tt>Zlib::SYNC_FLUSH</tt> is used if
3556
- * +flush+ is omitted. It is no use giving flush <tt>Zlib::NO_FLUSH</tt>.
3569
+ * +flush+ is same as in Zstdlib::Deflate#deflate. <tt>Zstdlib::SYNC_FLUSH</tt> is used if
3570
+ * +flush+ is omitted. It is no use giving flush <tt>Zstdlib::NO_FLUSH</tt>.
3557
3571
  */
3558
3572
  static VALUE
3559
3573
  rb_gzwriter_flush(int argc, VALUE *argv, VALUE obj)
@@ -3634,25 +3648,25 @@ rb_gzwriter_putc(VALUE obj, VALUE ch)
3634
3648
  /* ------------------------------------------------------------------------- */
3635
3649
 
3636
3650
  /*
3637
- * Document-class: Zlib::GzipReader
3651
+ * Document-class: Zstdlib::GzipReader
3638
3652
  *
3639
- * Zlib::GzipReader is the class for reading a gzipped file. GzipReader should
3653
+ * Zstdlib::GzipReader is the class for reading a gzipped file. GzipReader should
3640
3654
  * be used as an IO, or -IO-like, object.
3641
3655
  *
3642
- * Zlib::GzipReader.open('hoge.gz') {|gz|
3656
+ * Zstdlib::GzipReader.open('hoge.gz') {|gz|
3643
3657
  * print gz.read
3644
3658
  * }
3645
3659
  *
3646
3660
  * File.open('hoge.gz') do |f|
3647
- * gz = Zlib::GzipReader.new(f)
3661
+ * gz = Zstdlib::GzipReader.new(f)
3648
3662
  * print gz.read
3649
3663
  * gz.close
3650
3664
  * end
3651
3665
  *
3652
3666
  * == Method Catalogue
3653
3667
  *
3654
- * The following methods in Zlib::GzipReader are just like their counterparts
3655
- * in IO, but they raise Zlib::Error or Zlib::GzipFile::Error exception if an
3668
+ * The following methods in Zstdlib::GzipReader are just like their counterparts
3669
+ * in IO, but they raise Zstdlib::Error or Zstdlib::GzipFile::Error exception if an
3656
3670
  * error was found in the gzip file.
3657
3671
  * - #each
3658
3672
  * - #each_line
@@ -3670,15 +3684,15 @@ rb_gzwriter_putc(VALUE obj, VALUE ch)
3670
3684
  * Be careful of the footer of the gzip file. A gzip file has the checksum of
3671
3685
  * pre-compressed data in its footer. GzipReader checks all uncompressed data
3672
3686
  * against that checksum at the following cases, and if it fails, raises
3673
- * <tt>Zlib::GzipFile::NoFooter</tt>, <tt>Zlib::GzipFile::CRCError</tt>, or
3674
- * <tt>Zlib::GzipFile::LengthError</tt> exception.
3687
+ * <tt>Zstdlib::GzipFile::NoFooter</tt>, <tt>Zstdlib::GzipFile::CRCError</tt>, or
3688
+ * <tt>Zstdlib::GzipFile::LengthError</tt> exception.
3675
3689
  *
3676
3690
  * - When an reading request is received beyond the end of file (the end of
3677
- * compressed data). That is, when Zlib::GzipReader#read,
3678
- * Zlib::GzipReader#gets, or some other methods for reading returns nil.
3679
- * - When Zlib::GzipFile#close method is called after the object reaches the
3691
+ * compressed data). That is, when Zstdlib::GzipReader#read,
3692
+ * Zstdlib::GzipReader#gets, or some other methods for reading returns nil.
3693
+ * - When Zstdlib::GzipFile#close method is called after the object reaches the
3680
3694
  * end of file.
3681
- * - When Zlib::GzipReader#unused method is called after the object reaches
3695
+ * - When Zstdlib::GzipReader#unused method is called after the object reaches
3682
3696
  * the end of file.
3683
3697
  *
3684
3698
  * The rest of the methods are adequately described in their own
@@ -3692,13 +3706,13 @@ rb_gzreader_s_allocate(VALUE klass)
3692
3706
  }
3693
3707
 
3694
3708
  /*
3695
- * Document-method: Zlib::GzipReader.open
3709
+ * Document-method: Zstdlib::GzipReader.open
3696
3710
  *
3697
- * call-seq: Zlib::GzipReader.open(filename) {|gz| ... }
3711
+ * call-seq: Zstdlib::GzipReader.open(filename) {|gz| ... }
3698
3712
  *
3699
3713
  * Opens a file specified by +filename+ as a gzipped file, and returns a
3700
3714
  * GzipReader object associated with that file. Further details of this method
3701
- * are in Zlib::GzipReader.new and ZLib::GzipFile.wrap.
3715
+ * are in Zstdlib::GzipReader.new and ZLib::GzipFile.wrap.
3702
3716
  */
3703
3717
  static VALUE
3704
3718
  rb_gzreader_s_open(int argc, VALUE *argv, VALUE klass)
@@ -3707,10 +3721,10 @@ rb_gzreader_s_open(int argc, VALUE *argv, VALUE klass)
3707
3721
  }
3708
3722
 
3709
3723
  /*
3710
- * Document-method: Zlib::GzipReader.new
3724
+ * Document-method: Zstdlib::GzipReader.new
3711
3725
  *
3712
3726
  * call-seq:
3713
- * Zlib::GzipReader.new(io, options = {})
3727
+ * Zstdlib::GzipReader.new(io, options = {})
3714
3728
  *
3715
3729
  * Creates a GzipReader object associated with +io+. The GzipReader object reads
3716
3730
  * gzipped data from +io+, and parses/decompresses it. The +io+ must
@@ -3720,7 +3734,7 @@ rb_gzreader_s_open(int argc, VALUE *argv, VALUE klass)
3720
3734
  * +:external_encoding+, +:internal_encoding+ and +:encoding+ may be set as in
3721
3735
  * IO::new.
3722
3736
  *
3723
- * If the gzip file header is incorrect, raises an Zlib::GzipFile::Error
3737
+ * If the gzip file header is incorrect, raises an Zstdlib::GzipFile::Error
3724
3738
  * exception.
3725
3739
  */
3726
3740
  static VALUE
@@ -3752,7 +3766,7 @@ rb_gzreader_initialize(int argc, VALUE *argv, VALUE obj)
3752
3766
  }
3753
3767
 
3754
3768
  /*
3755
- * Document-method: Zlib::GzipReader#rewind
3769
+ * Document-method: Zstdlib::GzipReader#rewind
3756
3770
  *
3757
3771
  * Resets the position of the file pointer to the point created the GzipReader
3758
3772
  * object. The associated IO object needs to respond to the +seek+ method.
@@ -3766,7 +3780,7 @@ rb_gzreader_rewind(VALUE obj)
3766
3780
  }
3767
3781
 
3768
3782
  /*
3769
- * Document-method: Zlib::GzipReader#unused
3783
+ * Document-method: Zstdlib::GzipReader#unused
3770
3784
  *
3771
3785
  * Returns the rest of the data which had read for parsing gzip format, or
3772
3786
  * +nil+ if the whole gzip file is not parsed yet.
@@ -3780,9 +3794,9 @@ rb_gzreader_unused(VALUE obj)
3780
3794
  }
3781
3795
 
3782
3796
  /*
3783
- * Document-method: Zlib::GzipReader#read
3797
+ * Document-method: Zstdlib::GzipReader#read
3784
3798
  *
3785
- * See Zlib::GzipReader documentation for a description.
3799
+ * See Zstdlib::GzipReader documentation for a description.
3786
3800
  */
3787
3801
  static VALUE
3788
3802
  rb_gzreader_read(int argc, VALUE *argv, VALUE obj)
@@ -3804,7 +3818,7 @@ rb_gzreader_read(int argc, VALUE *argv, VALUE obj)
3804
3818
  }
3805
3819
 
3806
3820
  /*
3807
- * Document-method: Zlib::GzipReader#readpartial
3821
+ * Document-method: Zstdlib::GzipReader#readpartial
3808
3822
  *
3809
3823
  * call-seq:
3810
3824
  * gzipreader.readpartial(maxlen [, outbuf]) => string, outbuf
@@ -3834,9 +3848,9 @@ rb_gzreader_readpartial(int argc, VALUE *argv, VALUE obj)
3834
3848
  }
3835
3849
 
3836
3850
  /*
3837
- * Document-method: Zlib::GzipReader#getc
3851
+ * Document-method: Zstdlib::GzipReader#getc
3838
3852
  *
3839
- * See Zlib::GzipReader documentation for a description.
3853
+ * See Zstdlib::GzipReader documentation for a description.
3840
3854
  */
3841
3855
  static VALUE
3842
3856
  rb_gzreader_getc(VALUE obj)
@@ -3847,9 +3861,9 @@ rb_gzreader_getc(VALUE obj)
3847
3861
  }
3848
3862
 
3849
3863
  /*
3850
- * Document-method: Zlib::GzipReader#readchar
3864
+ * Document-method: Zstdlib::GzipReader#readchar
3851
3865
  *
3852
- * See Zlib::GzipReader documentation for a description.
3866
+ * See Zstdlib::GzipReader documentation for a description.
3853
3867
  */
3854
3868
  static VALUE
3855
3869
  rb_gzreader_readchar(VALUE obj)
@@ -3863,9 +3877,9 @@ rb_gzreader_readchar(VALUE obj)
3863
3877
  }
3864
3878
 
3865
3879
  /*
3866
- * Document-method: Zlib::GzipReader#getbyte
3880
+ * Document-method: Zstdlib::GzipReader#getbyte
3867
3881
  *
3868
- * See Zlib::GzipReader documentation for a description.
3882
+ * See Zstdlib::GzipReader documentation for a description.
3869
3883
  */
3870
3884
  static VALUE
3871
3885
  rb_gzreader_getbyte(VALUE obj)
@@ -3881,9 +3895,9 @@ rb_gzreader_getbyte(VALUE obj)
3881
3895
  }
3882
3896
 
3883
3897
  /*
3884
- * Document-method: Zlib::GzipReader#readbyte
3898
+ * Document-method: Zstdlib::GzipReader#readbyte
3885
3899
  *
3886
- * See Zlib::GzipReader documentation for a description.
3900
+ * See Zstdlib::GzipReader documentation for a description.
3887
3901
  */
3888
3902
  static VALUE
3889
3903
  rb_gzreader_readbyte(VALUE obj)
@@ -3897,9 +3911,9 @@ rb_gzreader_readbyte(VALUE obj)
3897
3911
  }
3898
3912
 
3899
3913
  /*
3900
- * Document-method: Zlib::GzipReader#each_char
3914
+ * Document-method: Zstdlib::GzipReader#each_char
3901
3915
  *
3902
- * See Zlib::GzipReader documentation for a description.
3916
+ * See Zstdlib::GzipReader documentation for a description.
3903
3917
  */
3904
3918
  static VALUE
3905
3919
  rb_gzreader_each_char(VALUE obj)
@@ -3915,9 +3929,9 @@ rb_gzreader_each_char(VALUE obj)
3915
3929
  }
3916
3930
 
3917
3931
  /*
3918
- * Document-method: Zlib::GzipReader#each_byte
3932
+ * Document-method: Zstdlib::GzipReader#each_byte
3919
3933
  *
3920
- * See Zlib::GzipReader documentation for a description.
3934
+ * See Zstdlib::GzipReader documentation for a description.
3921
3935
  */
3922
3936
  static VALUE
3923
3937
  rb_gzreader_each_byte(VALUE obj)
@@ -3933,23 +3947,23 @@ rb_gzreader_each_byte(VALUE obj)
3933
3947
  }
3934
3948
 
3935
3949
  /*
3936
- * Document-method: Zlib::GzipReader#bytes
3950
+ * Document-method: Zstdlib::GzipReader#bytes
3937
3951
  *
3938
3952
  * This is a deprecated alias for <code>each_byte</code>.
3939
3953
  */
3940
3954
  static VALUE
3941
3955
  rb_gzreader_bytes(VALUE obj)
3942
3956
  {
3943
- rb_warn("Zlib::GzipReader#bytes is deprecated; use #each_byte instead");
3957
+ rb_warn("Zstdlib::GzipReader#bytes is deprecated; use #each_byte instead");
3944
3958
  if (!rb_block_given_p())
3945
3959
  return rb_enumeratorize(obj, ID2SYM(rb_intern("each_byte")), 0, 0);
3946
3960
  return rb_gzreader_each_byte(obj);
3947
3961
  }
3948
3962
 
3949
3963
  /*
3950
- * Document-method: Zlib::GzipReader#ungetc
3964
+ * Document-method: Zstdlib::GzipReader#ungetc
3951
3965
  *
3952
- * See Zlib::GzipReader documentation for a description.
3966
+ * See Zstdlib::GzipReader documentation for a description.
3953
3967
  */
3954
3968
  static VALUE
3955
3969
  rb_gzreader_ungetc(VALUE obj, VALUE s)
@@ -3969,9 +3983,9 @@ rb_gzreader_ungetc(VALUE obj, VALUE s)
3969
3983
  }
3970
3984
 
3971
3985
  /*
3972
- * Document-method: Zlib::GzipReader#ungetbyte
3986
+ * Document-method: Zstdlib::GzipReader#ungetbyte
3973
3987
  *
3974
- * See Zlib::GzipReader documentation for a description.
3988
+ * See Zstdlib::GzipReader documentation for a description.
3975
3989
  */
3976
3990
  static VALUE
3977
3991
  rb_gzreader_ungetbyte(VALUE obj, VALUE ch)
@@ -4169,9 +4183,9 @@ gzreader_gets(int argc, VALUE *argv, VALUE obj)
4169
4183
  }
4170
4184
 
4171
4185
  /*
4172
- * Document-method: Zlib::GzipReader#gets
4186
+ * Document-method: Zstdlib::GzipReader#gets
4173
4187
  *
4174
- * See Zlib::GzipReader documentation for a description.
4188
+ * See Zstdlib::GzipReader documentation for a description.
4175
4189
  */
4176
4190
  static VALUE
4177
4191
  rb_gzreader_gets(int argc, VALUE *argv, VALUE obj)
@@ -4185,9 +4199,9 @@ rb_gzreader_gets(int argc, VALUE *argv, VALUE obj)
4185
4199
  }
4186
4200
 
4187
4201
  /*
4188
- * Document-method: Zlib::GzipReader#readline
4202
+ * Document-method: Zstdlib::GzipReader#readline
4189
4203
  *
4190
- * See Zlib::GzipReader documentation for a description.
4204
+ * See Zstdlib::GzipReader documentation for a description.
4191
4205
  */
4192
4206
  static VALUE
4193
4207
  rb_gzreader_readline(int argc, VALUE *argv, VALUE obj)
@@ -4201,9 +4215,9 @@ rb_gzreader_readline(int argc, VALUE *argv, VALUE obj)
4201
4215
  }
4202
4216
 
4203
4217
  /*
4204
- * Document-method: Zlib::GzipReader#each
4218
+ * Document-method: Zstdlib::GzipReader#each
4205
4219
  *
4206
- * See Zlib::GzipReader documentation for a description.
4220
+ * See Zstdlib::GzipReader documentation for a description.
4207
4221
  */
4208
4222
  static VALUE
4209
4223
  rb_gzreader_each(int argc, VALUE *argv, VALUE obj)
@@ -4219,23 +4233,23 @@ rb_gzreader_each(int argc, VALUE *argv, VALUE obj)
4219
4233
  }
4220
4234
 
4221
4235
  /*
4222
- * Document-method: Zlib::GzipReader#lines
4236
+ * Document-method: Zstdlib::GzipReader#lines
4223
4237
  *
4224
4238
  * This is a deprecated alias for <code>each_line</code>.
4225
4239
  */
4226
4240
  static VALUE
4227
4241
  rb_gzreader_lines(int argc, VALUE *argv, VALUE obj)
4228
4242
  {
4229
- rb_warn("Zlib::GzipReader#lines is deprecated; use #each_line instead");
4243
+ rb_warn("Zstdlib::GzipReader#lines is deprecated; use #each_line instead");
4230
4244
  if (!rb_block_given_p())
4231
4245
  return rb_enumeratorize(obj, ID2SYM(rb_intern("each_line")), argc, argv);
4232
4246
  return rb_gzreader_each(argc, argv, obj);
4233
4247
  }
4234
4248
 
4235
4249
  /*
4236
- * Document-method: Zlib::GzipReader#readlines
4250
+ * Document-method: Zstdlib::GzipReader#readlines
4237
4251
  *
4238
- * See Zlib::GzipReader documentation for a description.
4252
+ * See Zstdlib::GzipReader documentation for a description.
4239
4253
  */
4240
4254
  static VALUE
4241
4255
  rb_gzreader_readlines(int argc, VALUE *argv, VALUE obj)
@@ -4249,9 +4263,9 @@ rb_gzreader_readlines(int argc, VALUE *argv, VALUE obj)
4249
4263
  }
4250
4264
 
4251
4265
  /*
4252
- * Document-method: Zlib::GzipReader#external_encoding
4266
+ * Document-method: Zstdlib::GzipReader#external_encoding
4253
4267
  *
4254
- * See Zlib::GzipReader documentation for a description.
4268
+ * See Zstdlib::GzipReader documentation for a description.
4255
4269
  */
4256
4270
  static VALUE
4257
4271
  rb_gzreader_external_encoding(VALUE self)
@@ -4262,14 +4276,14 @@ rb_gzreader_external_encoding(VALUE self)
4262
4276
  #endif /* GZIP_SUPPORT */
4263
4277
 
4264
4278
  void
4265
- Init_zlib(void)
4279
+ Init_zstdlib(void)
4266
4280
  {
4267
4281
  VALUE mZlib, cZStream, cDeflate, cInflate;
4268
4282
  #if GZIP_SUPPORT
4269
4283
  VALUE cGzipFile, cGzipWriter, cGzipReader;
4270
4284
  #endif
4271
4285
 
4272
- mZlib = rb_define_module("Zlib");
4286
+ mZlib = rb_define_module("Zstdlib");
4273
4287
 
4274
4288
  id_dictionaries = rb_intern("@dictionaries");
4275
4289
 
@@ -4293,6 +4307,8 @@ Init_zlib(void)
4293
4307
  rb_define_const(mZlib, "VERSION", rb_str_new2(RUBY_ZLIB_VERSION));
4294
4308
  /* The string which represents the version of zlib.h */
4295
4309
  rb_define_const(mZlib, "ZLIB_VERSION", rb_str_new2(ZLIB_VERSION));
4310
+ rb_define_const(mZlib, "ZSTD_VERSION", rb_str_new2(ZSTD_versionString()));
4311
+ rb_define_module_function(mZlib, "zstd_version", rb_zstd_version, 0);
4296
4312
 
4297
4313
  cZStream = rb_define_class_under(mZlib, "ZStream", rb_cObject);
4298
4314
  rb_undef_alloc_func(cZStream);
@@ -4316,7 +4332,7 @@ Init_zlib(void)
4316
4332
 
4317
4333
  /* Represents binary data as guessed by deflate.
4318
4334
  *
4319
- * See Zlib::Deflate#data_type. */
4335
+ * See Zstdlib::Deflate#data_type. */
4320
4336
  rb_define_const(mZlib, "BINARY", INT2FIX(Z_BINARY));
4321
4337
 
4322
4338
  /* Represents text data as guessed by deflate.
@@ -4324,19 +4340,19 @@ Init_zlib(void)
4324
4340
  * NOTE: The underlying constant Z_ASCII was deprecated in favor of Z_TEXT
4325
4341
  * in zlib 1.2.2. New applications should not use this constant.
4326
4342
  *
4327
- * See Zlib::Deflate#data_type. */
4343
+ * See Zstdlib::Deflate#data_type. */
4328
4344
  rb_define_const(mZlib, "ASCII", INT2FIX(Z_ASCII));
4329
4345
 
4330
4346
  #ifdef Z_TEXT
4331
4347
  /* Represents text data as guessed by deflate.
4332
4348
  *
4333
- * See Zlib::Deflate#data_type. */
4349
+ * See Zstdlib::Deflate#data_type. */
4334
4350
  rb_define_const(mZlib, "TEXT", INT2FIX(Z_TEXT));
4335
4351
  #endif
4336
4352
 
4337
4353
  /* Represents an unknown data type as guessed by deflate.
4338
4354
  *
4339
- * See Zlib::Deflate#data_type. */
4355
+ * See Zstdlib::Deflate#data_type. */
4340
4356
  rb_define_const(mZlib, "UNKNOWN", INT2FIX(Z_UNKNOWN));
4341
4357
 
4342
4358
  cDeflate = rb_define_class_under(mZlib, "Deflate", cZStream);
@@ -4370,12 +4386,12 @@ Init_zlib(void)
4370
4386
  /* Fastest compression level, but with the lowest space savings. */
4371
4387
  rb_define_const(mZlib, "BEST_SPEED", INT2FIX(Z_BEST_SPEED));
4372
4388
  /* Slowest compression level, but with the best space savings. */
4373
- rb_define_const(mZlib, "BEST_COMPRESSION", INT2FIX(Z_BEST_COMPRESSION));
4389
+ rb_define_const(mZlib, "BEST_COMPRESSION", INT2FIX(ZSTD_maxCLevel()));
4374
4390
  /* Default compression level which is a good trade-off between space and
4375
4391
  * time
4376
4392
  */
4377
4393
  rb_define_const(mZlib, "DEFAULT_COMPRESSION",
4378
- INT2FIX(Z_DEFAULT_COMPRESSION));
4394
+ INT2FIX(ZSTD_CLEVEL_DEFAULT));
4379
4395
 
4380
4396
  /* Deflate strategy for data produced by a filter (or predictor). The
4381
4397
  * effect of FILTERED is to force more Huffman codes and less string
@@ -4406,7 +4422,7 @@ Init_zlib(void)
4406
4422
  rb_define_const(mZlib, "DEFAULT_STRATEGY", INT2FIX(Z_DEFAULT_STRATEGY));
4407
4423
 
4408
4424
  /* The maximum size of the zlib history buffer. Note that zlib allows
4409
- * larger values to enable different inflate modes. See Zlib::Inflate.new
4425
+ * larger values to enable different inflate modes. See Zstdlib::Inflate.new
4410
4426
  * for details.
4411
4427
  */
4412
4428
  rb_define_const(mZlib, "MAX_WBITS", INT2FIX(MAX_WBITS));
@@ -4568,28 +4584,28 @@ Init_zlib(void)
4568
4584
  /* Document error classes. */
4569
4585
 
4570
4586
  /*
4571
- * Document-class: Zlib::Error
4587
+ * Document-class: Zstdlib::Error
4572
4588
  *
4573
4589
  * The superclass for all exceptions raised by Ruby/zlib.
4574
4590
  *
4575
- * The following exceptions are defined as subclasses of Zlib::Error. These
4591
+ * The following exceptions are defined as subclasses of Zstdlib::Error. These
4576
4592
  * exceptions are raised when zlib library functions return with an error
4577
4593
  * status.
4578
4594
  *
4579
- * - Zlib::StreamEnd
4580
- * - Zlib::NeedDict
4581
- * - Zlib::DataError
4582
- * - Zlib::StreamError
4583
- * - Zlib::MemError
4584
- * - Zlib::BufError
4585
- * - Zlib::VersionError
4595
+ * - Zstdlib::StreamEnd
4596
+ * - Zstdlib::NeedDict
4597
+ * - Zstdlib::DataError
4598
+ * - Zstdlib::StreamError
4599
+ * - Zstdlib::MemError
4600
+ * - Zstdlib::BufError
4601
+ * - Zstdlib::VersionError
4586
4602
  *
4587
4603
  */
4588
4604
 
4589
4605
  /*
4590
- * Document-class: Zlib::StreamEnd
4606
+ * Document-class: Zstdlib::StreamEnd
4591
4607
  *
4592
- * Subclass of Zlib::Error
4608
+ * Subclass of Zstdlib::Error
4593
4609
  *
4594
4610
  * When zlib returns a Z_STREAM_END
4595
4611
  * is return if the end of the compressed data has been reached
@@ -4598,20 +4614,20 @@ Init_zlib(void)
4598
4614
  */
4599
4615
 
4600
4616
  /*
4601
- * Document-class: Zlib::NeedDict
4617
+ * Document-class: Zstdlib::NeedDict
4602
4618
  *
4603
- * Subclass of Zlib::Error
4619
+ * Subclass of Zstdlib::Error
4604
4620
  *
4605
4621
  * When zlib returns a Z_NEED_DICT
4606
4622
  * if a preset dictionary is needed at this point.
4607
4623
  *
4608
- * Used by Zlib::Inflate.inflate and <tt>Zlib.inflate</tt>
4624
+ * Used by Zstdlib::Inflate.inflate and <tt>Zstdlib.inflate</tt>
4609
4625
  */
4610
4626
 
4611
4627
  /*
4612
- * Document-class: Zlib::VersionError
4628
+ * Document-class: Zstdlib::VersionError
4613
4629
  *
4614
- * Subclass of Zlib::Error
4630
+ * Subclass of Zstdlib::Error
4615
4631
  *
4616
4632
  * When zlib returns a Z_VERSION_ERROR,
4617
4633
  * usually if the zlib library version is incompatible with the
@@ -4620,9 +4636,9 @@ Init_zlib(void)
4620
4636
  */
4621
4637
 
4622
4638
  /*
4623
- * Document-class: Zlib::MemError
4639
+ * Document-class: Zstdlib::MemError
4624
4640
  *
4625
- * Subclass of Zlib::Error
4641
+ * Subclass of Zstdlib::Error
4626
4642
  *
4627
4643
  * When zlib returns a Z_MEM_ERROR,
4628
4644
  * usually if there was not enough memory.
@@ -4630,9 +4646,9 @@ Init_zlib(void)
4630
4646
  */
4631
4647
 
4632
4648
  /*
4633
- * Document-class: Zlib::StreamError
4649
+ * Document-class: Zstdlib::StreamError
4634
4650
  *
4635
- * Subclass of Zlib::Error
4651
+ * Subclass of Zstdlib::Error
4636
4652
  *
4637
4653
  * When zlib returns a Z_STREAM_ERROR,
4638
4654
  * usually if the stream state was inconsistent.
@@ -4640,44 +4656,44 @@ Init_zlib(void)
4640
4656
  */
4641
4657
 
4642
4658
  /*
4643
- * Document-class: Zlib::BufError
4659
+ * Document-class: Zstdlib::BufError
4644
4660
  *
4645
- * Subclass of Zlib::Error when zlib returns a Z_BUF_ERROR.
4661
+ * Subclass of Zstdlib::Error when zlib returns a Z_BUF_ERROR.
4646
4662
  *
4647
4663
  * Usually if no progress is possible.
4648
4664
  *
4649
4665
  */
4650
4666
 
4651
4667
  /*
4652
- * Document-class: Zlib::DataError
4668
+ * Document-class: Zstdlib::DataError
4653
4669
  *
4654
- * Subclass of Zlib::Error when zlib returns a Z_DATA_ERROR.
4670
+ * Subclass of Zstdlib::Error when zlib returns a Z_DATA_ERROR.
4655
4671
  *
4656
4672
  * Usually if a stream was prematurely freed.
4657
4673
  *
4658
4674
  */
4659
4675
 
4660
4676
  /*
4661
- * Document-class: Zlib::GzipFile::Error
4677
+ * Document-class: Zstdlib::GzipFile::Error
4662
4678
  *
4663
4679
  * Base class of errors that occur when processing GZIP files.
4664
4680
  */
4665
4681
 
4666
4682
  /*
4667
- * Document-class: Zlib::GzipFile::NoFooter
4683
+ * Document-class: Zstdlib::GzipFile::NoFooter
4668
4684
  *
4669
4685
  * Raised when gzip file footer is not found.
4670
4686
  */
4671
4687
 
4672
4688
  /*
4673
- * Document-class: Zlib::GzipFile::CRCError
4689
+ * Document-class: Zstdlib::GzipFile::CRCError
4674
4690
  *
4675
4691
  * Raised when the CRC checksum recorded in gzip file footer is not equivalent
4676
4692
  * to the CRC checksum of the actual uncompressed data.
4677
4693
  */
4678
4694
 
4679
4695
  /*
4680
- * Document-class: Zlib::GzipFile::LengthError
4696
+ * Document-class: Zstdlib::GzipFile::LengthError
4681
4697
  *
4682
4698
  * Raised when the data length recorded in the gzip file footer is not equivalent
4683
4699
  * to the length of the actual uncompressed data.