#endif
#endif
-#ifdef __APPLE__
+#if defined(__APPLE__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64)
// 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)
/* change_file_date : change the date/time of a file
filename : the filename of the file where date/time must be modified
- dosdate : the new date at the MSDos format (4 bytes)
+ dosdate : the new date at the MSDOS format (4 bytes)
tmu_date : the SAME new date at the tm_unz format */
-static 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;
ut.actime=ut.modtime=mktime(&newdate);
utime(filename,&ut);
+#else
+ (void)filename;
+ (void)dosdate;
+ (void)tmu_date;
#endif
#endif
}
/* mymkdir and change_file_date are not 100 % portable
As I don't know well Unix, I wait feedback for the unix portion */
-static int mymkdir(dirname)
- const char* dirname;
-{
+static int mymkdir(const char* dirname) {
int ret=0;
#ifdef _WIN32
ret = _mkdir(dirname);
ret = mkdir (dirname,0775);
#elif __APPLE__
ret = mkdir (dirname,0775);
+#else
+ (void)dirname;
#endif
return ret;
}
-static int makedir (newdir)
- const char *newdir;
-{
+static int makedir(const char *newdir) {
char *buffer ;
char *p;
size_t len = strlen(newdir);
return 1;
}
-static 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");
}
-static 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" \
" -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");
}
-static 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;
printf("%s",&number[pos_string]);
}
-static int do_list(uf)
- unzFile uf;
-{
+static int do_list(unzFile uf) {
uLong i;
unz_global_info64 gi;
int err;
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)
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='*';
}
-static 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;
else
write_filename = filename_withoutpath;
+ if (write_filename[0]!='\0')
+ {
+ const char* relative_check = write_filename;
+ while (relative_check[1]!='\0')
+ {
+ if (relative_check[0]=='.' && relative_check[1]=='.')
+ write_filename = relative_check;
+ relative_check++;
+ }
+ }
+
+ while (write_filename[0]=='/' || write_filename[0]=='.')
+ write_filename++;
+
err = unzOpenCurrentFilePassword(uf,password);
if (err!=UNZ_OK)
{
}
-static 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;
return 0;
}
-static 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;
-{
+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);
}
-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;
# 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