diff options
Diffstat (limited to 'src/common/grfio.c')
-rw-r--r-- | src/common/grfio.c | 91 |
1 files changed, 1 insertions, 90 deletions
diff --git a/src/common/grfio.c b/src/common/grfio.c index b15b37018..a96663b8f 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -4,20 +4,8 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <sys/stat.h> -#include "grfio.h" -#include "malloc.h" -#include "../zlib/unzip.h" - -#ifdef __WIN32 - #include "../zlib/zlib.h" - #include "../zlib/iowin32.h" -#else - #ifndef __FREEBSD__ - #include <zlib.h> - #endif -#endif +#include <zlib.h> int decode_zip(unsigned char *dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen) { @@ -79,80 +67,3 @@ int encode_zip(unsigned char *dest, unsigned long* destLen, const unsigned char* err = deflateEnd(&stream); return err; } - -/* =================================== -* Unzips a file. 1: success, 0: error -* Adapted from miniunz.c [Celest] -* Version 1.01b, May 30th, 2004 -* Copyright (C) 1998-2004 Gilles Vollant -* ------------------------------------- -*/ -int deflate_file (const char *source, const char *filename) -{ -#ifdef _WIN32 - zlib_filefunc_def ffunc; -#endif - unzFile uf = NULL; - int err = UNZ_OK; - uInt size_buf = 8192; - FILE *fout = NULL; - void *buf; - -#ifdef _WIN32 - fill_win32_filefunc(&ffunc); - uf = unzOpen2(source, &ffunc); -#else - uf = unzOpen(source); -#endif - - if (uf == NULL) { - //printf("Cannot open %s\n", source); - return 0; - } - //printf("%s opened\n", source); - - if (unzLocateFile(uf, filename, 0) != UNZ_OK) { - //printf("file %s not found in the zipfile\n", filename); - return 0; - } - - err = unzOpenCurrentFilePassword(uf, NULL); - //if (err != UNZ_OK) - // printf("error %d with zipfile in unzOpenCurrentFilePassword\n", err); - - fout = fopen(filename,"wb"); - if (fout == NULL) { - //printf("error opening %s\n", filename); - return 0; - } - - buf = (void *)aMalloc(size_buf); - do { - err = unzReadCurrentFile(uf, buf, size_buf); - if (err < 0) { - //printf("error %d with zipfile in unzReadCurrentFile\n", err); - break; - } - if (err > 0 && - fwrite(buf, err, 1, fout)!=1) - { - //printf("error in writing extracted file\n"); - err = UNZ_ERRNO; - break; - } - } while (err > 0); - - if (fout) fclose(fout); - - if (err == UNZ_OK) { - err = unzCloseCurrentFile (uf); - //if (err != UNZ_OK) - // printf("error %d with zipfile in unzCloseCurrentFile\n", err); - aFree(buf); - return (err == UNZ_OK); - } - - unzCloseCurrentFile(uf); /* don't lose the error */ - - return 0; -} |