zipruby 0.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of zipruby might be problematic. Click here for more details.

@@ -0,0 +1,368 @@
1
+ #include <errno.h>
2
+
3
+ #ifndef _WIN32
4
+ #include <alloca.h>
5
+ #else
6
+ #include <malloc.h>
7
+ #endif
8
+
9
+ #include "zip.h"
10
+ #include "zipruby.h"
11
+ #include "zipruby_archive.h"
12
+ #include "zipruby_file.h"
13
+ #include "zipruby_stat.h"
14
+ #include "ruby.h"
15
+
16
+ static VALUE zipruby_file(VALUE klass);
17
+ static VALUE zipruby_file_alloc(VALUE klass);
18
+ static void zipruby_file_mark(struct zipruby_file *p);
19
+ static void zipruby_file_free(struct zipruby_file *p);
20
+ static VALUE zipruby_file_initialize(int argc, VALUE *argv, VALUE self);
21
+ static VALUE zipruby_file_close(VALUE self);
22
+ static VALUE zipruby_file_read(VALUE self);
23
+ static VALUE zipruby_file_stat(VALUE self);
24
+ static VALUE zipruby_file_get_comment(int argc, VALUE *argv, VALUE self);
25
+ static VALUE zipruby_file_set_comment(VALUE self, VALUE comment);
26
+ static VALUE zipruby_file_delete(VALUE self);
27
+ static VALUE zipruby_file_rename(VALUE self, VALUE name);
28
+ static VALUE zipruby_file_unchange(VALUE self);
29
+ static VALUE zipruby_file_name(VALUE self);
30
+ static VALUE zipruby_file_index(VALUE self);
31
+ static VALUE zipruby_file_crc(VALUE self);
32
+ static VALUE zipruby_file_size(VALUE self);
33
+ static VALUE zipruby_file_mtime(VALUE self);
34
+ static VALUE zipruby_file_comp_size(VALUE self);
35
+ static VALUE zipruby_file_comp_method(VALUE self);
36
+ static VALUE zipruby_file_encryption_method(VALUE self);
37
+
38
+ extern VALUE Zip;
39
+ extern VALUE Archive;
40
+ VALUE File;
41
+ extern VALUE Stat;
42
+ extern VALUE Error;
43
+
44
+ void Init_zipruby_file() {
45
+ File = rb_define_class_under(Zip, "File", rb_cObject);
46
+ rb_define_alloc_func(File, zipruby_file_alloc);
47
+ rb_define_method(File, "initialize", zipruby_file_initialize, -1);
48
+ rb_define_method(File, "close", zipruby_file_close, 0);
49
+ rb_define_method(File, "read", zipruby_file_read, 0);
50
+ rb_define_method(File, "stat", zipruby_file_stat, 0);
51
+ rb_define_method(File, "get_comment", zipruby_file_get_comment, -1);
52
+ rb_define_method(File, "comment", zipruby_file_get_comment, -1);
53
+ rb_define_method(File, "comment=", zipruby_file_set_comment, 1);
54
+ rb_define_method(File, "delete", zipruby_file_delete, 0);
55
+ rb_define_method(File, "rename", zipruby_file_rename, 1);
56
+ rb_define_method(File, "unchange", zipruby_file_unchange, 1);
57
+ rb_define_method(File, "revert", zipruby_file_unchange, 1);
58
+ rb_define_method(File, "name", zipruby_file_name, 0);
59
+ rb_define_method(File, "index", zipruby_file_index, 0);
60
+ rb_define_method(File, "crc", zipruby_file_crc, 0);
61
+ rb_define_method(File, "size", zipruby_file_size, 0);
62
+ rb_define_method(File, "mtime", zipruby_file_mtime, 0);
63
+ rb_define_method(File, "comp_size", zipruby_file_comp_size, 0);
64
+ rb_define_method(File, "comp_method", zipruby_file_comp_method, 0);
65
+ rb_define_method(File, "encryption_method", zipruby_file_encryption_method, 0);
66
+ }
67
+
68
+ static VALUE zipruby_file_alloc(VALUE klass) {
69
+ struct zipruby_file *p = ALLOC(struct zipruby_file);
70
+
71
+ p->archive = NULL;
72
+ p->file = NULL;
73
+ p->sb = NULL;
74
+
75
+ return Data_Wrap_Struct(klass, zipruby_file_mark, zipruby_file_free, p);
76
+ }
77
+
78
+ static void zipruby_file_mark(struct zipruby_file *p) {
79
+ if (p->archive) { rb_gc_mark(p->v_archive); }
80
+ if (p->sb) { rb_gc_mark(p->v_sb); }
81
+ }
82
+
83
+ static void zipruby_file_free(struct zipruby_file *p) {
84
+ xfree(p);
85
+ }
86
+
87
+ /* */
88
+ static VALUE zipruby_file_initialize(int argc, VALUE *argv, VALUE self) {
89
+ VALUE archive, index, flags, stat_flags;
90
+ struct zipruby_archive *p_archive;
91
+ struct zipruby_file *p_file;
92
+ struct zipruby_stat *p_stat;
93
+ struct zip_file *fzip;
94
+ char *fname = NULL;
95
+ int i_index = -1, i_flags = 0;
96
+
97
+ rb_scan_args(argc, argv, "22", &archive, &index, &flags, &stat_flags);
98
+
99
+ if (!rb_obj_is_instance_of(archive, Archive)) {
100
+ rb_raise(rb_eTypeError, "wrong argument type %s (expected Zip::Archive)", rb_class2name(CLASS_OF(archive)));
101
+ }
102
+
103
+ switch (TYPE(index)) {
104
+ case T_STRING: fname = StringValuePtr(index); break;
105
+ case T_FIXNUM: i_index = NUM2INT(index); break;
106
+ default:
107
+ rb_raise(rb_eTypeError, "wrong argument type %s (expected String or Fixnum)", rb_class2name(CLASS_OF(index)));
108
+ }
109
+
110
+ if (!NIL_P(flags)) {
111
+ i_flags = NUM2INT(flags);
112
+ }
113
+
114
+ Data_Get_Struct(archive, struct zipruby_archive, p_archive);
115
+ Check_Archive(p_archive);
116
+
117
+ if (fname) {
118
+ fzip = zip_fopen(p_archive->archive, fname, i_flags);
119
+
120
+ if (fzip == NULL) {
121
+ rb_raise(Error, "Open file failed - %s: %s", fname, zip_strerror(p_archive->archive));
122
+ }
123
+ } else {
124
+ fzip = zip_fopen_index(p_archive->archive, i_index, i_flags);
125
+
126
+ if (fzip == NULL) {
127
+ rb_raise(Error, "Open file failed at %d", i_index, zip_strerror(p_archive->archive));
128
+ }
129
+ }
130
+
131
+ Data_Get_Struct(self, struct zipruby_file, p_file);
132
+ p_file->v_archive = archive;
133
+ p_file->archive = p_archive->archive;
134
+ p_file->file = fzip;
135
+ p_file->v_sb = rb_funcall(Stat, rb_intern("new"), 3, archive, index, stat_flags);
136
+ Data_Get_Struct(p_file->v_sb, struct zipruby_stat, p_stat);
137
+ p_file->sb = p_stat->sb;
138
+
139
+ return Qnil;
140
+ }
141
+
142
+ /* */
143
+ static VALUE zipruby_file_close(VALUE self) {
144
+ struct zipruby_file *p_file;
145
+ int error;
146
+
147
+ Data_Get_Struct(self, struct zipruby_file, p_file);
148
+ Check_File(p_file);
149
+
150
+ if ((error = zip_fclose(p_file->file)) != 0) {
151
+ char errstr[ERRSTR_BUFSIZE];
152
+ zip_error_to_str(errstr, ERRSTR_BUFSIZE, error, errno);
153
+ zip_unchange(p_file->archive, p_file->sb->index);
154
+ rb_raise(Error, "Close file failed: %s", errstr);
155
+ }
156
+
157
+ p_file->archive = NULL;
158
+ p_file->file = NULL;
159
+ p_file->sb = NULL;
160
+
161
+ return Qnil;
162
+ }
163
+
164
+ /* */
165
+ static VALUE zipruby_file_read(VALUE self) {
166
+ struct zipruby_file *p_file;
167
+ struct zip_stat sb;
168
+ char *buf;
169
+
170
+ Data_Get_Struct(self, struct zipruby_file, p_file);
171
+ Check_File(p_file);
172
+
173
+ zip_stat_init(&sb);
174
+
175
+ if (zip_stat_index(p_file->archive, p_file->sb->index, 0, &sb)) {
176
+ rb_raise(Error, "Read file failed: %s", zip_strerror(p_file->archive));
177
+ }
178
+
179
+ buf = alloca(sb.size);
180
+
181
+ if (zip_fread(p_file->file, buf, sb.size) == -1) {
182
+ rb_raise(Error, "Read file failed: %s", zip_file_strerror(p_file->file));
183
+ }
184
+
185
+ return rb_str_new(buf, sb.size);
186
+ }
187
+
188
+ /* */
189
+ static VALUE zipruby_file_stat(VALUE self) {
190
+ struct zipruby_file *p_file;
191
+
192
+ Data_Get_Struct(self, struct zipruby_file, p_file);
193
+ Check_File(p_file);
194
+
195
+ return p_file->v_sb;
196
+ }
197
+
198
+ /* */
199
+ static VALUE zipruby_file_get_comment(int argc, VALUE *argv, VALUE self) {
200
+ VALUE flags;
201
+ struct zipruby_file *p_file;
202
+ const char *comment;
203
+ int lenp, i_flags = 0;
204
+
205
+ rb_scan_args(argc, argv, "01", &flags);
206
+
207
+ if (!NIL_P(flags)) {
208
+ i_flags = NUM2INT(flags);
209
+ }
210
+
211
+ Data_Get_Struct(self, struct zipruby_file, p_file);
212
+ Check_File(p_file);
213
+
214
+ // XXX: How is the error checked?
215
+ comment = zip_get_file_comment(p_file->archive, p_file->sb->index, &lenp, i_flags);
216
+
217
+ return comment ? rb_str_new(comment, lenp) : Qnil;
218
+ }
219
+
220
+ /* */
221
+ static VALUE zipruby_file_set_comment(VALUE self, VALUE comment) {
222
+ struct zipruby_file *p_file;
223
+ char *s_comment = NULL;
224
+ int len = 0;
225
+
226
+ if (!NIL_P(comment)) {
227
+ Check_Type(comment, T_STRING);
228
+ s_comment = StringValuePtr(comment);
229
+ len = RSTRING(comment)->len;
230
+ }
231
+
232
+ Data_Get_Struct(self, struct zipruby_file, p_file);
233
+ Check_File(p_file);
234
+
235
+ if (zip_set_file_comment(p_file->archive, p_file->sb->index, s_comment, len) == -1) {
236
+ zip_unchange_all(p_file->archive);
237
+ zip_unchange_archive(p_file->archive);
238
+ rb_raise(Error, "Comment file failed - %s: %s", p_file->sb->name, zip_strerror(p_file->archive));
239
+ }
240
+
241
+ return Qnil;
242
+ }
243
+
244
+ /* */
245
+ static VALUE zipruby_file_delete(VALUE self) {
246
+ struct zipruby_file *p_file;
247
+
248
+ Data_Get_Struct(self, struct zipruby_file, p_file);
249
+ Check_File(p_file);
250
+
251
+ if (zip_delete(p_file->archive, p_file->sb->index) == -1) {
252
+ zip_unchange_all(p_file->archive);
253
+ zip_unchange_archive(p_file->archive);
254
+ rb_raise(Error, "Delete file failed - %s: %s", p_file->sb->name, zip_strerror(p_file->archive));
255
+ }
256
+
257
+ return Qnil;
258
+ }
259
+
260
+ /* */
261
+ static VALUE zipruby_file_rename(VALUE self, VALUE name) {
262
+ struct zipruby_file *p_file;
263
+
264
+ Data_Get_Struct(self, struct zipruby_file, p_file);
265
+ Check_File(p_file);
266
+
267
+ if (zip_rename(p_file->archive, p_file->sb->index, StringValuePtr(name)) == -1) {
268
+ zip_unchange_all(p_file->archive);
269
+ zip_unchange_archive(p_file->archive);
270
+ rb_raise(Error, "Rename file failed - %s: %s", p_file->sb->name, zip_strerror(p_file->archive));
271
+ }
272
+
273
+ return Qnil;
274
+ }
275
+
276
+ /* */
277
+ static VALUE zipruby_file_unchange(VALUE self) {
278
+ struct zipruby_file *p_file;
279
+
280
+ Data_Get_Struct(self, struct zipruby_file, p_file);
281
+ Check_File(p_file);
282
+
283
+ if (zip_unchange(p_file->archive, p_file->sb->index) == -1) {
284
+ rb_raise(Error, "Unchange file failed - %s: %s", p_file->sb->name, zip_strerror(p_file->archive));
285
+ }
286
+
287
+ return Qnil;
288
+ }
289
+
290
+ /* */
291
+ static VALUE zipruby_file_name(VALUE self) {
292
+ struct zipruby_file *p_file;
293
+
294
+ Data_Get_Struct(self, struct zipruby_file, p_file);
295
+ Check_File(p_file);
296
+
297
+ return rb_funcall(p_file->v_sb, rb_intern("name"), 0);
298
+ }
299
+
300
+ /* */
301
+ static VALUE zipruby_file_index(VALUE self) {
302
+ struct zipruby_file *p_file;
303
+
304
+ Data_Get_Struct(self, struct zipruby_file, p_file);
305
+ Check_File(p_file);
306
+
307
+ return rb_funcall(p_file->v_sb, rb_intern("index"), 0);
308
+ }
309
+
310
+ /* */
311
+ static VALUE zipruby_file_crc(VALUE self) {
312
+ struct zipruby_file *p_file;
313
+
314
+ Data_Get_Struct(self, struct zipruby_file, p_file);
315
+ Check_File(p_file);
316
+
317
+ return rb_funcall(p_file->v_sb, rb_intern("crc"), 0);
318
+ }
319
+
320
+ /* */
321
+ static VALUE zipruby_file_size(VALUE self) {
322
+ struct zipruby_file *p_file;
323
+
324
+ Data_Get_Struct(self, struct zipruby_file, p_file);
325
+ Check_File(p_file);
326
+
327
+ return rb_funcall(p_file->v_sb, rb_intern("size"), 0);
328
+ }
329
+
330
+ /* */
331
+ static VALUE zipruby_file_mtime(VALUE self) {
332
+ struct zipruby_file *p_file;
333
+
334
+ Data_Get_Struct(self, struct zipruby_file, p_file);
335
+ Check_File(p_file);
336
+
337
+ return rb_funcall(p_file->v_sb, rb_intern("mtime"), 0);
338
+ }
339
+
340
+ /* */
341
+ static VALUE zipruby_file_comp_size(VALUE self) {
342
+ struct zipruby_file *p_file;
343
+
344
+ Data_Get_Struct(self, struct zipruby_file, p_file);
345
+ Check_File(p_file);
346
+
347
+ return rb_funcall(p_file->v_sb, rb_intern("comp_size"), 0);
348
+ }
349
+
350
+ /* */
351
+ static VALUE zipruby_file_comp_method(VALUE self) {
352
+ struct zipruby_file *p_file;
353
+
354
+ Data_Get_Struct(self, struct zipruby_file, p_file);
355
+ Check_File(p_file);
356
+
357
+ return rb_funcall(p_file->v_sb, rb_intern("comp_method"), 0);
358
+ }
359
+
360
+ /* */
361
+ static VALUE zipruby_file_encryption_method(VALUE self) {
362
+ struct zipruby_file *p_file;
363
+
364
+ Data_Get_Struct(self, struct zipruby_file, p_file);
365
+ Check_File(p_file);
366
+
367
+ return rb_funcall(p_file->v_sb, rb_intern("encryption_method"), 0);
368
+ }
@@ -0,0 +1,23 @@
1
+ #ifndef __ZIPRUBY_FILE_H__
2
+ #define __ZIPRUBY_FILE_H__
3
+
4
+ #include "zip.h"
5
+ #include "ruby.h"
6
+
7
+ struct zipruby_file {
8
+ VALUE v_archive;
9
+ struct zip *archive;
10
+ struct zip_file *file;
11
+ VALUE v_sb;
12
+ struct zip_stat *sb;
13
+ };
14
+
15
+ void Init_zipruby_file();
16
+
17
+ #define Check_File(p) do { \
18
+ if ((p)->archive == NULL || (p)->file == NULL || (p)->sb == NULL) { \
19
+ rb_raise(rb_eRuntimeError, "invalid Zip::File"); \
20
+ } \
21
+ } while(0)
22
+
23
+ #endif
@@ -0,0 +1,164 @@
1
+ #include "zip.h"
2
+ #include "zipruby.h"
3
+ #include "zipruby_archive.h"
4
+ #include "zipruby_stat.h"
5
+ #include "ruby.h"
6
+
7
+ static VALUE zipruby_stat_alloc(VALUE klass);
8
+ static void zipruby_stat_free(struct zipruby_stat *p);
9
+ static VALUE zipruby_stat_initialize(int argc, VALUE *argv, VALUE self);
10
+ static VALUE zipruby_stat_name(VALUE self);
11
+ static VALUE zipruby_stat_index(VALUE self);
12
+ static VALUE zipruby_stat_crc(VALUE self);
13
+ static VALUE zipruby_stat_size(VALUE self);
14
+ static VALUE zipruby_stat_mtime(VALUE self);
15
+ static VALUE zipruby_stat_comp_size(VALUE self);
16
+ static VALUE zipruby_stat_comp_method(VALUE self);
17
+ static VALUE zipruby_stat_encryption_method(VALUE self);
18
+
19
+ extern VALUE Zip;
20
+ extern VALUE Archive;
21
+ VALUE Stat;
22
+ extern VALUE Error;
23
+
24
+ void Init_zipruby_stat() {
25
+ Stat = rb_define_class_under(Zip, "Stat", rb_cObject);
26
+ rb_define_alloc_func(Stat, zipruby_stat_alloc);
27
+ rb_define_method(Stat, "initialize", zipruby_stat_initialize, -1);
28
+ rb_define_method(Stat, "name", zipruby_stat_name, 0);
29
+ rb_define_method(Stat, "index", zipruby_stat_index, 0);
30
+ rb_define_method(Stat, "crc", zipruby_stat_crc, 0);
31
+ rb_define_method(Stat, "size", zipruby_stat_size, 0);
32
+ rb_define_method(Stat, "mtime", zipruby_stat_mtime, 0);
33
+ rb_define_method(Stat, "comp_size", zipruby_stat_comp_size, 0);
34
+ rb_define_method(Stat, "comp_method", zipruby_stat_comp_method, 0);
35
+ rb_define_method(Stat, "encryption_method", zipruby_stat_encryption_method, 0);
36
+ }
37
+
38
+ static VALUE zipruby_stat_alloc(VALUE klass) {
39
+ struct zipruby_stat *p = ALLOC(struct zipruby_stat);
40
+
41
+ p->sb = ALLOC(struct zip_stat);
42
+ zip_stat_init(p->sb);
43
+
44
+ return Data_Wrap_Struct(klass, 0, zipruby_stat_free, p);
45
+ }
46
+
47
+ static void zipruby_stat_free(struct zipruby_stat *p) {
48
+ xfree(p->sb);
49
+ xfree(p);
50
+ }
51
+
52
+ /* */
53
+ static VALUE zipruby_stat_initialize(int argc, VALUE *argv, VALUE self) {
54
+ VALUE archive, index, flags;
55
+ struct zipruby_archive *p_archive;
56
+ struct zipruby_stat *p_stat;
57
+ char *fname = NULL;
58
+ int i_index = -1, i_flags = 0;
59
+
60
+ rb_scan_args(argc, argv, "21", &archive, &index, &flags);
61
+
62
+ if (!rb_obj_is_instance_of(archive, Archive)) {
63
+ rb_raise(rb_eTypeError, "wrong argument type %s (expected Zip::Archive)", rb_class2name(CLASS_OF(archive)));
64
+ }
65
+
66
+ switch (TYPE(index)) {
67
+ case T_STRING: fname = StringValuePtr(index); break;
68
+ case T_FIXNUM: i_index = NUM2INT(index); break;
69
+ default:
70
+ rb_raise(rb_eTypeError, "wrong argument type %s (expected String or Fixnum)", rb_class2name(CLASS_OF(index)));
71
+ }
72
+
73
+ if (!NIL_P(flags)) {
74
+ i_flags = NUM2INT(flags);
75
+ }
76
+
77
+ Data_Get_Struct(archive, struct zipruby_archive, p_archive);
78
+ Check_Archive(p_archive);
79
+ Data_Get_Struct(self, struct zipruby_stat, p_stat);
80
+
81
+ if (fname) {
82
+ if (zip_stat(p_archive->archive, fname, i_flags, p_stat->sb) != 0) {
83
+ rb_raise(Error, "Obtain file status failed - %s: %s", fname, zip_strerror(p_archive->archive));
84
+ }
85
+ } else {
86
+ if (zip_stat_index(p_archive->archive, i_index, i_flags, p_stat->sb) != 0) {
87
+ rb_raise(Error, "Obtain file status failed at %d: %s", i_index, zip_strerror(p_archive->archive));
88
+ }
89
+ }
90
+
91
+ return Qnil;
92
+ }
93
+
94
+ /* */
95
+ static VALUE zipruby_stat_name(VALUE self) {
96
+ struct zipruby_stat *p_stat;
97
+
98
+ Data_Get_Struct(self, struct zipruby_stat, p_stat);
99
+
100
+ return p_stat->sb->name ? rb_str_new2(p_stat->sb->name) : Qnil;
101
+ }
102
+
103
+ /* */
104
+ static VALUE zipruby_stat_index(VALUE self) {
105
+ struct zipruby_stat *p_stat;
106
+
107
+ Data_Get_Struct(self, struct zipruby_stat, p_stat);
108
+
109
+ return INT2NUM(p_stat->sb->index);
110
+ }
111
+
112
+ /* */
113
+ static VALUE zipruby_stat_crc(VALUE self) {
114
+ struct zipruby_stat *p_stat;
115
+
116
+ Data_Get_Struct(self, struct zipruby_stat, p_stat);
117
+
118
+ return UINT2NUM(p_stat->sb->crc);
119
+ }
120
+
121
+ /* */
122
+ static VALUE zipruby_stat_size(VALUE self) {
123
+ struct zipruby_stat *p_stat;
124
+
125
+ Data_Get_Struct(self, struct zipruby_stat, p_stat);
126
+
127
+ return LONG2NUM(p_stat->sb->size);
128
+ }
129
+
130
+ /* */
131
+ static VALUE zipruby_stat_mtime(VALUE self) {
132
+ struct zipruby_stat *p_stat;
133
+
134
+ Data_Get_Struct(self, struct zipruby_stat, p_stat);
135
+
136
+ return rb_funcall(rb_cTime, rb_intern("at"), 1, LONG2NUM((long) p_stat->sb->mtime));
137
+ }
138
+
139
+ /* */
140
+ static VALUE zipruby_stat_comp_size(VALUE self) {
141
+ struct zipruby_stat *p_stat;
142
+
143
+ Data_Get_Struct(self, struct zipruby_stat, p_stat);
144
+
145
+ return LONG2NUM(p_stat->sb->comp_size);
146
+ }
147
+
148
+ /* */
149
+ static VALUE zipruby_stat_comp_method(VALUE self) {
150
+ struct zipruby_stat *p_stat;
151
+
152
+ Data_Get_Struct(self, struct zipruby_stat, p_stat);
153
+
154
+ return INT2NUM(p_stat->sb->comp_method);
155
+ }
156
+
157
+ /* */
158
+ static VALUE zipruby_stat_encryption_method(VALUE self) {
159
+ struct zipruby_stat *p_stat;
160
+
161
+ Data_Get_Struct(self, struct zipruby_stat, p_stat);
162
+
163
+ return INT2NUM(p_stat->sb->encryption_method);
164
+ }
@@ -0,0 +1,12 @@
1
+ #ifndef __ZIPRUBY_STAT_H__
2
+ #define __ZIPRUBY_STAT_H__
3
+
4
+ #include "zip.h"
5
+
6
+ struct zipruby_stat {
7
+ struct zip_stat *sb;
8
+ };
9
+
10
+ void Init_zipruby_stat();
11
+
12
+ #endif
data/ext/zipruby_zip.c ADDED
@@ -0,0 +1,37 @@
1
+ #include "ruby.h"
2
+ #include "zip.h"
3
+ #include "zipruby.h"
4
+ #include "zipruby_zip.h"
5
+
6
+ VALUE Zip;
7
+
8
+ void Init_zipruby_zip() {
9
+ Zip = rb_define_module("Zip");
10
+ rb_define_const(Zip, "VERSION", rb_str_new2(VERSION));
11
+
12
+ rb_define_const(Zip, "CREATE", INT2NUM(ZIP_CREATE));
13
+ rb_define_const(Zip, "EXCL", INT2NUM(ZIP_EXCL));
14
+ rb_define_const(Zip, "CHECKCONS", INT2NUM(ZIP_CHECKCONS));
15
+
16
+ rb_define_const(Zip, "FL_NOCASE", INT2NUM(ZIP_FL_NOCASE));
17
+ rb_define_const(Zip, "FL_NODIR", INT2NUM(ZIP_FL_NODIR));
18
+ rb_define_const(Zip, "FL_COMPRESSED", INT2NUM(ZIP_FL_COMPRESSED));
19
+ rb_define_const(Zip, "FL_UNCHANGED", INT2NUM(ZIP_FL_UNCHANGED));
20
+
21
+ rb_define_const(Zip, "CM_DEFAULT" , INT2NUM(ZIP_CM_DEFAULT));
22
+ rb_define_const(Zip, "CM_STORE", INT2NUM(ZIP_CM_STORE));
23
+ rb_define_const(Zip, "CM_SHRINK", INT2NUM(ZIP_CM_SHRINK));
24
+ rb_define_const(Zip, "CM_REDUCE_1", INT2NUM(ZIP_CM_REDUCE_1));
25
+ rb_define_const(Zip, "CM_REDUCE_2", INT2NUM(ZIP_CM_REDUCE_2));
26
+ rb_define_const(Zip, "CM_REDUCE_3", INT2NUM(ZIP_CM_REDUCE_3));
27
+ rb_define_const(Zip, "CM_REDUCE_4", INT2NUM(ZIP_CM_REDUCE_4));
28
+ rb_define_const(Zip, "CM_IMPLODE", INT2NUM(ZIP_CM_IMPLODE));
29
+ rb_define_const(Zip, "CM_DEFLATE", INT2NUM(ZIP_CM_DEFLATE));
30
+ rb_define_const(Zip, "CM_DEFLATE64", INT2NUM(ZIP_CM_DEFLATE64));
31
+ rb_define_const(Zip, "CM_PKWARE_IMPLODE", INT2NUM(ZIP_CM_PKWARE_IMPLODE));
32
+ rb_define_const(Zip, "CM_BZIP2", INT2NUM(ZIP_CM_BZIP2));
33
+
34
+ rb_define_const(Zip, "EM_NONE", INT2NUM(ZIP_EM_NONE));
35
+ rb_define_const(Zip, "EM_TRAD_PKWARE", INT2NUM(ZIP_EM_TRAD_PKWARE));
36
+ // XXX: Strong Encryption Header not parsed yet
37
+ }
data/ext/zipruby_zip.h ADDED
@@ -0,0 +1,6 @@
1
+ #ifndef __ZIPRUBY_ZIP_H__
2
+ #define __ZIPRUBY_ZIP_H__
3
+
4
+ void Init_zipruby_zip();
5
+
6
+ #endif