diff options
Diffstat (limited to 'contrib/minizip/minizip.c')
-rw-r--r-- | contrib/minizip/minizip.c | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/contrib/minizip/minizip.c b/contrib/minizip/minizip.c index 5746f5c..918c322 100644 --- a/contrib/minizip/minizip.c +++ b/contrib/minizip/minizip.c | |||
@@ -1,3 +1,10 @@ | |||
1 | /* | ||
2 | minizip.c | ||
3 | Version 1.01b, May 30th, 2004 | ||
4 | |||
5 | Copyright (C) 1998-2004 Gilles Vollant | ||
6 | */ | ||
7 | |||
1 | #include <stdio.h> | 8 | #include <stdio.h> |
2 | #include <stdlib.h> | 9 | #include <stdlib.h> |
3 | #include <string.h> | 10 | #include <string.h> |
@@ -53,8 +60,8 @@ uLong filetime(f, tmzip, dt) | |||
53 | #else | 60 | #else |
54 | #ifdef unix | 61 | #ifdef unix |
55 | uLong filetime(f, tmzip, dt) | 62 | uLong filetime(f, tmzip, dt) |
56 | char *f; /* name of file to get info on */ | 63 | char *f; /* name of file to get info on */ |
57 | tm_zip *tmzip; /* return value: access, modific. and creation times */ | 64 | tm_zip *tmzip; /* return value: access, modific. and creation times */ |
58 | uLong *dt; /* dostime */ | 65 | uLong *dt; /* dostime */ |
59 | { | 66 | { |
60 | int ret=0; | 67 | int ret=0; |
@@ -66,6 +73,8 @@ uLong filetime(f, tmzip, dt) | |||
66 | { | 73 | { |
67 | char name[MAXFILENAME+1]; | 74 | char name[MAXFILENAME+1]; |
68 | int len = strlen(f); | 75 | int len = strlen(f); |
76 | if (len > MAXFILENAME) | ||
77 | len = MAXFILENAME; | ||
69 | 78 | ||
70 | strncpy(name, f,MAXFILENAME-1); | 79 | strncpy(name, f,MAXFILENAME-1); |
71 | /* strncpy doesnt append the trailing NULL, of the string is too long. */ | 80 | /* strncpy doesnt append the trailing NULL, of the string is too long. */ |
@@ -120,7 +129,7 @@ int check_exist_file(filename) | |||
120 | 129 | ||
121 | void do_banner() | 130 | void do_banner() |
122 | { | 131 | { |
123 | printf("MiniZip 1.00, demo of zLib + Zip package written by Gilles Vollant\n"); | 132 | printf("MiniZip 1.01b, demo of zLib + Zip package written by Gilles Vollant\n"); |
124 | printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n"); | 133 | printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n"); |
125 | } | 134 | } |
126 | 135 | ||
@@ -269,8 +278,13 @@ int main(argc,argv) | |||
269 | do | 278 | do |
270 | { | 279 | { |
271 | char answer[128]; | 280 | char answer[128]; |
272 | printf("The file %s exist. Overwrite ? [y]es, [n]o, [a]ppend : ",filename_try); | 281 | int ret; |
273 | scanf("%1s",answer); | 282 | printf("The file %s exists. Overwrite ? [y]es, [n]o, [a]ppend : ",filename_try); |
283 | ret = scanf("%1s",answer); | ||
284 | if (ret != 1) | ||
285 | { | ||
286 | exit(EXIT_FAILURE); | ||
287 | } | ||
274 | rep = answer[0] ; | 288 | rep = answer[0] ; |
275 | if ((rep>='a') && (rep<='z')) | 289 | if ((rep>='a') && (rep<='z')) |
276 | rep -= 0x20; | 290 | rep -= 0x20; |
@@ -305,7 +319,12 @@ int main(argc,argv) | |||
305 | 319 | ||
306 | for (i=zipfilenamearg+1;(i<argc) && (err==ZIP_OK);i++) | 320 | for (i=zipfilenamearg+1;(i<argc) && (err==ZIP_OK);i++) |
307 | { | 321 | { |
308 | if (((*(argv[i]))!='-') && ((*(argv[i]))!='/')) | 322 | if (!((((*(argv[i]))=='-') || ((*(argv[i]))=='/')) && |
323 | ((argv[i][1]=='o') || (argv[i][1]=='O') || | ||
324 | (argv[i][1]=='a') || (argv[i][1]=='A') || | ||
325 | (argv[i][1]=='p') || (argv[i][1]=='P') || | ||
326 | ((argv[i][1]>='0') || (argv[i][1]<='9'))) && | ||
327 | (strlen(argv[i]) == 2))) | ||
309 | { | 328 | { |
310 | FILE * fin; | 329 | FILE * fin; |
311 | int size_read; | 330 | int size_read; |
@@ -390,7 +409,11 @@ int main(argc,argv) | |||
390 | errclose = zipClose(zf,NULL); | 409 | errclose = zipClose(zf,NULL); |
391 | if (errclose != ZIP_OK) | 410 | if (errclose != ZIP_OK) |
392 | printf("error in closing %s\n",filename_try); | 411 | printf("error in closing %s\n",filename_try); |
393 | } | 412 | } |
413 | else | ||
414 | { | ||
415 | do_help(); | ||
416 | } | ||
394 | 417 | ||
395 | free(buf); | 418 | free(buf); |
396 | return 0; | 419 | return 0; |