qlzruby 0.1.1-mswin32 → 0.1.2-mswin32
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.
- data/README +50 -0
- data/ext/qlzruby.c +16 -118
- data/lib/i386-mswin32/qlzruby.so +0 -0
- metadata +23 -9
- data/README.txt +0 -76
data/README
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
= QuickLZ/Ruby
|
2
|
+
|
3
|
+
Copyright (c) 2008 SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
|
4
|
+
|
5
|
+
== Description
|
6
|
+
|
7
|
+
Ruby bindings for QuickLZ.
|
8
|
+
|
9
|
+
QuickLZ is a data compression library which gives fast compression.
|
10
|
+
|
11
|
+
== Source Code
|
12
|
+
|
13
|
+
https://bitbucket.org/winebarrel/quick-ruby
|
14
|
+
|
15
|
+
== Install
|
16
|
+
|
17
|
+
gem install qlzruby
|
18
|
+
|
19
|
+
== Example
|
20
|
+
|
21
|
+
require 'qlzruby'
|
22
|
+
require 'open-uri'
|
23
|
+
require 'stringio'
|
24
|
+
|
25
|
+
source = <<-EOS
|
26
|
+
London Bridge Is falling down,
|
27
|
+
Falling down, Falling down.
|
28
|
+
London Bridge Is falling down,
|
29
|
+
My fair lady.
|
30
|
+
EOS
|
31
|
+
|
32
|
+
comp_data = QuickLZ.compress(source)
|
33
|
+
decomp_data = QuickLZ.decompress(comp_data)
|
34
|
+
|
35
|
+
puts <<-EOS
|
36
|
+
- block compress -
|
37
|
+
uncompress size: #{source.length}
|
38
|
+
compress size: #{comp_data.length}
|
39
|
+
decompress size: #{decomp_data.length}
|
40
|
+
decompress success?: #{source == decomp_data}
|
41
|
+
EOS
|
42
|
+
|
43
|
+
=== QuickLZ
|
44
|
+
|
45
|
+
QuickLZ/Ruby contains QuickLZ.
|
46
|
+
|
47
|
+
QuickLZ is a data compression library which gives fast compression.
|
48
|
+
|
49
|
+
* http://www.quicklz.com/
|
50
|
+
* Copyright 2006-2008 Lasse Reinhold
|
data/ext/qlzruby.c
CHANGED
@@ -6,7 +6,7 @@ __declspec(dllexport) void Init_qlzruby(void);
|
|
6
6
|
#endif
|
7
7
|
|
8
8
|
#include <string.h>
|
9
|
-
#include "quicklz
|
9
|
+
#include "quicklz.h"
|
10
10
|
#include "ruby.h"
|
11
11
|
|
12
12
|
#ifndef RSTRING_PTR
|
@@ -26,155 +26,53 @@ __declspec(dllexport) void Init_qlzruby(void);
|
|
26
26
|
} \
|
27
27
|
} while(0)
|
28
28
|
|
29
|
-
#define VERSION "0.1.
|
29
|
+
#define VERSION "0.1.2"
|
30
30
|
#define DEFAULT_BLOCKSIZE 5120
|
31
31
|
#define HEADER_LEN 9
|
32
32
|
|
33
33
|
/* */
|
34
|
-
static VALUE
|
34
|
+
static VALUE qlzruby_compress(VALUE self, VALUE v_src) {
|
35
35
|
VALUE v_dst;
|
36
|
-
char *src, *dst
|
36
|
+
char *src, *dst;
|
37
|
+
qlz_state_compress *state_compress;
|
37
38
|
size_t len;
|
38
39
|
|
39
40
|
Check_Type(v_src, T_STRING);
|
40
41
|
src = RSTRING_PTR(v_src);
|
41
42
|
len = RSTRING_LEN(v_src);
|
43
|
+
state_compress = (qlz_state_compress *) xmalloc(sizeof(qlz_state_compress));
|
42
44
|
dst = xmalloc(len + 400);
|
43
|
-
|
44
|
-
memset(scratch, 0, SCRATCH_COMPRESS);
|
45
|
-
len = qlz_compress(src, dst, len, scratch);
|
45
|
+
len = qlz_compress(src, dst, len, state_compress);
|
46
46
|
v_dst = rb_str_new(dst, len);
|
47
|
-
xfree(
|
47
|
+
xfree(state_compress);
|
48
48
|
xfree(dst);
|
49
49
|
|
50
50
|
return v_dst;
|
51
51
|
}
|
52
52
|
|
53
53
|
/* */
|
54
|
-
static VALUE
|
54
|
+
static VALUE qlzruby_decompress(VALUE self, VALUE v_src) {
|
55
55
|
VALUE v_dst;
|
56
|
-
char *src, *dst
|
56
|
+
char *src, *dst;
|
57
|
+
qlz_state_decompress *state_decompress;
|
57
58
|
size_t len;
|
58
59
|
|
59
60
|
Check_Type(v_src, T_STRING);
|
60
61
|
src = RSTRING_PTR(v_src);
|
61
62
|
len = qlz_size_decompressed(src);
|
62
63
|
dst = xmalloc(len);
|
63
|
-
|
64
|
-
|
65
|
-
len = qlz_decompress(src, dst, scratch);
|
64
|
+
state_decompress = (qlz_state_decompress *) xmalloc(sizeof(qlz_state_decompress));
|
65
|
+
len = qlz_decompress(src, dst, state_decompress);
|
66
66
|
v_dst = rb_str_new(dst, len);
|
67
|
-
xfree(
|
67
|
+
xfree(state_decompress);
|
68
68
|
xfree(dst);
|
69
69
|
|
70
70
|
return v_dst;
|
71
71
|
}
|
72
72
|
|
73
|
-
/* */
|
74
|
-
static VALUE qlzruby_stream_compress(int argc, const VALUE *argv, VALUE self) {
|
75
|
-
VALUE in, out, blocksize, v_src, v_dst;
|
76
|
-
char *src, *dst, *scratch;
|
77
|
-
size_t len, i_blocksize;
|
78
|
-
|
79
|
-
rb_scan_args(argc, argv, "21", &in, &out, &blocksize);
|
80
|
-
Check_IO(in);
|
81
|
-
Check_IO(out);
|
82
|
-
|
83
|
-
if (NIL_P(blocksize)) {
|
84
|
-
blocksize = INT2FIX(DEFAULT_BLOCKSIZE);
|
85
|
-
i_blocksize = DEFAULT_BLOCKSIZE;
|
86
|
-
} else {
|
87
|
-
i_blocksize = NUM2LONG(blocksize);
|
88
|
-
|
89
|
-
if (i_blocksize < 1) {
|
90
|
-
blocksize = INT2FIX(DEFAULT_BLOCKSIZE);
|
91
|
-
i_blocksize = DEFAULT_BLOCKSIZE;
|
92
|
-
}
|
93
|
-
}
|
94
|
-
|
95
|
-
dst = alloca(i_blocksize + 400);
|
96
|
-
scratch = alloca(SCRATCH_COMPRESS);
|
97
|
-
memset(scratch, 0, SCRATCH_COMPRESS);
|
98
|
-
|
99
|
-
while (1) {
|
100
|
-
v_src = rb_funcall(in, rb_intern("read"), 1, blocksize);
|
101
|
-
|
102
|
-
if (NIL_P(v_src)) { break; }
|
103
|
-
|
104
|
-
src = RSTRING_PTR(v_src);
|
105
|
-
len = RSTRING_LEN(v_src);
|
106
|
-
|
107
|
-
if (len < 1) { break; }
|
108
|
-
|
109
|
-
len = qlz_compress(src, dst, len, scratch);
|
110
|
-
v_dst = rb_str_new(dst, len);
|
111
|
-
rb_funcall(out, rb_intern("write"), 1, v_dst);
|
112
|
-
}
|
113
|
-
|
114
|
-
return Qnil;
|
115
|
-
}
|
116
|
-
|
117
|
-
static size_t qlzruby_stream_decompress_block(VALUE in, VALUE out, char *scratch) {
|
118
|
-
VALUE v_header, v_src, v_dst;
|
119
|
-
char *header, *src, *dst;
|
120
|
-
size_t header_len, len;
|
121
|
-
|
122
|
-
v_header = rb_funcall(in, rb_intern("read"), 1, INT2FIX(HEADER_LEN));
|
123
|
-
|
124
|
-
if (NIL_P(v_header)) { return 0; }
|
125
|
-
|
126
|
-
header = RSTRING_PTR(v_header);
|
127
|
-
header_len = RSTRING_LEN(v_header);
|
128
|
-
|
129
|
-
if (header_len < HEADER_LEN) { return 0; }
|
130
|
-
|
131
|
-
len = qlz_size_compressed(header);
|
132
|
-
v_src = rb_funcall(in, rb_intern("read"), 1, INT2FIX(len - HEADER_LEN));
|
133
|
-
len = RSTRING_LEN(v_src);
|
134
|
-
|
135
|
-
if (len < 1) { return 0; }
|
136
|
-
|
137
|
-
len += HEADER_LEN;
|
138
|
-
src = alloca(len);
|
139
|
-
memcpy(src, header, HEADER_LEN);
|
140
|
-
memcpy(src + HEADER_LEN, RSTRING_PTR(v_src), len - HEADER_LEN);
|
141
|
-
|
142
|
-
len = qlz_size_decompressed(src);
|
143
|
-
dst = alloca(len);
|
144
|
-
len = qlz_decompress(src, dst, scratch);
|
145
|
-
v_dst = rb_str_new(dst, len);
|
146
|
-
rb_funcall(out, rb_intern("write"), 1, v_dst);
|
147
|
-
|
148
|
-
return len;
|
149
|
-
}
|
150
|
-
|
151
|
-
/* */
|
152
|
-
static VALUE qlzruby_stream_decompress(VALUE self, VALUE in, VALUE out) {
|
153
|
-
char *scratch;
|
154
|
-
|
155
|
-
Check_IO(in);
|
156
|
-
Check_IO(out);
|
157
|
-
|
158
|
-
scratch = alloca(SCRATCH_DECOMPRESS);
|
159
|
-
memset(scratch, 0, SCRATCH_DECOMPRESS);
|
160
|
-
|
161
|
-
while (1) {
|
162
|
-
int len = qlzruby_stream_decompress_block(in, out, scratch);
|
163
|
-
|
164
|
-
if (len < 1) {
|
165
|
-
break;
|
166
|
-
}
|
167
|
-
}
|
168
|
-
|
169
|
-
return Qnil;
|
170
|
-
|
171
|
-
}
|
172
|
-
|
173
73
|
void Init_qlzruby() {
|
174
74
|
VALUE QuickLZ = rb_define_module("QuickLZ");
|
175
75
|
rb_define_const(QuickLZ, "VERSION", rb_str_new2(VERSION));
|
176
|
-
rb_define_module_function(QuickLZ, "
|
177
|
-
rb_define_module_function(QuickLZ, "
|
178
|
-
rb_define_module_function(QuickLZ, "stream_compress", qlzruby_stream_compress, -1);
|
179
|
-
rb_define_module_function(QuickLZ, "stream_decompress", qlzruby_stream_decompress, 2);
|
76
|
+
rb_define_module_function(QuickLZ, "compress", qlzruby_compress, 1);
|
77
|
+
rb_define_module_function(QuickLZ, "decompress", qlzruby_decompress, 1);
|
180
78
|
}
|
data/lib/i386-mswin32/qlzruby.so
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qlzruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 31
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
5
11
|
platform: mswin32
|
6
12
|
authors:
|
7
13
|
- winebarrel
|
@@ -9,7 +15,7 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date:
|
18
|
+
date: 2011-01-13 00:00:00 +09:00
|
13
19
|
default_executable:
|
14
20
|
dependencies: []
|
15
21
|
|
@@ -20,16 +26,18 @@ executables: []
|
|
20
26
|
extensions: []
|
21
27
|
|
22
28
|
extra_rdoc_files:
|
23
|
-
- README
|
29
|
+
- README
|
24
30
|
- ext/qlzruby.c
|
25
31
|
- LICENSE.txt
|
26
32
|
files:
|
27
33
|
- lib/i386-mswin32/qlzruby.so
|
28
|
-
- README
|
34
|
+
- README
|
29
35
|
- ext/qlzruby.c
|
30
36
|
- LICENSE.txt
|
31
37
|
has_rdoc: true
|
32
|
-
homepage:
|
38
|
+
homepage: https://bitbucket.org/winebarrel/quick-ruby
|
39
|
+
licenses: []
|
40
|
+
|
33
41
|
post_install_message:
|
34
42
|
rdoc_options:
|
35
43
|
- --title
|
@@ -37,23 +45,29 @@ rdoc_options:
|
|
37
45
|
require_paths:
|
38
46
|
- lib/i386-mswin32
|
39
47
|
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
none: false
|
40
49
|
requirements:
|
41
50
|
- - ">="
|
42
51
|
- !ruby/object:Gem::Version
|
52
|
+
hash: 3
|
53
|
+
segments:
|
54
|
+
- 0
|
43
55
|
version: "0"
|
44
|
-
version:
|
45
56
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
46
58
|
requirements:
|
47
59
|
- - ">="
|
48
60
|
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
62
|
+
segments:
|
63
|
+
- 0
|
49
64
|
version: "0"
|
50
|
-
version:
|
51
65
|
requirements: []
|
52
66
|
|
53
67
|
rubyforge_project: qlzruby
|
54
|
-
rubygems_version: 1.
|
68
|
+
rubygems_version: 1.3.7
|
55
69
|
signing_key:
|
56
|
-
specification_version:
|
70
|
+
specification_version: 3
|
57
71
|
summary: Ruby bindings for QuickLZ.
|
58
72
|
test_files: []
|
59
73
|
|
data/README.txt
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
= QuickLZ/Ruby
|
2
|
-
|
3
|
-
Copyright (c) 2008 SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
|
4
|
-
|
5
|
-
== Description
|
6
|
-
|
7
|
-
Ruby bindings for QuickLZ.
|
8
|
-
|
9
|
-
QuickLZ is a data compression library which gives fast compression.
|
10
|
-
|
11
|
-
== Project Page
|
12
|
-
|
13
|
-
http://rubyforge.org/projects/qlzruby
|
14
|
-
|
15
|
-
== Install
|
16
|
-
|
17
|
-
gem install qlzruby
|
18
|
-
|
19
|
-
== Download
|
20
|
-
|
21
|
-
http://rubyforge.org/frs/?group_id=6766
|
22
|
-
|
23
|
-
== Example
|
24
|
-
|
25
|
-
require 'qlzruby'
|
26
|
-
require 'open-uri'
|
27
|
-
require 'stringio'
|
28
|
-
|
29
|
-
# block compress
|
30
|
-
source = <<-EOS
|
31
|
-
London Bridge Is falling down,
|
32
|
-
Falling down, Falling down.
|
33
|
-
London Bridge Is falling down,
|
34
|
-
My fair lady.
|
35
|
-
EOS
|
36
|
-
|
37
|
-
comp_data = QuickLZ.block_compress(source)
|
38
|
-
decomp_data = QuickLZ.block_decompress(comp_data)
|
39
|
-
|
40
|
-
puts <<-EOS
|
41
|
-
- block compress -
|
42
|
-
uncompress size: #{source.length}
|
43
|
-
compress size: #{comp_data.length}
|
44
|
-
decompress size: #{decomp_data.length}
|
45
|
-
decompress success?: #{source == decomp_data}
|
46
|
-
|
47
|
-
EOS
|
48
|
-
|
49
|
-
# stream compress
|
50
|
-
source = open('http://www.ruby-lang.org/') {|f| f.read }
|
51
|
-
source = StringIO.new(source)
|
52
|
-
comp_data = StringIO.new
|
53
|
-
|
54
|
-
QuickLZ.stream_compress(source, comp_data)
|
55
|
-
|
56
|
-
comp_data.seek(0)
|
57
|
-
decomp_data = StringIO.new
|
58
|
-
|
59
|
-
QuickLZ.stream_decompress(comp_data, decomp_data)
|
60
|
-
|
61
|
-
puts <<-EOS
|
62
|
-
- stream compress -
|
63
|
-
uncompress size: #{source.length}
|
64
|
-
compress size: #{comp_data.length}
|
65
|
-
decompress size: #{decomp_data.length}
|
66
|
-
decompress success?: #{source.string == decomp_data.string}
|
67
|
-
EOS
|
68
|
-
|
69
|
-
=== QuickLZ
|
70
|
-
|
71
|
-
QuickLZ/Ruby contains QuickLZ.
|
72
|
-
|
73
|
-
QuickLZ is a data compression library which gives fast compression.
|
74
|
-
|
75
|
-
* http://www.quicklz.com/
|
76
|
-
* Copyright 2006-2008 Lasse Reinhold
|