zipruby 0.1.1 → 0.1.2

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.

Files changed (60) hide show
  1. data/README.txt +131 -0
  2. data/ext/extconf.rb +1 -1
  3. data/ext/libzip.mswin32.patch +113 -0
  4. data/ext/libzip.vcproj +308 -0
  5. data/ext/libzip.vcproj.IBM-94B792EFFD1.sugawara.user +37 -0
  6. data/ext/mkstemp.c +143 -0
  7. data/ext/zip.h +211 -0
  8. data/ext/zip_add.c +52 -0
  9. data/ext/zip_add_dir.c +83 -0
  10. data/ext/zip_close.c +566 -0
  11. data/ext/zip_delete.c +61 -0
  12. data/ext/zip_dirent.c +531 -0
  13. data/ext/zip_entry_free.c +55 -0
  14. data/ext/zip_entry_new.c +81 -0
  15. data/ext/zip_err_str.c +72 -0
  16. data/ext/zip_error.c +104 -0
  17. data/ext/zip_error_clear.c +47 -0
  18. data/ext/zip_error_get.c +47 -0
  19. data/ext/zip_error_get_sys_type.c +50 -0
  20. data/ext/zip_error_strerror.c +93 -0
  21. data/ext/zip_error_to_str.c +77 -0
  22. data/ext/zip_fclose.c +74 -0
  23. data/ext/zip_file_error_clear.c +47 -0
  24. data/ext/zip_file_error_get.c +47 -0
  25. data/ext/zip_file_get_offset.c +77 -0
  26. data/ext/zip_file_strerror.c +47 -0
  27. data/ext/zip_fopen.c +52 -0
  28. data/ext/zip_fopen_index.c +219 -0
  29. data/ext/zip_fread.c +125 -0
  30. data/ext/zip_free.c +83 -0
  31. data/ext/zip_get_archive_comment.c +63 -0
  32. data/ext/zip_get_file_comment.c +61 -0
  33. data/ext/zip_get_name.c +74 -0
  34. data/ext/zip_get_num_files.c +50 -0
  35. data/ext/zip_memdup.c +58 -0
  36. data/ext/zip_name_locate.c +95 -0
  37. data/ext/zip_new.c +71 -0
  38. data/ext/zip_open.c +520 -0
  39. data/ext/zip_rename.c +52 -0
  40. data/ext/zip_replace.c +81 -0
  41. data/ext/zip_set_archive_comment.c +68 -0
  42. data/ext/zip_set_file_comment.c +69 -0
  43. data/ext/zip_set_name.c +77 -0
  44. data/ext/zip_source_buffer.c +160 -0
  45. data/ext/zip_source_file.c +71 -0
  46. data/ext/zip_source_filep.c +176 -0
  47. data/ext/zip_source_free.c +54 -0
  48. data/ext/zip_source_function.c +62 -0
  49. data/ext/zip_source_zip.c +189 -0
  50. data/ext/zip_stat.c +52 -0
  51. data/ext/zip_stat_index.c +93 -0
  52. data/ext/zip_stat_init.c +53 -0
  53. data/ext/zip_strerror.c +47 -0
  54. data/ext/zip_unchange.c +84 -0
  55. data/ext/zip_unchange_all.c +56 -0
  56. data/ext/zip_unchange_archive.c +52 -0
  57. data/ext/zip_unchange_data.c +53 -0
  58. data/ext/zipint.h +240 -0
  59. data/ext/zipruby.h +1 -1
  60. metadata +63 -5
data/ext/zipint.h ADDED
@@ -0,0 +1,240 @@
1
+ #ifndef _HAD_ZIPINT_H
2
+ #define _HAD_ZIPINT_H
3
+
4
+ /*
5
+ $NiH: zipint.h,v 1.50 2006/10/04 15:21:09 dillo Exp $
6
+
7
+ zipint.h -- internal declarations.
8
+ Copyright (C) 1999-2006 Dieter Baron and Thomas Klausner
9
+
10
+ This file is part of libzip, a library to manipulate ZIP archives.
11
+ The authors can be contacted at <nih@giga.or.at>
12
+
13
+ Redistribution and use in source and binary forms, with or without
14
+ modification, are permitted provided that the following conditions
15
+ are met:
16
+ 1. Redistributions of source code must retain the above copyright
17
+ notice, this list of conditions and the following disclaimer.
18
+ 2. Redistributions in binary form must reproduce the above copyright
19
+ notice, this list of conditions and the following disclaimer in
20
+ the documentation and/or other materials provided with the
21
+ distribution.
22
+ 3. The names of the authors may not be used to endorse or promote
23
+ products derived from this software without specific prior
24
+ written permission.
25
+
26
+ THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
27
+ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
30
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
32
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
34
+ IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
35
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
36
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37
+ */
38
+
39
+ #include <zlib.h>
40
+
41
+ #include "zip.h"
42
+ #ifndef _WIN32
43
+ #include "config.h"
44
+ #endif
45
+
46
+ #ifndef HAVE_MKSTEMP
47
+ int _zip_mkstemp(char *);
48
+ #define mkstemp _zip_mkstemp
49
+ #endif
50
+
51
+ #ifndef HAVE_FSEEKO
52
+ #define fseeko(s, o, w) (fseek((s), (long int)(o), (w)))
53
+ #endif
54
+ #ifndef HAVE_FTELLO
55
+ #define ftello(s) ((long)ftell((s)))
56
+ #endif
57
+
58
+
59
+
60
+ #define CENTRAL_MAGIC "PK\1\2"
61
+ #define LOCAL_MAGIC "PK\3\4"
62
+ #define EOCD_MAGIC "PK\5\6"
63
+ #define DATADES_MAGIC "PK\7\8"
64
+ #define CDENTRYSIZE 46u
65
+ #define LENTRYSIZE 30
66
+ #define MAXCOMLEN 65536
67
+ #define EOCDLEN 22
68
+ #define CDBUFSIZE (MAXCOMLEN+EOCDLEN)
69
+ #define BUFSIZE 8192
70
+
71
+
72
+
73
+ /* state of change of a file in zip archive */
74
+
75
+ enum zip_state { ZIP_ST_UNCHANGED, ZIP_ST_DELETED, ZIP_ST_REPLACED,
76
+ ZIP_ST_ADDED, ZIP_ST_RENAMED };
77
+
78
+ /* constants for struct zip_file's member flags */
79
+
80
+ #define ZIP_ZF_EOF 1 /* EOF reached */
81
+ #define ZIP_ZF_DECOMP 2 /* decompress data */
82
+ #define ZIP_ZF_CRC 4 /* compute and compare CRC */
83
+
84
+ /* directory entry: general purpose bit flags */
85
+
86
+ #define ZIP_GPBF_ENCRYPTED 0x0001 /* is encrypted */
87
+ #define ZIP_GPBF_DATA_DESCRIPTOR 0x0008 /* crc/size after file data */
88
+ #define ZIP_GPBF_STRONG_ENCRYPTION 0x0040 /* uses strong encryption */
89
+
90
+ /* error information */
91
+
92
+ struct zip_error {
93
+ int zip_err; /* libzip error code (ZIP_ER_*) */
94
+ int sys_err; /* copy of errno (E*) or zlib error code */
95
+ char *str; /* string representation or NULL */
96
+ };
97
+
98
+ /* zip archive, part of API */
99
+
100
+ struct zip {
101
+ char *zn; /* file name */
102
+ FILE *zp; /* file */
103
+ struct zip_error error; /* error information */
104
+
105
+ struct zip_cdir *cdir; /* central directory */
106
+ char *ch_comment; /* changed archive comment */
107
+ int ch_comment_len; /* length of changed zip archive
108
+ * comment, -1 if unchanged */
109
+ int nentry; /* number of entries */
110
+ int nentry_alloc; /* number of entries allocated */
111
+ struct zip_entry *entry; /* entries */
112
+ int nfile; /* number of opened files within archive */
113
+ int nfile_alloc; /* number of files allocated */
114
+ struct zip_file **file; /* opened files within archive */
115
+ };
116
+
117
+ /* file in zip archive, part of API */
118
+
119
+ struct zip_file {
120
+ struct zip *za; /* zip archive containing this file */
121
+ struct zip_error error; /* error information */
122
+ int flags; /* -1: eof, >0: error */
123
+
124
+ int method; /* compression method */
125
+ off_t fpos; /* position within zip file (fread/fwrite) */
126
+ unsigned long bytes_left; /* number of bytes left to read */
127
+ unsigned long cbytes_left; /* number of bytes of compressed data left */
128
+
129
+ unsigned long crc; /* CRC so far */
130
+ unsigned long crc_orig; /* CRC recorded in archive */
131
+
132
+ char *buffer;
133
+ z_stream *zstr;
134
+ };
135
+
136
+ /* zip archive directory entry (central or local) */
137
+
138
+ struct zip_dirent {
139
+ unsigned short version_madeby; /* (c) version of creator */
140
+ unsigned short version_needed; /* (cl) version needed to extract */
141
+ unsigned short bitflags; /* (cl) general purpose bit flag */
142
+ unsigned short comp_method; /* (cl) compression method used */
143
+ time_t last_mod; /* (cl) time of last modification */
144
+ unsigned int crc; /* (cl) CRC-32 of uncompressed data */
145
+ unsigned int comp_size; /* (cl) size of commpressed data */
146
+ unsigned int uncomp_size; /* (cl) size of uncommpressed data */
147
+ char *filename; /* (cl) file name (NUL-terminated) */
148
+ unsigned short filename_len; /* (cl) length of filename (w/o NUL) */
149
+ char *extrafield; /* (cl) extra field */
150
+ unsigned short extrafield_len; /* (cl) length of extra field */
151
+ char *comment; /* (c) file comment */
152
+ unsigned short comment_len; /* (c) length of file comment */
153
+ unsigned short disk_number; /* (c) disk number start */
154
+ unsigned short int_attrib; /* (c) internal file attributes */
155
+ unsigned int ext_attrib; /* (c) external file attributes */
156
+ unsigned int offset; /* (c) offset of local header */
157
+ };
158
+
159
+ /* zip archive central directory */
160
+
161
+ struct zip_cdir {
162
+ struct zip_dirent *entry; /* directory entries */
163
+ int nentry; /* number of entries */
164
+
165
+ unsigned int size; /* size of central direcotry */
166
+ unsigned int offset; /* offset of central directory in file */
167
+ char *comment; /* zip archive comment */
168
+ unsigned short comment_len; /* length of zip archive comment */
169
+ };
170
+
171
+
172
+
173
+ struct zip_source {
174
+ zip_source_callback f;
175
+ void *ud;
176
+ };
177
+
178
+ /* entry in zip archive directory */
179
+
180
+ struct zip_entry {
181
+ enum zip_state state;
182
+ struct zip_source *source;
183
+ char *ch_filename;
184
+ char *ch_comment;
185
+ int ch_comment_len;
186
+ };
187
+
188
+
189
+
190
+ extern const char * const _zip_err_str[];
191
+ extern const int _zip_nerr_str;
192
+ extern const int _zip_err_type[];
193
+
194
+
195
+
196
+ #define ZIP_ENTRY_DATA_CHANGED(x) \
197
+ ((x)->state == ZIP_ST_REPLACED \
198
+ || (x)->state == ZIP_ST_ADDED)
199
+
200
+
201
+
202
+ void _zip_cdir_free(struct zip_cdir *);
203
+ struct zip_cdir *_zip_cdir_new(int, struct zip_error *);
204
+ int _zip_cdir_write(struct zip_cdir *, FILE *, struct zip_error *);
205
+
206
+ void _zip_dirent_finalize(struct zip_dirent *);
207
+ void _zip_dirent_init(struct zip_dirent *);
208
+ int _zip_dirent_read(struct zip_dirent *, FILE *,
209
+ unsigned char **, unsigned int, int, struct zip_error *);
210
+ int _zip_dirent_write(struct zip_dirent *, FILE *, int, struct zip_error *);
211
+
212
+ void _zip_entry_free(struct zip_entry *);
213
+ void _zip_entry_init(struct zip *, int);
214
+ struct zip_entry *_zip_entry_new(struct zip *);
215
+
216
+ void _zip_error_clear(struct zip_error *);
217
+ void _zip_error_copy(struct zip_error *, struct zip_error *);
218
+ void _zip_error_fini(struct zip_error *);
219
+ void _zip_error_get(struct zip_error *, int *, int *);
220
+ void _zip_error_init(struct zip_error *);
221
+ void _zip_error_set(struct zip_error *, int, int);
222
+ const char *_zip_error_strerror(struct zip_error *);
223
+
224
+ int _zip_file_fillbuf(void *, size_t, struct zip_file *);
225
+ unsigned int _zip_file_get_offset(struct zip *, int);
226
+
227
+ void _zip_free(struct zip *);
228
+ const char *_zip_get_name(struct zip *, int, int, struct zip_error *);
229
+ int _zip_local_header_read(struct zip *, int);
230
+ void *_zip_memdup(const void *, size_t, struct zip_error *);
231
+ int _zip_name_locate(struct zip *, const char *, int, struct zip_error *);
232
+ struct zip *_zip_new(struct zip_error *);
233
+ unsigned short _zip_read2(unsigned char **);
234
+ unsigned int _zip_read4(unsigned char **);
235
+ int _zip_replace(struct zip *, int, const char *, struct zip_source *);
236
+ int _zip_set_name(struct zip *, int, const char *);
237
+ int _zip_unchange(struct zip *, int, int);
238
+ void _zip_unchange_data(struct zip_entry *);
239
+
240
+ #endif /* zipint.h */
data/ext/zipruby.h CHANGED
@@ -1,7 +1,7 @@
1
1
  #ifndef __ZIPRUBY_H__
2
2
  #define __ZIPRUBY_H__
3
3
 
4
- #define VERSION "0.1.1"
4
+ #define VERSION "0.1.2"
5
5
  #define ERRSTR_BUFSIZE 256
6
6
 
7
7
  void Init_zipruby();
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zipruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - winebarrel
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-04-24 00:00:00 +09:00
12
+ date: 2008-04-26 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -20,21 +20,79 @@ executables: []
20
20
  extensions:
21
21
  - ext/extconf.rb
22
22
  extra_rdoc_files:
23
+ - README.txt
23
24
  - zipruby.c
24
25
  files:
26
+ - ext/extconf.rb
27
+ - ext/libzip.mswin32.patch
28
+ - ext/libzip.vcproj
29
+ - ext/libzip.vcproj.IBM-94B792EFFD1.sugawara.user
30
+ - ext/mkstemp.c
31
+ - ext/zip.h
32
+ - ext/zipint.h
25
33
  - ext/zipruby.c
26
34
  - ext/zipruby.h
27
35
  - ext/zipruby_archive.c
28
36
  - ext/zipruby_archive.h
37
+ - ext/zipruby_error.c
38
+ - ext/zipruby_error.h
29
39
  - ext/zipruby_file.c
30
40
  - ext/zipruby_file.h
31
41
  - ext/zipruby_stat.c
32
42
  - ext/zipruby_stat.h
33
- - ext/zipruby_error.c
34
- - ext/zipruby_error.h
35
43
  - ext/zipruby_zip.c
36
44
  - ext/zipruby_zip.h
37
- - ext/extconf.rb
45
+ - ext/zip_add.c
46
+ - ext/zip_add_dir.c
47
+ - ext/zip_close.c
48
+ - ext/zip_delete.c
49
+ - ext/zip_dirent.c
50
+ - ext/zip_entry_free.c
51
+ - ext/zip_entry_new.c
52
+ - ext/zip_error.c
53
+ - ext/zip_error_clear.c
54
+ - ext/zip_error_get.c
55
+ - ext/zip_error_get_sys_type.c
56
+ - ext/zip_error_strerror.c
57
+ - ext/zip_error_to_str.c
58
+ - ext/zip_err_str.c
59
+ - ext/zip_fclose.c
60
+ - ext/zip_file_error_clear.c
61
+ - ext/zip_file_error_get.c
62
+ - ext/zip_file_get_offset.c
63
+ - ext/zip_file_strerror.c
64
+ - ext/zip_fopen.c
65
+ - ext/zip_fopen_index.c
66
+ - ext/zip_fread.c
67
+ - ext/zip_free.c
68
+ - ext/zip_get_archive_comment.c
69
+ - ext/zip_get_file_comment.c
70
+ - ext/zip_get_name.c
71
+ - ext/zip_get_num_files.c
72
+ - ext/zip_memdup.c
73
+ - ext/zip_name_locate.c
74
+ - ext/zip_new.c
75
+ - ext/zip_open.c
76
+ - ext/zip_rename.c
77
+ - ext/zip_replace.c
78
+ - ext/zip_set_archive_comment.c
79
+ - ext/zip_set_file_comment.c
80
+ - ext/zip_set_name.c
81
+ - ext/zip_source_buffer.c
82
+ - ext/zip_source_file.c
83
+ - ext/zip_source_filep.c
84
+ - ext/zip_source_free.c
85
+ - ext/zip_source_function.c
86
+ - ext/zip_source_zip.c
87
+ - ext/zip_stat.c
88
+ - ext/zip_stat_index.c
89
+ - ext/zip_stat_init.c
90
+ - ext/zip_strerror.c
91
+ - ext/zip_unchange.c
92
+ - ext/zip_unchange_all.c
93
+ - ext/zip_unchange_archive.c
94
+ - ext/zip_unchange_data.c
95
+ - README.txt
38
96
  - zipruby.c
39
97
  has_rdoc: true
40
98
  homepage: http://zipruby.rubyforge.org