ruby-zstds 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/AUTHORS +1 -0
 - data/LICENSE +21 -0
 - data/README.md +498 -0
 - data/ext/extconf.rb +82 -0
 - data/ext/zstds_ext/buffer.c +30 -0
 - data/ext/zstds_ext/buffer.h +23 -0
 - data/ext/zstds_ext/common.h +16 -0
 - data/ext/zstds_ext/dictionary.c +106 -0
 - data/ext/zstds_ext/dictionary.h +16 -0
 - data/ext/zstds_ext/error.c +81 -0
 - data/ext/zstds_ext/error.h +35 -0
 - data/ext/zstds_ext/io.c +512 -0
 - data/ext/zstds_ext/io.h +14 -0
 - data/ext/zstds_ext/macro.h +13 -0
 - data/ext/zstds_ext/main.c +25 -0
 - data/ext/zstds_ext/option.c +287 -0
 - data/ext/zstds_ext/option.h +122 -0
 - data/ext/zstds_ext/stream/compressor.c +241 -0
 - data/ext/zstds_ext/stream/compressor.h +31 -0
 - data/ext/zstds_ext/stream/decompressor.c +183 -0
 - data/ext/zstds_ext/stream/decompressor.h +29 -0
 - data/ext/zstds_ext/string.c +254 -0
 - data/ext/zstds_ext/string.h +14 -0
 - data/lib/zstds.rb +9 -0
 - data/lib/zstds/dictionary.rb +47 -0
 - data/lib/zstds/error.rb +22 -0
 - data/lib/zstds/file.rb +46 -0
 - data/lib/zstds/option.rb +194 -0
 - data/lib/zstds/stream/abstract.rb +153 -0
 - data/lib/zstds/stream/delegates.rb +36 -0
 - data/lib/zstds/stream/raw/abstract.rb +55 -0
 - data/lib/zstds/stream/raw/compressor.rb +101 -0
 - data/lib/zstds/stream/raw/decompressor.rb +70 -0
 - data/lib/zstds/stream/reader.rb +166 -0
 - data/lib/zstds/stream/reader_helpers.rb +192 -0
 - data/lib/zstds/stream/stat.rb +78 -0
 - data/lib/zstds/stream/writer.rb +145 -0
 - data/lib/zstds/stream/writer_helpers.rb +93 -0
 - data/lib/zstds/string.rb +31 -0
 - data/lib/zstds/validation.rb +48 -0
 - data/lib/zstds/version.rb +6 -0
 - metadata +182 -0
 
    
        data/ext/zstds_ext/io.h
    ADDED
    
    | 
         @@ -0,0 +1,14 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            // Ruby bindings for zstd library.
         
     | 
| 
      
 2 
     | 
    
         
            +
            // Copyright (c) 2019 AUTHORS, MIT License.
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            #if !defined(ZSTDS_EXT_IO_H)
         
     | 
| 
      
 5 
     | 
    
         
            +
            #define ZSTDS_EXT_IO_H
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            #include "ruby.h"
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            VALUE zstds_ext_compress_io(VALUE self, VALUE source, VALUE destination, VALUE options);
         
     | 
| 
      
 10 
     | 
    
         
            +
            VALUE zstds_ext_decompress_io(VALUE self, VALUE source, VALUE destination, VALUE options);
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            void zstds_ext_io_exports(VALUE root_module);
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            #endif // ZSTDS_EXT_IO_H
         
     | 
| 
         @@ -0,0 +1,13 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            // Ruby bindings for zstd library.
         
     | 
| 
      
 2 
     | 
    
         
            +
            // Copyright (c) 2019 AUTHORS, MIT License.
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            #if !defined(ZSTDS_EXT_MACRO_H)
         
     | 
| 
      
 5 
     | 
    
         
            +
            #define ZSTDS_EXT_MACRO_H
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            #if defined(__GNUC__)
         
     | 
| 
      
 8 
     | 
    
         
            +
            #define ZSTDS_EXT_UNUSED(x) x __attribute__((__unused__))
         
     | 
| 
      
 9 
     | 
    
         
            +
            #else
         
     | 
| 
      
 10 
     | 
    
         
            +
            #define ZSTDS_EXT_UNUSED(x) x
         
     | 
| 
      
 11 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            #endif // ZSTDS_EXT_MACRO_H
         
     | 
| 
         @@ -0,0 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            // Ruby bindings for zstd library.
         
     | 
| 
      
 2 
     | 
    
         
            +
            // Copyright (c) 2019 AUTHORS, MIT License.
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            #include "ruby.h"
         
     | 
| 
      
 5 
     | 
    
         
            +
            #include "zstds_ext/buffer.h"
         
     | 
| 
      
 6 
     | 
    
         
            +
            #include "zstds_ext/common.h"
         
     | 
| 
      
 7 
     | 
    
         
            +
            #include "zstds_ext/dictionary.h"
         
     | 
| 
      
 8 
     | 
    
         
            +
            #include "zstds_ext/io.h"
         
     | 
| 
      
 9 
     | 
    
         
            +
            #include "zstds_ext/option.h"
         
     | 
| 
      
 10 
     | 
    
         
            +
            #include "zstds_ext/stream/compressor.h"
         
     | 
| 
      
 11 
     | 
    
         
            +
            #include "zstds_ext/stream/decompressor.h"
         
     | 
| 
      
 12 
     | 
    
         
            +
            #include "zstds_ext/string.h"
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            void Init_zstds_ext()
         
     | 
| 
      
 15 
     | 
    
         
            +
            {
         
     | 
| 
      
 16 
     | 
    
         
            +
              VALUE root_module = rb_define_module(ZSTDS_EXT_MODULE_NAME);
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              zstds_ext_buffer_exports(root_module);
         
     | 
| 
      
 19 
     | 
    
         
            +
              zstds_ext_dictionary_exports(root_module);
         
     | 
| 
      
 20 
     | 
    
         
            +
              zstds_ext_io_exports(root_module);
         
     | 
| 
      
 21 
     | 
    
         
            +
              zstds_ext_option_exports(root_module);
         
     | 
| 
      
 22 
     | 
    
         
            +
              zstds_ext_compressor_exports(root_module);
         
     | 
| 
      
 23 
     | 
    
         
            +
              zstds_ext_decompressor_exports(root_module);
         
     | 
| 
      
 24 
     | 
    
         
            +
              zstds_ext_string_exports(root_module);
         
     | 
| 
      
 25 
     | 
    
         
            +
            }
         
     | 
| 
         @@ -0,0 +1,287 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            // Ruby bindings for zstd library.
         
     | 
| 
      
 2 
     | 
    
         
            +
            // Copyright (c) 2019 AUTHORS, MIT License.
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            #include "zstds_ext/option.h"
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            #include <stdbool.h>
         
     | 
| 
      
 7 
     | 
    
         
            +
            #include <stdint.h>
         
     | 
| 
      
 8 
     | 
    
         
            +
            #include <stdlib.h>
         
     | 
| 
      
 9 
     | 
    
         
            +
            #include <zstd.h>
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            #include "ruby.h"
         
     | 
| 
      
 12 
     | 
    
         
            +
            #include "zstds_ext/common.h"
         
     | 
| 
      
 13 
     | 
    
         
            +
            #include "zstds_ext/dictionary.h"
         
     | 
| 
      
 14 
     | 
    
         
            +
            #include "zstds_ext/error.h"
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            // -- values --
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            static inline VALUE get_raw_option_value(VALUE options, const char* name)
         
     | 
| 
      
 19 
     | 
    
         
            +
            {
         
     | 
| 
      
 20 
     | 
    
         
            +
              return rb_funcall(options, rb_intern("[]"), 1, ID2SYM(rb_intern(name)));
         
     | 
| 
      
 21 
     | 
    
         
            +
            }
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            static inline bool get_bool_option_value(VALUE raw_value)
         
     | 
| 
      
 24 
     | 
    
         
            +
            {
         
     | 
| 
      
 25 
     | 
    
         
            +
              int raw_type = TYPE(raw_value);
         
     | 
| 
      
 26 
     | 
    
         
            +
              if (raw_type != T_TRUE && raw_type != T_FALSE) {
         
     | 
| 
      
 27 
     | 
    
         
            +
                zstds_ext_raise_error(ZSTDS_EXT_ERROR_VALIDATE_FAILED);
         
     | 
| 
      
 28 
     | 
    
         
            +
              }
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
              return raw_type == T_TRUE;
         
     | 
| 
      
 31 
     | 
    
         
            +
            }
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
            static inline unsigned int get_uint_option_value(VALUE raw_value)
         
     | 
| 
      
 34 
     | 
    
         
            +
            {
         
     | 
| 
      
 35 
     | 
    
         
            +
              Check_Type(raw_value, T_FIXNUM);
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
              return NUM2UINT(raw_value);
         
     | 
| 
      
 38 
     | 
    
         
            +
            }
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
            static inline int get_int_option_value(VALUE raw_value)
         
     | 
| 
      
 41 
     | 
    
         
            +
            {
         
     | 
| 
      
 42 
     | 
    
         
            +
              Check_Type(raw_value, T_FIXNUM);
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
              return NUM2INT(raw_value);
         
     | 
| 
      
 45 
     | 
    
         
            +
            }
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
            static inline unsigned long long get_ull_option_value(VALUE raw_value)
         
     | 
| 
      
 48 
     | 
    
         
            +
            {
         
     | 
| 
      
 49 
     | 
    
         
            +
              Check_Type(raw_value, T_FIXNUM);
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
              return NUM2ULL(raw_value);
         
     | 
| 
      
 52 
     | 
    
         
            +
            }
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
            static inline ZSTD_strategy get_strategy_option_value(VALUE raw_value)
         
     | 
| 
      
 55 
     | 
    
         
            +
            {
         
     | 
| 
      
 56 
     | 
    
         
            +
              Check_Type(raw_value, T_SYMBOL);
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
              ID raw_id = SYM2ID(raw_value);
         
     | 
| 
      
 59 
     | 
    
         
            +
              if (raw_id == rb_intern("fast")) {
         
     | 
| 
      
 60 
     | 
    
         
            +
                return ZSTD_fast;
         
     | 
| 
      
 61 
     | 
    
         
            +
              }
         
     | 
| 
      
 62 
     | 
    
         
            +
              else if (raw_id == rb_intern("dfast")) {
         
     | 
| 
      
 63 
     | 
    
         
            +
                return ZSTD_dfast;
         
     | 
| 
      
 64 
     | 
    
         
            +
              }
         
     | 
| 
      
 65 
     | 
    
         
            +
              else if (raw_id == rb_intern("greedy")) {
         
     | 
| 
      
 66 
     | 
    
         
            +
                return ZSTD_greedy;
         
     | 
| 
      
 67 
     | 
    
         
            +
              }
         
     | 
| 
      
 68 
     | 
    
         
            +
              else if (raw_id == rb_intern("lazy")) {
         
     | 
| 
      
 69 
     | 
    
         
            +
                return ZSTD_lazy;
         
     | 
| 
      
 70 
     | 
    
         
            +
              }
         
     | 
| 
      
 71 
     | 
    
         
            +
              else if (raw_id == rb_intern("lazy2")) {
         
     | 
| 
      
 72 
     | 
    
         
            +
                return ZSTD_lazy2;
         
     | 
| 
      
 73 
     | 
    
         
            +
              }
         
     | 
| 
      
 74 
     | 
    
         
            +
              else if (raw_id == rb_intern("btlazy2")) {
         
     | 
| 
      
 75 
     | 
    
         
            +
                return ZSTD_btlazy2;
         
     | 
| 
      
 76 
     | 
    
         
            +
              }
         
     | 
| 
      
 77 
     | 
    
         
            +
              else if (raw_id == rb_intern("btopt")) {
         
     | 
| 
      
 78 
     | 
    
         
            +
                return ZSTD_btopt;
         
     | 
| 
      
 79 
     | 
    
         
            +
              }
         
     | 
| 
      
 80 
     | 
    
         
            +
              else if (raw_id == rb_intern("btultra")) {
         
     | 
| 
      
 81 
     | 
    
         
            +
                return ZSTD_btultra;
         
     | 
| 
      
 82 
     | 
    
         
            +
              }
         
     | 
| 
      
 83 
     | 
    
         
            +
              else if (raw_id == rb_intern("btultra2")) {
         
     | 
| 
      
 84 
     | 
    
         
            +
                return ZSTD_btultra2;
         
     | 
| 
      
 85 
     | 
    
         
            +
              }
         
     | 
| 
      
 86 
     | 
    
         
            +
              else {
         
     | 
| 
      
 87 
     | 
    
         
            +
                zstds_ext_raise_error(ZSTDS_EXT_ERROR_VALIDATE_FAILED);
         
     | 
| 
      
 88 
     | 
    
         
            +
              }
         
     | 
| 
      
 89 
     | 
    
         
            +
            }
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
            void zstds_ext_get_option(VALUE options, zstds_ext_option_t* option, zstds_ext_option_type_t type, const char* name)
         
     | 
| 
      
 92 
     | 
    
         
            +
            {
         
     | 
| 
      
 93 
     | 
    
         
            +
              VALUE raw_value = get_raw_option_value(options, name);
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
              option->has_value = raw_value != Qnil;
         
     | 
| 
      
 96 
     | 
    
         
            +
              if (!option->has_value) {
         
     | 
| 
      
 97 
     | 
    
         
            +
                return;
         
     | 
| 
      
 98 
     | 
    
         
            +
              }
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
              zstds_ext_option_value_t value;
         
     | 
| 
      
 101 
     | 
    
         
            +
             
     | 
| 
      
 102 
     | 
    
         
            +
              switch (type) {
         
     | 
| 
      
 103 
     | 
    
         
            +
                case ZSTDS_EXT_OPTION_TYPE_BOOL:
         
     | 
| 
      
 104 
     | 
    
         
            +
                  value = get_bool_option_value(raw_value) ? 1 : 0;
         
     | 
| 
      
 105 
     | 
    
         
            +
                  break;
         
     | 
| 
      
 106 
     | 
    
         
            +
                case ZSTDS_EXT_OPTION_TYPE_UINT:
         
     | 
| 
      
 107 
     | 
    
         
            +
                  value = (zstds_ext_option_value_t)get_uint_option_value(raw_value);
         
     | 
| 
      
 108 
     | 
    
         
            +
                  break;
         
     | 
| 
      
 109 
     | 
    
         
            +
                case ZSTDS_EXT_OPTION_TYPE_INT:
         
     | 
| 
      
 110 
     | 
    
         
            +
                  value = (zstds_ext_option_value_t)get_int_option_value(raw_value);
         
     | 
| 
      
 111 
     | 
    
         
            +
                  break;
         
     | 
| 
      
 112 
     | 
    
         
            +
                case ZSTDS_EXT_OPTION_TYPE_STRATEGY:
         
     | 
| 
      
 113 
     | 
    
         
            +
                  value = (zstds_ext_option_value_t)get_strategy_option_value(raw_value);
         
     | 
| 
      
 114 
     | 
    
         
            +
                  break;
         
     | 
| 
      
 115 
     | 
    
         
            +
                default:
         
     | 
| 
      
 116 
     | 
    
         
            +
                  zstds_ext_raise_error(ZSTDS_EXT_ERROR_UNEXPECTED);
         
     | 
| 
      
 117 
     | 
    
         
            +
              }
         
     | 
| 
      
 118 
     | 
    
         
            +
             
     | 
| 
      
 119 
     | 
    
         
            +
              option->value = value;
         
     | 
| 
      
 120 
     | 
    
         
            +
            }
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
            void zstds_ext_get_ull_option(VALUE options, zstds_ext_ull_option_t* option, const char* name)
         
     | 
| 
      
 123 
     | 
    
         
            +
            {
         
     | 
| 
      
 124 
     | 
    
         
            +
              VALUE raw_value = get_raw_option_value(options, name);
         
     | 
| 
      
 125 
     | 
    
         
            +
             
     | 
| 
      
 126 
     | 
    
         
            +
              option->has_value = raw_value != Qnil;
         
     | 
| 
      
 127 
     | 
    
         
            +
              if (option->has_value) {
         
     | 
| 
      
 128 
     | 
    
         
            +
                option->value = (zstds_ext_ull_option_value_t)get_ull_option_value(raw_value);
         
     | 
| 
      
 129 
     | 
    
         
            +
              }
         
     | 
| 
      
 130 
     | 
    
         
            +
            }
         
     | 
| 
      
 131 
     | 
    
         
            +
             
     | 
| 
      
 132 
     | 
    
         
            +
            void zstds_ext_get_dictionary_option(VALUE options, VALUE* option, const char* name)
         
     | 
| 
      
 133 
     | 
    
         
            +
            {
         
     | 
| 
      
 134 
     | 
    
         
            +
              VALUE raw_value = get_raw_option_value(options, name);
         
     | 
| 
      
 135 
     | 
    
         
            +
             
     | 
| 
      
 136 
     | 
    
         
            +
              if (raw_value != Qnil) {
         
     | 
| 
      
 137 
     | 
    
         
            +
                VALUE root_module = rb_define_module(ZSTDS_EXT_MODULE_NAME);
         
     | 
| 
      
 138 
     | 
    
         
            +
                VALUE dictionary  = rb_const_get_at(root_module, rb_intern("Dictionary"));
         
     | 
| 
      
 139 
     | 
    
         
            +
                if (rb_obj_is_kind_of(raw_value, dictionary) != Qtrue) {
         
     | 
| 
      
 140 
     | 
    
         
            +
                  zstds_ext_raise_error(ZSTDS_EXT_ERROR_VALIDATE_FAILED);
         
     | 
| 
      
 141 
     | 
    
         
            +
                }
         
     | 
| 
      
 142 
     | 
    
         
            +
              }
         
     | 
| 
      
 143 
     | 
    
         
            +
             
     | 
| 
      
 144 
     | 
    
         
            +
              *option = raw_value;
         
     | 
| 
      
 145 
     | 
    
         
            +
            }
         
     | 
| 
      
 146 
     | 
    
         
            +
             
     | 
| 
      
 147 
     | 
    
         
            +
            size_t zstds_ext_get_size_option_value(VALUE options, const char* name)
         
     | 
| 
      
 148 
     | 
    
         
            +
            {
         
     | 
| 
      
 149 
     | 
    
         
            +
              VALUE raw_value = get_raw_option_value(options, name);
         
     | 
| 
      
 150 
     | 
    
         
            +
             
     | 
| 
      
 151 
     | 
    
         
            +
              Check_Type(raw_value, T_FIXNUM);
         
     | 
| 
      
 152 
     | 
    
         
            +
             
     | 
| 
      
 153 
     | 
    
         
            +
              return NUM2SIZET(raw_value);
         
     | 
| 
      
 154 
     | 
    
         
            +
            }
         
     | 
| 
      
 155 
     | 
    
         
            +
             
     | 
| 
      
 156 
     | 
    
         
            +
            // -- set params --
         
     | 
| 
      
 157 
     | 
    
         
            +
             
     | 
| 
      
 158 
     | 
    
         
            +
            #define SET_OPTION_VALUE(function, ctx, param, option)       \
         
     | 
| 
      
 159 
     | 
    
         
            +
              if (option.has_value) {                                    \
         
     | 
| 
      
 160 
     | 
    
         
            +
                result = function(ctx, param, option.value);             \
         
     | 
| 
      
 161 
     | 
    
         
            +
                if (ZSTD_isError(result)) {                              \
         
     | 
| 
      
 162 
     | 
    
         
            +
                  return zstds_ext_get_error(ZSTD_getErrorCode(result)); \
         
     | 
| 
      
 163 
     | 
    
         
            +
                }                                                        \
         
     | 
| 
      
 164 
     | 
    
         
            +
              }
         
     | 
| 
      
 165 
     | 
    
         
            +
             
     | 
| 
      
 166 
     | 
    
         
            +
            #define SET_COMPRESSOR_PARAM(ctx, param, option) \
         
     | 
| 
      
 167 
     | 
    
         
            +
              SET_OPTION_VALUE(ZSTD_CCtx_setParameter, ctx, param, option);
         
     | 
| 
      
 168 
     | 
    
         
            +
             
     | 
| 
      
 169 
     | 
    
         
            +
            zstds_ext_result_t zstds_ext_set_compressor_options(ZSTD_CCtx* ctx, zstds_ext_compressor_options_t* options)
         
     | 
| 
      
 170 
     | 
    
         
            +
            {
         
     | 
| 
      
 171 
     | 
    
         
            +
              zstds_result_t result;
         
     | 
| 
      
 172 
     | 
    
         
            +
             
     | 
| 
      
 173 
     | 
    
         
            +
              SET_COMPRESSOR_PARAM(ctx, ZSTD_c_compressionLevel, options->compression_level);
         
     | 
| 
      
 174 
     | 
    
         
            +
              SET_COMPRESSOR_PARAM(ctx, ZSTD_c_windowLog, options->window_log);
         
     | 
| 
      
 175 
     | 
    
         
            +
              SET_COMPRESSOR_PARAM(ctx, ZSTD_c_hashLog, options->hash_log);
         
     | 
| 
      
 176 
     | 
    
         
            +
              SET_COMPRESSOR_PARAM(ctx, ZSTD_c_chainLog, options->chain_log);
         
     | 
| 
      
 177 
     | 
    
         
            +
              SET_COMPRESSOR_PARAM(ctx, ZSTD_c_searchLog, options->search_log);
         
     | 
| 
      
 178 
     | 
    
         
            +
              SET_COMPRESSOR_PARAM(ctx, ZSTD_c_minMatch, options->min_match);
         
     | 
| 
      
 179 
     | 
    
         
            +
              SET_COMPRESSOR_PARAM(ctx, ZSTD_c_targetLength, options->target_length);
         
     | 
| 
      
 180 
     | 
    
         
            +
              SET_COMPRESSOR_PARAM(ctx, ZSTD_c_strategy, options->strategy);
         
     | 
| 
      
 181 
     | 
    
         
            +
              SET_COMPRESSOR_PARAM(ctx, ZSTD_c_enableLongDistanceMatching, options->enable_long_distance_matching);
         
     | 
| 
      
 182 
     | 
    
         
            +
              SET_COMPRESSOR_PARAM(ctx, ZSTD_c_ldmHashLog, options->ldm_hash_log);
         
     | 
| 
      
 183 
     | 
    
         
            +
              SET_COMPRESSOR_PARAM(ctx, ZSTD_c_ldmMinMatch, options->ldm_min_match);
         
     | 
| 
      
 184 
     | 
    
         
            +
              SET_COMPRESSOR_PARAM(ctx, ZSTD_c_ldmBucketSizeLog, options->ldm_bucket_size_log);
         
     | 
| 
      
 185 
     | 
    
         
            +
              SET_COMPRESSOR_PARAM(ctx, ZSTD_c_ldmHashRateLog, options->ldm_hash_rate_log);
         
     | 
| 
      
 186 
     | 
    
         
            +
              SET_COMPRESSOR_PARAM(ctx, ZSTD_c_contentSizeFlag, options->content_size_flag);
         
     | 
| 
      
 187 
     | 
    
         
            +
              SET_COMPRESSOR_PARAM(ctx, ZSTD_c_checksumFlag, options->checksum_flag);
         
     | 
| 
      
 188 
     | 
    
         
            +
              SET_COMPRESSOR_PARAM(ctx, ZSTD_c_dictIDFlag, options->dict_id_flag);
         
     | 
| 
      
 189 
     | 
    
         
            +
              SET_COMPRESSOR_PARAM(ctx, ZSTD_c_nbWorkers, options->nb_workers);
         
     | 
| 
      
 190 
     | 
    
         
            +
              SET_COMPRESSOR_PARAM(ctx, ZSTD_c_jobSize, options->job_size);
         
     | 
| 
      
 191 
     | 
    
         
            +
              SET_COMPRESSOR_PARAM(ctx, ZSTD_c_overlapLog, options->overlap_log);
         
     | 
| 
      
 192 
     | 
    
         
            +
             
     | 
| 
      
 193 
     | 
    
         
            +
              if (options->pledged_size.has_value) {
         
     | 
| 
      
 194 
     | 
    
         
            +
                result = ZSTD_CCtx_setPledgedSrcSize(ctx, options->pledged_size.value);
         
     | 
| 
      
 195 
     | 
    
         
            +
                if (ZSTD_isError(result)) {
         
     | 
| 
      
 196 
     | 
    
         
            +
                  return zstds_ext_get_error(ZSTD_getErrorCode(result));
         
     | 
| 
      
 197 
     | 
    
         
            +
                }
         
     | 
| 
      
 198 
     | 
    
         
            +
              }
         
     | 
| 
      
 199 
     | 
    
         
            +
             
     | 
| 
      
 200 
     | 
    
         
            +
              if (options->dictionary != Qnil) {
         
     | 
| 
      
 201 
     | 
    
         
            +
                VALUE dictionary_buffer = rb_attr_get(options->dictionary, rb_intern("@buffer"));
         
     | 
| 
      
 202 
     | 
    
         
            +
             
     | 
| 
      
 203 
     | 
    
         
            +
                result = ZSTD_CCtx_loadDictionary(ctx, RSTRING_PTR(dictionary_buffer), RSTRING_LEN(dictionary_buffer));
         
     | 
| 
      
 204 
     | 
    
         
            +
                if (ZSTD_isError(result)) {
         
     | 
| 
      
 205 
     | 
    
         
            +
                  return zstds_ext_get_error(ZSTD_getErrorCode(result));
         
     | 
| 
      
 206 
     | 
    
         
            +
                }
         
     | 
| 
      
 207 
     | 
    
         
            +
              }
         
     | 
| 
      
 208 
     | 
    
         
            +
             
     | 
| 
      
 209 
     | 
    
         
            +
              return 0;
         
     | 
| 
      
 210 
     | 
    
         
            +
            }
         
     | 
| 
      
 211 
     | 
    
         
            +
             
     | 
| 
      
 212 
     | 
    
         
            +
            #define SET_DECOMPRESSOR_PARAM(ctx, param, option) \
         
     | 
| 
      
 213 
     | 
    
         
            +
              SET_OPTION_VALUE(ZSTD_DCtx_setParameter, ctx, param, option);
         
     | 
| 
      
 214 
     | 
    
         
            +
             
     | 
| 
      
 215 
     | 
    
         
            +
            zstds_ext_result_t zstds_ext_set_decompressor_options(ZSTD_DCtx* ctx, zstds_ext_decompressor_options_t* options)
         
     | 
| 
      
 216 
     | 
    
         
            +
            {
         
     | 
| 
      
 217 
     | 
    
         
            +
              zstds_result_t result;
         
     | 
| 
      
 218 
     | 
    
         
            +
             
     | 
| 
      
 219 
     | 
    
         
            +
              SET_DECOMPRESSOR_PARAM(ctx, ZSTD_d_windowLogMax, options->window_log_max);
         
     | 
| 
      
 220 
     | 
    
         
            +
             
     | 
| 
      
 221 
     | 
    
         
            +
              if (options->dictionary != Qnil) {
         
     | 
| 
      
 222 
     | 
    
         
            +
                VALUE dictionary_buffer = rb_attr_get(options->dictionary, rb_intern("@buffer"));
         
     | 
| 
      
 223 
     | 
    
         
            +
             
     | 
| 
      
 224 
     | 
    
         
            +
                result = ZSTD_DCtx_loadDictionary(ctx, RSTRING_PTR(dictionary_buffer), RSTRING_LEN(dictionary_buffer));
         
     | 
| 
      
 225 
     | 
    
         
            +
                if (ZSTD_isError(result)) {
         
     | 
| 
      
 226 
     | 
    
         
            +
                  return zstds_ext_get_error(ZSTD_getErrorCode(result));
         
     | 
| 
      
 227 
     | 
    
         
            +
                }
         
     | 
| 
      
 228 
     | 
    
         
            +
              }
         
     | 
| 
      
 229 
     | 
    
         
            +
             
     | 
| 
      
 230 
     | 
    
         
            +
              return 0;
         
     | 
| 
      
 231 
     | 
    
         
            +
            }
         
     | 
| 
      
 232 
     | 
    
         
            +
             
     | 
| 
      
 233 
     | 
    
         
            +
            // -- exports --
         
     | 
| 
      
 234 
     | 
    
         
            +
             
     | 
| 
      
 235 
     | 
    
         
            +
            #define EXPORT_PARAM_BOUNDS(function, module, param, type, name)                 \
         
     | 
| 
      
 236 
     | 
    
         
            +
              bounds = function(param);                                                      \
         
     | 
| 
      
 237 
     | 
    
         
            +
              if (ZSTD_isError(bounds.error)) {                                              \
         
     | 
| 
      
 238 
     | 
    
         
            +
                zstds_ext_raise_error(zstds_ext_get_error(ZSTD_getErrorCode(bounds.error))); \
         
     | 
| 
      
 239 
     | 
    
         
            +
              }                                                                              \
         
     | 
| 
      
 240 
     | 
    
         
            +
                                                                                             \
         
     | 
| 
      
 241 
     | 
    
         
            +
              rb_define_const(module, "MIN_" name, type##2NUM(bounds.lowerBound));           \
         
     | 
| 
      
 242 
     | 
    
         
            +
              rb_define_const(module, "MAX_" name, type##2NUM(bounds.upperBound));
         
     | 
| 
      
 243 
     | 
    
         
            +
             
     | 
| 
      
 244 
     | 
    
         
            +
            #define EXPORT_COMPRESSOR_PARAM_BOUNDS(module, param, type, name) \
         
     | 
| 
      
 245 
     | 
    
         
            +
              EXPORT_PARAM_BOUNDS(ZSTD_cParam_getBounds, module, param, type, name);
         
     | 
| 
      
 246 
     | 
    
         
            +
             
     | 
| 
      
 247 
     | 
    
         
            +
            #define EXPORT_DECOMPRESSOR_PARAM_BOUNDS(module, param, type, name) \
         
     | 
| 
      
 248 
     | 
    
         
            +
              EXPORT_PARAM_BOUNDS(ZSTD_dParam_getBounds, module, param, type, name);
         
     | 
| 
      
 249 
     | 
    
         
            +
             
     | 
| 
      
 250 
     | 
    
         
            +
            void zstds_ext_option_exports(VALUE root_module)
         
     | 
| 
      
 251 
     | 
    
         
            +
            {
         
     | 
| 
      
 252 
     | 
    
         
            +
              VALUE module = rb_define_module_under(root_module, "Option");
         
     | 
| 
      
 253 
     | 
    
         
            +
             
     | 
| 
      
 254 
     | 
    
         
            +
              ZSTD_bounds bounds;
         
     | 
| 
      
 255 
     | 
    
         
            +
             
     | 
| 
      
 256 
     | 
    
         
            +
              EXPORT_COMPRESSOR_PARAM_BOUNDS(module, ZSTD_c_compressionLevel, INT, "COMPRESSION_LEVEL");
         
     | 
| 
      
 257 
     | 
    
         
            +
              EXPORT_COMPRESSOR_PARAM_BOUNDS(module, ZSTD_c_windowLog, UINT, "WINDOW_LOG");
         
     | 
| 
      
 258 
     | 
    
         
            +
              EXPORT_COMPRESSOR_PARAM_BOUNDS(module, ZSTD_c_hashLog, UINT, "HASH_LOG");
         
     | 
| 
      
 259 
     | 
    
         
            +
              EXPORT_COMPRESSOR_PARAM_BOUNDS(module, ZSTD_c_chainLog, UINT, "CHAIN_LOG");
         
     | 
| 
      
 260 
     | 
    
         
            +
              EXPORT_COMPRESSOR_PARAM_BOUNDS(module, ZSTD_c_searchLog, UINT, "SEARCH_LOG");
         
     | 
| 
      
 261 
     | 
    
         
            +
              EXPORT_COMPRESSOR_PARAM_BOUNDS(module, ZSTD_c_minMatch, UINT, "MIN_MATCH");
         
     | 
| 
      
 262 
     | 
    
         
            +
              EXPORT_COMPRESSOR_PARAM_BOUNDS(module, ZSTD_c_targetLength, UINT, "TARGET_LENGTH");
         
     | 
| 
      
 263 
     | 
    
         
            +
             
     | 
| 
      
 264 
     | 
    
         
            +
              VALUE strategies = rb_ary_new_from_args(
         
     | 
| 
      
 265 
     | 
    
         
            +
                9,
         
     | 
| 
      
 266 
     | 
    
         
            +
                ID2SYM(rb_intern("fast")),
         
     | 
| 
      
 267 
     | 
    
         
            +
                ID2SYM(rb_intern("dfast")),
         
     | 
| 
      
 268 
     | 
    
         
            +
                ID2SYM(rb_intern("greedy")),
         
     | 
| 
      
 269 
     | 
    
         
            +
                ID2SYM(rb_intern("lazy")),
         
     | 
| 
      
 270 
     | 
    
         
            +
                ID2SYM(rb_intern("lazy2")),
         
     | 
| 
      
 271 
     | 
    
         
            +
                ID2SYM(rb_intern("btlazy2")),
         
     | 
| 
      
 272 
     | 
    
         
            +
                ID2SYM(rb_intern("btopt")),
         
     | 
| 
      
 273 
     | 
    
         
            +
                ID2SYM(rb_intern("btultra")),
         
     | 
| 
      
 274 
     | 
    
         
            +
                ID2SYM(rb_intern("btultra2")));
         
     | 
| 
      
 275 
     | 
    
         
            +
              rb_define_const(module, "STRATEGIES", strategies);
         
     | 
| 
      
 276 
     | 
    
         
            +
              RB_GC_GUARD(strategies);
         
     | 
| 
      
 277 
     | 
    
         
            +
             
     | 
| 
      
 278 
     | 
    
         
            +
              EXPORT_COMPRESSOR_PARAM_BOUNDS(module, ZSTD_c_ldmHashLog, UINT, "LDM_HASH_LOG");
         
     | 
| 
      
 279 
     | 
    
         
            +
              EXPORT_COMPRESSOR_PARAM_BOUNDS(module, ZSTD_c_ldmMinMatch, UINT, "LDM_MIN_MATCH");
         
     | 
| 
      
 280 
     | 
    
         
            +
              EXPORT_COMPRESSOR_PARAM_BOUNDS(module, ZSTD_c_ldmBucketSizeLog, UINT, "LDM_BUCKET_SIZE_LOG");
         
     | 
| 
      
 281 
     | 
    
         
            +
              EXPORT_COMPRESSOR_PARAM_BOUNDS(module, ZSTD_c_ldmHashRateLog, UINT, "LDM_HASH_RATE_LOG");
         
     | 
| 
      
 282 
     | 
    
         
            +
              EXPORT_COMPRESSOR_PARAM_BOUNDS(module, ZSTD_c_nbWorkers, UINT, "NB_WORKERS");
         
     | 
| 
      
 283 
     | 
    
         
            +
              EXPORT_COMPRESSOR_PARAM_BOUNDS(module, ZSTD_c_jobSize, UINT, "JOB_SIZE");
         
     | 
| 
      
 284 
     | 
    
         
            +
              EXPORT_COMPRESSOR_PARAM_BOUNDS(module, ZSTD_c_overlapLog, UINT, "OVERLAP_LOG");
         
     | 
| 
      
 285 
     | 
    
         
            +
             
     | 
| 
      
 286 
     | 
    
         
            +
              EXPORT_DECOMPRESSOR_PARAM_BOUNDS(module, ZSTD_d_windowLogMax, UINT, "WINDOW_LOG_MAX");
         
     | 
| 
      
 287 
     | 
    
         
            +
            }
         
     | 
| 
         @@ -0,0 +1,122 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            // Ruby bindings for zstd library.
         
     | 
| 
      
 2 
     | 
    
         
            +
            // Copyright (c) 2019 AUTHORS, MIT License.
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            #if !defined(ZSTDS_EXT_OPTIONS_H)
         
     | 
| 
      
 5 
     | 
    
         
            +
            #define ZSTDS_EXT_OPTIONS_H
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            #include <stdbool.h>
         
     | 
| 
      
 8 
     | 
    
         
            +
            #include <stdint.h>
         
     | 
| 
      
 9 
     | 
    
         
            +
            #include <stdlib.h>
         
     | 
| 
      
 10 
     | 
    
         
            +
            #include <zstd.h>
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            #include "ruby.h"
         
     | 
| 
      
 13 
     | 
    
         
            +
            #include "zstds_ext/common.h"
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            // Default option values depends on zstd library.
         
     | 
| 
      
 16 
     | 
    
         
            +
            // We will set only user defined values.
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            enum {
         
     | 
| 
      
 19 
     | 
    
         
            +
              ZSTDS_EXT_OPTION_TYPE_BOOL = 1,
         
     | 
| 
      
 20 
     | 
    
         
            +
              ZSTDS_EXT_OPTION_TYPE_UINT,
         
     | 
| 
      
 21 
     | 
    
         
            +
              ZSTDS_EXT_OPTION_TYPE_INT,
         
     | 
| 
      
 22 
     | 
    
         
            +
              ZSTDS_EXT_OPTION_TYPE_STRATEGY
         
     | 
| 
      
 23 
     | 
    
         
            +
            };
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            typedef uint_fast8_t       zstds_ext_option_type_t;
         
     | 
| 
      
 26 
     | 
    
         
            +
            typedef int                zstds_ext_option_value_t;
         
     | 
| 
      
 27 
     | 
    
         
            +
            typedef unsigned long long zstds_ext_ull_option_value_t;
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            typedef struct {
         
     | 
| 
      
 30 
     | 
    
         
            +
              bool                     has_value;
         
     | 
| 
      
 31 
     | 
    
         
            +
              zstds_ext_option_value_t value;
         
     | 
| 
      
 32 
     | 
    
         
            +
            } zstds_ext_option_t;
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            typedef struct {
         
     | 
| 
      
 35 
     | 
    
         
            +
              bool                         has_value;
         
     | 
| 
      
 36 
     | 
    
         
            +
              zstds_ext_ull_option_value_t value;
         
     | 
| 
      
 37 
     | 
    
         
            +
            } zstds_ext_ull_option_t;
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
            typedef struct {
         
     | 
| 
      
 40 
     | 
    
         
            +
              zstds_ext_option_t     compression_level;
         
     | 
| 
      
 41 
     | 
    
         
            +
              zstds_ext_option_t     window_log;
         
     | 
| 
      
 42 
     | 
    
         
            +
              zstds_ext_option_t     hash_log;
         
     | 
| 
      
 43 
     | 
    
         
            +
              zstds_ext_option_t     chain_log;
         
     | 
| 
      
 44 
     | 
    
         
            +
              zstds_ext_option_t     search_log;
         
     | 
| 
      
 45 
     | 
    
         
            +
              zstds_ext_option_t     min_match;
         
     | 
| 
      
 46 
     | 
    
         
            +
              zstds_ext_option_t     target_length;
         
     | 
| 
      
 47 
     | 
    
         
            +
              zstds_ext_option_t     strategy;
         
     | 
| 
      
 48 
     | 
    
         
            +
              zstds_ext_option_t     enable_long_distance_matching;
         
     | 
| 
      
 49 
     | 
    
         
            +
              zstds_ext_option_t     ldm_hash_log;
         
     | 
| 
      
 50 
     | 
    
         
            +
              zstds_ext_option_t     ldm_min_match;
         
     | 
| 
      
 51 
     | 
    
         
            +
              zstds_ext_option_t     ldm_bucket_size_log;
         
     | 
| 
      
 52 
     | 
    
         
            +
              zstds_ext_option_t     ldm_hash_rate_log;
         
     | 
| 
      
 53 
     | 
    
         
            +
              zstds_ext_option_t     content_size_flag;
         
     | 
| 
      
 54 
     | 
    
         
            +
              zstds_ext_option_t     checksum_flag;
         
     | 
| 
      
 55 
     | 
    
         
            +
              zstds_ext_option_t     dict_id_flag;
         
     | 
| 
      
 56 
     | 
    
         
            +
              zstds_ext_option_t     nb_workers;
         
     | 
| 
      
 57 
     | 
    
         
            +
              zstds_ext_option_t     job_size;
         
     | 
| 
      
 58 
     | 
    
         
            +
              zstds_ext_option_t     overlap_log;
         
     | 
| 
      
 59 
     | 
    
         
            +
              zstds_ext_ull_option_t pledged_size;
         
     | 
| 
      
 60 
     | 
    
         
            +
              VALUE                  dictionary;
         
     | 
| 
      
 61 
     | 
    
         
            +
            } zstds_ext_compressor_options_t;
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
            typedef struct {
         
     | 
| 
      
 64 
     | 
    
         
            +
              zstds_ext_option_t window_log_max;
         
     | 
| 
      
 65 
     | 
    
         
            +
              VALUE              dictionary;
         
     | 
| 
      
 66 
     | 
    
         
            +
            } zstds_ext_decompressor_options_t;
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
            void zstds_ext_get_option(VALUE options, zstds_ext_option_t* option, zstds_ext_option_type_t type, const char* name);
         
     | 
| 
      
 69 
     | 
    
         
            +
            void zstds_ext_get_ull_option(VALUE options, zstds_ext_ull_option_t* option, const char* name);
         
     | 
| 
      
 70 
     | 
    
         
            +
            void zstds_ext_get_dictionary_option(VALUE options, VALUE* option, const char* name);
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
            #define ZSTDS_EXT_GET_OPTION(options, target_options, type, name) \
         
     | 
| 
      
 73 
     | 
    
         
            +
              zstds_ext_get_option(options, &target_options.name, type, #name);
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
            #define ZSTDS_EXT_GET_ULL_OPTION(options, target_options, name) \
         
     | 
| 
      
 76 
     | 
    
         
            +
              zstds_ext_get_ull_option(options, &target_options.name, #name);
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
            #define ZSTDS_EXT_GET_DICTIONARY_OPTION(options, target_options, name) \
         
     | 
| 
      
 79 
     | 
    
         
            +
              zstds_ext_get_dictionary_option(options, &target_options.name, #name);
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
            #define ZSTDS_EXT_GET_COMPRESSOR_OPTIONS(options)                                                               \
         
     | 
| 
      
 82 
     | 
    
         
            +
              zstds_ext_compressor_options_t compressor_options;                                                            \
         
     | 
| 
      
 83 
     | 
    
         
            +
                                                                                                                            \
         
     | 
| 
      
 84 
     | 
    
         
            +
              ZSTDS_EXT_GET_OPTION(options, compressor_options, ZSTDS_EXT_OPTION_TYPE_INT, compression_level);              \
         
     | 
| 
      
 85 
     | 
    
         
            +
              ZSTDS_EXT_GET_OPTION(options, compressor_options, ZSTDS_EXT_OPTION_TYPE_UINT, window_log);                    \
         
     | 
| 
      
 86 
     | 
    
         
            +
              ZSTDS_EXT_GET_OPTION(options, compressor_options, ZSTDS_EXT_OPTION_TYPE_UINT, hash_log);                      \
         
     | 
| 
      
 87 
     | 
    
         
            +
              ZSTDS_EXT_GET_OPTION(options, compressor_options, ZSTDS_EXT_OPTION_TYPE_UINT, chain_log);                     \
         
     | 
| 
      
 88 
     | 
    
         
            +
              ZSTDS_EXT_GET_OPTION(options, compressor_options, ZSTDS_EXT_OPTION_TYPE_UINT, search_log);                    \
         
     | 
| 
      
 89 
     | 
    
         
            +
              ZSTDS_EXT_GET_OPTION(options, compressor_options, ZSTDS_EXT_OPTION_TYPE_UINT, min_match);                     \
         
     | 
| 
      
 90 
     | 
    
         
            +
              ZSTDS_EXT_GET_OPTION(options, compressor_options, ZSTDS_EXT_OPTION_TYPE_UINT, target_length);                 \
         
     | 
| 
      
 91 
     | 
    
         
            +
              ZSTDS_EXT_GET_OPTION(options, compressor_options, ZSTDS_EXT_OPTION_TYPE_STRATEGY, strategy);                  \
         
     | 
| 
      
 92 
     | 
    
         
            +
              ZSTDS_EXT_GET_OPTION(options, compressor_options, ZSTDS_EXT_OPTION_TYPE_BOOL, enable_long_distance_matching); \
         
     | 
| 
      
 93 
     | 
    
         
            +
              ZSTDS_EXT_GET_OPTION(options, compressor_options, ZSTDS_EXT_OPTION_TYPE_UINT, ldm_hash_log);                  \
         
     | 
| 
      
 94 
     | 
    
         
            +
              ZSTDS_EXT_GET_OPTION(options, compressor_options, ZSTDS_EXT_OPTION_TYPE_UINT, ldm_min_match);                 \
         
     | 
| 
      
 95 
     | 
    
         
            +
              ZSTDS_EXT_GET_OPTION(options, compressor_options, ZSTDS_EXT_OPTION_TYPE_UINT, ldm_bucket_size_log);           \
         
     | 
| 
      
 96 
     | 
    
         
            +
              ZSTDS_EXT_GET_OPTION(options, compressor_options, ZSTDS_EXT_OPTION_TYPE_UINT, ldm_hash_rate_log);             \
         
     | 
| 
      
 97 
     | 
    
         
            +
              ZSTDS_EXT_GET_OPTION(options, compressor_options, ZSTDS_EXT_OPTION_TYPE_BOOL, content_size_flag);             \
         
     | 
| 
      
 98 
     | 
    
         
            +
              ZSTDS_EXT_GET_OPTION(options, compressor_options, ZSTDS_EXT_OPTION_TYPE_BOOL, checksum_flag);                 \
         
     | 
| 
      
 99 
     | 
    
         
            +
              ZSTDS_EXT_GET_OPTION(options, compressor_options, ZSTDS_EXT_OPTION_TYPE_BOOL, dict_id_flag);                  \
         
     | 
| 
      
 100 
     | 
    
         
            +
              ZSTDS_EXT_GET_OPTION(options, compressor_options, ZSTDS_EXT_OPTION_TYPE_UINT, nb_workers);                    \
         
     | 
| 
      
 101 
     | 
    
         
            +
              ZSTDS_EXT_GET_OPTION(options, compressor_options, ZSTDS_EXT_OPTION_TYPE_UINT, job_size);                      \
         
     | 
| 
      
 102 
     | 
    
         
            +
              ZSTDS_EXT_GET_OPTION(options, compressor_options, ZSTDS_EXT_OPTION_TYPE_UINT, overlap_log);                   \
         
     | 
| 
      
 103 
     | 
    
         
            +
              ZSTDS_EXT_GET_ULL_OPTION(options, compressor_options, pledged_size);                                          \
         
     | 
| 
      
 104 
     | 
    
         
            +
              ZSTDS_EXT_GET_DICTIONARY_OPTION(options, compressor_options, dictionary);
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
            #define ZSTDS_EXT_GET_DECOMPRESSOR_OPTIONS(options)                                                \
         
     | 
| 
      
 107 
     | 
    
         
            +
              zstds_ext_decompressor_options_t decompressor_options;                                           \
         
     | 
| 
      
 108 
     | 
    
         
            +
                                                                                                               \
         
     | 
| 
      
 109 
     | 
    
         
            +
              ZSTDS_EXT_GET_OPTION(options, decompressor_options, ZSTDS_EXT_OPTION_TYPE_UINT, window_log_max); \
         
     | 
| 
      
 110 
     | 
    
         
            +
              ZSTDS_EXT_GET_DICTIONARY_OPTION(options, decompressor_options, dictionary);
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
      
 112 
     | 
    
         
            +
            size_t zstds_ext_get_size_option_value(VALUE options, const char* name);
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
            #define ZSTDS_EXT_GET_BUFFER_LENGTH_OPTION(options, name) \
         
     | 
| 
      
 115 
     | 
    
         
            +
              size_t name = zstds_ext_get_size_option_value(options, #name);
         
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
            zstds_ext_result_t zstds_ext_set_compressor_options(ZSTD_CCtx* ctx, zstds_ext_compressor_options_t* options);
         
     | 
| 
      
 118 
     | 
    
         
            +
            zstds_ext_result_t zstds_ext_set_decompressor_options(ZSTD_DCtx* ctx, zstds_ext_decompressor_options_t* options);
         
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
      
 120 
     | 
    
         
            +
            void zstds_ext_option_exports(VALUE root_module);
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
            #endif // ZSTDS_EXT_OPTIONS_H
         
     |