You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by to...@apache.org on 2008/03/04 09:02:45 UTC
svn commit: r633384 [5/15] - in /harmony/enhanced/classlib/branches/java6:
depends/build/platform/ depends/files/ depends/files/bcprov/ doc/
doc/classlib/ make/ make/linux.ia64/ make/linux.ppc32/ make/linux.ppc64/
make/linux.x86.libstdc++6/ make/linux....
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/hyzip/shared/hyzip.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/hyzip/shared/hyzip.c?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/hyzip/shared/hyzip.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/hyzip/shared/hyzip.c Tue Mar 4 00:02:13 2008
@@ -15,190 +15,142 @@
* limitations under the License.
*/
+#include "vmizip.h"
#include "zipsup.h"
-#include "hyzip.h"
-#include "vmi.h"
#include "hyport.h"
I_32 VMCALL
-hyzip_getZipEntryData(VMInterface * vmi, struct HyZipFile * zipFile, struct HyZipEntry * entry, U_8 * buffer, U_32 bufferSize)
+vmizip_getZipEntryData(VMInterface * vmi, struct VMIZipFile * zipFile, struct VMIZipEntry * entry, U_8 * buffer, U_32 bufferSize)
{
PORT_ACCESS_FROM_VMI(vmi);
return zip_getZipEntryData(PORTLIB, zipFile, entry, buffer, bufferSize);
}
I_32 VMCALL
-hyzip_getZipEntryFromOffset(VMInterface * vmi, struct HyZipFile * zipFile, struct HyZipEntry * entry, IDATA offset)
+vmizip_getZipEntryFromOffset(VMInterface * vmi, struct VMIZipFile * zipFile, struct VMIZipEntry * entry, IDATA offset, I_32 flags)
{
PORT_ACCESS_FROM_VMI(vmi);
return zip_getZipEntryFromOffset(PORTLIB, zipFile, entry, offset);
}
-I_32 VMCALL
-hyzip_establishCache(VMInterface * vmi, struct HyZipFile * zipFile)
-{
- PORT_ACCESS_FROM_VMI(vmi);
- return zip_establishCache(PORTLIB, zipFile);
-}
-
void VMCALL
-hyzip_resetZipFile(VMInterface * vmi, struct HyZipFile * zipFile, IDATA * nextEntryPointer)
+vmizip_resetZipFile(VMInterface * vmi, struct VMIZipFile * zipFile, IDATA * nextEntryPointer)
{
PORT_ACCESS_FROM_VMI(vmi);
zip_resetZipFile(PORTLIB, zipFile, nextEntryPointer);
}
I_32 VMCALL
-hyzip_getNextZipEntry(VMInterface * vmi, struct HyZipFile * zipFile, struct HyZipEntry * zipEntry, IDATA * nextEntryPointer)
+vmizip_getNextZipEntry(VMInterface * vmi, struct VMIZipFile * zipFile, struct VMIZipEntry * zipEntry, IDATA * nextEntryPointer, I_32 flags)
{
PORT_ACCESS_FROM_VMI(vmi);
return zip_getNextZipEntry(PORTLIB, zipFile, zipEntry, nextEntryPointer);
}
I_32 VMCALL
-hyzip_getZipEntry(VMInterface * vmi, struct HyZipFile * zipFile, struct HyZipEntry * entry, const char *filename, BOOLEAN findDirectory)
+vmizip_getZipEntry(VMInterface * vmi, struct VMIZipFile * zipFile, struct VMIZipEntry * entry, const char *filename, I_32 flags)
{
PORT_ACCESS_FROM_VMI(vmi);
- return zip_getZipEntry(PORTLIB, zipFile,entry, filename, findDirectory);
+ return zip_getZipEntry(PORTLIB, zipFile,entry, filename, flags);
}
I_32 VMCALL
-hyzip_getZipEntryExtraField(VMInterface * vmi, struct HyZipFile * zipFile, struct HyZipEntry * entry, U_8 * buffer, U_32 bufferSize)
+vmizip_getZipEntryExtraField(VMInterface * vmi, struct VMIZipFile * zipFile, struct VMIZipEntry * entry, U_8 * buffer, U_32 bufferSize)
{
PORT_ACCESS_FROM_VMI(vmi);
return zip_getZipEntryExtraField(PORTLIB, zipFile, entry, buffer, bufferSize);
}
+I_32 VMCALL
+vmizip_getZipEntryRawData(VMInterface * vmi, VMIZipFile * zipFile, VMIZipEntry * entry, U_8 * buffer, U_32 bufferSize, U_32 offset)
+{
+ PORT_ACCESS_FROM_VMI(vmi);
+ return zip_getZipEntryRawData(PORTLIB, zipFile, entry, buffer, bufferSize, offset);
+}
+
+
void VMCALL
-hyzip_initZipEntry(VMInterface * vmi, struct HyZipEntry * entry)
+vmizip_initZipEntry(VMInterface * vmi, struct VMIZipEntry * entry)
{
PORT_ACCESS_FROM_VMI(vmi);
zip_initZipEntry(PORTLIB, entry);
}
I_32 VMCALL
-hyzip_openZipFile(VMInterface * vmi, char *filename, struct HyZipFile * zipFile)
+vmizip_openZipFile(VMInterface * vmi, char *filename, struct VMIZipFile * zipFile, I_32 flags)
{
PORT_ACCESS_FROM_VMI(vmi);
- HyZipFunctionTable *zipFuncs = (*vmi)->GetZipFunctions(vmi);
+ VMIZipFunctionTable *zipFuncs = (*vmi)->GetZipFunctions(vmi);
/* This is a synchonization hole, should probably add a mutex to control setting this variable. */
if ( zipFuncs->reserved == NULL ) {
zipFuncs->reserved = zipCachePool_new(PORTLIB);
}
- return zip_openZipFile(PORTLIB, filename, zipFile, (HyZipCachePool *)zipFuncs->reserved);
+ return zip_openZipFile(PORTLIB, filename, zipFile, (flags & ZIP_FLAG_OPEN_CACHE) ? (HyZipCachePool *)zipFuncs->reserved : NULL );
}
void VMCALL
-hyzip_freeZipEntry(VMInterface * vmi, struct HyZipEntry * entry)
+vmizip_freeZipEntry(VMInterface * vmi, struct VMIZipEntry * entry)
{
PORT_ACCESS_FROM_VMI(vmi);
zip_freeZipEntry(PORTLIB, entry);
}
I_32 VMCALL
-hyzip_closeZipFile(VMInterface * vmi, struct HyZipFile * zipFile)
+vmizip_closeZipFile(VMInterface * vmi, struct VMIZipFile * zipFile)
{
PORT_ACCESS_FROM_VMI(vmi);
return zip_closeZipFile(PORTLIB, zipFile);
}
I_32 VMCALL
-hyzip_getZipEntryComment(VMInterface * vmi, struct HyZipFile * zipFile, struct HyZipEntry * entry, U_8 * buffer, U_32 bufferSize)
+vmizip_getZipEntryComment(VMInterface * vmi, struct VMIZipFile * zipFile, struct VMIZipEntry * entry, U_8 * buffer, U_32 bufferSize)
{
PORT_ACCESS_FROM_VMI(vmi);
return zip_getZipEntryComment(PORTLIB, zipFile, entry, buffer, bufferSize);
}
-UDATA VMCALL
-hyzipCache_findElement(struct HyZipCache * zipCache, const char *elementName, BOOLEAN searchDirList)
-{
- return zipCache_findElement(zipCache, elementName, searchDirList);
-}
-
-void VMCALL
-hyzipCache_kill(struct HyZipCache * zipCache)
-{
- zipCache_kill(zipCache);
-}
-
IDATA VMCALL
-hyzipCache_enumGetDirName(void *handle, char *nameBuf, UDATA nameBufSize)
+vmizipCache_enumGetDirName(void *handle, char *nameBuf, UDATA nameBufSize)
{
return zipCache_enumGetDirName(handle, nameBuf, nameBufSize);
}
-struct HyZipCache *VMCALL
-hyzipCache_new(VMInterface * vmi, char *zipName, IDATA zipNameLength)
-{
- PORT_ACCESS_FROM_VMI(vmi);
- return (struct HyZipCache *)zipCache_new(PORTLIB, zipName, zipNameLength);
-}
-
IDATA VMCALL
-hyzipCache_enumNew(struct HyZipCache * zipCache, char *directoryName, void **handle)
+vmizipCache_enumNew(struct HyZipCache * zipCache, char *directoryName, void **handle)
{
return zipCache_enumNew(zipCache, directoryName, handle);
}
IDATA VMCALL
-hyzipCache_enumElement(void *handle, char *nameBuf, UDATA nameBufSize, UDATA * offset)
+vmizipCache_enumElement(void *handle, char *nameBuf, UDATA nameBufSize, UDATA * offset)
{
return zipCache_enumElement(handle, nameBuf, nameBufSize, offset);
}
void VMCALL
-hyzipCache_enumKill(void *handle)
+vmizipCache_enumKill(void *handle)
{
zipCache_enumKill(handle);
}
-BOOLEAN VMCALL
-hyzipCache_addElement(struct HyZipCache * zipCache, char *elementName, UDATA elementOffset)
-{
- return zipCache_addElement(zipCache, elementName, elementOffset);
-}
-
-void * VMCALL
-hyzip_zalloc(void *opaque, U_32 items, U_32 size)
-{
- PORT_ACCESS_FROM_VMI (((VMInterface *) opaque));
-
- return hymem_allocate_memory (items * size);
-}
-
-void VMCALL
-hyzip_zfree(void *opaque, void *address)
-{
- PORT_ACCESS_FROM_VMI ((VMInterface *) opaque);
-
- hymem_free_memory (address);
-
-}
-
-HyZipFunctionTable HyZipLibraryTable = {
- hyzip_getZipEntryData,
- hyzip_getZipEntryFromOffset,
- hyzip_establishCache,
- hyzip_resetZipFile,
- hyzip_getNextZipEntry,
- hyzip_getZipEntry,
- hyzip_getZipEntryExtraField,
- hyzip_initZipEntry,
- hyzip_openZipFile,
- hyzip_freeZipEntry,
- hyzip_closeZipFile,
- hyzip_getZipEntryComment,
- hyzipCache_findElement,
- hyzipCache_kill,
- hyzipCache_enumGetDirName,
- hyzipCache_new,
- hyzipCache_enumNew,
- hyzipCache_enumElement,
- hyzipCache_enumKill,
- hyzipCache_addElement,
- hyzip_zalloc,
- hyzip_zfree,
+VMIZipFunctionTable VMIZipLibraryTable = {
+ vmizip_closeZipFile,
+ vmizip_freeZipEntry,
+ vmizip_getNextZipEntry,
+ vmizip_getZipEntry,
+ vmizip_getZipEntryComment,
+ vmizip_getZipEntryData,
+ vmizip_getZipEntryExtraField,
+ vmizip_getZipEntryFromOffset,
+ vmizip_getZipEntryRawData,
+ vmizip_initZipEntry,
+ vmizip_openZipFile,
+ vmizip_resetZipFile,
+ vmizipCache_enumElement,
+ vmizipCache_enumGetDirName,
+ vmizipCache_enumKill,
+ vmizipCache_enumNew,
NULL
};
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/hyzip/shared/zipcache.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/hyzip/shared/zipcache.c?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/hyzip/shared/zipcache.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/hyzip/shared/zipcache.c Tue Mar 4 00:02:13 2008
@@ -114,7 +114,7 @@
const char *namePtr, IDATA nameSize, BOOLEAN isClass,
UDATA elementOffset));
UDATA *zipCache_reserveEntry
-PROTOTYPE ((HaZipChunkHeader * chunk, UDATA entryBytes, UDATA stringBytes));
+PROTOTYPE ((HyZipCacheEntry *zce, HaZipChunkHeader * chunk, UDATA entryBytes, UDATA stringBytes));
HyZipFileEntry *zipCache_searchFileList
PROTOTYPE ((HaZipDirEntry * dirEntry, const char *namePtr, UDATA nameSize,
BOOLEAN isClass));
@@ -139,7 +139,7 @@
*/
HyZipCache *
-zipCache_new (HyPortLibrary * portLib, char *zipName, IDATA zipNameLength)
+zipCache_new (HyPortLibrary * portLib, char *zipName, IDATA zipNameLength, IDATA zipFileSize, I_64 zipTimeStamp, IDATA startCentralDir)
{
HaZipChunkHeader *chunk;
HyZipCacheEntry *zce;
@@ -150,9 +150,7 @@
if (!chunk)
return NULL;
- zce =
- (HyZipCacheEntry *) zipCache_reserveEntry (chunk,
- sizeof (HyZipCacheEntry), 0);
+ zce = (HyZipCacheEntry *) zipCache_reserveEntry (NULL, chunk, sizeof (HyZipCacheEntry), 0);
if (!zce)
{
/* ACTUAL_CHUNK_SIZE is so small it can't hold one HyZipCacheEntry?? */
@@ -164,7 +162,7 @@
zce->currentChunk = chunk;
/* Try to put the name string in this chunk. If it won't fit, we'll allocate it separately */
- if (zipCache_reserveEntry (chunk, 0, zipNameLength + 1))
+ if (zipCache_reserveEntry (zce, chunk, 0, zipNameLength + 1))
{
zce->info.zipFileName = chunk->endFree;
}
@@ -179,8 +177,9 @@
}
memcpy (zce->info.zipFileName, zipName, zipNameLength);
zce->info.zipFileName[zipNameLength] = '\0';
- zce->info.zipFileSize = zce->info.startCentralDir = -1;
- zce->info.zipTimeStamp = -1;
+ zce->info.zipFileSize = zipFileSize;
+ zce->info.startCentralDir = startCentralDir;
+ zce->info.zipTimeStamp = zipTimeStamp;
/* zce->info.cachePool is already NULL */
/* zce->info.cachePoolEntry is already NULL */
zce->root.zipFileOffset = 1;
@@ -431,9 +430,7 @@
HaZipChunkHeader *chunk = zce->currentChunk;
zce->chunkActiveDir = NULL;
- entry =
- (HaZipDirEntry *) zipCache_reserveEntry (chunk, sizeof (*entry),
- nameSize + 1);
+ entry = (HaZipDirEntry *) zipCache_reserveEntry (zce, chunk, sizeof (*entry), nameSize + 1);
if (!entry)
{
if (!(chunk = zipCache_allocateChunk (zce->info.portLib)))
@@ -441,8 +438,7 @@
chunk->next = zce->currentChunk;
zce->currentChunk = chunk;
entry =
- (HaZipDirEntry *) zipCache_reserveEntry (chunk, sizeof (*entry),
- nameSize + 1);
+ (HaZipDirEntry *) zipCache_reserveEntry (zce, chunk, sizeof (*entry), nameSize + 1);
if (!entry)
{
/* ACTUAL_CHUNK_SIZE is so small it can't hold one HaZipDirEntry?? */
@@ -473,9 +469,7 @@
if (zce->chunkActiveDir == dirEntry)
{
- if (entry =
- (HyZipFileEntry *) zipCache_reserveEntry (chunk, sizeof (*entry),
- nameSize + 1))
+ if (entry = (HyZipFileEntry *) zipCache_reserveEntry (zce, chunk, sizeof (*entry), nameSize + 1))
{
/* add to end of existing entry */
zce->chunkActiveDir->fileList->entryCount++;
@@ -483,9 +477,7 @@
}
}
- record =
- (HyZipFileRecord *) zipCache_reserveEntry (chunk, sizeof (*record),
- nameSize + 1);
+ record = (HyZipFileRecord *) zipCache_reserveEntry (zce, chunk, sizeof (*record), nameSize + 1);
if (!record)
{
if (!(chunk = zipCache_allocateChunk (zce->info.portLib)))
@@ -493,9 +485,7 @@
chunk->next = zce->currentChunk;
zce->currentChunk = chunk;
zce->chunkActiveDir = NULL;
- record =
- (HyZipFileRecord *) zipCache_reserveEntry (chunk, sizeof (*record),
- nameSize + 1);
+ record = (HyZipFileRecord *) zipCache_reserveEntry (zce, chunk, sizeof (*record), nameSize + 1);
if (!record)
{
/* ACTUAL_CHUNK_SIZE is so small it can't hold one zipFileRecord?? */
@@ -553,7 +543,7 @@
/* to the allocated stringBytes. */
UDATA *
-zipCache_reserveEntry (HaZipChunkHeader * chunk, UDATA entryBytes,
+zipCache_reserveEntry (HyZipCacheEntry * zce, HaZipChunkHeader * chunk, UDATA entryBytes,
UDATA stringBytes)
{
UDATA *entry;
@@ -918,3 +908,25 @@
}
return 0;
}
+
+/**
+ * Return the startCentralDir of the cache.
+ *
+ * @param[in] zipCache the zip cache
+ *
+ * @return the startCentralDir of the cache
+ */
+IDATA zipCache_getStartCentralDir(HyZipCache *zipCache) {
+ return zipCache->startCentralDir;
+}
+
+/**
+ * Whack the cache timestamp to keep other people from starting to use it. Once all the current
+ * users of the cache have stopped using it, it will go away.
+ *
+ * @param[in] zipCache the zip cache
+ */
+void zipCache_invalidateCache(HyZipCache * zipCache) {
+ zipCache->zipTimeStamp = -2;
+}
+
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/hyzip/shared/zipsup.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/hyzip/shared/zipsup.c?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/hyzip/shared/zipsup.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/hyzip/shared/zipsup.c Tue Mar 4 00:02:13 2008
@@ -23,6 +23,7 @@
#include <string.h>
+#include "vmi.h"
#include "hyport.h"
#include "zipsup.h"
#include "hyzipnls.h"
@@ -54,7 +55,7 @@
#define CDEV_CURRENT_FUNCTION _prototypes_private
I_32 zip_populateCache
-PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile));
+PROTOTYPE ((HyPortLibrary * portLib, VMIZipFile * zipFile, HyZipCentralEnd *endEntry, IDATA startCentralDir));
static I_32 inflateData
PROTOTYPE ((struct workBuffer * workBuf, U_8 * inputBuffer,
@@ -63,16 +64,16 @@
I_32 checkZipLibrary PROTOTYPE ((HyPortLibrary * portLib));
I_32 scanForDataDescriptor
-PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile,
- HyZipEntry * zipEntry));
+PROTOTYPE ((HyPortLibrary * portLib, VMIZipFile * zipFile,
+ VMIZipEntry * zipEntry));
void zdatafree PROTOTYPE ((void *opaque, void *address));
static I_32 readZipEntry
-PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile,
- HyZipEntry * zipEntry, const char *filename,
+PROTOTYPE ((HyPortLibrary * portLib, VMIZipFile * zipFile,
+ VMIZipEntry * zipEntry, const char *filename,
IDATA * enumerationPointer, IDATA * entryStart,
BOOLEAN findDirectory));
I_32 scanForCentralEnd
-PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile,
+PROTOTYPE ((HyPortLibrary * portLib, VMIZipFile * zipFile,
HyZipCentralEnd * endEntry));
void *zdataalloc PROTOTYPE ((void *opaque, U_32 items, U_32 size));
@@ -80,36 +81,39 @@
#define CDEV_CURRENT_FUNCTION _prototypes_public
I_32 zip_getZipEntryData
-PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile, HyZipEntry * entry,
+PROTOTYPE ((HyPortLibrary * portLib, VMIZipFile * zipFile, VMIZipEntry * entry,
U_8 * buffer, U_32 bufferSize));
I_32 zip_getZipEntryFromOffset
-PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile, HyZipEntry * entry,
+PROTOTYPE ((HyPortLibrary * portLib, VMIZipFile * zipFile, VMIZipEntry * entry,
IDATA offset));
I_32 zip_establishCache
-PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile));
+PROTOTYPE ((HyPortLibrary * portLib, VMIZipFile * zipFile));
void zip_resetZipFile
-PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile,
+PROTOTYPE ((HyPortLibrary * portLib, VMIZipFile * zipFile,
IDATA * nextEntryPointer));
I_32 zip_getNextZipEntry
-PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile,
- HyZipEntry * zipEntry, IDATA * nextEntryPointer));
+PROTOTYPE ((HyPortLibrary * portLib, VMIZipFile * zipFile,
+ VMIZipEntry * zipEntry, IDATA * nextEntryPointer));
I_32 zip_getZipEntry
-PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile, HyZipEntry * entry,
+PROTOTYPE ((HyPortLibrary * portLib, VMIZipFile * zipFile, VMIZipEntry * entry,
const char *filename, BOOLEAN findDirectory));
I_32 zip_getZipEntryExtraField
-PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile, HyZipEntry * entry,
+PROTOTYPE ((HyPortLibrary * portLib, VMIZipFile * zipFile, VMIZipEntry * entry,
U_8 * buffer, U_32 bufferSize));
+I_32 zip_getZipEntryRawData
+PROTOTYPE((HyPortLibrary * portLib, VMIZipFile * zipFile, VMIZipEntry * entry,
+ U_8 * buffer, U_32 bufferSize, U_32 offset));
void zip_initZipEntry
-PROTOTYPE ((HyPortLibrary * portLib, HyZipEntry * entry));
+PROTOTYPE ((HyPortLibrary * portLib, VMIZipEntry * entry));
I_32 zip_openZipFile
-PROTOTYPE ((HyPortLibrary * portLib, char *filename, HyZipFile * zipFile,
+PROTOTYPE ((HyPortLibrary * portLib, char *filename, VMIZipFile * zipFile,
HyZipCachePool * cachePool));
void zip_freeZipEntry
-PROTOTYPE ((HyPortLibrary * portLib, HyZipEntry * entry));
+PROTOTYPE ((HyPortLibrary * portLib, VMIZipEntry * entry));
I_32 VMCALL zip_closeZipFile
-PROTOTYPE ((HyPortLibrary * portLib, struct HyZipFile * zipFile));
+PROTOTYPE ((HyPortLibrary * portLib, struct VMIZipFile * zipFile));
I_32 zip_getZipEntryComment
-PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile, HyZipEntry * entry,
+PROTOTYPE ((HyPortLibrary * portLib, VMIZipFile * zipFile, VMIZipEntry * entry,
U_8 * buffer, U_32 bufferSize));
#undef CDEV_CURRENT_FUNCTION
@@ -260,7 +264,7 @@
ZIP_ERR_FILE_CORRUPT
*/
I_32
-scanForCentralEnd (HyPortLibrary * portLib, HyZipFile * zipFile,
+scanForCentralEnd (HyPortLibrary * portLib, VMIZipFile * zipFile,
HyZipCentralEnd * endEntry)
{
U_8 *current;
@@ -380,8 +384,8 @@
ZIP_ERR_FILE_CORRUPT
*/
I_32
-scanForDataDescriptor (HyPortLibrary * portLib, HyZipFile * zipFile,
- HyZipEntry * zipEntry)
+scanForDataDescriptor (HyPortLibrary * portLib, VMIZipFile * zipFile,
+ VMIZipEntry * zipEntry)
{
U_8 *current;
U_8 buffer[SCAN_CHUNK_SIZE], descriptor[16];
@@ -542,7 +546,7 @@
ZIP_ERR_INTERNAL_ERROR
*/
I_32
-zip_populateCache (HyPortLibrary * portLib, HyZipFile * zipFile)
+zip_populateCache (HyPortLibrary * portLib, VMIZipFile * zipFile, HyZipCentralEnd *endEntry, IDATA startCentralDir)
{
PORT_ACCESS_FROM_PORT (portLib);
@@ -552,32 +556,19 @@
IDATA bufferedSize = 0;
IDATA bytesToRead = 0;
IDATA filenameCopied;
- HyZipEntry entry;
- HyZipCentralEnd endEntry;
+ VMIZipEntry entry;
U_8 *buffer = NULL;
U_8 *filename = NULL;
IDATA filenameSize = 256; /* Should be sufficient for most filenames */
U_8 *current;
U_32 sig;
U_32 localHeaderOffset;
- IDATA startCentralDir;
I_64 seekResult;
if (!zipFile->cache)
return ZIP_ERR_INTERNAL_ERROR;
- /* Find and read the end-of-central-dir record. */
- result = scanForCentralEnd (portLib, zipFile, &endEntry);
- if (result != 0)
- return result;
-
- unreadSize = endEntry.dirSize + 4 /* slop */ ;
-#ifndef HY_ZIP_API
- zipFile->cache->startCentralDir = startCentralDir =
-#else /* HY_ZIP_API */
- ((HyZipCache *)(zipFile->cache))->startCentralDir = startCentralDir =
-#endif /* HY_ZIP_API */
- (IDATA) ((UDATA) endEntry.dirOffset);
+ unreadSize = endEntry->dirSize + 4 /* slop */ ;
if (zipFile->pointer != startCentralDir)
{
@@ -819,8 +810,8 @@
ZIP_ERR_NO_MORE_ENTRIES
*/
static I_32
-readZipEntry (HyPortLibrary * portLib, HyZipFile * zipFile,
- HyZipEntry * zipEntry, const char *filename,
+readZipEntry (HyPortLibrary * portLib, VMIZipFile * zipFile,
+ VMIZipEntry * zipEntry, const char *filename,
IDATA * enumerationPointer, IDATA * entryStart,
BOOLEAN findDirectory)
{
@@ -843,11 +834,7 @@
readBuffer = NULL;
/* Guess how many bytes we'll need to read. If we guess correctly we will do fewer I/O operations */
headerSize = 30; /* local zip header size */
-#ifndef HY_ZIP_API
- if (zipFile->cache && (zipFile->pointer >= zipFile->cache->startCentralDir))
-#else /* HY_ZIP_API */
- if (zipFile->cache && (zipFile->pointer >= ((HyZipCache *)(zipFile->cache))->startCentralDir))
-#endif /* HY_ZIP_API */
+ if (zipFile->cache && (zipFile->pointer >= zipCache_getStartCentralDir(zipFile->cache)))
{
headerSize = 46; /* central zip header size */
}
@@ -999,7 +986,7 @@
}
memcpy (zipEntry->filename, current, readLength);
- /* Read the rest of the filename if necessary. Allocate space in HyZipEntry for it! */
+ /* Read the rest of the filename if necessary. Allocate space in VMIZipEntry for it! */
if (readLength < zipEntry->filenameLength)
{
result =
@@ -1120,7 +1107,7 @@
*
*/
I_32 VMCALL
-zip_closeZipFile (HyPortLibrary * portLib, struct HyZipFile * zipFile)
+zip_closeZipFile (HyPortLibrary * portLib, struct VMIZipFile * zipFile)
{
PORT_ACCESS_FROM_PORT (portLib);
#if defined(HY_NO_THR)
@@ -1181,10 +1168,9 @@
*/
I_32
-zip_establishCache (HyPortLibrary * portLib, HyZipFile * zipFile)
+zip_establishCache (HyPortLibrary * portLib, VMIZipFile * zipFile)
{
PORT_ACCESS_FROM_PORT (portLib);
- I_32 result;
I_64 timeStamp, actualFileSize;
IDATA fileSize, filenameLength;
@@ -1192,13 +1178,9 @@
{
if (zipFile->cachePool)
{
- /* Whack cache timestamp to keep other people from starting to use it (we will create a new one for them
+ /* Invalidate the cache to keep other people from starting to use it (we will create a new one for them
to start to use instead). Once all the current users of the cache have stopped using it, it will go away */
-#ifndef HY_ZIP_API
- zipFile->cache->zipTimeStamp = -2;
-#else /* HY_ZIP_API */
- ((HyZipCache *)(zipFile->cache))->zipTimeStamp = -2;
-#endif /* HY_ZIP_API */
+ zipCache_invalidateCache(zipFile->cache);
zipCachePool_release (zipFile->cachePool, zipFile->cache);
}
zipFile->cache = NULL;
@@ -1224,21 +1206,22 @@
fileSize, timeStamp);
if (!zipFile->cache)
{
+ I_32 result = 0;
+ HyZipCentralEnd endEntry;
+ IDATA startCentralDir;
+ /* Find and read the end-of-central-dir record. */
+ result = scanForCentralEnd(portLib, zipFile, &endEntry);
+ if ( result != 0) return result;
+
+ startCentralDir = (IDATA)((UDATA)endEntry.dirOffset);
+
/* Build a new cache. Because caller asked for a cache, fail if we can't provide one */
zipFile->cache =
- zipCache_new (portLib, (char *) zipFile->filename, filenameLength);
+ zipCache_new (portLib, (char *) zipFile->filename, filenameLength, fileSize, timeStamp, startCentralDir);
if (!zipFile->cache)
return ZIP_ERR_OUT_OF_MEMORY;
-#ifndef HY_ZIP_API
- zipFile->cache->zipFileSize = fileSize;
- zipFile->cache->zipTimeStamp = timeStamp;
-#else /* HY_ZIP_API */
- ((HyZipCache *)(zipFile->cache))->zipFileSize = fileSize;
- ((HyZipCache *)(zipFile->cache))->zipTimeStamp = timeStamp;
-#endif /* HY_ZIP_API */
-
- result = zip_populateCache (portLib, zipFile);
+ result = zip_populateCache (portLib, zipFile, &endEntry, startCentralDir);
if (result != 0)
{
zipCache_kill (zipFile->cache);
@@ -1270,7 +1253,7 @@
*/
void
-zip_initZipEntry (HyPortLibrary * portLib, HyZipEntry * entry)
+zip_initZipEntry (HyPortLibrary * portLib, VMIZipEntry * entry)
{
memset (entry, 0, sizeof (*entry));
}
@@ -1290,7 +1273,7 @@
*/
void
-zip_freeZipEntry (HyPortLibrary * portLib, HyZipEntry * entry)
+zip_freeZipEntry (HyPortLibrary * portLib, VMIZipEntry * entry)
{
PORT_ACCESS_FROM_PORT (portLib);
@@ -1340,8 +1323,8 @@
*
*/
I_32
-zip_getNextZipEntry (HyPortLibrary * portLib, HyZipFile * zipFile,
- HyZipEntry * zipEntry, IDATA * nextEntryPointer)
+zip_getNextZipEntry (HyPortLibrary * portLib, VMIZipFile * zipFile,
+ VMIZipEntry * zipEntry, IDATA * nextEntryPointer)
{
PORT_ACCESS_FROM_PORT (portLib);
#if defined(HY_NO_THR)
@@ -1404,11 +1387,7 @@
FALSE);
if (result != entryStart)
{
-#ifndef HY_ZIP_API
- if (result >= zipFile->cache->startCentralDir)
-#else /* HY_ZIP_API */
- if (result >= ((HyZipCache *)(zipFile->cache))->startCentralDir)
-#endif /* HY_ZIP_API */
+ if (result >= zipCache_getStartCentralDir(zipFile->cache))
{
/* ! Cache contents are not valid. Invalidate it and make a new one */
if (!retryAllowed)
@@ -1468,8 +1447,8 @@
*/
I_32
-zip_getZipEntry (HyPortLibrary * portLib, HyZipFile * zipFile,
- HyZipEntry * entry, const char *filename,
+zip_getZipEntry (HyPortLibrary * portLib, VMIZipFile * zipFile,
+ VMIZipEntry * entry, const char *filename,
BOOLEAN findDirectory)
{
PORT_ACCESS_FROM_PORT (portLib);
@@ -1609,8 +1588,8 @@
*
*/
I_32
-zip_getZipEntryData (HyPortLibrary * portLib, HyZipFile * zipFile,
- HyZipEntry * entry, U_8 * buffer, U_32 bufferSize)
+zip_getZipEntryData (HyPortLibrary * portLib, VMIZipFile * zipFile,
+ VMIZipEntry * entry, U_8 * buffer, U_32 bufferSize)
{
PORT_ACCESS_FROM_PORT (portLib);
#if defined(HY_NO_THR)
@@ -1782,8 +1761,8 @@
* @see zip_freeZipEntry
*/
I_32
-zip_getZipEntryExtraField (HyPortLibrary * portLib, HyZipFile * zipFile,
- HyZipEntry * entry, U_8 * buffer, U_32 bufferSize)
+zip_getZipEntryExtraField (HyPortLibrary * portLib, VMIZipFile * zipFile,
+ VMIZipEntry * entry, U_8 * buffer, U_32 bufferSize)
{
PORT_ACCESS_FROM_PORT (portLib);
#if defined(HY_NO_THR)
@@ -1869,6 +1848,75 @@
#undef CDEV_CURRENT_FUNCTION
+/**
+ * Attempt to read the raw data for the zip entry entry.
+ *
+ * @param[in] portLib the port library
+ * @param[in] zipFile the zip file being read from.
+ * @param[in,out] entry the zip entry
+ * @param[in] buffer may not be NULL
+ * @param[in] bufferSize
+ * @param[in] offset from the start of the entry data
+
+ * @return 0 on success
+ * @return ZIP_ERR_FILE_READ_ERROR if there is an error reading from zipEntry
+ * @return ZIP_ERR_FILE_CORRUPT if zipFile is corrupt
+ * @return ZIP_ERR_ENTRY_NOT_FOUND if entry is not found
+ * @return ZIP_ERR_OUT_OF_MEMORY if there is not enough memory to complete this call
+ * @return ZIP_ERR_BUFFER_TOO_SMALL if buffer is too small to hold the comment for zipFile
+ *
+ * @see zip_freeZipEntry
+ *
+*/
+I_32 zip_getZipEntryRawData(HyPortLibrary* portLib, VMIZipFile* zipFile, VMIZipEntry* entry, U_8* buffer, U_32 bufferSize, U_32 offset)
+{
+ PORT_ACCESS_FROM_PORT(portLib);
+#if defined(HY_NO_THR)
+ THREAD_ACCESS_FROM_PORT(portLib);
+#endif /* HY_NO_THR */
+
+ I_32 result;
+ I_64 seekResult;
+
+ ENTER();
+
+ if((offset + bufferSize) > entry->compressedSize) {
+ EXIT();
+ /* Trying to read past the end of the data. */
+ return ZIP_ERR_INTERNAL_ERROR;
+ }
+
+ /* Just read the data in. */
+ if (zipFile->pointer != (entry->dataPointer + offset)) {
+ seekResult = hyfile_seek(zipFile->fd, entry->dataPointer + offset, HySeekSet);
+ if ((seekResult < 0) || (seekResult > HYCONST64(0x7FFFFFFF))) {
+ result = ZIP_ERR_FILE_READ_ERROR;
+ goto finished;
+ }
+ zipFile->pointer = (I_32) seekResult;
+
+ if (zipFile->pointer != (entry->dataPointer + offset)) {
+ result = ZIP_ERR_FILE_READ_ERROR;
+ goto finished;
+ }
+ }
+ result = hyfile_read(zipFile->fd, buffer, bufferSize);
+ if (result != bufferSize) {
+ result = ZIP_ERR_FILE_READ_ERROR;
+ goto finished;
+ }
+ zipFile->pointer += result;
+ EXIT();
+ return 0;
+
+finished:
+ if (result == ZIP_ERR_FILE_READ_ERROR) {
+ zipFile->pointer = -1;
+ }
+ EXIT();
+ return result;
+}
+
#define CDEV_CURRENT_FUNCTION zip_getZipEntryComment
/**
* Read the file comment for entry.
@@ -1893,8 +1941,8 @@
*/
I_32
-zip_getZipEntryComment (HyPortLibrary * portLib, HyZipFile * zipFile,
- HyZipEntry * entry, U_8 * buffer, U_32 bufferSize)
+zip_getZipEntryComment (HyPortLibrary * portLib, VMIZipFile * zipFile,
+ VMIZipEntry * entry, U_8 * buffer, U_32 bufferSize)
{
PORT_ACCESS_FROM_PORT (portLib);
#if defined(HY_NO_THR)
@@ -2007,7 +2055,7 @@
* @return ZIP_ERR_OUT_OF_MEMORY if we are out of memory
*/
I_32
-zip_openZipFile (HyPortLibrary * portLib, char *filename, HyZipFile * zipFile,
+zip_openZipFile (HyPortLibrary * portLib, char *filename, VMIZipFile * zipFile,
HyZipCachePool * cachePool)
{
PORT_ACCESS_FROM_PORT (portLib);
@@ -2142,18 +2190,14 @@
*
*/
void
-zip_resetZipFile (HyPortLibrary * portLib, HyZipFile * zipFile,
+zip_resetZipFile (HyPortLibrary * portLib, VMIZipFile * zipFile,
IDATA * nextEntryPointer)
{
*nextEntryPointer = 0;
if (zipFile)
{
if (zipFile->cache)
-#ifndef HY_ZIP_API
- *nextEntryPointer = zipFile->cache->startCentralDir;
-#else /* HY_ZIP_API */
- *nextEntryPointer = ((HyZipCache *)(zipFile->cache))->startCentralDir;
-#endif /* HY_ZIP_API */
+ *nextEntryPointer = zipCache_getStartCentralDir(zipFile->cache);
else
{
I_32 result;
@@ -2190,8 +2234,8 @@
* @see zip_freeZipEntry
*/
I_32
-zip_getZipEntryFromOffset (HyPortLibrary * portLib, HyZipFile * zipFile,
- HyZipEntry * entry, IDATA offset)
+zip_getZipEntryFromOffset (HyPortLibrary * portLib, VMIZipFile * zipFile,
+ VMIZipEntry * entry, IDATA offset)
{
PORT_ACCESS_FROM_PORT (portLib);
#if defined(HY_NO_THR)
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/hyzip/shared/zipsup.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/hyzip/shared/zipsup.h?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/hyzip/shared/zipsup.h (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/hyzip/shared/zipsup.h Tue Mar 4 00:02:13 2008
@@ -26,7 +26,7 @@
{
#endif
#include "hyport.h"
-#include "hyzip.h"
+#include "vmizip.h"
#if defined(HY_LOCAL_ZLIB)
#define HY_ZIP_DLL_NAME "z"
@@ -34,6 +34,16 @@
#define HY_ZIP_DLL_NAME "hyzlib"
#endif
+typedef struct HyZipCachePool HyZipCachePool;
+
+#define ZIP_CentralEnd 0x6054B50
+#define ZIP_CentralHeader 0x2014B50
+#define ZIP_LocalHeader 0x4034B50
+#define ZIP_DataDescriptor 0x8074B50
+#define ZIP_INTERNAL_MAX 80
+#define ZIP_Unknown 0
+#define ZIP_PKZIP 1
+
typedef struct HyZipCache
{
U_8 *zipFileName;
@@ -70,39 +80,42 @@
/* HySourceZipSupport*/
extern HY_CFUNC I_32 zip_getZipEntryData
- PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile,
- HyZipEntry * entry, U_8 * buffer, U_32 bufferSize));
+ PROTOTYPE ((HyPortLibrary * portLib, VMIZipFile * zipFile,
+ VMIZipEntry * entry, U_8 * buffer, U_32 bufferSize));
extern HY_CFUNC I_32 zip_getZipEntryFromOffset
- PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile,
- HyZipEntry * entry, IDATA offset));
+ PROTOTYPE ((HyPortLibrary * portLib, VMIZipFile * zipFile,
+ VMIZipEntry * entry, IDATA offset));
extern HY_CFUNC I_32 zip_establishCache
- PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile));
+ PROTOTYPE ((HyPortLibrary * portLib, VMIZipFile * zipFile));
extern HY_CFUNC void zip_resetZipFile
- PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile,
+ PROTOTYPE ((HyPortLibrary * portLib, VMIZipFile * zipFile,
IDATA * nextEntryPointer));
extern HY_CFUNC I_32 zip_getNextZipEntry
- PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile,
- HyZipEntry * zipEntry, IDATA * nextEntryPointer));
+ PROTOTYPE ((HyPortLibrary * portLib, VMIZipFile * zipFile,
+ VMIZipEntry * zipEntry, IDATA * nextEntryPointer));
extern HY_CFUNC I_32 zip_getZipEntry
- PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile,
- HyZipEntry * entry, const char *filename,
+ PROTOTYPE ((HyPortLibrary * portLib, VMIZipFile * zipFile,
+ VMIZipEntry * entry, const char *filename,
BOOLEAN findDirectory));
extern HY_CFUNC I_32 zip_getZipEntryExtraField
- PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile,
- HyZipEntry * entry, U_8 * buffer, U_32 bufferSize));
+ PROTOTYPE ((HyPortLibrary * portLib, VMIZipFile * zipFile,
+ VMIZipEntry * entry, U_8 * buffer, U_32 bufferSize));
+ extern HY_CFUNC I_32 zip_getZipEntryRawData
+ PROTOTYPE((HyPortLibrary * portLib, VMIZipFile * zipFile, VMIZipEntry * entry,
+ U_8 * buffer, U_32 bufferSize, U_32 offset));
extern HY_CFUNC void zip_initZipEntry
- PROTOTYPE ((HyPortLibrary * portLib, HyZipEntry * entry));
+ PROTOTYPE ((HyPortLibrary * portLib, VMIZipEntry * entry));
extern HY_CFUNC I_32 zip_openZipFile
- PROTOTYPE ((HyPortLibrary * portLib, char *filename, HyZipFile * zipFile,
+ PROTOTYPE ((HyPortLibrary * portLib, char *filename, VMIZipFile * zipFile,
HyZipCachePool * cachePool));
extern HY_CFUNC void zip_freeZipEntry
- PROTOTYPE ((HyPortLibrary * portLib, HyZipEntry * entry));
- struct HyZipFile;
+ PROTOTYPE ((HyPortLibrary * portLib, VMIZipEntry * entry));
+ struct VMIZipFile;
extern HY_CFUNC I_32 VMCALL zip_closeZipFile
- PROTOTYPE ((HyPortLibrary * portLib, struct HyZipFile * zipFile));
+ PROTOTYPE ((HyPortLibrary * portLib, struct VMIZipFile * zipFile));
extern HY_CFUNC I_32 zip_getZipEntryComment
- PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile,
- HyZipEntry * entry, U_8 * buffer, U_32 bufferSize));
+ PROTOTYPE ((HyPortLibrary * portLib, VMIZipFile * zipFile,
+ VMIZipEntry * entry, U_8 * buffer, U_32 bufferSize));
/* HySourceZipCache*/
extern HY_CFUNC UDATA zipCache_findElement
PROTOTYPE ((HyZipCache * zipCache, const char *elementName,
@@ -111,7 +124,7 @@
extern HY_CFUNC IDATA zipCache_enumGetDirName
PROTOTYPE ((void *handle, char *nameBuf, UDATA nameBufSize));
extern HY_CFUNC HyZipCache *zipCache_new
- PROTOTYPE ((HyPortLibrary * portLib, char *zipName, IDATA zipNameLength));
+ PROTOTYPE ((HyPortLibrary * portLib, char *zipName, IDATA zipNameLength, IDATA zipFileSize, I_64 zipTimeStamp, IDATA startCentralDir));
extern HY_CFUNC IDATA zipCache_enumNew
PROTOTYPE ((HyZipCache * zipCache, char *directoryName, void **handle));
extern HY_CFUNC IDATA zipCache_enumElement
@@ -121,6 +134,10 @@
extern HY_CFUNC BOOLEAN zipCache_addElement
PROTOTYPE ((HyZipCache * zipCache, char *elementName,
UDATA elementOffset));
+ extern HY_CFUNC IDATA zipCache_getStartCentralDir
+ PROTOTYPE ((HyZipCache *zipCache));
+ extern HY_CFUNC void zipCache_invalidateCache
+ PROTOTYPE ((HyZipCache *zipCache));
/* HySourceZipCachePool*/
extern HY_CFUNC BOOLEAN zipCachePool_release
PROTOTYPE ((HyZipCachePool * zcp, HyZipCache * zipCache));
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/shared/vmi.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/shared/vmi.h?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/shared/vmi.h (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/include/shared/vmi.h Tue Mar 4 00:02:13 2008
@@ -108,7 +108,7 @@
HyZipCachePool *(JNICALL * GetZipCachePool) (VMInterface * vmi);
#else /* HY_ZIP_API */
- struct HyZipFunctionTable *(JNICALL * GetZipFunctions) (VMInterface * vmi);
+ struct VMIZipFunctionTable *(JNICALL * GetZipFunctions) (VMInterface * vmi);
#endif /* HY_ZIP_API */
JavaVMInitArgs *(JNICALL * GetInitArgs) (VMInterface * vmi);
vmiError (JNICALL * GetSystemProperty) (VMInterface * vmi, char *key,
Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/launcher/shared/main.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/launcher/shared/main.c?rev=633384&r1=633383&r2=633384&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/launcher/shared/main.c (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/native/launcher/shared/main.c Tue Mar 4 00:02:13 2008
@@ -36,7 +36,7 @@
#define PORT_LIB_OPTION "_org.apache.harmony.vmi.portlib"
-#define HY_COPYRIGHT_STRING "Apache Harmony Launcher : (c) Copyright 1991, 2007 The Apache Software Foundation or its licensors, as applicable."
+#define HY_COPYRIGHT_STRING "Apache Harmony Launcher : (c) Copyright 1991, 2008 The Apache Software Foundation or its licensors, as applicable."
/* Tools launchers will invoke HY_TOOLS_PACKAGE+"."+<execname>+"."+HY_TOOLS_MAIN_TYPE */
#define HY_TOOLS_PACKAGE "org.apache.harmony.tools"