Update of /cvsroot/opengtoolkit/lvzip/c_source In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv31009/c_source Modified Files: ioapi.c ioapi.h iomem.c iowin32.c macbin.c macbin.h unzip.c zip.c zip.h zlibvc.def Log Message: Addition of memory stream for ZIP file Index: macbin.c =================================================================== RCS file: /cvsroot/opengtoolkit/lvzip/c_source/macbin.c,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** macbin.c 16 Sep 2007 14:26:17 -0000 1.28 --- macbin.c 17 Sep 2007 05:07:16 -0000 1.29 *************** *** 955,965 **** } ! extern long ZEXPORT InitializeFileFuncs (zlib_filefunc_def* pzlib_filefunc_def, LStrHandle memory) { if (pzlib_filefunc_def) { if (memory) fill_mem_filefunc(pzlib_filefunc_def, memory); ! else #if Win32 fill_win32_filefunc(pzlib_filefunc_def); --- 955,969 ---- } ! extern long ZEXPORT InitializeFileFuncs (zlib_filefunc_def* pzlib_filefunc_def, LStrHandle *memory) { if (pzlib_filefunc_def) { if (memory) + { fill_mem_filefunc(pzlib_filefunc_def, memory); ! *memory = NULL; ! } ! else ! { #if Win32 fill_win32_filefunc(pzlib_filefunc_def); *************** *** 967,970 **** --- 971,975 ---- fill_fopen_filefunc(pzlib_filefunc_def); #endif + } return noErr; } Index: zip.c =================================================================== RCS file: /cvsroot/opengtoolkit/lvzip/c_source/zip.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** zip.c 2 Apr 2007 21:11:48 -0000 1.8 --- zip.c 17 Sep 2007 05:07:16 -0000 1.9 *************** *** 29,32 **** --- 29,33 ---- #endif + #include "macbin.h" #ifndef local *************** *** 536,540 **** if (zi==NULL) { ! ZCLOSE(ziinit.z_filefunc,ziinit.filestream); return NULL; } --- 537,541 ---- if (zi==NULL) { ! ZCLOSE(ziinit.z_filefunc,ziinit.filestream, NULL); return NULL; } *************** *** 613,617 **** if (err!=ZIP_OK) { ! ZCLOSE(ziinit.z_filefunc, ziinit.filestream); return NULL; } --- 614,618 ---- if (err!=ZIP_OK) { ! ZCLOSE(ziinit.z_filefunc, ziinit.filestream, NULL); return NULL; } *************** *** 720,727 **** int err = ZIP_OK; ! # ifdef NOCRYPT if (password != NULL) return ZIP_PARAMERROR; ! # endif if (file == NULL) --- 721,730 ---- int err = ZIP_OK; ! #ifdef NOCRYPT if (password != NULL) return ZIP_PARAMERROR; ! #endif ! ! DoDebugger(); if (file == NULL) *************** *** 1134,1140 **** } ! extern int ZEXPORT zipClose (file, global_comment) zipFile file; const char* global_comment; { zip_internal* zi; --- 1137,1144 ---- } ! extern int ZEXPORT zipClose2 (file, global_comment, output) zipFile file; const char* global_comment; + voidpf output; { zip_internal* zi; *************** *** 1210,1214 **** err = ZIP_ERRNO; ! if (ZCLOSE(zi->z_filefunc,zi->filestream) != 0) if (err == ZIP_OK) err = ZIP_ERRNO; --- 1214,1218 ---- err = ZIP_ERRNO; ! if (ZCLOSE(zi->z_filefunc,zi->filestream, output) != 0) if (err == ZIP_OK) err = ZIP_ERRNO; *************** *** 1221,1222 **** --- 1225,1233 ---- return err; } + + extern int ZEXPORT zipClose (file, global_comment) + zipFile file; + const char* global_comment; + { + return zipClose2(file, global_comment, NULL); + } \ No newline at end of file Index: ioapi.h =================================================================== RCS file: /cvsroot/opengtoolkit/lvzip/c_source/ioapi.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ioapi.h 7 Jan 2006 20:06:23 -0000 1.5 --- ioapi.h 17 Sep 2007 05:07:16 -0000 1.6 *************** *** 41,45 **** typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); ! typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); --- 41,45 ---- typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); ! typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream, voidpf output)); typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); *************** *** 64,68 **** #define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream)) #define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode)) ! #define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream)) #define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream)) --- 64,68 ---- #define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream)) #define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode)) ! #define ZCLOSE(filefunc,filestream,output) ((*((filefunc).zclose_file))((filefunc).opaque,filestream,output)) #define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream)) Index: macbin.h =================================================================== RCS file: /cvsroot/opengtoolkit/lvzip/c_source/macbin.h,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** macbin.h 16 Sep 2007 14:26:17 -0000 1.21 --- macbin.h 17 Sep 2007 05:07:16 -0000 1.22 *************** *** 268,272 **** uInt32 denyMode)); ! extern long ZEXPORT InitializeFileFuncs OF((zlib_filefunc_def* pzlib_filefunc_def, LStrHandle memory)); #ifdef __cplusplus --- 268,272 ---- uInt32 denyMode)); ! extern long ZEXPORT InitializeFileFuncs OF((zlib_filefunc_def* pzlib_filefunc_def, LStrHandle *memory)); #ifdef __cplusplus Index: iowin32.c =================================================================== RCS file: /cvsroot/opengtoolkit/lvzip/c_source/iowin32.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** iowin32.c 7 Jan 2006 20:06:23 -0000 1.5 --- iowin32.c 17 Sep 2007 05:07:16 -0000 1.6 *************** *** 51,55 **** int ZCALLBACK win32_close_file_func OF(( voidpf opaque, ! voidpf stream)); int ZCALLBACK win32_error_file_func OF(( --- 51,56 ---- int ZCALLBACK win32_close_file_func OF(( voidpf opaque, ! voidpf stream, ! voidpf output)); int ZCALLBACK win32_error_file_func OF(( *************** *** 225,231 **** } ! int ZCALLBACK win32_close_file_func (opaque, stream) voidpf opaque; voidpf stream; { int ret=-1; --- 226,233 ---- } ! int ZCALLBACK win32_close_file_func (opaque, stream, output) voidpf opaque; voidpf stream; + voidpf output; { int ret=-1; Index: zip.h =================================================================== RCS file: /cvsroot/opengtoolkit/lvzip/c_source/zip.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** zip.h 7 Jan 2006 20:06:23 -0000 1.5 --- zip.h 17 Sep 2007 05:07:16 -0000 1.6 *************** *** 227,234 **** --- 227,238 ---- extern int ZEXPORT zipClose OF((zipFile file, const char* global_comment)); + + extern int ZEXPORT zipClose2 OF((zipFile file, + const char* global_comment, voidpf stream)); /* Close the zipfile */ + #ifdef __cplusplus } Index: zlibvc.def =================================================================== RCS file: /cvsroot/opengtoolkit/lvzip/c_source/zlibvc.def,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** zlibvc.def 25 Oct 2006 08:58:37 -0000 1.15 --- zlibvc.def 17 Sep 2007 05:07:16 -0000 1.16 *************** *** 91,94 **** --- 91,95 ---- zipOpen2 @87 zipOpenNewFileInZip3 @88 + zipClose2 @89 unzGetFilePos @100 Index: unzip.c =================================================================== RCS file: /cvsroot/opengtoolkit/lvzip/c_source/unzip.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** unzip.c 2 Apr 2007 21:11:48 -0000 1.6 --- unzip.c 17 Sep 2007 05:07:16 -0000 1.7 *************** *** 483,487 **** if (err!=UNZ_OK) { ! ZCLOSE(us.z_filefunc, us.filestream); return NULL; } --- 483,487 ---- if (err!=UNZ_OK) { ! ZCLOSE(us.z_filefunc, us.filestream, NULL); return NULL; } *************** *** 523,527 **** unzCloseCurrentFile(file); ! ZCLOSE(s->z_filefunc, s->filestream); TRYFREE(s); return UNZ_OK; --- 523,527 ---- unzCloseCurrentFile(file); ! ZCLOSE(s->z_filefunc, s->filestream, NULL); TRYFREE(s); return UNZ_OK; Index: iomem.c =================================================================== RCS file: /cvsroot/opengtoolkit/lvzip/c_source/iomem.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** iomem.c 16 Sep 2007 15:08:05 -0000 1.2 --- iomem.c 17 Sep 2007 05:07:16 -0000 1.3 *************** *** 39,43 **** int ZCALLBACK mem_close_file_func OF(( voidpf opaque, ! voidpf stream)); int ZCALLBACK mem_error_file_func OF(( --- 39,44 ---- int ZCALLBACK mem_close_file_func OF(( voidpf opaque, ! voidpf stream, ! voidpf output)); int ZCALLBACK mem_error_file_func OF(( *************** *** 66,70 **** memio.pos = 0; else ! memio.pos = LStrLen(*(LStrHandle)opaque); memio.error = 0; ret = malloc(sizeof(MEMORY_IO)); --- 67,71 ---- memio.pos = 0; else ! memio.pos = LStrLen(**(LStrHandle*)opaque); memio.error = 0; ret = malloc(sizeof(MEMORY_IO)); *************** *** 88,96 **** MEMORY_IO* mem = (MEMORY_IO*)stream; uLong pos = mem->pos; ! ret = LStrLen(*(LStrHandle)opaque) - pos; if (size < ret) ret = size; ! zmemcpy(buf, LStrBuf(*(LStrHandle)opaque) + pos, ret); mem->pos += ret; } --- 89,97 ---- MEMORY_IO* mem = (MEMORY_IO*)stream; uLong pos = mem->pos; ! ret = LStrLen(**(LStrHandle*)opaque) - pos; if (size < ret) ret = size; ! zmemcpy(buf, LStrBuf(**(LStrHandle*)opaque) + pos, ret); mem->pos += ret; } *************** *** 108,118 **** uLong pos = 0; if (stream != NULL && (mem->mode & ZLIB_FILEFUNC_MODE_WRITE)) { pos = mem->pos; ! if ((uLong)LStrLen(*(LStrHandle)opaque) < pos + size) { int err; ! if (err = NumericArrayResize(uB, 1, &(UHandle)opaque, pos + size)) { mem->error = err; --- 109,122 ---- uLong pos = 0; + DoDebugger(); if (stream != NULL && (mem->mode & ZLIB_FILEFUNC_MODE_WRITE)) { pos = mem->pos; ! if ((*(LStrHandle*)opaque) || ! ((uLong)LStrLen(**(LStrHandle*)opaque) < (pos + size))) { int err; ! ! if (err = NumericArrayResize(uB, 1, (UHandle*)opaque, pos + size)) { mem->error = err; *************** *** 120,124 **** } } ! zmemcpy(LStrBuf(*(LStrHandle)opaque) + pos, buf, size); mem->pos += size; pos = size; --- 124,129 ---- } } ! zmemcpy(LStrBuf(**(LStrHandle*)opaque) + pos, buf, size); ! LStrLen(**(LStrHandle*)opaque) = size; mem->pos += size; pos = size; *************** *** 157,161 **** break; case ZLIB_FILEFUNC_SEEK_END : ! pos = LStrLen(*(LStrHandle)opaque) + offset; break; case ZLIB_FILEFUNC_SEEK_SET : --- 162,166 ---- break; case ZLIB_FILEFUNC_SEEK_END : ! pos = LStrLen(**(LStrHandle*)opaque) + offset; break; case ZLIB_FILEFUNC_SEEK_SET : *************** *** 166,180 **** } ! if (pos > LStrLen(*(LStrHandle)opaque)) { if (mem->mode & ZLIB_FILEFUNC_MODE_WRITE) { MgErr err; ! if (err = NumericArrayResize(uB, 1, &(UHandle)opaque, pos)) { mem->error = err; return -1; } ! } else return -1; --- 171,186 ---- } ! if (!(*(LStrHandle*)opaque) || (pos > LStrLen(**(LStrHandle*)opaque))) { if (mem->mode & ZLIB_FILEFUNC_MODE_WRITE) { MgErr err; ! if (err = NumericArrayResize(uB, 1, (UHandle*)opaque, pos)) { mem->error = err; return -1; } ! LStrLen(**(LStrHandle*)opaque) = pos; ! } else return -1; *************** *** 186,198 **** } ! int ZCALLBACK mem_close_file_func (opaque, stream) voidpf opaque; voidpf stream; { ! int ret=-1; if (stream != NULL) { free(stream); } return ret; --- 192,216 ---- } ! int ZCALLBACK mem_close_file_func (opaque, stream, output) voidpf opaque; voidpf stream; + voidpf output; { ! int ret = -1; ! ! if (output) ! { ! UHandle *p = (UHandle*)output; ! if (*p) ! DSDisposeHandle(*p); ! *p = *(UHandle*)opaque; ! } ! else ! DSDisposeHandle(*(UHandle*)opaque); if (stream != NULL) { free(stream); + ret = 0; } return ret; Index: ioapi.c =================================================================== RCS file: /cvsroot/opengtoolkit/lvzip/c_source/ioapi.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ioapi.c 7 Jan 2006 20:06:23 -0000 1.5 --- ioapi.c 17 Sep 2007 05:07:16 -0000 1.6 *************** *** 59,63 **** int ZCALLBACK fclose_file_func OF(( voidpf opaque, ! voidpf stream)); int ZCALLBACK ferror_file_func OF(( --- 59,64 ---- int ZCALLBACK fclose_file_func OF(( voidpf opaque, ! voidpf stream, ! voidpf output)); int ZCALLBACK ferror_file_func OF(( *************** *** 146,152 **** } ! int ZCALLBACK fclose_file_func (opaque, stream) voidpf opaque; voidpf stream; { int ret; --- 147,154 ---- } ! int ZCALLBACK fclose_file_func (opaque, stream, output) voidpf opaque; voidpf stream; + voidpf output; { int ret; |