/[zanavi_public1]/navit/navit/maptool/zip.c
ZANavi

Diff of /navit/navit/maptool/zip.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 30 Revision 31
1/**
2 * ZANavi, Zoff Android Navigation system.
3 * Copyright (C) 2011-2012 Zoff <zoff@zoff.cc>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
1/** 20/**
2 * Navit, a modular navigation system. 21 * Navit, a modular navigation system.
3 * Copyright (C) 2005-2008 Navit Team 22 * Copyright (C) 2005-2008 Navit Team
4 * 23 *
5 * This program is free software; you can redistribute it and/or 24 * This program is free software; you can redistribute it and/or
30#include <openssl/evp.h> 49#include <openssl/evp.h>
31#include <openssl/rand.h> 50#include <openssl/rand.h>
32#include <openssl/md5.h> 51#include <openssl/md5.h>
33#endif 52#endif
34 53
35struct zip_info { 54struct zip_info
55{
36 int zipnum; 56 int zipnum;
37 int dir_size; 57 int dir_size;
38 long long offset; 58 long long offset;
39 int compression_level; 59 int compression_level;
40 int maxnamelen; 60 int maxnamelen;
49 MD5_CTX md5_ctx; 69 MD5_CTX md5_ctx;
50#endif 70#endif
51 int md5; 71 int md5;
52}; 72};
53 73
54static int
55zip_write(struct zip_info *info, void *data, int len) 74static int zip_write(struct zip_info *info, void *data, int len)
56{ 75{
57 if (fwrite(data, len, 1, info->res2) != 1) 76 if (fwrite(data, len, 1, info->res2) != 1)
58 return 0; 77 return 0;
59#ifdef HAVE_LIBCRYPTO 78#ifdef HAVE_LIBCRYPTO
60 if (info->md5) 79 if (info->md5)
61 MD5_Update(&info->md5_ctx, data, len); 80 MD5_Update(&info->md5_ctx, data, len);
62#endif 81#endif
63 return 1; 82 return 1;
64} 83}
65 84
66#ifdef HAVE_ZLIB 85#ifdef HAVE_ZLIB
82 101
83 err = deflateInit2(&stream, level, Z_DEFLATED, -15, 9, Z_DEFAULT_STRATEGY); 102 err = deflateInit2(&stream, level, Z_DEFLATED, -15, 9, Z_DEFAULT_STRATEGY);
84 if (err != Z_OK) return err; 103 if (err != Z_OK) return err;
85 104
86 err = deflate(&stream, Z_FINISH); 105 err = deflate(&stream, Z_FINISH);
87 if (err != Z_STREAM_END) { 106 if (err != Z_STREAM_END)
107 {
88 deflateEnd(&stream); 108 deflateEnd(&stream);
89 return err == Z_OK ? Z_BUF_ERROR : err; 109 return err == Z_OK ? Z_BUF_ERROR : err;
90 } 110 }
91 *destLen = stream.total_out; 111 *destLen = stream.total_out;
92 112
93 err = deflateEnd(&stream); 113 err = deflateEnd(&stream);
94 return err; 114 return err;
95} 115}
96#endif 116#endif
97 117
98void
99write_zipmember(struct zip_info *zip_info, char *name, int filelen, char *data, int data_size) 118void write_zipmember(struct zip_info *zip_info, char *name, int filelen, char *data, int data_size)
100{ 119{
101 struct zip_lfh lfh = { 120 struct zip_lfh lfh =
102 0x04034b50, 121 { 0x04034b50, 0x0a, 0x0, 0x0, zip_info->time, zip_info->date, 0x0, 0x0, 0x0, filelen, 0x0, };
103 0x0a,
104 0x0,
105 0x0,
106 zip_info->time,
107 zip_info->date,
108 0x0,
109 0x0,
110 0x0,
111 filelen,
112 0x0,
113 };
114 struct zip_cd cd = { 122 struct zip_cd cd =
115 0x02014b50, 123 { 0x02014b50, 0x17, 0x00, 0x0a, 0x00, 0x0000, 0x0, zip_info->time, zip_info->date, 0x0, 0x0, 0x0, filelen, 0x0000, 0x0000, 0x0000, 0x0000, 0x0, zip_info->offset, };
116 0x17,
117 0x00,
118 0x0a,
119 0x00,
120 0x0000,
121 0x0,
122 zip_info->time,
123 zip_info->date,
124 0x0,
125 0x0,
126 0x0,
127 filelen,
128 0x0000,
129 0x0000,
130 0x0000,
131 0x0000,
132 0x0,
133 zip_info->offset,
134 };
135 struct zip_cd_ext cd_ext = { 124 struct zip_cd_ext cd_ext =
136 0x1, 125 { 0x1, 0x8, zip_info->offset, };
137 0x8,
138 zip_info->offset,
139 };
140#ifdef HAVE_LIBCRYPTO 126#ifdef HAVE_LIBCRYPTO
141 struct zip_enc enc = { 127 struct zip_enc enc =
128 {
142 0x9901, 129 0x9901,
143 0x7, 130 0x7,
144 0x2, 131 0x2,
145 'A','E', 132 'A','E',
146 0x1, 133 0x1,
147 0x0, 134 0x0,
148 }; 135 };
149 unsigned char salt[8], key[34], verify[2], mac[10]; 136 unsigned char salt[8], key[34], verify[2], mac[10];
150#endif 137#endif
151 char filename[filelen+1]; 138 char filename[filelen + 1];
152 int error,crc=0,len,comp_size=data_size; 139 int error, crc = 0, len, comp_size = data_size;
153 uLongf destlen=data_size+data_size/500+12; 140 uLongf destlen = data_size + data_size / 500 + 12;
154 char *compbuffer; 141 char *compbuffer;
155 142
156 compbuffer = malloc(destlen); 143 compbuffer = malloc(destlen);
157 if (!compbuffer) { 144 if (!compbuffer)
145 {
158 fprintf(stderr, "No more memory.\n"); 146 fprintf(stderr, "No more memory.\n");
159 exit (1); 147 exit(1);
160 } 148 }
161#ifdef HAVE_LIBCRYPTO 149#ifdef HAVE_LIBCRYPTO
162 if (zip_info->passwd) { 150 if (zip_info->passwd)
151 {
163 RAND_bytes(salt, sizeof(salt)); 152 RAND_bytes(salt, sizeof(salt));
164 PKCS5_PBKDF2_HMAC_SHA1(zip_info->passwd, strlen(zip_info->passwd), salt, sizeof(salt), 1000, sizeof(key), key); 153 PKCS5_PBKDF2_HMAC_SHA1(zip_info->passwd, strlen(zip_info->passwd), salt, sizeof(salt), 1000, sizeof(key), key);
165 verify[0]=key[32]; 154 verify[0]=key[32];
166 verify[1]=key[33]; 155 verify[1]=key[33];
167 } else { 156 }
157 else
158 {
168#endif 159#endif
169 crc=crc32(0, NULL, 0); 160 crc = crc32(0, NULL, 0);
170 crc=crc32(crc, (unsigned char *)data, data_size); 161 crc = crc32(crc, (unsigned char *) data, data_size);
171#ifdef HAVE_LIBCRYPTO 162#ifdef HAVE_LIBCRYPTO
172 } 163}
173#endif 164#endif
174 lfh.zipmthd=zip_info->compression_level ? 8:0; 165 lfh.zipmthd = zip_info->compression_level ? 8 : 0;
175#ifdef HAVE_ZLIB 166#ifdef HAVE_ZLIB
176 if (zip_info->compression_level) { 167 if (zip_info->compression_level)
168 {
177 error=compress2_int((Byte *)compbuffer, &destlen, (Bytef *)data, data_size, zip_info->compression_level); 169 error=compress2_int((Byte *)compbuffer, &destlen, (Bytef *)data, data_size, zip_info->compression_level);
178 if (error == Z_OK) { 170 if (error == Z_OK)
171 {
179 if (destlen < data_size) { 172 if (destlen < data_size)
173 {
180 data=compbuffer; 174 data=compbuffer;
181 comp_size=destlen; 175 comp_size=destlen;
176 }
182 } else 177 else
183 lfh.zipmthd=0; 178 lfh.zipmthd=0;
179 }
184 } else { 180 else
181 {
185 fprintf(stderr,"compress2 returned %d\n", error); 182 fprintf(stderr,"compress2 returned %d\n", error);
186 } 183 }
187 } 184 }
188#endif 185#endif
189 lfh.zipcrc=crc; 186 lfh.zipcrc = crc;
190 lfh.zipsize=comp_size; 187 lfh.zipsize = comp_size;
191 lfh.zipuncmp=data_size; 188 lfh.zipuncmp = data_size;
192#ifdef HAVE_LIBCRYPTO 189#ifdef HAVE_LIBCRYPTO
193 if (zip_info->passwd) { 190 if (zip_info->passwd)
191 {
194 enc.compress_method=lfh.zipmthd; 192 enc.compress_method=lfh.zipmthd;
195 lfh.zipmthd=99; 193 lfh.zipmthd=99;
196 lfh.zipxtraln+=sizeof(enc); 194 lfh.zipxtraln+=sizeof(enc);
197 lfh.zipgenfld|=1; 195 lfh.zipgenfld|=1;
198 lfh.zipsize+=sizeof(salt)+sizeof(verify)+sizeof(mac); 196 lfh.zipsize+=sizeof(salt)+sizeof(verify)+sizeof(mac);
199 } 197 }
200#endif 198#endif
201 cd.zipccrc=crc; 199 cd.zipccrc = crc;
202 cd.zipcsiz=lfh.zipsize; 200 cd.zipcsiz = lfh.zipsize;
203 cd.zipcunc=data_size; 201 cd.zipcunc = data_size;
204 cd.zipcmthd=lfh.zipmthd; 202 cd.zipcmthd = lfh.zipmthd;
205 if (zip_info->zip64) { 203 if (zip_info->zip64)
204 {
206 cd.zipofst=0xffffffff; 205 cd.zipofst = 0xffffffff;
207 cd.zipcxtl+=sizeof(cd_ext); 206 cd.zipcxtl += sizeof(cd_ext);
208 } 207 }
209#ifdef HAVE_LIBCRYPTO 208#ifdef HAVE_LIBCRYPTO
210 if (zip_info->passwd) { 209 if (zip_info->passwd)
210 {
211 cd.zipcmthd=99; 211 cd.zipcmthd=99;
212 cd.zipcxtl+=sizeof(enc); 212 cd.zipcxtl+=sizeof(enc);
213 cd.zipcflg|=1; 213 cd.zipcflg|=1;
214 } 214 }
215#endif 215#endif
216 strcpy(filename, name); 216 strcpy(filename, name);
217 len=strlen(filename); 217 len = strlen(filename);
218 while (len < filelen) { 218 while (len < filelen)
219 {
219 filename[len++]='_'; 220 filename[len++] = '_';
220 } 221 }
221 filename[filelen]='\0'; 222 filename[filelen] = '\0';
222 zip_write(zip_info, &lfh, sizeof(lfh)); 223 zip_write(zip_info, &lfh, sizeof(lfh));
223 zip_write(zip_info, filename, filelen); 224 zip_write(zip_info, filename, filelen);
224 zip_info->offset+=sizeof(lfh)+filelen; 225 zip_info->offset += sizeof(lfh) + filelen;
225#ifdef HAVE_LIBCRYPTO 226#ifdef HAVE_LIBCRYPTO
226 if (zip_info->passwd) { 227 if (zip_info->passwd)
228 {
227 unsigned char counter[16], xor[16], *datap=(unsigned char *)data; 229 unsigned char counter[16], xor[16], *datap=(unsigned char *)data;
228 int size=comp_size; 230 int size=comp_size;
229 AES_KEY aeskey; 231 AES_KEY aeskey;
230 zip_write(zip_info, &enc, sizeof(enc)); 232 zip_write(zip_info, &enc, sizeof(enc));
231 zip_write(zip_info, salt, sizeof(salt)); 233 zip_write(zip_info, salt, sizeof(salt));
232 zip_write(zip_info, verify, sizeof(verify)); 234 zip_write(zip_info, verify, sizeof(verify));
233 zip_info->offset+=sizeof(enc)+sizeof(salt)+sizeof(verify); 235 zip_info->offset+=sizeof(enc)+sizeof(salt)+sizeof(verify);
234 AES_set_encrypt_key(key, 128, &aeskey); 236 AES_set_encrypt_key(key, 128, &aeskey);
235 memset(counter, 0, sizeof(counter)); 237 memset(counter, 0, sizeof(counter));
236 while (size > 0) { 238 while (size > 0)
239 {
237 int i,curr_size,idx=0; 240 int i,curr_size,idx=0;
238 do { 241 do
242 {
239 counter[idx]++; 243 counter[idx]++;
240 } while (!counter[idx++]); 244 }while (!counter[idx++]);
241 AES_encrypt(counter, xor, &aeskey); 245 AES_encrypt(counter, xor, &aeskey);
242 curr_size=size; 246 curr_size=size;
243 if (curr_size > sizeof(xor)) 247 if (curr_size > sizeof(xor))
244 curr_size=sizeof(xor); 248 curr_size=sizeof(xor);
245 for (i = 0 ; i < curr_size ; i++) 249 for (i = 0; i < curr_size; i++)
246 *datap++^=xor[i]; 250 *datap++^=xor[i];
247 size-=curr_size; 251 size-=curr_size;
248 } 252 }
249 } 253 }
250#endif 254#endif
251 zip_write(zip_info, data, comp_size); 255 zip_write(zip_info, data, comp_size);
252 zip_info->offset+=comp_size; 256 zip_info->offset += comp_size;
253#ifdef HAVE_LIBCRYPTO 257#ifdef HAVE_LIBCRYPTO
254 if (zip_info->passwd) { 258 if (zip_info->passwd)
259 {
255 unsigned int maclen=sizeof(mac); 260 unsigned int maclen=sizeof(mac);
256 unsigned char mactmp[maclen*2]; 261 unsigned char mactmp[maclen*2];
257 HMAC(EVP_sha1(), key+16, 16, (unsigned char *)data, comp_size, mactmp, &maclen); 262 HMAC(EVP_sha1(), key+16, 16, (unsigned char *)data, comp_size, mactmp, &maclen);
258 zip_write(zip_info, mactmp, sizeof(mac)); 263 zip_write(zip_info, mactmp, sizeof(mac));
259 zip_info->offset+=sizeof(mac); 264 zip_info->offset+=sizeof(mac);
260 } 265 }
261#endif 266#endif
262 fwrite(&cd, sizeof(cd), 1, zip_info->dir); 267 fwrite(&cd, sizeof(cd), 1, zip_info->dir);
263 fwrite(filename, filelen, 1, zip_info->dir); 268 fwrite(filename, filelen, 1, zip_info->dir);
264 zip_info->dir_size+=sizeof(cd)+filelen; 269 zip_info->dir_size += sizeof(cd) + filelen;
265 if (zip_info->zip64) { 270 if (zip_info->zip64)
271 {
266 fwrite(&cd_ext, sizeof(cd_ext), 1, zip_info->dir); 272 fwrite(&cd_ext, sizeof(cd_ext), 1, zip_info->dir);
267 zip_info->dir_size+=sizeof(cd_ext); 273 zip_info->dir_size += sizeof(cd_ext);
268 } 274 }
269#ifdef HAVE_LIBCRYPTO 275#ifdef HAVE_LIBCRYPTO
270 if (zip_info->passwd) { 276 if (zip_info->passwd)
277 {
271 fwrite(&enc, sizeof(enc), 1, zip_info->dir); 278 fwrite(&enc, sizeof(enc), 1, zip_info->dir);
272 zip_info->dir_size+=sizeof(enc); 279 zip_info->dir_size+=sizeof(enc);
273 } 280 }
274#endif 281#endif
275 282
276 free(compbuffer); 283 free(compbuffer);
277} 284}
278 285
279void
280zip_write_index(struct zip_info *info) 286void zip_write_index(struct zip_info *info)
281{ 287{
282 int size=ftell(info->index); 288 int size = ftell(info->index);
283 char buffer[size]; 289 char *buffer99 = NULL;
284 290 buffer99 = malloc(size);
285 fseek(info->index, 0, SEEK_SET); 291 fseek(info->index, 0, SEEK_SET);
286 fread(buffer, size, 1, info->index); 292 fread(buffer99, size, 1, info->index);
287 write_zipmember(info, "index", strlen("index"), buffer, size); 293 write_zipmember(info, "index", strlen("index"), buffer99, size);
288 info->zipnum++; 294 info->zipnum++;
295 free(buffer99);
289} 296}
290 297
291static void
292zip_write_file_data(struct zip_info *info, FILE *in) 298static void zip_write_file_data(struct zip_info *info, FILE *in)
293{ 299{
294 size_t size; 300 size_t size;
295 char buffer[4096]; 301 char buffer[4096];
296 while ((size=fread(buffer, 1, 4096, in))) 302 while ((size = fread(buffer, 1, 4096, in)))
303 {
297 zip_write(info, buffer, size); 304 zip_write(info, buffer, size);
305 }
298} 306}
299 307
300int
301zip_write_directory(struct zip_info *info) 308int zip_write_directory(struct zip_info *info)
302{ 309{
303 struct zip_eoc eoc = { 310 struct zip_eoc eoc =
304 0x06054b50, 311 { 0x06054b50, 0x0000, 0x0000, 0x0000, 0x0000, 0x0, 0x0, 0x0, };
305 0x0000,
306 0x0000,
307 0x0000,
308 0x0000,
309 0x0,
310 0x0,
311 0x0,
312 };
313 struct zip64_eoc eoc64 = { 312 struct zip64_eoc eoc64 =
314 0x06064b50, 313 { 0x06064b50, 0x0, 0x0, 0x0403, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, };
315 0x0,
316 0x0,
317 0x0403,
318 0x0,
319 0x0,
320 0x0,
321 0x0,
322 0x0,
323 0x0,
324 };
325 struct zip64_eocl eocl = { 314 struct zip64_eocl eocl =
326 0x07064b50, 315 { 0x07064b50, 0x0, 0x0, 0x0, };
327 0x0,
328 0x0,
329 0x0,
330 };
331 316
332 fseek(info->dir, 0, SEEK_SET); 317 fseek(info->dir, 0, SEEK_SET);
333 zip_write_file_data(info, info->dir); 318 zip_write_file_data(info, info->dir);
334 if (info->zip64) { 319 if (info->zip64)
320 {
335 eoc64.zip64esize=sizeof(eoc64)-12; 321 eoc64.zip64esize = sizeof(eoc64) - 12;
336 eoc64.zip64enum=info->zipnum; 322 eoc64.zip64enum = info->zipnum;
337 eoc64.zip64ecenn=info->zipnum; 323 eoc64.zip64ecenn = info->zipnum;
338 eoc64.zip64ecsz=info->dir_size; 324 eoc64.zip64ecsz = info->dir_size;
339 eoc64.zip64eofst=info->offset; 325 eoc64.zip64eofst = info->offset;
340 zip_write(info, &eoc64, sizeof(eoc64)); 326 zip_write(info, &eoc64, sizeof(eoc64));
341 eocl.zip64lofst=info->offset+info->dir_size; 327 eocl.zip64lofst = info->offset + info->dir_size;
342 zip_write(info, &eocl, sizeof(eocl)); 328 zip_write(info, &eocl, sizeof(eocl));
343 } 329 }
344 eoc.zipenum=info->zipnum; 330 eoc.zipenum = info->zipnum;
345 eoc.zipecenn=info->zipnum; 331 eoc.zipecenn = info->zipnum;
346 eoc.zipecsz=info->dir_size; 332 eoc.zipecsz = info->dir_size;
347 eoc.zipeofst=info->offset; 333 eoc.zipeofst = info->offset;
348 zip_write(info, &eoc, sizeof(eoc)); 334 zip_write(info, &eoc, sizeof(eoc));
349 sig_alrm(0); 335 //sig_alrm(0);
350#ifndef _WIN32 336#ifndef _WIN32
351 alarm(0); 337 //alarm(0);
352#endif 338#endif
353 return 0; 339 return 0;
354} 340}
355 341
356struct zip_info * 342struct zip_info *
357zip_new(void) 343zip_new(void)
358{ 344{
359 return g_new0(struct zip_info, 1); 345return g_new0(struct zip_info, 1);
360} 346}
361 347
362void
363zip_set_md5(struct zip_info *info, int on) 348void zip_set_md5(struct zip_info *info, int on)
364{ 349{
365#ifdef HAVE_LIBCRYPTO 350#ifdef HAVE_LIBCRYPTO
366 info->md5=on; 351 info->md5=on;
367 if (on) 352 if (on)
368 MD5_Init(&info->md5_ctx); 353 MD5_Init(&info->md5_ctx);
369#endif 354#endif
370} 355}
371 356
372int
373zip_get_md5(struct zip_info *info, unsigned char *out) 357int zip_get_md5(struct zip_info *info, unsigned char *out)
374{ 358{
375 if (!info->md5) 359 if (!info->md5)
376 return 0; 360 return 0;
377#ifdef HAVE_LIBCRYPTO 361#ifdef HAVE_LIBCRYPTO
378 MD5_Final(out, &info->md5_ctx); 362 MD5_Final(out, &info->md5_ctx);
379 return 1; 363 return 1;
380#endif 364#endif
381 return 0; 365 return 0;
382} 366}
383 367
384void
385zip_set_zip64(struct zip_info *info, int on) 368void zip_set_zip64(struct zip_info *info, int on)
386{ 369{
387 info->zip64=on; 370 info->zip64 = on;
388} 371}
389 372
390void
391zip_set_compression_level(struct zip_info *info, int level) 373void zip_set_compression_level(struct zip_info *info, int level)
392{ 374{
393 info->compression_level=level; 375 info->compression_level = level;
394} 376}
395 377
396void
397zip_set_maxnamelen(struct zip_info *info, int max) 378void zip_set_maxnamelen(struct zip_info *info, int max)
398{ 379{
399 info->maxnamelen=max; 380 info->maxnamelen = max;
400} 381}
401 382
402int
403zip_get_maxnamelen(struct zip_info *info) 383int zip_get_maxnamelen(struct zip_info *info)
404{ 384{
405 return info->maxnamelen; 385 return info->maxnamelen;
406} 386}
407 387
408int
409zip_add_member(struct zip_info *info) 388int zip_add_member(struct zip_info *info)
410{ 389{
411 return info->zipnum++; 390 return info->zipnum++;
412} 391}
413 392
414
415int
416zip_set_timestamp(struct zip_info *info, char *timestamp) 393int zip_set_timestamp(struct zip_info *info, char *timestamp)
417{ 394{
418 int year,month,day,hour,min,sec; 395 int year, month, day, hour, min, sec;
419 396
420 if (sscanf(timestamp,"%d-%d-%dT%d:%d:%d",&year,&month,&day,&hour,&min,&sec) == 6) { 397 if (sscanf(timestamp, "%d-%d-%dT%d:%d:%d", &year, &month, &day, &hour, &min, &sec) == 6)
398 {
421 info->date=day | (month << 5) | ((year-1980) << 9); 399 info->date = day | (month << 5) | ((year - 1980) << 9);
422 info->time=(sec >> 1) | (min << 5) | (hour << 11); 400 info->time = (sec >> 1) | (min << 5) | (hour << 11);
423 return 1; 401 return 1;
424 } 402 }
425 return 0; 403 return 0;
426} 404}
427 405
428int
429zip_set_password(struct zip_info *info, char *passwd) 406int zip_set_password(struct zip_info *info, char *passwd)
430{ 407{
431 info->passwd=passwd; 408 info->passwd = passwd;
432 return 1; 409 return 1;
433} 410}
434 411
435
436void
437zip_open(struct zip_info *info, char *out, char *dir, char *index) 412void zip_open(struct zip_info *info, char *out, char *dir, char *index)
438{ 413{
439 info->res2=fopen(out,"wb+"); 414 info->res2 = fopen(out, "wb+");
440 info->dir=fopen(dir,"wb+"); 415 info->dir = fopen(dir, "wb+");
441 info->index=fopen(index,"wb+"); 416 info->index = fopen(index, "wb+");
442} 417}
443 418
444FILE * 419FILE *
445zip_get_index(struct zip_info *info) 420zip_get_index(struct zip_info *info)
446{ 421{
447 return info->index; 422 return info->index;
448} 423}
449 424
450int
451zip_get_zipnum(struct zip_info *info) 425int zip_get_zipnum(struct zip_info *info)
452{ 426{
453 return info->zipnum; 427 return info->zipnum;
454} 428}
455 429
456void
457zip_set_zipnum(struct zip_info *info, int num) 430void zip_set_zipnum(struct zip_info *info, int num)
458{ 431{
459 info->zipnum=num; 432 info->zipnum = num;
460} 433}
461 434
462void
463zip_close(struct zip_info *info) 435void zip_close(struct zip_info *info)
464{ 436{
465 fclose(info->index); 437 fclose(info->index);
466 fclose(info->dir); 438 fclose(info->dir);
467 fclose(info->res2); 439 fclose(info->res2);
468} 440}
469 441
470void
471zip_destroy(struct zip_info *info) 442void zip_destroy(struct zip_info *info)
472{ 443{
473 g_free(info); 444 g_free(info);
474} 445}

Legend:
Removed from v.30  
changed lines
  Added in v.31

   
Visit the ZANavi Wiki