summaryrefslogtreecommitdiff
path: root/contrib/minizip/miniunz.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/minizip/miniunz.c')
-rw-r--r--contrib/minizip/miniunz.c84
1 files changed, 28 insertions, 56 deletions
diff --git a/contrib/minizip/miniunz.c b/contrib/minizip/miniunz.c
index 08737f6..5b4312e 100644
--- a/contrib/minizip/miniunz.c
+++ b/contrib/minizip/miniunz.c
@@ -27,7 +27,7 @@
#endif
#endif
-#if defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__)
+#if defined(__APPLE__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64) || defined(__Fuchsia__) || defined(__ANDROID_API__)
// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
#define FTELLO_FUNC(stream) ftello(stream)
@@ -81,11 +81,7 @@
filename : the filename of the file where date/time must be modified
dosdate : the new date at the MSDos format (4 bytes)
tmu_date : the SAME new date at the tm_unz format */
-void change_file_date(filename,dosdate,tmu_date)
- const char *filename;
- uLong dosdate;
- tm_unz tmu_date;
-{
+static void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_date) {
#ifdef _WIN32
HANDLE hFile;
FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite;
@@ -99,6 +95,7 @@ void change_file_date(filename,dosdate,tmu_date)
CloseHandle(hFile);
#else
#if defined(unix) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__)
+ (void)dosdate;
struct utimbuf ut;
struct tm newdate;
newdate.tm_sec = tmu_date.tm_sec;
@@ -114,6 +111,10 @@ void change_file_date(filename,dosdate,tmu_date)
ut.actime=ut.modtime=mktime(&newdate);
utime(filename,&ut);
+#else
+ (void)filename;
+ (void)dosdate;
+ (void)tmu_date;
#endif
#endif
}
@@ -122,26 +123,24 @@ void change_file_date(filename,dosdate,tmu_date)
/* mymkdir and change_file_date are not 100 % portable
As I don't know well Unix, I wait feedback for the unix portion */
-int mymkdir(dirname)
- const char* dirname;
-{
+static int mymkdir(const char* dirname) {
int ret=0;
#if defined(_WIN32)
ret = _mkdir(dirname);
#elif defined(unix) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__ANDROID_API__)
ret = mkdir (dirname,0775);
+#else
+ (void)dirname;
#endif
return ret;
}
-int makedir (newdir)
- char *newdir;
-{
+static int makedir(const char *newdir) {
char *buffer ;
char *p;
- int len = (int)strlen(newdir);
+ size_t len = strlen(newdir);
- if (len <= 0)
+ if (len == 0)
return 0;
buffer = (char*)malloc(len+1);
@@ -184,14 +183,12 @@ int makedir (newdir)
return 1;
}
-void do_banner()
-{
- printf("MiniUnz 1.01b, demo of zLib + Unz package written by Gilles Vollant\n");
+static void do_banner(void) {
+ printf("MiniUnz 1.1, demo of zLib + Unz package written by Gilles Vollant\n");
printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n");
}
-void do_help()
-{
+static void do_help(void) {
printf("Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.] [-d extractdir]\n\n" \
" -e Extract without pathname (junk paths)\n" \
" -x Extract with pathname\n" \
@@ -199,11 +196,10 @@ void do_help()
" -l list files\n" \
" -d directory to extract into\n" \
" -o overwrite files without prompting\n" \
- " -p extract crypted file using password\n\n");
+ " -p extract encrypted file using password\n\n");
}
-void Display64BitsSize(ZPOS64_T n, int size_char)
-{
+static void Display64BitsSize(ZPOS64_T n, int size_char) {
/* to avoid compatibility problem , we do here the conversion */
char number[21];
int offset=19;
@@ -230,9 +226,7 @@ void Display64BitsSize(ZPOS64_T n, int size_char)
printf("%s",&number[pos_string]);
}
-int do_list(uf)
- unzFile uf;
-{
+static int do_list(unzFile uf) {
uLong i;
unz_global_info64 gi;
int err;
@@ -247,7 +241,7 @@ int do_list(uf)
char filename_inzip[256];
unz_file_info64 file_info;
uLong ratio=0;
- const char *string_method;
+ const char *string_method = "";
char charCrypt=' ';
err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
if (err!=UNZ_OK)
@@ -258,7 +252,7 @@ int do_list(uf)
if (file_info.uncompressed_size>0)
ratio = (uLong)((file_info.compressed_size*100)/file_info.uncompressed_size);
- /* display a '*' if the file is crypted */
+ /* display a '*' if the file is encrypted */
if ((file_info.flag & 1) != 0)
charCrypt='*';
@@ -308,12 +302,7 @@ int do_list(uf)
}
-int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
- unzFile uf;
- const int* popt_extract_without_path;
- int* popt_overwrite;
- const char* password;
-{
+static int do_extract_currentfile(unzFile uf, const int* popt_extract_without_path, int* popt_overwrite, const char* password) {
char filename_inzip[256];
char* filename_withoutpath;
char* p;
@@ -323,7 +312,6 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
uInt size_buf;
unz_file_info64 file_info;
- uLong ratio=0;
err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
if (err!=UNZ_OK)
@@ -438,7 +426,7 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
break;
}
if (err>0)
- if (fwrite(buf,err,1,fout)!=1)
+ if (fwrite(buf,(unsigned)err,1,fout)!=1)
{
printf("error in writing extracted file\n");
err=UNZ_ERRNO;
@@ -471,16 +459,10 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
}
-int do_extract(uf,opt_extract_without_path,opt_overwrite,password)
- unzFile uf;
- int opt_extract_without_path;
- int opt_overwrite;
- const char* password;
-{
+static int do_extract(unzFile uf, int opt_extract_without_path, int opt_overwrite, const char* password) {
uLong i;
unz_global_info64 gi;
int err;
- FILE* fout=NULL;
err = unzGetGlobalInfo64(uf,&gi);
if (err!=UNZ_OK)
@@ -507,14 +489,7 @@ int do_extract(uf,opt_extract_without_path,opt_overwrite,password)
return 0;
}
-int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite,password)
- unzFile uf;
- const char* filename;
- int opt_extract_without_path;
- int opt_overwrite;
- const char* password;
-{
- int err = UNZ_OK;
+static int do_extract_onefile(unzFile uf, const char* filename, int opt_extract_without_path, int opt_overwrite, const char* password) {
if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK)
{
printf("file %s not found in the zipfile\n",filename);
@@ -530,10 +505,7 @@ int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite,passwo
}
-int main(argc,argv)
- int argc;
- char *argv[];
-{
+int main(int argc, char *argv[]) {
const char *zipfilename=NULL;
const char *filename_to_extract=NULL;
const char *password=NULL;
@@ -564,7 +536,7 @@ int main(argc,argv)
while ((*p)!='\0')
{
- char c=*(p++);;
+ char c=*(p++);
if ((c=='l') || (c=='L'))
opt_do_list = 1;
if ((c=='v') || (c=='V'))
@@ -606,7 +578,7 @@ int main(argc,argv)
# endif
strncpy(filename_try, zipfilename,MAXFILENAME-1);
- /* strncpy doesnt append the trailing NULL, of the string is too long. */
+ /* strncpy doesn't append the trailing NULL, of the string is too long. */
filename_try[ MAXFILENAME ] = '\0';
# ifdef USEWIN32IOAPI