diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/Makefile | 6 | ||||
-rw-r--r-- | src/common/grfio.c | 91 | ||||
-rw-r--r-- | src/common/grfio.h | 12 |
3 files changed, 2 insertions, 107 deletions
diff --git a/src/common/Makefile b/src/common/Makefile index b310d7991..655cc157e 100644 --- a/src/common/Makefile +++ b/src/common/Makefile @@ -6,7 +6,7 @@ obj: common: obj/core.o obj/socket.o obj/timer.o obj/db.o obj/plugins.o obj/lock.o \ obj/nullpo.o obj/malloc.o obj/showmsg.o obj/strlib.o obj/utils.o \ obj/grfio.o obj/minicore.o obj/minisocket.o obj/minimalloc.o \ - obj/mapindex.o obj/unz.o obj/ers.o obj/md5calc.o + obj/mapindex.o obj/ers.o obj/md5calc.o obj/%.o: %.c @@ -15,10 +15,6 @@ obj/%.o: %.c obj/mini%.o: %.c $(COMPILE.c) -DMINICORE $(OUTPUT_OPTION) $< -obj/unz.o: - $(MAKE) -C ../zlib - @touch $@ - clean: rm -rf *.o obj GNUmakefile 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; -} diff --git a/src/common/grfio.h b/src/common/grfio.h index 0d6268b0d..68371576d 100644 --- a/src/common/grfio.h +++ b/src/common/grfio.h @@ -4,20 +4,8 @@ #ifndef _GRFIO_H_ #define _GRFIO_H_ -void grfio_init(char*); // GRFIO Initialize -void grfio_final(void); // GRFIO Finalize -void* grfio_reads(char*,int*); // GRFIO data file read & size get -char *grfio_find_file(char *fname); -char *grfio_alloc_ptr(char *fname); - -#define grfio_read(fn) grfio_reads(fn, NULL) - -int grfio_size(char*); // GRFIO data file size get -unsigned long grfio_crc32(const unsigned char *buf, unsigned int len); - int decode_zip(unsigned char *dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen); int encode_zip(unsigned char *dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen); -int deflate_file (const char *source, const char *filename); #endif /* _GRFIO_H_ */ |