yaz0 0.1.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/ext/yaz0/ext_yaz0.c +165 -0
- data/ext/yaz0/ext_yaz0.h +8 -0
- data/ext/yaz0/extconf.rb +11 -1
- data/lib/yaz0/version.rb +1 -1
- data/lib/yaz0/yaz0.bundle +0 -0
- data/lib/yaz0.rb +42 -0
- data/libyaz0/include/yaz0.h +34 -0
- data/libyaz0/src/libyaz0/CMakeLists.txt +3 -0
- data/libyaz0/src/libyaz0/compress.c +434 -0
- data/libyaz0/src/libyaz0/decompress.c +197 -0
- data/libyaz0/src/libyaz0/libyaz0.c +64 -0
- data/libyaz0/src/libyaz0/libyaz0.h +49 -0
- data/libyaz0/src/libyaz0/util.c +6 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/yaz0_spec.rb +39 -0
- data/yaz0.gemspec +13 -3
- metadata +19 -16
- data/.gitignore +0 -19
- data/.travis.yml +0 -6
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/ext/yaz0/buffer.c +0 -29
- data/ext/yaz0/compress.c +0 -319
- data/ext/yaz0/decompress.c +0 -64
- data/ext/yaz0/yaz0.c +0 -48
- data/ext/yaz0/yaz0.h +0 -38
data/ext/yaz0/yaz0.c
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
#include "yaz0.h"
|
2
|
-
#include <stdio.h>
|
3
|
-
|
4
|
-
static VALUE compress(VALUE self, VALUE str)
|
5
|
-
{
|
6
|
-
Yaz0Buffer buffer;
|
7
|
-
VALUE ret;
|
8
|
-
|
9
|
-
if (TYPE(str) != T_STRING)
|
10
|
-
{
|
11
|
-
rb_raise(rb_eTypeError, "Expected a string");
|
12
|
-
return Qnil;
|
13
|
-
}
|
14
|
-
|
15
|
-
yaz0BufferAlloc(&buffer, 16);
|
16
|
-
yaz0Compress(&buffer, StringValuePtr(str), RSTRING_LEN(str));
|
17
|
-
ret = rb_str_new(buffer.data, buffer.size);
|
18
|
-
yaz0BufferFree(&buffer);
|
19
|
-
|
20
|
-
return ret;
|
21
|
-
}
|
22
|
-
|
23
|
-
static VALUE decompress(VALUE self, VALUE str)
|
24
|
-
{
|
25
|
-
Yaz0Buffer buffer;
|
26
|
-
VALUE ret;
|
27
|
-
|
28
|
-
if (TYPE(str) != T_STRING)
|
29
|
-
{
|
30
|
-
rb_raise(rb_eTypeError, "Expected a string");
|
31
|
-
return Qnil;
|
32
|
-
}
|
33
|
-
|
34
|
-
yaz0BufferAlloc(&buffer, 16);
|
35
|
-
yaz0Decompress(&buffer, StringValuePtr(str), RSTRING_LEN(str));
|
36
|
-
ret = rb_str_new(buffer.data, buffer.size);
|
37
|
-
yaz0BufferFree(&buffer);
|
38
|
-
|
39
|
-
return ret;
|
40
|
-
}
|
41
|
-
|
42
|
-
void Init_yaz0(void)
|
43
|
-
{
|
44
|
-
VALUE mod;
|
45
|
-
mod = rb_define_module("Yaz0");
|
46
|
-
rb_define_module_function(mod, "compress", &compress, 1);
|
47
|
-
rb_define_module_function(mod, "decompress", &decompress, 1);
|
48
|
-
}
|
data/ext/yaz0/yaz0.h
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
#ifndef YAZ0_H
|
2
|
-
#define YAZ0_H 1
|
3
|
-
|
4
|
-
#include <stddef.h>
|
5
|
-
#include "ruby.h"
|
6
|
-
|
7
|
-
/*
|
8
|
-
* Swap
|
9
|
-
*/
|
10
|
-
inline static uint16_t swap16(uint16_t v)
|
11
|
-
{
|
12
|
-
return (v << 8) | (v >> 8);
|
13
|
-
}
|
14
|
-
|
15
|
-
inline static uint32_t swap32(uint32_t v)
|
16
|
-
{
|
17
|
-
return (v << 24) | ((v << 8) & 0x00ff0000) | ((v >> 8) & 0x0000ff00) | (v >> 24);
|
18
|
-
}
|
19
|
-
|
20
|
-
/*
|
21
|
-
* Buffer
|
22
|
-
*/
|
23
|
-
|
24
|
-
typedef struct
|
25
|
-
{
|
26
|
-
size_t size;
|
27
|
-
size_t capacity;
|
28
|
-
char *data;
|
29
|
-
} Yaz0Buffer;
|
30
|
-
|
31
|
-
void yaz0BufferAlloc(Yaz0Buffer *buf, size_t cap);
|
32
|
-
void yaz0BufferFree(Yaz0Buffer *buf);
|
33
|
-
void yaz0BufferWrite(Yaz0Buffer *buf, const void *data, size_t len);
|
34
|
-
|
35
|
-
int yaz0Compress(Yaz0Buffer *dst, const char *data, size_t len);
|
36
|
-
int yaz0Decompress(Yaz0Buffer *dst, const char *data, size_t len);
|
37
|
-
|
38
|
-
#endif /* YAZ0_H */
|