zipruby 0.2.9 → 0.3.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.
- data/LICENSE.libzip +27 -0
- data/README.txt +3 -3
- data/ext/tmpfile.c +175 -173
- data/ext/tmpfile.h +9 -9
- data/ext/zip.h +1 -1
- data/ext/zip_error_to_str.c +2 -0
- data/ext/zipint.h +1 -1
- data/ext/zipruby.c +18 -18
- data/ext/zipruby.h +28 -25
- data/ext/zipruby_archive.c +1330 -1326
- data/ext/zipruby_archive.h +23 -23
- data/ext/zipruby_error.c +10 -10
- data/ext/zipruby_error.h +6 -6
- data/ext/zipruby_file.c +398 -404
- data/ext/zipruby_file.h +23 -23
- data/ext/zipruby_stat.c +164 -164
- data/ext/zipruby_stat.h +12 -12
- data/ext/zipruby_zip.c +38 -38
- data/ext/zipruby_zip.h +6 -6
- data/ext/zipruby_zip_source_proc.c +67 -67
- data/ext/zipruby_zip_source_proc.h +14 -14
- data/zipruby.c +2200 -2200
- metadata +5 -6
- data/ext/libzip.mswin32.patch +0 -113
- data/ext/libzip.vcproj +0 -312
- data/ext/libzip.vcproj.LENOVO-72DB7FA8.sugawara.user +0 -37
data/LICENSE.libzip
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
Copyright (C) 1999-2008 Dieter Baron and Thomas Klausner
|
2
|
+
The authors can be contacted at <libzip@nih.at>
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
5
|
+
modification, are permitted provided that the following conditions
|
6
|
+
are met:
|
7
|
+
1. Redistributions of source code must retain the above copyright
|
8
|
+
notice, this list of conditions and the following disclaimer.
|
9
|
+
2. Redistributions in binary form must reproduce the above copyright
|
10
|
+
notice, this list of conditions and the following disclaimer in
|
11
|
+
the documentation and/or other materials provided with the
|
12
|
+
distribution.
|
13
|
+
3. The names of the authors may not be used to endorse or promote
|
14
|
+
products derived from this software without specific prior
|
15
|
+
written permission.
|
16
|
+
|
17
|
+
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
|
18
|
+
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
19
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
20
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
21
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
22
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
23
|
+
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
24
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
25
|
+
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
26
|
+
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
27
|
+
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.txt
CHANGED
@@ -155,14 +155,14 @@ https://rubyforge.org/frs/?group_id=6124
|
|
155
155
|
Zip::Archive.encrypt('filename.zip', 'password')
|
156
156
|
# or
|
157
157
|
# Zip::Archive.encrypt('filename.zip') do |ar|
|
158
|
-
# ar.encrypt('
|
158
|
+
# ar.encrypt('password')
|
159
159
|
# end
|
160
160
|
|
161
161
|
# decrypt
|
162
162
|
Zip::Archive.decrypt('filename.zip', 'password')
|
163
163
|
# or
|
164
164
|
# Zip::Archive.decrypt('filename.zip') do |ar|
|
165
|
-
# ar.decrypt('
|
165
|
+
# ar.decrypt('password')
|
166
166
|
# end
|
167
167
|
|
168
168
|
=== modifying zip data in memory
|
@@ -199,7 +199,7 @@ https://rubyforge.org/frs/?group_id=6124
|
|
199
199
|
end
|
200
200
|
|
201
201
|
== License
|
202
|
-
Copyright (c) 2008 SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
|
202
|
+
Copyright (c) 2008,2009 SUGAWARA Genki <sgwr_dts@yahoo.co.jp>
|
203
203
|
All rights reserved.
|
204
204
|
|
205
205
|
Redistribution and use in source and binary forms, with or without modification,
|
data/ext/tmpfile.c
CHANGED
@@ -1,173 +1,175 @@
|
|
1
|
-
#include <stdio.h>
|
2
|
-
#include <stdlib.h>
|
3
|
-
#include <string.h>
|
4
|
-
#include <sys/types.h>
|
5
|
-
#include <sys/stat.h>
|
6
|
-
|
7
|
-
#ifdef _WIN32
|
8
|
-
#
|
9
|
-
#include <
|
10
|
-
#
|
11
|
-
#include <
|
12
|
-
#
|
13
|
-
|
14
|
-
#
|
15
|
-
|
16
|
-
|
17
|
-
#
|
18
|
-
|
19
|
-
|
20
|
-
#
|
21
|
-
|
22
|
-
#
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
#
|
85
|
-
int
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
#
|
141
|
-
|
142
|
-
#
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
1
|
+
#include <stdio.h>
|
2
|
+
#include <stdlib.h>
|
3
|
+
#include <string.h>
|
4
|
+
#include <sys/types.h>
|
5
|
+
#include <sys/stat.h>
|
6
|
+
|
7
|
+
#ifdef _WIN32
|
8
|
+
#if RUBY_VERSION_MAJOR == 1 && RUBY_VERSION_MINOR == 8
|
9
|
+
#include <windows.h>
|
10
|
+
#endif
|
11
|
+
#include <io.h>
|
12
|
+
#include <fcntl.h>
|
13
|
+
#include <share.h>
|
14
|
+
#endif
|
15
|
+
|
16
|
+
#include "tmpfile.h"
|
17
|
+
#include "ruby.h"
|
18
|
+
|
19
|
+
#ifndef _WIN32
|
20
|
+
#ifndef HAVE_MKSTEMP
|
21
|
+
int _zip_mkstemp(char *);
|
22
|
+
#define mkstemp _zip_mkstemp
|
23
|
+
#endif
|
24
|
+
#endif
|
25
|
+
|
26
|
+
static int write_from_proc(VALUE proc, int fd);
|
27
|
+
static VALUE proc_call(VALUE proc);
|
28
|
+
|
29
|
+
char *zipruby_tmpnam(void *data, int len) {
|
30
|
+
char *filnam;
|
31
|
+
|
32
|
+
#ifdef _WIN32
|
33
|
+
int fd;
|
34
|
+
char tmpdirnam[_MAX_PATH];
|
35
|
+
char tmpfilnam[_MAX_PATH];
|
36
|
+
int namlen;
|
37
|
+
|
38
|
+
memset(tmpdirnam, 0, _MAX_PATH);
|
39
|
+
|
40
|
+
if (GetTempPathA(_MAX_PATH, tmpdirnam) == 0) {
|
41
|
+
return NULL;
|
42
|
+
}
|
43
|
+
|
44
|
+
memset(tmpfilnam, 0, _MAX_PATH);
|
45
|
+
|
46
|
+
if (GetTempFileNameA(tmpdirnam, "zrb", 0, tmpfilnam) == 0) {
|
47
|
+
return NULL;
|
48
|
+
}
|
49
|
+
|
50
|
+
namlen = strlen(tmpfilnam) + 1;
|
51
|
+
|
52
|
+
if ((filnam = calloc(namlen, sizeof(char))) == NULL) {
|
53
|
+
return NULL;
|
54
|
+
}
|
55
|
+
|
56
|
+
if (strcpy_s(filnam, namlen, tmpfilnam) != 0) {
|
57
|
+
free(filnam);
|
58
|
+
return NULL;
|
59
|
+
}
|
60
|
+
|
61
|
+
if (data) {
|
62
|
+
if ((_sopen_s(&fd, filnam, _O_WRONLY | _O_BINARY, _SH_DENYRD, _S_IWRITE)) != 0) {
|
63
|
+
free(filnam);
|
64
|
+
return NULL;
|
65
|
+
}
|
66
|
+
|
67
|
+
if (len < 0) {
|
68
|
+
if (write_from_proc((VALUE) data, fd) == -1) {
|
69
|
+
free(filnam);
|
70
|
+
return NULL;
|
71
|
+
}
|
72
|
+
} else {
|
73
|
+
if (_write(fd, data, len) == -1) {
|
74
|
+
free(filnam);
|
75
|
+
return NULL;
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
if (_close(fd) == -1) {
|
80
|
+
free(filnam);
|
81
|
+
return NULL;
|
82
|
+
}
|
83
|
+
}
|
84
|
+
#else
|
85
|
+
int fd;
|
86
|
+
#ifdef P_tmpdir
|
87
|
+
int namlen = 16 + strlen(P_tmpdir);
|
88
|
+
char *dirnam = P_tmpdir;
|
89
|
+
#else
|
90
|
+
int namlen = 20;
|
91
|
+
char *dirnam = "/tmp";
|
92
|
+
#endif
|
93
|
+
|
94
|
+
if ((filnam = calloc(namlen, sizeof(char))) == NULL) {
|
95
|
+
return NULL;
|
96
|
+
}
|
97
|
+
|
98
|
+
strcpy(filnam, dirnam);
|
99
|
+
strcat(filnam, "/zipruby.XXXXXX");
|
100
|
+
|
101
|
+
if ((fd = mkstemp(filnam)) == -1) {
|
102
|
+
free(filnam);
|
103
|
+
return NULL;
|
104
|
+
}
|
105
|
+
|
106
|
+
if (data) {
|
107
|
+
if (len < 0) {
|
108
|
+
if (write_from_proc((VALUE) data, fd) == -1) {
|
109
|
+
free(filnam);
|
110
|
+
return NULL;
|
111
|
+
}
|
112
|
+
} else {
|
113
|
+
if (write(fd, data, len) == -1) {
|
114
|
+
free(filnam);
|
115
|
+
return NULL;
|
116
|
+
}
|
117
|
+
}
|
118
|
+
}
|
119
|
+
|
120
|
+
if (close(fd) == -1) {
|
121
|
+
free(filnam);
|
122
|
+
return NULL;
|
123
|
+
}
|
124
|
+
#endif
|
125
|
+
|
126
|
+
return filnam;
|
127
|
+
}
|
128
|
+
|
129
|
+
void zipruby_rmtmp(const char *tmpfilnam) {
|
130
|
+
struct stat st;
|
131
|
+
|
132
|
+
if (!tmpfilnam) {
|
133
|
+
return;
|
134
|
+
}
|
135
|
+
|
136
|
+
if (stat(tmpfilnam, &st) != 0) {
|
137
|
+
return;
|
138
|
+
}
|
139
|
+
|
140
|
+
#ifdef _WIN32
|
141
|
+
_unlink(tmpfilnam);
|
142
|
+
#else
|
143
|
+
unlink(tmpfilnam);
|
144
|
+
#endif
|
145
|
+
}
|
146
|
+
|
147
|
+
static int write_from_proc(VALUE proc, int fd) {
|
148
|
+
while (1) {
|
149
|
+
VALUE src = rb_protect(proc_call, proc, NULL);
|
150
|
+
|
151
|
+
if (TYPE(src) != T_STRING) {
|
152
|
+
break;
|
153
|
+
}
|
154
|
+
|
155
|
+
if (RSTRING_LEN(src) < 1) {
|
156
|
+
break;
|
157
|
+
}
|
158
|
+
|
159
|
+
#ifdef _WIN32
|
160
|
+
if (_write(fd, RSTRING_PTR(src), RSTRING_LEN(src)) == -1) {
|
161
|
+
return -1;
|
162
|
+
}
|
163
|
+
#else
|
164
|
+
if (write(fd, RSTRING_PTR(src), RSTRING_LEN(src)) == -1) {
|
165
|
+
return -1;
|
166
|
+
}
|
167
|
+
#endif
|
168
|
+
}
|
169
|
+
|
170
|
+
return 0;
|
171
|
+
}
|
172
|
+
|
173
|
+
static VALUE proc_call(VALUE proc) {
|
174
|
+
return rb_funcall(proc, rb_intern("call"), 0);
|
175
|
+
}
|
data/ext/tmpfile.h
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
#ifndef __TMPFILE_H__
|
2
|
-
#define __TMPFILE_H__
|
3
|
-
|
4
|
-
#include <stdio.h>
|
5
|
-
|
6
|
-
char *zipruby_tmpnam(void *data, int len);
|
7
|
-
void zipruby_rmtmp(const char *tmpfilnam);
|
8
|
-
|
9
|
-
#endif
|
1
|
+
#ifndef __TMPFILE_H__
|
2
|
+
#define __TMPFILE_H__
|
3
|
+
|
4
|
+
#include <stdio.h>
|
5
|
+
|
6
|
+
char *zipruby_tmpnam(void *data, int len);
|
7
|
+
void zipruby_rmtmp(const char *tmpfilnam);
|
8
|
+
|
9
|
+
#endif
|
data/ext/zip.h
CHANGED
data/ext/zip_error_to_str.c
CHANGED
data/ext/zipint.h
CHANGED
data/ext/zipruby.c
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
#ifdef _WIN32
|
2
|
-
__declspec(dllexport) void Init_zipruby(void);
|
3
|
-
#endif
|
4
|
-
|
5
|
-
#include "zipruby.h"
|
6
|
-
#include "zipruby_zip.h"
|
7
|
-
#include "zipruby_archive.h"
|
8
|
-
#include "zipruby_file.h"
|
9
|
-
#include "zipruby_stat.h"
|
10
|
-
#include "zipruby_error.h"
|
11
|
-
|
12
|
-
void Init_zipruby() {
|
13
|
-
Init_zipruby_zip();
|
14
|
-
Init_zipruby_archive();
|
15
|
-
Init_zipruby_file();
|
16
|
-
Init_zipruby_stat();
|
17
|
-
Init_zipruby_error();
|
18
|
-
}
|
1
|
+
#ifdef _WIN32
|
2
|
+
__declspec(dllexport) void Init_zipruby(void);
|
3
|
+
#endif
|
4
|
+
|
5
|
+
#include "zipruby.h"
|
6
|
+
#include "zipruby_zip.h"
|
7
|
+
#include "zipruby_archive.h"
|
8
|
+
#include "zipruby_file.h"
|
9
|
+
#include "zipruby_stat.h"
|
10
|
+
#include "zipruby_error.h"
|
11
|
+
|
12
|
+
void Init_zipruby() {
|
13
|
+
Init_zipruby_zip();
|
14
|
+
Init_zipruby_archive();
|
15
|
+
Init_zipruby_file();
|
16
|
+
Init_zipruby_stat();
|
17
|
+
Init_zipruby_error();
|
18
|
+
}
|
data/ext/zipruby.h
CHANGED
@@ -1,25 +1,28 @@
|
|
1
|
-
#ifndef __ZIPRUBY_H__
|
2
|
-
#define __ZIPRUBY_H__
|
3
|
-
|
4
|
-
#include "ruby.h"
|
5
|
-
|
6
|
-
#ifndef RSTRING_PTR
|
7
|
-
#define RSTRING_PTR(s) (RSTRING(s)->ptr)
|
8
|
-
#endif
|
9
|
-
#ifndef RSTRING_LEN
|
10
|
-
#define RSTRING_LEN(s) (RSTRING(s)->len)
|
11
|
-
#endif
|
12
|
-
|
13
|
-
#define Check_IO(x) do { \
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
}
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
1
|
+
#ifndef __ZIPRUBY_H__
|
2
|
+
#define __ZIPRUBY_H__
|
3
|
+
|
4
|
+
#include "ruby.h"
|
5
|
+
|
6
|
+
#ifndef RSTRING_PTR
|
7
|
+
#define RSTRING_PTR(s) (RSTRING(s)->ptr)
|
8
|
+
#endif
|
9
|
+
#ifndef RSTRING_LEN
|
10
|
+
#define RSTRING_LEN(s) (RSTRING(s)->len)
|
11
|
+
#endif
|
12
|
+
|
13
|
+
#define Check_IO(x) do { \
|
14
|
+
const char *classname = rb_class2name(CLASS_OF(x)); \
|
15
|
+
if (rb_obj_is_kind_of((x), rb_cIO)) { \
|
16
|
+
rb_io_binmode(x); \
|
17
|
+
} else if (strcmp(classname, "StringIO") != 0) { \
|
18
|
+
rb_raise(rb_eTypeError, "wrong argument type %s (expected IO or StringIO)", classname); \
|
19
|
+
} \
|
20
|
+
} while(0)
|
21
|
+
|
22
|
+
#define VERSION "0.3.0"
|
23
|
+
#define ERRSTR_BUFSIZE 256
|
24
|
+
#define DATA_BUFSIZE 8192
|
25
|
+
|
26
|
+
void Init_zipruby();
|
27
|
+
|
28
|
+
#endif
|