Index: depends/build/defines.mak
===================================================================
--- depends/build/defines.mak (revision 537917)
+++ depends/build/defines.mak (working copy)
@@ -71,3 +71,8 @@
!ELSE
HYCFLAGS = $(HYCFLAGS) -DHY_NO_SIG
!ENDIF
+
+!IF "$(HY_ZIP_API)" == "true"
+HYCFLAGS = $(HYCFLAGS) -DHY_ZIP_API
+!ENDIF
+
Index: depends/build/defines.mk
===================================================================
--- depends/build/defines.mk (revision 537917)
+++ depends/build/defines.mk (working copy)
@@ -80,3 +80,7 @@
else
DEFINES += -DHY_NO_SIG
endif
+
+ifeq ($(HY_ZIP_API),true)
+DEFINES += -DHY_ZIP_API
+endif
\ No newline at end of file
Index: make/properties.xml
===================================================================
--- make/properties.xml (revision 537917)
+++ make/properties.xml (working copy)
@@ -279,6 +279,13 @@
+
+
+
+
+
+
+
@@ -445,6 +452,7 @@
+
Index: modules/archive/build.xml
===================================================================
--- modules/archive/build.xml (revision 537917)
+++ modules/archive/build.xml (working copy)
@@ -43,11 +43,8 @@
-
+
-
-
-
@@ -54,6 +51,14 @@
+
+
+
+
+
+
+
+
@@ -66,9 +71,13 @@
-
+
+
+
+
+
Index: modules/archive/src/main/native/archive/shared/archiveglob.c
===================================================================
--- modules/archive/src/main/native/archive/shared/archiveglob.c (revision 537917)
+++ modules/archive/src/main/native/archive/shared/archiveglob.c (working copy)
@@ -99,6 +99,10 @@
JCLZipFile *jclZipFile;
PORT_ACCESS_FROM_ENV (env);
+#ifdef HY_ZIP_API
+ VMI_ACCESS_FROM_ENV(env);
+ HyZipFunctionTable *zipFuncs = (*VMI)->GetZipFunctions(VMI);
+#endif /* HY_ZIP_API */
/* Detach from the common library */
ClearLibDetach (env);
@@ -111,7 +115,11 @@
while (jclZipFile != NULL)
{
JCLZipFile *next = jclZipFile->next;
+#ifndef HY_ZIP_API
zip_closeZipFile (PORTLIB, &jclZipFile->hyZipFile);
+#else /* HY_ZIP_API */
+ zipFuncs->zip_closeZipFile (VMI, &jclZipFile->hyZipFile);
+#endif /* HY_ZIP_API */
jclmem_free_memory (env, jclZipFile);
jclZipFile = next;
}
Index: modules/archive/src/main/native/archive/shared/deflater.c
===================================================================
--- modules/archive/src/main/native/archive/shared/deflater.c (revision 537917)
+++ modules/archive/src/main/native/archive/shared/deflater.c (working copy)
@@ -24,8 +24,10 @@
#include "jclglob.h"
#include "jclprots.h"
+#ifndef HY_ZIP_API
void zfree PROTOTYPE ((void *opaque, void *address));
void *zalloc PROTOTYPE ((void *opaque, U_32 items, U_32 size));
+#endif
JNIEXPORT void JNICALL
Java_java_util_zip_Deflater_setDictionaryImpl (JNIEnv * env, jobject recv,
@@ -92,7 +94,6 @@
jboolean noHeader)
{
PORT_ACCESS_FROM_ENV (env);
-
JCLZipStream *jstream;
z_stream *stream;
int err = 0;
@@ -97,6 +98,11 @@
z_stream *stream;
int err = 0;
int wbits = 15; /*Use MAX for fastest */
+#ifdef HY_ZIP_API
+ VMI_ACCESS_FROM_ENV (env);
+ HyZipFunctionTable *zipFuncs;
+ zipFuncs = (*VMI)->GetZipFunctions(VMI);
+#endif
/*Allocate mem for wrapped struct */
jstream = jclmem_allocate_memory (env, sizeof (JCLZipStream));
@@ -113,9 +119,15 @@
throwNewOutOfMemoryError (env, "");
return -1;
}
+#ifndef HY_ZIP_API
stream->opaque = (void *) privatePortLibrary;
stream->zalloc = zalloc;
stream->zfree = zfree;
+#else
+ stream->opaque = (void *) VMI;
+ stream->zalloc = zipFuncs->zip_zalloc;
+ stream->zfree =zipFuncs->zip_zfree;
+#endif
jstream->stream = stream;
jstream->dict = NULL;
jstream->inaddr = NULL;
Index: modules/archive/src/main/native/archive/shared/inflater.c
===================================================================
--- modules/archive/src/main/native/archive/shared/inflater.c (revision 537917)
+++ modules/archive/src/main/native/archive/shared/inflater.c (working copy)
@@ -36,6 +36,11 @@
z_stream *stream;
int err = 0;
int wbits = 15; /*Use MAX for fastest */
+#ifdef HY_ZIP_API
+ VMI_ACCESS_FROM_ENV (env);
+ HyZipFunctionTable *zipFuncs;
+ zipFuncs = (*VMI)->GetZipFunctions(VMI);
+#endif
/*Allocate mem for wrapped struct */
jstream = jclmem_allocate_memory (env, sizeof (JCLZipStream));
@@ -53,9 +58,15 @@
throwNewOutOfMemoryError (env, "");
return -1;
}
+#ifndef HY_ZIP_API
stream->opaque = (void *) privatePortLibrary;
stream->zalloc = zalloc;
stream->zfree = zfree;
+#else
+ stream->opaque = (void *) VMI;
+ stream->zalloc = zipFuncs->zip_zalloc;
+ stream->zfree = zipFuncs->zip_zfree;
+#endif
stream->adler = 1;
jstream->stream = stream;
jstream->dict = NULL;
Index: modules/archive/src/main/native/archive/shared/jarfile.c
===================================================================
--- modules/archive/src/main/native/archive/shared/jarfile.c (revision 537917)
+++ modules/archive/src/main/native/archive/shared/jarfile.c (working copy)
@@ -20,8 +20,12 @@
#include "exceptions.h"
#include "jclglob.h"
#include "jclprots.h"
+#ifndef HY_ZIP_API
#include "zipsup.h"
+#else /* HY_ZIP_API */
+#include "hyzip.h"
+#endif /* HY_ZIP_API */
/* Build a new ZipEntry from the C struct */
jobject
@@ -28,9 +32,15 @@
createZipEntry (JNIEnv * env, HyZipFile * zipFile, HyZipEntry * zipEntry)
{
PORT_ACCESS_FROM_ENV (env);
+#ifdef HY_ZIP_API
+ VMI_ACCESS_FROM_ENV(env);
+#endif /* HY_ZIP_API */
jclass javaClass;
jobject java_ZipEntry, extra, entryName;
jmethodID mid;
+#ifdef HY_ZIP_API
+ HyZipFunctionTable *zipFuncs = (*VMI)->GetZipFunctions(VMI);
+#endif /* HY_ZIP_API */
/* Build a new ZipEntry from the C struct */
entryName = ((*env)->NewStringUTF (env, zipEntry->filename));
@@ -40,7 +50,11 @@
extra = NULL;
if (zipEntry->extraFieldLength > 0)
{
+#ifndef HY_ZIP_API
zip_getZipEntryExtraField (PORTLIB, zipFile, zipEntry, NULL,
+#else /* HY_ZIP_API */
+ zipFuncs->zip_getZipEntryExtraField (VMI, zipFile, zipEntry, NULL,
+#endif /* HY_ZIP_API */
zipEntry->extraFieldLength);
if (zipEntry->extraField == NULL)
return NULL;
@@ -81,6 +95,9 @@
#define RESULT_BUF_SIZE 256
PORT_ACCESS_FROM_ENV (env);
+#ifdef HY_ZIP_API
+ VMI_ACCESS_FROM_ENV(env);
+#endif /* HY_ZIP_API */
JCLZipFile *jclZipFile;
HyZipFile *zipFile;
@@ -97,6 +114,9 @@
char startNameBuf[MAX_PATH];
UDATA nameBufSize = MAX_PATH;
IDATA rc;
+#ifdef HY_ZIP_API
+ HyZipFunctionTable *zipFuncs = (*VMI)->GetZipFunctions(VMI);
+#endif /* HY_ZIP_API */
nameBuf = (char *) &startNameBuf;
@@ -113,11 +133,19 @@
if (zipFile->cache)
{
+#ifndef HY_ZIP_API
if (zipCache_enumNew (zipFile->cache, "META-INF/", &scanPtr))
+#else /* HY_ZIP_API */
+ if (zipFuncs->zipCache_enumNew (zipFile->cache, "META-INF/", &scanPtr))
+#endif /* HY_ZIP_API */
return NULL;
if (0 !=
+#ifndef HY_ZIP_API
zipCache_enumGetDirName (scanPtr, (char *) &metaInfName,
+#else /* HY_ZIP_API */
+ zipFuncs->zipCache_enumGetDirName (scanPtr, (char *) &metaInfName,
+#endif /* HY_ZIP_API */
sizeof (metaInfName)))
return NULL;
@@ -123,7 +151,11 @@
for (;;)
{
+#ifndef HY_ZIP_API
rc = zipCache_enumElement (scanPtr, nameBuf, nameBufSize, &offset);
+#else /* HY_ZIP_API */
+ rc = zipFuncs->zipCache_enumElement (scanPtr, nameBuf, nameBufSize, &offset);
+#endif /* HY_ZIP_API */
if (rc < 0)
{
break; /* we're done, leave the loop */
@@ -144,11 +176,20 @@
continue; /* go to the top of the loop again */
}
+#ifndef HY_ZIP_API
zip_initZipEntry (PORTLIB, &zipEntry);
if (zip_getZipEntryFromOffset (PORTLIB, zipFile, &zipEntry, offset))
+#else /* HY_ZIP_API */
+ zipFuncs->zip_initZipEntry (VMI, &zipEntry);
+ if (zipFuncs->zip_getZipEntryFromOffset (VMI, zipFile, &zipEntry, offset))
+#endif /* HY_ZIP_API */
goto cleanup;
current = createZipEntry (env, zipFile, &zipEntry);
+#ifndef HY_ZIP_API
zip_freeZipEntry (PORTLIB, &zipEntry);
+#else /* HY_ZIP_API */
+ zipFuncs->zip_freeZipEntry (VMI, &zipEntry);
+#endif /* HY_ZIP_API */
if (resultCount == RESULT_BUF_SIZE)
goto cleanup; /* fail - should fix. */
if (current)
@@ -173,7 +214,11 @@
(*env)->SetObjectArrayElement (env, result, i, resultArray[i]);
}
cleanup:
+#ifndef HY_ZIP_API
zipCache_enumKill (scanPtr);
+#else /* HY_ZIP_API */
+ zipFuncs->zipCache_enumKill (scanPtr);
+#endif /* HY_ZIP_API */
if (oldNameBuf)
jclmem_free_memory (env, oldNameBuf); /* free old before checking result so we clean up on fail */
return result;
Index: modules/archive/src/main/native/archive/shared/zip.c
===================================================================
--- modules/archive/src/main/native/archive/shared/zip.c (revision 537917)
+++ modules/archive/src/main/native/archive/shared/zip.c (working copy)
@@ -54,7 +54,11 @@
JCLZipFileLink *zipfileHandles;
jsize length;
char pathCopy[HyMaxPath];
+#ifndef HY_ZIP_API
HyZipCachePool *zipCachePool;
+#else /* HY_ZIP_API */
+ HyZipFunctionTable *zipFuncs;
+#endif /* HY_ZIP_API */
jclZipFile = jclmem_allocate_memory (env, sizeof (*jclZipFile));
if (!jclZipFile)
@@ -66,6 +70,7 @@
pathCopy[length++] = '\0';
ioh_convertToPlatform (pathCopy);
+#ifndef HY_ZIP_API
/* Open the zip file (caching will be managed automatically by zipsup) */
zipCachePool = (*VMI)->GetZipCachePool (VMI);
retval =
@@ -71,6 +76,11 @@
retval =
zip_openZipFile (privatePortLibrary, pathCopy, &(jclZipFile->hyZipFile),
zipCachePool);
+#else /* HY_ZIP_API */
+ /* Open the zip file (caching will be managed automatically) */
+ zipFuncs = (*VMI)->GetZipFunctions(VMI);
+ retval = zipFuncs->zip_openZipFile(VMI, pathCopy, &(jclZipFile->hyZipFile));
+#endif /* HY_ZIP_API */
if (retval)
{
@@ -103,6 +113,9 @@
Java_java_util_zip_ZipFile_getEntryImpl (JNIEnv * env, jobject recv,
jlong zipPointer, jstring entryName)
{
+#ifdef HY_ZIP_API
+ VMI_ACCESS_FROM_ENV(env);
+#endif /* HY_ZIP_API */
PORT_ACCESS_FROM_ENV (env);
I_32 retval;
@@ -113,6 +126,9 @@
jmethodID mid;
const char *entryCopy;
JCLZipFile *jclZipFile = (JCLZipFile *) (IDATA) zipPointer;
+#ifdef HY_ZIP_API
+ HyZipFunctionTable *zipFuncs = (*VMI)->GetZipFunctions(VMI);
+#endif /* HY_ZIP_API */
if (jclZipFile == (void *) -1)
{
@@ -124,12 +140,21 @@
if (entryCopy == NULL)
return (jobject) NULL;
+#ifndef HY_ZIP_API
zip_initZipEntry (PORTLIB, &zipEntry);
retval = zip_getZipEntry (PORTLIB, zipFile, &zipEntry, entryCopy, TRUE);
+#else /* HY_ZIP_API */
+ zipFuncs->zip_initZipEntry (VMI, &zipEntry);
+ retval = zipFuncs->zip_getZipEntry (VMI, zipFile, &zipEntry, entryCopy, TRUE);
+#endif /* HY_ZIP_API */
(*env)->ReleaseStringUTFChars (env, entryName, entryCopy);
if (retval)
{
+#ifndef HY_ZIP_API
zip_freeZipEntry (PORTLIB, &zipEntry);
+#else /* HY_ZIP_API */
+ zipFuncs->zip_freeZipEntry (VMI, &zipEntry);
+#endif /* HY_ZIP_API */
return (jobject) NULL;
}
@@ -136,11 +161,19 @@
extra = NULL;
if (zipEntry.extraFieldLength > 0)
{
+#ifndef HY_ZIP_API
zip_getZipEntryExtraField (PORTLIB, zipFile, &zipEntry, NULL,
+#else /* HY_ZIP_API */
+ zipFuncs->zip_getZipEntryExtraField (VMI, zipFile, &zipEntry, NULL,
+#endif /* HY_ZIP_API */
zipEntry.extraFieldLength);
if (zipEntry.extraField == NULL)
{
+#ifndef HY_ZIP_API
zip_freeZipEntry (PORTLIB, &zipEntry);
+#else /* HY_ZIP_API */
+ zipFuncs->zip_freeZipEntry (VMI, &zipEntry);
+#endif /* HY_ZIP_API */
return (jobject) NULL;
}
extra = ((*env)->NewByteArray (env, zipEntry.extraFieldLength));
@@ -146,7 +179,11 @@
extra = ((*env)->NewByteArray (env, zipEntry.extraFieldLength));
if (((*env)->ExceptionCheck (env)))
{
+#ifndef HY_ZIP_API
zip_freeZipEntry (PORTLIB, &zipEntry);
+#else /* HY_ZIP_API */
+ zipFuncs->zip_freeZipEntry (VMI, &zipEntry);
+#endif /* HY_ZIP_API */
return (jobject) NULL;
}
((*env)->
@@ -157,7 +194,11 @@
entryClass = JCL_CACHE_GET (env, CLS_java_util_zip_ZipEntry);
entryClass = (*env)->NewLocalRef(env, entryClass);
if (entryClass == NULL) {
+#ifndef HY_ZIP_API
zip_freeZipEntry (PORTLIB, &zipEntry);
+#else /* HY_ZIP_API */
+ zipFuncs->zip_freeZipEntry (VMI, &zipEntry);
+#endif /* HY_ZIP_API */
return (jobject) NULL;
}
mid = JCL_CACHE_GET (env, MID_java_util_zip_ZipEntry_init);
@@ -171,7 +212,11 @@
zipEntry.compressionMethod,
(jlong) zipEntry.lastModDate,
(jlong) zipEntry.dataPointer));
+#ifndef HY_ZIP_API
zip_freeZipEntry (PORTLIB, &zipEntry);
+#else /* HY_ZIP_API */
+ zipFuncs->zip_freeZipEntry (VMI, &zipEntry);
+#endif /* HY_ZIP_API */
return java_ZipEntry;
}
@@ -179,6 +224,9 @@
Java_java_util_zip_ZipFile_closeZipImpl (JNIEnv * env, jobject recv)
{
PORT_ACCESS_FROM_ENV (env);
+#ifdef HY_ZIP_API
+ VMI_ACCESS_FROM_ENV(env);
+#endif /* HY_ZIP_API */
I_32 retval = 0;
JCLZipFile *jclZipFile;
@@ -184,6 +232,9 @@
JCLZipFile *jclZipFile;
jfieldID descriptorFID =
JCL_CACHE_GET (env, FID_java_util_zip_ZipFile_descriptor);
+#ifdef HY_ZIP_API
+ HyZipFunctionTable *zipFuncs = (*VMI)->GetZipFunctions(VMI);
+#endif /* HY_ZIP_API */
jclZipFile = (JCLZipFile *) (IDATA) (*env)->GetLongField (env, recv, descriptorFID);
if (jclZipFile != (void *) -1)
@@ -189,7 +240,11 @@
if (jclZipFile != (void *) -1)
{
retval =
+#ifndef HY_ZIP_API
zip_closeZipFile (privatePortLibrary, &(jclZipFile->hyZipFile));
+#else /* HY_ZIP_API */
+ zipFuncs->zip_closeZipFile (VMI, &(jclZipFile->hyZipFile));
+#endif /* HY_ZIP_API */
(*env)->SetLongField (env, recv, descriptorFID, -1);
/* Free the zip struct */
@@ -276,9 +331,15 @@
jlong descriptor)
{
PORT_ACCESS_FROM_ENV (env);
+#ifdef HY_ZIP_API
+ VMI_ACCESS_FROM_ENV(env);
+#endif /* HY_ZIP_API */
IDATA nextEntryPointer;
JCLZipFile *jclZipFile = (JCLZipFile *) (IDATA) descriptor;
+#ifdef HY_ZIP_API
+ HyZipFunctionTable *zipFuncs = (*VMI)->GetZipFunctions(VMI);
+#endif /* HY_ZIP_API */
if (jclZipFile == (void *) -1)
{
@@ -285,7 +346,11 @@
throwNewIllegalStateException (env, "");
return 0;
}
+#ifndef HY_ZIP_API
zip_resetZipFile (privatePortLibrary,
+#else /* HY_ZIP_API */
+ zipFuncs->zip_resetZipFile (VMI,
+#endif /* HY_ZIP_API */
&(jclZipFile->hyZipFile),
&nextEntryPointer);
return nextEntryPointer;
@@ -298,6 +363,9 @@
jlong nextEntry)
{
PORT_ACCESS_FROM_ENV (env);
+#ifdef HY_ZIP_API
+ VMI_ACCESS_FROM_ENV(env);
+#endif /* HY_ZIP_API */
I_32 retval;
HyZipFile *zipFile;
@@ -308,6 +376,9 @@
jstring entryName = NULL;
IDATA nextEntryPointer;
JCLZipFile *jclZipFile = (JCLZipFile *) (IDATA) descriptor;
+#ifdef HY_ZIP_API
+ HyZipFunctionTable *zipFuncs = (*VMI)->GetZipFunctions(VMI);
+#endif /* HY_ZIP_API */
if (jclZipFile == (void *) -1)
{
@@ -315,11 +386,19 @@
return NULL;
}
zipFile = &(jclZipFile->hyZipFile);
+#ifndef HY_ZIP_API
zip_initZipEntry (PORTLIB, &zipEntry);
+#else /* HY_ZIP_API */
+ zipFuncs->zip_initZipEntry (VMI, &zipEntry);
+#endif /* HY_ZIP_API */
nextEntryPointer = (IDATA) nextEntry;
retval =
+#ifndef HY_ZIP_API
zip_getNextZipEntry (PORTLIB, zipFile, &zipEntry, &nextEntryPointer);
+#else /* HY_ZIP_API */
+ zipFuncs->zip_getNextZipEntry (VMI, zipFile, &zipEntry, &nextEntryPointer);
+#endif /* HY_ZIP_API */
if (retval)
{
if (retval != ZIP_ERR_NO_MORE_ENTRIES)
@@ -340,7 +419,11 @@
extra = NULL;
if (zipEntry.extraFieldLength > 0)
{
+#ifndef HY_ZIP_API
zip_getZipEntryExtraField (PORTLIB, zipFile, &zipEntry, NULL,
+#else /* HY_ZIP_API */
+ zipFuncs->zip_getZipEntryExtraField (VMI, zipFile, &zipEntry, NULL,
+#endif /* HY_ZIP_API */
zipEntry.extraFieldLength);
extra = ((*env)->NewByteArray (env, zipEntry.extraFieldLength));
if (((*env)->ExceptionCheck (env)))
@@ -346,7 +429,11 @@
if (((*env)->ExceptionCheck (env)))
{
/* free the extraField entry */
+#ifndef HY_ZIP_API
zip_freeZipEntry (PORTLIB, &zipEntry);
+#else /* HY_ZIP_API */
+ zipFuncs->zip_freeZipEntry (VMI, &zipEntry);
+#endif /* HY_ZIP_API */
return NULL;
}
((*env)->
@@ -371,7 +458,11 @@
zipEntry.compressionMethod,
(jlong) zipEntry.lastModDate,
(jlong) zipEntry.dataPointer));
+#ifndef HY_ZIP_API
zip_freeZipEntry (PORTLIB, &zipEntry);
+#else /* HY_ZIP_API */
+ zipFuncs->zip_freeZipEntry (VMI, &zipEntry);
+#endif /* HY_ZIP_API */
(*env)->SetLongField (env, recv,
JCL_CACHE_GET (env,
FID_java_util_zip_ZipFile_nextEntryPointer),
@@ -385,6 +476,9 @@
jstring entryName)
{
PORT_ACCESS_FROM_ENV (env);
+#ifdef HY_ZIP_API
+ VMI_ACCESS_FROM_ENV(env);
+#endif /* HY_ZIP_API */
I_32 retval;
HyZipFile *zipFile;
@@ -392,6 +486,9 @@
const char *entryCopy;
jbyteArray buf;
JCLZipFile *jclZipFile = (JCLZipFile *) (IDATA) descriptor;
+#ifdef HY_ZIP_API
+ HyZipFunctionTable *zipFuncs = (*VMI)->GetZipFunctions(VMI);
+#endif /* HY_ZIP_API */
/* Build the zipFile */
if (jclZipFile == (void *) -1)
@@ -404,13 +501,25 @@
if (entryCopy == NULL)
return NULL;
+#ifndef HY_ZIP_API
zip_initZipEntry (privatePortLibrary, &zipEntry);
+#else /* HY_ZIP_API */
+ zipFuncs->zip_initZipEntry (VMI, &zipEntry);
+#endif /* HY_ZIP_API */
retval =
+#ifndef HY_ZIP_API
zip_getZipEntry (privatePortLibrary, zipFile, &zipEntry, entryCopy, TRUE);
+#else /* HY_ZIP_API */
+ zipFuncs->zip_getZipEntry (VMI, zipFile, &zipEntry, entryCopy, TRUE);
+#endif /* HY_ZIP_API */
(*env)->ReleaseStringUTFChars (env, entryName, entryCopy);
if (retval)
{
+#ifndef HY_ZIP_API
zip_freeZipEntry (privatePortLibrary, &zipEntry);
+#else /* HY_ZIP_API */
+ zipFuncs->zip_freeZipEntry (VMI, &zipEntry);
+#endif /* HY_ZIP_API */
if (retval == ZIP_ERR_OUT_OF_MEMORY)
throwNewOutOfMemoryError (env, "");
return NULL;
@@ -424,7 +533,11 @@
}
retval =
+#ifndef HY_ZIP_API
zip_getZipEntryData (privatePortLibrary, zipFile, &zipEntry, NULL,
+#else /* HY_ZIP_API */
+ zipFuncs->zip_getZipEntryData (VMI, zipFile, &zipEntry, NULL,
+#endif /* HY_ZIP_API */
zipEntry.uncompressedSize);
if (retval == 0)
(*env)->SetByteArrayRegion (env, buf, 0, zipEntry.uncompressedSize,
@@ -429,7 +542,11 @@
if (retval == 0)
(*env)->SetByteArrayRegion (env, buf, 0, zipEntry.uncompressedSize,
zipEntry.data);
+#ifndef HY_ZIP_API
zip_freeZipEntry (privatePortLibrary, &zipEntry);
+#else /* HY_ZIP_API */
+ zipFuncs->zip_freeZipEntry (VMI, &zipEntry);
+#endif /* HY_ZIP_API */
if (!retval)
return buf;
Index: modules/archive/src/main/native/archive/shared/zip.h
===================================================================
--- modules/archive/src/main/native/archive/shared/zip.h (revision 537917)
+++ modules/archive/src/main/native/archive/shared/zip.h (working copy)
@@ -18,7 +18,11 @@
#if !defined(zip_h)
#define zip_h
+#ifndef HY_ZIP_API
#include "zipsup.h"
+#else /* HY_ZIP_API */
+#include "hyzip.h"
+#endif /* HY_ZIP_API */
typedef struct JCLZipFile
{
Index: modules/archive/src/main/native/archive/unix/makefile
===================================================================
--- modules/archive/src/main/native/archive/unix/makefile (revision 537917)
+++ modules/archive/src/main/native/archive/unix/makefile (working copy)
@@ -26,8 +26,12 @@
$(SHAREDSUB)zip.o $(SHAREDSUB)adler32.o $(SHAREDSUB)inflater.o \
$(SHAREDSUB)jarfile.o $(SHAREDSUB)deflater.o $(SHAREDSUB)archiveglob.o
+ifneq ($(HY_ZIP_API),true)
+MDLLIBFILES += $(LIBPATH)libhyzip.a
+endif
+
MDLLIBFILES += \
- $(LIBPATH)libhyzip.a $(DLLPATH)libhyzlib$(HY_LINKLIB_SUFFIX) \
+ $(DLLPATH)libhyzlib$(HY_LINKLIB_SUFFIX) \
$(LIBPATH)libhypool.a $(LIBPATH)libhyfdlibm.a $(LIBPATH)libvmi$(HY_LINKLIB_SUFFIX)
DLLNAME=../libhyarchive$(HY_SHLIB_SUFFIX)
Index: modules/archive/src/main/native/archive/windows/makefile
===================================================================
--- modules/archive/src/main/native/archive/windows/makefile (revision 537917)
+++ modules/archive/src/main/native/archive/windows/makefile (working copy)
@@ -36,9 +36,13 @@
SYSLIBFILES = ws2_32.lib Iphlpapi.lib
+!IF "$(HY_ZIP_API)" != "true"
+MDLLIBFILES = $(MDLLIBFILES) $(LIBPATH)hyzip$(HY_LINKLIB_SUFFIX)
+!ENDIF
+
MDLLIBFILES = $(MDLLIBFILES) \
- $(LIBPATH)hyzip$(HY_LINKLIB_SUFFIX) \
- $(LIBPATH)hyzlib$(HY_LINKLIB_SUFFIX) $(LIBPATH)hypool$(HY_LINKLIB_SUFFIX) \
+ $(LIBPATH)hyzlib$(HY_LINKLIB_SUFFIX) \
+ $(LIBPATH)hypool$(HY_LINKLIB_SUFFIX) \
$(LIBPATH)hyfdlibm$(HY_LINKLIB_SUFFIX) $(LIBPATH)vmi$(HY_LINKLIB_SUFFIX)
DLLBASE=0x13100000
Index: modules/auth/src/main/native/auth/unix/makefile
===================================================================
--- modules/auth/src/main/native/auth/unix/makefile (revision 537917)
+++ modules/auth/src/main/native/auth/unix/makefile (working copy)
@@ -21,9 +21,14 @@
CFLAGS += -fpic
BUILDFILES = $(SHAREDSUB)auth_copyright.o authnix.o
+
+ifneq ($(HY_ZIP_API),true)
+MDLLIBFILES += $(LIBPATH)libhyzip.a $(DLLPATH)libhyzlib$(HY_LINKLIB_SUFFIX)
+endif
+
MDLLIBFILES += \
- $(LIBPATH)libhyzip.a $(DLLPATH)libhyzlib$(HY_LINKLIB_SUFFIX) \
- $(LIBPATH)libhypool.a $(LIBPATH)libhyfdlibm.a $(LIBPATH)libvmi$(HY_LINKLIB_SUFFIX)
+ $(LIBPATH)libhypool.a $(LIBPATH)libhyfdlibm.a \
+ $(LIBPATH)libvmi$(HY_LINKLIB_SUFFIX)
DLLNAME = ../libhyauth$(HY_SHLIB_SUFFIX)
EXPNAME = HYAUTH_0.1
Index: modules/auth/src/main/native/auth/windows/makefile
===================================================================
--- modules/auth/src/main/native/auth/windows/makefile (revision 537917)
+++ modules/auth/src/main/native/auth/windows/makefile (working copy)
@@ -28,8 +28,12 @@
SYSLIBFILES = ws2_32.lib Iphlpapi.lib
-MDLLIBFILES = $(MDLLIBFILES) $(LIBPATH)hyzip$(HY_LINKLIB_SUFFIX) \
- $(LIBPATH)hyzlib$(HY_LINKLIB_SUFFIX) $(LIBPATH)hypool$(HY_LINKLIB_SUFFIX) \
+!IF "$(HY_ZIP_API)" != "true"
+MDLLIBFILES = $(MDLLIBFILES) \
+ $(LIBPATH)hyzip$(HY_LINKLIB_SUFFIX) $(LIBPATH)hyzlib$(HY_LINKLIB_SUFFIX)
+!ENDIF
+
+MDLLIBFILES = $(MDLLIBFILES) $(LIBPATH)hypool$(HY_LINKLIB_SUFFIX) \
$(LIBPATH)hyfdlibm$(HY_LINKLIB_SUFFIX) $(LIBPATH)vmi$(HY_LINKLIB_SUFFIX)
DLLBASE=0x1300000
COMMENT=/comment:"Auth component native code. (c) Copyright 2005, 2006 The Apache Software Foundation or its licensors, as applicable."
Index: modules/awt/src/main/native/gl/unix/makefile
===================================================================
--- modules/awt/src/main/native/gl/unix/makefile (revision 537917)
+++ modules/awt/src/main/native/gl/unix/makefile (working copy)
@@ -28,9 +28,13 @@
$(SHAREDSUB)/SurfaceDataStructure.o \
libpng.a
+ifneq ($(HY_ZIP_API),true)
MDLLIBFILES += \
- $(LIBPATH)libhyzip.a $(DLLPATH)libhyzlib$(HY_LINKLIB_SUFFIX) \
- $(LIBPATH)libhypool.a $(LIBPATH)libhyfdlibm.a $(LIBPATH)libvmi$(HY_LINKLIB_SUFFIX)
+ $(LIBPATH)libhyzip.a $(DLLPATH)libhyzlib$(HY_LINKLIB_SUFFIX)
+endif
+
+MDLLIBFILES += $(LIBPATH)libhypool.a $(LIBPATH)libhyfdlibm.a \
+ $(LIBPATH)libvmi$(HY_LINKLIB_SUFFIX)
OSLIBS += $(STDCLIBS)
Index: modules/awt/src/main/native/jpegdecoder/unix/makefile
===================================================================
--- modules/awt/src/main/native/jpegdecoder/unix/makefile (revision 537917)
+++ modules/awt/src/main/native/jpegdecoder/unix/makefile (working copy)
@@ -24,9 +24,12 @@
$(SHAREDSUB)JpegDecoder.o \
libjpeg.a
-MDLLIBFILES += \
- $(LIBPATH)libhyzip.a $(DLLPATH)libhyzlib$(HY_LINKLIB_SUFFIX) \
- $(LIBPATH)libhypool.a $(LIBPATH)libhyfdlibm.a $(LIBPATH)libvmi$(HY_LINKLIB_SUFFIX)
+ifneq ($(HY_ZIP_API),true)
+MDLLIBFILES += $(LIBPATH)libhyzip.a $(DLLPATH)libhyzlib$(HY_LINKLIB_SUFFIX)
+endif
+
+MDLLIBFILES += $(LIBPATH)libhypool.a $(LIBPATH)libhyfdlibm.a \
+ $(LIBPATH)libvmi$(HY_LINKLIB_SUFFIX)
DLLNAME=../libjpegdecoder$(HY_SHLIB_SUFFIX)
EXPNAME=HYJPEGDECODER_0.1
Index: modules/awt/src/main/native/lcmm/unix/makefile
===================================================================
--- modules/awt/src/main/native/lcmm/unix/makefile (revision 537917)
+++ modules/awt/src/main/native/lcmm/unix/makefile (working copy)
@@ -28,9 +28,12 @@
$(SHAREDSUB)/NativeImageFormat.o \
liblcms.a
-MDLLIBFILES += \
- $(LIBPATH)libhyzip.a $(DLLPATH)libhyzlib$(HY_LINKLIB_SUFFIX) \
- $(LIBPATH)libhypool.a $(LIBPATH)libhyfdlibm.a $(LIBPATH)libvmi$(HY_LINKLIB_SUFFIX)
+ifneq ($(HY_ZIP_API),true)
+MDLLIBFILES += $(LIBPATH)libhyzip.a $(DLLPATH)libhyzlib$(HY_LINKLIB_SUFFIX)
+endif
+
+MDLLIBFILES += $(LIBPATH)libhypool.a $(LIBPATH)libhyfdlibm.a \
+ $(LIBPATH)libvmi$(HY_LINKLIB_SUFFIX)
DLLNAME=../liblcmm$(HY_SHLIB_SUFFIX)
EXPNAME=HYLCMM_0.1
Index: modules/awt/src/main/native/linuxfont/unix/makefile
===================================================================
--- modules/awt/src/main/native/linuxfont/unix/makefile (revision 537917)
+++ modules/awt/src/main/native/linuxfont/unix/makefile (working copy)
@@ -24,9 +24,12 @@
BUILDFILES = LinuxNativeFont.o
-MDLLIBFILES += \
- $(LIBPATH)libhyzip.a $(DLLPATH)libhyzlib$(HY_LINKLIB_SUFFIX) \
- $(LIBPATH)libhypool.a $(LIBPATH)libhyfdlibm.a $(LIBPATH)libvmi$(HY_LINKLIB_SUFFIX)
+ifneq ($(HY_ZIP_API),true)
+MDLLIBFILES += $(LIBPATH)libhyzip.a $(DLLPATH)libhyzlib$(HY_LINKLIB_SUFFIX)
+endif
+
+MDLLIBFILES += $(LIBPATH)libhypool.a $(LIBPATH)libhyfdlibm.a \
+ $(LIBPATH)libvmi$(HY_LINKLIB_SUFFIX)
OSLIBS += $(XLIBS)
Index: modules/awt/src/main/native/oglwrapper/unix/makefile
===================================================================
--- modules/awt/src/main/native/oglwrapper/unix/makefile (revision 537917)
+++ modules/awt/src/main/native/oglwrapper/unix/makefile (working copy)
@@ -1,33 +1,36 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-include $(HY_HDK)/build/make/defines.mk
-
-CFLAGS += -fpic
-INCLUDES += -I$(SHARED)common -I$(SHAREDSUB)/include
-
-BUILDFILES = \
- $(SHAREDSUB)/org_apache_harmony_awt_gl_opengl_GL.o
-
-MDLLIBFILES += \
- $(LIBPATH)libhyzip.a $(DLLPATH)libhyzlib$(HY_LINKLIB_SUFFIX) \
- $(LIBPATH)libhypool.a $(LIBPATH)libhyfdlibm.a $(LIBPATH)libvmi$(HY_LINKLIB_SUFFIX)
-
-OSLIBS += $(STDCLIBS)
-
-DLLNAME=../liboglwrapper$(HY_SHLIB_SUFFIX)
-EXPNAME=HYOGLWRAPPER_0.1
-
-include $(HY_HDK)/build/make/rules.mk
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+include $(HY_HDK)/build/make/defines.mk
+
+CFLAGS += -fpic
+INCLUDES += -I$(SHARED)common -I$(SHAREDSUB)/include
+
+BUILDFILES = \
+ $(SHAREDSUB)/org_apache_harmony_awt_gl_opengl_GL.o
+
+ifneq ($(HY_ZIP_API),true)
+MDLLIBFILES += $(LIBPATH)libhyzip.a $(DLLPATH)libhyzlib$(HY_LINKLIB_SUFFIX)
+endif
+
+MDLLIBFILES += $(LIBPATH)libhypool.a $(LIBPATH)libhyfdlibm.a \
+ $(LIBPATH)libvmi$(HY_LINKLIB_SUFFIX)
+
+OSLIBS += $(STDCLIBS)
+
+DLLNAME=../liboglwrapper$(HY_SHLIB_SUFFIX)
+EXPNAME=HYOGLWRAPPER_0.1
+
+include $(HY_HDK)/build/make/rules.mk
Index: modules/awt/src/main/native/x11wrapper/unix/makefile
===================================================================
--- modules/awt/src/main/native/x11wrapper/unix/makefile (revision 537917)
+++ modules/awt/src/main/native/x11wrapper/unix/makefile (working copy)
@@ -24,9 +24,12 @@
org_apache_harmony_awt_nativebridge_linux_X11.o \
org_apache_harmony_awt_nativebridge_linux_Xft.o
-MDLLIBFILES += \
- $(LIBPATH)libhyzip.a $(DLLPATH)libhyzlib$(HY_LINKLIB_SUFFIX) \
- $(LIBPATH)libhypool.a $(LIBPATH)libhyfdlibm.a $(LIBPATH)libvmi$(HY_LINKLIB_SUFFIX)
+ifneq ($(HY_ZIP_API),true)
+MDLLIBFILES += $(LIBPATH)libhyzip.a $(DLLPATH)libhyzlib$(HY_LINKLIB_SUFFIX)
+endif
+
+MDLLIBFILES += $(LIBPATH)libhypool.a $(LIBPATH)libhyfdlibm.a \
+ $(LIBPATH)libvmi$(HY_LINKLIB_SUFFIX)
OSLIBS += $(STDCLIBS) $(XLIBS)
Index: modules/imageio/src/main/native/jpegencoder/unix/makefile
===================================================================
--- modules/imageio/src/main/native/jpegencoder/unix/makefile (revision 537917)
+++ modules/imageio/src/main/native/jpegencoder/unix/makefile (working copy)
@@ -24,9 +24,12 @@
$(SHAREDSUB)JpegEncoder.o \
libjpeg.a
-MDLLIBFILES += \
- $(LIBPATH)libhyzip.a $(DLLPATH)libhyzlib$(HY_LINKLIB_SUFFIX) \
- $(LIBPATH)libhypool.a $(LIBPATH)libhyfdlibm.a $(LIBPATH)libvmi$(HY_LINKLIB_SUFFIX)
+ifneq ($(HY_ZIP_API),true)
+MDLLIBFILES += $(LIBPATH)libhyzip.a $(DLLPATH)libhyzlib$(HY_LINKLIB_SUFFIX)
+endif
+
+MDLLIBFILES += $(LIBPATH)libhypool.a $(LIBPATH)libhyfdlibm.a \
+ $(LIBPATH)libvmi$(HY_LINKLIB_SUFFIX)
DLLNAME=../libjpegencoder$(HY_SHLIB_SUFFIX)
EXPNAME=HYJPEGENCODER_0.1
Index: modules/imageio/src/main/native/jpegencoder/windows/makefile
===================================================================
--- modules/imageio/src/main/native/jpegencoder/windows/makefile (revision 537882)
+++ modules/imageio/src/main/native/jpegencoder/windows/makefile (working copy)
@@ -30,6 +30,10 @@
-D_DLL -D_MT -DWIN32 -D_WIN32_WINNT=0x0400 -D_WINSOCKAPI_ -DWINVER=0x0400 \
$(VMDEBUG) /I$(HY_HDK)\include /I$(HY_HDK)\jdk\include /I. \
-I$(SHAREDSUB)\include -I$(JPEG_DIR)
+!IF "$(HY_ZIP_API)" == "true"
+HYCFLAGS = $(HYCFLAGS) -DHY_ZIP_API
+!ENDIF
+
BUILDFILES = $(SHAREDSUB)JpegEncoder.obj
Index: modules/imageio/src/main/native/pngencoder/unix/makefile
===================================================================
--- modules/imageio/src/main/native/pngencoder/unix/makefile (revision 537917)
+++ modules/imageio/src/main/native/pngencoder/unix/makefile (working copy)
@@ -1,41 +1,44 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-include $(HY_HDK)/build/make/defines.mk
-
-PNG_DIR=$(HY_HDK)/../depends/libs/build/png/
-
-CFLAGS += -fpic
-INCLUDES += -I$(SHARED)common -I$(SHAREDSUB)include -I$(PNG_DIR)
-
-BUILDFILES = \
- $(SHAREDSUB)pngencoder.o \
- libpng.a
-
-MDLLIBFILES += \
- $(LIBPATH)libhyzip.a $(DLLPATH)libhyzlib$(HY_LINKLIB_SUFFIX) \
- $(LIBPATH)libhypool.a $(LIBPATH)libhyfdlibm.a $(LIBPATH)libvmi$(HY_LINKLIB_SUFFIX)
-
-OSLIBS += $(STDCLIBS)
-
-DLLNAME=../libpngencoder$(HY_SHLIB_SUFFIX)
-EXPNAME=HYPNGENCODER_0.1
-
-CLEANFILES=jconfig.h
-
-include $(HY_HDK)/build/make/rules.mk
-
-libpng.a: $(PNG_DIR)libpng.$(HY_PLATFORM)
- cp $< $@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+include $(HY_HDK)/build/make/defines.mk
+
+PNG_DIR=$(HY_HDK)/../depends/libs/build/png/
+
+CFLAGS += -fpic
+INCLUDES += -I$(SHARED)common -I$(SHAREDSUB)include -I$(PNG_DIR)
+
+BUILDFILES = \
+ $(SHAREDSUB)pngencoder.o \
+ libpng.a
+
+ifneq ($(HY_ZIP_API),true)
+MDLLIBFILES += $(LIBPATH)libhyzip.a $(DLLPATH)libhyzlib$(HY_LINKLIB_SUFFIX)
+endif
+
+MDLLIBFILES += $(LIBPATH)libhypool.a $(LIBPATH)libhyfdlibm.a \
+ $(LIBPATH)libvmi$(HY_LINKLIB_SUFFIX)
+
+OSLIBS += $(STDCLIBS)
+
+DLLNAME=../libpngencoder$(HY_SHLIB_SUFFIX)
+EXPNAME=HYPNGENCODER_0.1
+
+CLEANFILES=jconfig.h
+
+include $(HY_HDK)/build/make/rules.mk
+
+libpng.a: $(PNG_DIR)libpng.$(HY_PLATFORM)
+ cp $< $@
Index: modules/instrument/src/main/native/instrument/shared/inst_agt.c
===================================================================
--- modules/instrument/src/main/native/instrument/shared/inst_agt.c (revision 537917)
+++ modules/instrument/src/main/native/instrument/shared/inst_agt.c (working copy)
@@ -21,7 +21,11 @@
#include
#include
#include
+#ifndef HY_ZIP_API
#include
+#else /* HY_ZIP_API */
+#include
+#endif /* HY_ZIP_API */
#include
#include
@@ -160,8 +164,16 @@
VMI_ACCESS_FROM_JAVAVM(vm);
PORT_ACCESS_FROM_JAVAVM(vm);
+#ifdef HY_ZIP_API
+ HyZipFunctionTable *zipFuncs = (*VMI)->GetZipFunctions(VMI);
+
+#endif /* HY_ZIP_API */
/* open zip file */
+#ifndef HY_ZIP_API
retval = zip_openZipFile(privatePortLibrary, (char *)jar_name, &zipFile, NULL);
+#else /* HY_ZIP_API */
+ retval = zipFuncs->zip_openZipFile(VMI, (char *)jar_name, &zipFile);
+#endif /* HY_ZIP_API */
if(retval){
sprintf(errorMessage,"failed to open file:%s, %d\n", jar_name, retval);
(*env)->FatalError(env, errorMessage);
@@ -169,10 +181,19 @@
}
/* get manifest entry */
+#ifndef HY_ZIP_API
zip_initZipEntry(privatePortLibrary, &zipEntry);
retval = zip_getZipEntry(privatePortLibrary, &zipFile, &zipEntry, "META-INF/MANIFEST.MF", TRUE);
+#else /* HY_ZIP_API */
+ zipFuncs->zip_initZipEntry(VMI, &zipEntry);
+ retval = zipFuncs->zip_getZipEntry(VMI, &zipFile, &zipEntry, "META-INF/MANIFEST.MF", TRUE);
+#endif /* HY_ZIP_API */
if (retval) {
+#ifndef HY_ZIP_API
zip_freeZipEntry(PORTLIB, &zipEntry);
+#else /* HY_ZIP_API */
+ zipFuncs->zip_freeZipEntry(VMI, &zipEntry);
+#endif /* HY_ZIP_API */
sprintf(errorMessage,"failed to get entry: %d\n", retval);
(*env)->FatalError(env, errorMessage);
return NULL;
@@ -181,9 +202,17 @@
/* read bytes */
size = zipEntry.uncompressedSize;
result = (char *)hymem_allocate_memory(size*sizeof(char));
+#ifndef HY_ZIP_API
retval = zip_getZipEntryData(privatePortLibrary, &zipFile, &zipEntry, result, size);
+#else /* HY_ZIP_API */
+ retval = zipFuncs->zip_getZipEntryData(VMI, &zipFile, &zipEntry, result, size);
+#endif /* HY_ZIP_API */
if(retval){
+#ifndef HY_ZIP_API
zip_freeZipEntry(PORTLIB, &zipEntry);
+#else /* HY_ZIP_API */
+ zipFuncs->zip_freeZipEntry(VMI, &zipEntry);
+#endif /* HY_ZIP_API */
sprintf(errorMessage,"failed to get bytes from zip entry, %d\n", zipEntry.extraFieldLength);
(*env)->FatalError(env, errorMessage);
return NULL;
@@ -190,8 +219,13 @@
}
/* free resource */
+#ifndef HY_ZIP_API
zip_freeZipEntry(privatePortLibrary, &zipEntry);
retval = zip_closeZipFile(privatePortLibrary, &zipFile);
+#else /* HY_ZIP_API */
+ zipFuncs->zip_freeZipEntry(VMI, &zipEntry);
+ retval = zipFuncs->zip_closeZipFile(VMI, &zipFile);
+#endif /* HY_ZIP_API */
if (retval) {
sprintf(errorMessage,"failed to close zip file: %s, %d\n", jar_name, retval);
(*env)->FatalError(env, errorMessage);
Index: modules/instrument/src/main/native/instrument/unix/makefile
===================================================================
--- modules/instrument/src/main/native/instrument/unix/makefile (revision 537917)
+++ modules/instrument/src/main/native/instrument/unix/makefile (working copy)
@@ -24,8 +24,11 @@
BUILDFILES = \
../shared/instrument.o ../shared/inst_agt.o
+ifneq ($(HY_ZIP_API),true)
+MDLLIBFILES += $(LIBPATH)libhyzip.a
+endif
+
MDLLIBFILES += \
- $(LIBPATH)libhyzip.a \
$(LIBPATH)libhypool.a $(LIBPATH)libhyfdlibm.a \
$(LIBPATH)libvmi$(HY_LINKLIB_SUFFIX)
Index: modules/instrument/src/main/native/instrument/windows/makefile
===================================================================
--- modules/instrument/src/main/native/instrument/windows/makefile (revision 537917)
+++ modules/instrument/src/main/native/instrument/windows/makefile (working copy)
@@ -27,7 +27,7 @@
BUILDFILES = \
$(SHAREDSUB)instrument.obj $(SHAREDSUB)inst_agt.obj
-
+
VIRTFILES = hyinstrument.res
SYSLIBFILES = ws2_32.lib Iphlpapi.lib
@@ -32,10 +32,13 @@
SYSLIBFILES = ws2_32.lib Iphlpapi.lib
-MDLLIBFILES = $(MDLLIBFILES) \
- $(LIBPATH)hyzip$(HY_LINKLIB_SUFFIX) $(LIBPATH)hyzlib$(HY_LINKLIB_SUFFIX) \
- $(LIBPATH)hypool$(HY_LINKLIB_SUFFIX) $(LIBPATH)hyfdlibm$(HY_LINKLIB_SUFFIX) $(LIBPATH)vmi$(HY_LINKLIB_SUFFIX)
-
+!IF "$(HY_ZIP_API)" != "true"
+MDLLIBFILES = $(MDLLIBFILES) $(LIBPATH)hyzip$(HY_LINKLIB_SUFFIX) $(LIBPATH)hyzlib$(HY_LINKLIB_SUFFIX)
+!ENDIF
+
+MDLLIBFILES = $(MDLLIBFILES) $(LIBPATH)hypool$(HY_LINKLIB_SUFFIX) \
+ $(LIBPATH)hyfdlibm$(HY_LINKLIB_SUFFIX) $(LIBPATH)vmi$(HY_LINKLIB_SUFFIX)
+
DLLBASE=0x13200000
COMMENT=/comment:"instrument component native code. (c) Copyright 2006 The Apache Software Foundation or its licensors, as applicable."
Index: modules/luni/build.xml
===================================================================
--- modules/luni/build.xml (revision 537917)
+++ modules/luni/build.xml (working copy)
@@ -58,6 +58,7 @@
+
@@ -116,7 +117,11 @@
-
+
+
+
@@ -129,6 +134,14 @@
+
+
+
+
+
+
+
+
@@ -144,7 +157,6 @@
-
@@ -164,6 +176,8 @@
+
Index: modules/luni/src/main/native/include/shared/vmi.h
===================================================================
--- modules/luni/src/main/native/include/shared/vmi.h (revision 537917)
+++ modules/luni/src/main/native/include/shared/vmi.h (working copy)
@@ -32,7 +32,9 @@
#include "hyport.h"
#include "hyvmls.h"
+#ifndef HY_ZIP_API
#include "zipsup.h"
+#endif /* ! HY_ZIP_API */
/**
* @enum vmiError
* Enumeration of all possible return codes from VM interface functions
@@ -58,6 +60,9 @@
{
VMI_VERSION_UNKNOWN = 0x00000000, /**< Unknown VMInterface version */
VMI_VERSION_1_0 = 0x00010000, /**< VMInterface version 1.0 */
+#ifdef HY_ZIP_API
+ VMI_VERSION_2_0 = 0x00020000, /**< VMInterface version 2.0 */
+#endif /* HY_ZIP_API */
vmiVersionEnsureWideEnum = 0x1000000 /* ensure 4-byte enum */
} vmiVersion;
@@ -70,6 +75,9 @@
typedef void (JNICALL * vmiSystemPropertyIterator) (char *key, char *value,
void *userData);
+#ifdef HY_ZIP_API
+ struct HyZipFunctionTable;
+#endif /* HY_ZIP_API */
struct VMInterface_;
struct VMInterfaceFunctions_;
@@ -96,8 +104,12 @@
JavaVM *(JNICALL * GetJavaVM) (VMInterface * vmi);
HyPortLibrary *(JNICALL * GetPortLibrary) (VMInterface * vmi);
HyVMLSFunctionTable *(JNICALL * GetVMLSFunctions) (VMInterface * vmi);
+#ifndef HY_ZIP_API
HyZipCachePool *(JNICALL * GetZipCachePool) (VMInterface * vmi);
+#else /* HY_ZIP_API */
+ struct HyZipFunctionTable *(JNICALL * GetZipFunctions) (VMInterface * vmi);
+#endif /* HY_ZIP_API */
JavaVMInitArgs *(JNICALL * GetInitArgs) (VMInterface * vmi);
vmiError (JNICALL * GetSystemProperty) (VMInterface * vmi, char *key,
char **valuePtr);
@@ -188,17 +200,35 @@
HyVMLSFunctionTable *JNICALL GetVMLSFunctions (VMInterface * vmi);
/**
+#ifndef HY_ZIP_API
* @fn VMInterfaceFunctions_::GetZipCachePool(VMInterface * vmi)
* Return a pointer to the HyZipCachePool structure used by the VM. It is the
* responsibility of the vm to allocate the pool using zipCachePool_new().
+#else
+ * @fn VMInterfaceFunctions_::GetZipFunctions
+ * Return a pointer to a HyZipFunctionTable. This is a table of functions for managing zip files.
+#endif
*
+#ifndef HY_ZIP_API
* @code HyZipCachePool* JNICALL GetZipCachePool(VMInterface* vmi); @endcode
+#else
+ * @code HyZipFunctionTable* JNICALL GetZipFunctions(VMInterface* vmi); @endcode
+#endif
*
* @param[in] vmi The VM interface pointer
*
+#ifndef HY_ZIP_API
* @return a HyZipCachePool pointer
+#else
+ * @return a HyZipFunctionTable pointer
+#endif
*/
+#ifndef HY_ZIP_API
HyZipCachePool *JNICALL GetZipCachePool (VMInterface * vmi);
+#else /* HY_ZIP_API */
+ struct HyZipFunctionTable* JNICALL
+ GetZipFunctions(VMInterface* vmi);
+#endif /* HY_ZIP_API */
/**
* @fn VMInterfaceFunctions_::GetInitArgs(VMInterface * vmi)
Index: modules/luni/src/main/native/include/shared/hyzip.h
===================================================================
--- modules/luni/src/main/native/include/shared/hyzip.h
+++ modules/luni/src/main/native/include/shared/hyzip.h
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef hyzip_h
+#define hyzip_h
+
+#include "hycomp.h"
+#include "vmi.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct HyZipCachePool HyZipCachePool;
+
+#define ZIP_INTERNAL_MAX 80
+#define ZIP_CM_Reduced1 2
+#define ZIP_Unknown 0
+#define ZIP_GZIP 2
+#define ZIP_ERR_OUT_OF_MEMORY -3
+#define ZIP_ERR_FILE_CORRUPT -6
+#define ZIP_ERR_INTERNAL_ERROR -11
+#define ZIP_CM_Imploded 6
+#define ZIP_CM_Reduced4 5
+#define ZIP_CM_Shrunk 1
+#define ZIP_CM_Reduced2 3
+#define ZIP_ERR_FILE_READ_ERROR -1
+#define ZIP_CentralHeader 0x2014B50
+#define ZIP_ERR_FILE_CLOSE_ERROR -10
+#define ZIP_ERR_BUFFER_TOO_SMALL -7
+#define ZIP_CM_Reduced3 4
+#define ZIP_CM_Deflated 8
+#define ZIP_LocalHeader 0x4034B50
+#define ZIP_CM_Tokenized 7
+#define ZIP_PKZIP 1
+#define ZIP_CM_Stored 0
+#define ZIP_ERR_UNSUPPORTED_FILE_TYPE -5
+#define ZIP_ERR_NO_MORE_ENTRIES -2
+#define ZIP_CentralEnd 0x6054B50
+#define ZIP_ERR_FILE_OPEN_ERROR -9
+#define ZIP_ERR_UNKNOWN_FILE_TYPE -4
+#define ZIP_ERR_ENTRY_NOT_FOUND -8
+#define ZIP_DataDescriptor 0x8074B50
+
+typedef struct HyZipEntry
+{
+ U_8 *data;
+ U_8 *filename;
+ U_8 *extraField;
+ U_8 *fileComment;
+ I_32 dataPointer;
+ I_32 filenamePointer;
+ I_32 extraFieldPointer;
+ I_32 fileCommentPointer;
+ U_32 compressedSize;
+ U_32 uncompressedSize;
+ U_32 crc32;
+ U_16 filenameLength;
+ U_16 extraFieldLength;
+ U_16 fileCommentLength;
+ U_16 internalAttributes;
+ U_16 versionCreated;
+ U_16 versionNeeded;
+ U_16 flags;
+ U_16 compressionMethod;
+ U_16 lastModTime;
+ U_16 lastModDate;
+ U_8 internalFilename[80];
+} HyZipEntry;
+
+typedef struct HyZipFile
+{
+ U_8 *filename;
+ void *cache;
+ void *cachePool;
+ I_32 fd;
+ I_32 pointer;
+ U_8 internalFilename[80];
+ U_8 type;
+ char _hypadding0065[3]; /* 3 bytes of automatic padding */
+} HyZipFile;
+
+typedef struct HyZipFunctionTable {
+ I_32 (PVMCALL zip_getZipEntryData) (VMInterface * vmi, HyZipFile * zipFile, HyZipEntry * entry, U_8 * buffer, U_32 bufferSize) ;
+ I_32 (PVMCALL zip_getZipEntryFromOffset) (VMInterface * vmi, HyZipFile * zipFile, HyZipEntry * entry, IDATA offset) ;
+ I_32 (PVMCALL zip_establishCache) (VMInterface * vmi, HyZipFile * zipFile) ;
+ void (PVMCALL zip_resetZipFile) (VMInterface * vmi, HyZipFile * zipFile, IDATA * nextEntryPointer) ;
+ I_32 (PVMCALL zip_getNextZipEntry) (VMInterface * vmi, HyZipFile * zipFile, HyZipEntry * zipEntry, IDATA * nextEntryPointer) ;
+ I_32 (PVMCALL zip_getZipEntry) (VMInterface * vmi, HyZipFile * zipFile, HyZipEntry * entry, const char *filename, BOOLEAN findDirectory) ;
+ I_32 (PVMCALL zip_getZipEntryExtraField) (VMInterface * vmi, HyZipFile * zipFile, HyZipEntry * entry, U_8 * buffer, U_32 bufferSize) ;
+ void (PVMCALL zip_initZipEntry) (VMInterface * vmi, HyZipEntry * entry) ;
+ I_32 (PVMCALL zip_openZipFile) (VMInterface * vmi, char *filename, HyZipFile * zipFile) ;
+ void (PVMCALL zip_freeZipEntry) (VMInterface * vmi, HyZipEntry * entry) ;
+ I_32 (PVMCALL zip_closeZipFile) (VMInterface * vmi, HyZipFile * zipFile) ;
+ I_32 (PVMCALL zip_getZipEntryComment) (VMInterface * vmi, HyZipFile * zipFile, HyZipEntry * entry, U_8 * buffer, U_32 bufferSize) ;
+
+ UDATA (PVMCALL zipCache_findElement) (void * zipCache, const char *elementName, BOOLEAN searchDirList) ;
+ void (PVMCALL zipCache_kill) (void * zipCache) ;
+ IDATA (PVMCALL zipCache_enumGetDirName) (void *handle, char *nameBuf, UDATA nameBufSize) ;
+ struct HyZipCache *(PVMCALL zipCache_new) (VMInterface * vmi, char *zipName, IDATA zipNameLength) ;
+ IDATA (PVMCALL zipCache_enumNew) (void * zipCache, char *directoryName, void **handle) ;
+ IDATA (PVMCALL zipCache_enumElement) (void *handle, char *nameBuf, UDATA nameBufSize, UDATA * offset) ;
+ void (PVMCALL zipCache_enumKill) (void *handle) ;
+ BOOLEAN (PVMCALL zipCache_addElement) (void * zipCache, char *elementName, UDATA elementOffset) ;
+
+ void *(PVMCALL zip_zalloc) (void *opaque, U_32 items, U_32 size) ;
+ void (PVMCALL zip_zfree) (void *opaque, void *address) ;
+
+ void *reserved;
+} HyZipFunctionTable;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* hyzip_h */
Index: modules/luni/src/main/native/luni/unix/makefile
===================================================================
--- modules/luni/src/main/native/luni/unix/makefile (revision 537917)
+++ modules/luni/src/main/native/luni/unix/makefile (working copy)
@@ -36,9 +36,12 @@
OSMemory.o OSMemoryLinux32.o $(SHAREDSUB)OSNetworkSystem.o \
OSNetworkSystemLinux.o hyenv.o
-MDLLIBFILES += \
- $(LIBPATH)libhyzip.a $(DLLPATH)libhyzlib$(HY_LINKLIB_SUFFIX) \
- $(LIBPATH)libhypool.a $(LIBPATH)libhyfdlibm.a $(LIBPATH)libvmi$(HY_LINKLIB_SUFFIX)
+ifneq ($(HY_ZIP_API),true)
+MDLLIBFILES += $(LIBPATH)libhyzip.a $(DLLPATH)libhyzlib$(HY_LINKLIB_SUFFIX)
+endif
+
+MDLLIBFILES += $(LIBPATH)libhypool.a $(LIBPATH)libhyfdlibm.a \
+ $(LIBPATH)libvmi$(HY_LINKLIB_SUFFIX)
DLLNAME = ../libhyluni$(HY_SHLIB_SUFFIX)
EXPNAME = HYLUNI_0.1
Index: modules/luni/src/main/native/luni/windows/makefile
===================================================================
--- modules/luni/src/main/native/luni/windows/makefile (revision 537917)
+++ modules/luni/src/main/native/luni/windows/makefile (working copy)
@@ -43,9 +43,13 @@
SYSLIBFILES = ws2_32.lib Iphlpapi.lib Mswsock.lib
+!IF "$(HY_ZIP_API)" != "true"
MDLLIBFILES = $(MDLLIBFILES) \
- $(LIBPATH)hyzip$(HY_LINKLIB_SUFFIX) $(LIBPATH)hyzlib$(HY_LINKLIB_SUFFIX) \
- $(LIBPATH)hypool$(HY_LINKLIB_SUFFIX) $(LIBPATH)hyfdlibm$(HY_LINKLIB_SUFFIX) $(LIBPATH)vmi$(HY_LINKLIB_SUFFIX)
+ $(LIBPATH)hyzip$(HY_LINKLIB_SUFFIX) $(LIBPATH)hyzlib$(HY_LINKLIB_SUFFIX)
+!ENDIF
+
+MDLLIBFILES = $(MDLLIBFILES) $(LIBPATH)hypool$(HY_LINKLIB_SUFFIX) \
+ $(LIBPATH)hyfdlibm$(HY_LINKLIB_SUFFIX) $(LIBPATH)vmi$(HY_LINKLIB_SUFFIX)
DLLBASE=0x13200000
COMMENT=/comment:"LUNI component native code. (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable."
Index: modules/luni/src/main/native/hyzip/shared/hyzip.c
===================================================================
--- modules/luni/src/main/native/hyzip/shared/hyzip.c
+++ modules/luni/src/main/native/hyzip/shared/hyzip.c
@@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#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)
+{
+ 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)
+{
+ 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)
+{
+ 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)
+{
+ 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)
+{
+ PORT_ACCESS_FROM_VMI(vmi);
+ return zip_getZipEntry(PORTLIB, zipFile,entry, filename, findDirectory);
+}
+
+I_32 VMCALL
+hyzip_getZipEntryExtraField(VMInterface * vmi, struct HyZipFile * zipFile, struct HyZipEntry * entry, U_8 * buffer, U_32 bufferSize)
+{
+ PORT_ACCESS_FROM_VMI(vmi);
+ return zip_getZipEntryExtraField(PORTLIB, zipFile, entry, buffer, bufferSize);
+}
+
+void VMCALL
+hyzip_initZipEntry(VMInterface * vmi, struct HyZipEntry * entry)
+{
+ PORT_ACCESS_FROM_VMI(vmi);
+ zip_initZipEntry(PORTLIB, entry);
+}
+
+I_32 VMCALL
+hyzip_openZipFile(VMInterface * vmi, char *filename, struct HyZipFile * zipFile)
+{
+ PORT_ACCESS_FROM_VMI(vmi);
+
+ HyZipFunctionTable *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);
+}
+
+void VMCALL
+hyzip_freeZipEntry(VMInterface * vmi, struct HyZipEntry * entry)
+{
+ PORT_ACCESS_FROM_VMI(vmi);
+ zip_freeZipEntry(PORTLIB, entry);
+}
+
+I_32 VMCALL
+hyzip_closeZipFile(VMInterface * vmi, struct HyZipFile * 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)
+{
+ 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)
+{
+ 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)
+{
+ return zipCache_enumNew(zipCache, directoryName, handle);
+}
+
+IDATA VMCALL
+hyzipCache_enumElement(void *handle, char *nameBuf, UDATA nameBufSize, UDATA * offset)
+{
+ return zipCache_enumElement(handle, nameBuf, nameBufSize, offset);
+}
+
+void VMCALL
+hyzipCache_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,
+ NULL
+};
Index: modules/luni/src/main/native/hyzip/shared/hyzip.nls
===================================================================
--- modules/luni/src/main/native/hyzip/shared/hyzip.nls
+++ modules/luni/src/main/native/hyzip/shared/hyzip.nls
@@ -0,0 +1,47 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Externalised messages for the VM components of the JCL module.
+#
+# Note to developers:
+#
+# New messages MUST be added at the end of this file.
+# DO NOT delete messages from this file, as it will change their indices.
+# If you wish to remove a message, delete its text, but leave the key in place
+#
+# Note to translators:
+#
+# This file uses printf style substitutions. Sequences such as %s, %.*s, %10d
+# etc. will be subsituted at runtime. The special case of %% is not a substitution.
+# It indicates a single percent sign. Please do not modify the format specifiers, or
+# change their order. For instance, in a message like "from %d to %s", %d
+# MUST appear before %s in any translated message, or a run-time crash
+# could occur. This is a known limitation of the product.
+#
+# NLS_MESSAGEFORMAT_NONE
+#
+
+HYNLS.MODULE=ZIPS
+HYNLS.HEADER=hyzipnls.h
+
+# first argument is the name of the zip DLL
+# second argument is a platform error message
+HYNLS_ZIP_UNABLE_TO_OPEN_ZIP_DLL=Unable to open %1$s (%2$s)
+
+HYNLS_ZIP_MISSING_EXPORT=Unable to open %s (Missing export)
+
+
Index: modules/luni/src/main/native/hyzip/shared/hyzipnls.h
===================================================================
--- modules/luni/src/main/native/hyzip/shared/hyzipnls.h
+++ modules/luni/src/main/native/hyzip/shared/hyzipnls.h
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#if !defined(hyzipnls_h)
+#define hyzipnls_h
+#include "hyport.h"
+/* 0x5a495053 = ZIPS */
+#define HYNLS_ZIP_UNABLE_TO_OPEN_ZIP_DLL__MODULE 0x5a495053
+#define HYNLS_ZIP_UNABLE_TO_OPEN_ZIP_DLL__ID 0
+#define HYNLS_ZIP_UNABLE_TO_OPEN_ZIP_DLL HYNLS_ZIP_UNABLE_TO_OPEN_ZIP_DLL__MODULE, HYNLS_ZIP_UNABLE_TO_OPEN_ZIP_DLL__ID
+#define HYNLS_ZIP_MISSING_EXPORT__MODULE 0x5a495053
+#define HYNLS_ZIP_MISSING_EXPORT__ID 1
+#define HYNLS_ZIP_MISSING_EXPORT HYNLS_ZIP_MISSING_EXPORT__MODULE, HYNLS_ZIP_MISSING_EXPORT__ID
+#endif
Index: modules/luni/src/main/native/hyzip/shared/hyzip_ca.nls
===================================================================
--- modules/luni/src/main/native/hyzip/shared/hyzip_ca.nls
+++ modules/luni/src/main/native/hyzip/shared/hyzip_ca.nls
@@ -0,0 +1,34 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Externalised messages for the VM components of the JCL module.
+# New messages MUST be added at the end of this file.
+# DO NOT delete messages from this file, as it will change their indices.
+# If you wish to remove a message, delete its text, but leave the key in place
+# NLS_MESSAGEFORMAT_NONE
+
+HYNLS.MODULE=ZIPS
+HYNLS.HEADER=hyzipnls.h
+
+# first argument is the name of the zip DLL
+# second argument is a platform error message
+HYNLS_ZIP_UNABLE_TO_OPEN_ZIP_DLL=No es pot obrir %1$s (%2$s)
+
+HYNLS_ZIP_MISSING_EXPORT=No es pot obrir %s (falta l'exportaci\u00f3)
+
+
+
Index: modules/luni/src/main/native/hyzip/shared/hyzip_cs.nls
===================================================================
--- modules/luni/src/main/native/hyzip/shared/hyzip_cs.nls
+++ modules/luni/src/main/native/hyzip/shared/hyzip_cs.nls
@@ -0,0 +1,34 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Externalised messages for the VM components of the JCL module.
+# New messages MUST be added at the end of this file.
+# DO NOT delete messages from this file, as it will change their indices.
+# If you wish to remove a message, delete its text, but leave the key in place
+# NLS_MESSAGEFORMAT_NONE
+
+HYNLS.MODULE=ZIPS
+HYNLS.HEADER=hyzipnls.h
+
+# first argument is the name of the zip DLL
+# second argument is a platform error message
+HYNLS_ZIP_UNABLE_TO_OPEN_ZIP_DLL=Nelze otev\u0159\u00edt %1$s (%2$s)
+
+HYNLS_ZIP_MISSING_EXPORT=Nelze otev\u0159\u00edt %s (chyb\u011bj\u00edc\u00ed export)
+
+
+
Index: modules/luni/src/main/native/hyzip/shared/hyzip_de.nls
===================================================================
--- modules/luni/src/main/native/hyzip/shared/hyzip_de.nls
+++ modules/luni/src/main/native/hyzip/shared/hyzip_de.nls
@@ -0,0 +1,34 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Externalised messages for the VM components of the JCL module.
+# New messages MUST be added at the end of this file.
+# DO NOT delete messages from this file, as it will change their indices.
+# If you wish to remove a message, delete its text, but leave the key in place
+# NLS_MESSAGEFORMAT_NONE
+
+HYNLS.MODULE=ZIPS
+HYNLS.HEADER=hyzipnls.h
+
+# first argument is the name of the zip DLL
+# second argument is a platform error message
+HYNLS_ZIP_UNABLE_TO_OPEN_ZIP_DLL=%1$s kann nicht ge\u00f6ffnet werden (%2$s)
+
+HYNLS_ZIP_MISSING_EXPORT=%s kann nicht ge\u00f6ffnet werden (fehlender Export).
+
+
+
Index: modules/luni/src/main/native/hyzip/shared/hyzip_es.nls
===================================================================
--- modules/luni/src/main/native/hyzip/shared/hyzip_es.nls
+++ modules/luni/src/main/native/hyzip/shared/hyzip_es.nls
@@ -0,0 +1,34 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Externalised messages for the VM components of the JCL module.
+# New messages MUST be added at the end of this file.
+# DO NOT delete messages from this file, as it will change their indices.
+# If you wish to remove a message, delete its text, but leave the key in place
+# NLS_MESSAGEFORMAT_NONE
+
+HYNLS.MODULE=ZIPS
+HYNLS.HEADER=hyzipnls.h
+
+# first argument is the name of the zip DLL
+# second argument is a platform error message
+HYNLS_ZIP_UNABLE_TO_OPEN_ZIP_DLL=No se puede abrir %1$s (%2$s)
+
+HYNLS_ZIP_MISSING_EXPORT=No se puede abrir %s (falta la exportaci\u00f3n)
+
+
+
Index: modules/luni/src/main/native/hyzip/shared/hyzip_fr.nls
===================================================================
--- modules/luni/src/main/native/hyzip/shared/hyzip_fr.nls
+++ modules/luni/src/main/native/hyzip/shared/hyzip_fr.nls
@@ -0,0 +1,34 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Externalised messages for the VM components of the JCL module.
+# New messages MUST be added at the end of this file.
+# DO NOT delete messages from this file, as it will change their indices.
+# If you wish to remove a message, delete its text, but leave the key in place
+# NLS_MESSAGEFORMAT_NONE
+
+HYNLS.MODULE=ZIPS
+HYNLS.HEADER=hyzipnls.h
+
+# first argument is the name of the zip DLL
+# second argument is a platform error message
+HYNLS_ZIP_UNABLE_TO_OPEN_ZIP_DLL=Impossible d'ouvrir %1$s (%2$s)
+
+HYNLS_ZIP_MISSING_EXPORT=Impossible d'ouvrir %s (export manquant)
+
+
+
Index: modules/luni/src/main/native/hyzip/shared/hyzip_hu.nls
===================================================================
--- modules/luni/src/main/native/hyzip/shared/hyzip_hu.nls
+++ modules/luni/src/main/native/hyzip/shared/hyzip_hu.nls
@@ -0,0 +1,34 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Externalised messages for the VM components of the JCL module.
+# New messages MUST be added at the end of this file.
+# DO NOT delete messages from this file, as it will change their indices.
+# If you wish to remove a message, delete its text, but leave the key in place
+# NLS_MESSAGEFORMAT_NONE
+
+HYNLS.MODULE=ZIPS
+HYNLS.HEADER=hyzipnls.h
+
+# first argument is the name of the zip DLL
+# second argument is a platform error message
+HYNLS_ZIP_UNABLE_TO_OPEN_ZIP_DLL=%1$s nem nyithat\u00f3 meg (%2$s)
+
+HYNLS_ZIP_MISSING_EXPORT=%s nem nyithat\u00f3 meg (export hi\u00e1nyzik)
+
+
+
Index: modules/luni/src/main/native/hyzip/shared/hyzip_it.nls
===================================================================
--- modules/luni/src/main/native/hyzip/shared/hyzip_it.nls
+++ modules/luni/src/main/native/hyzip/shared/hyzip_it.nls
@@ -0,0 +1,34 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Externalised messages for the VM components of the JCL module.
+# New messages MUST be added at the end of this file.
+# DO NOT delete messages from this file, as it will change their indices.
+# If you wish to remove a message, delete its text, but leave the key in place
+# NLS_MESSAGEFORMAT_NONE
+
+HYNLS.MODULE=ZIPS
+HYNLS.HEADER=hyzipnls.h
+
+# first argument is the name of the zip DLL
+# second argument is a platform error message
+HYNLS_ZIP_UNABLE_TO_OPEN_ZIP_DLL=Impossibile aprire %1$s (%2$s)
+
+HYNLS_ZIP_MISSING_EXPORT=Impossibile aprire %s (Esportazione mancante)
+
+
+
Index: modules/luni/src/main/native/hyzip/shared/hyzip_ja.nls
===================================================================
--- modules/luni/src/main/native/hyzip/shared/hyzip_ja.nls
+++ modules/luni/src/main/native/hyzip/shared/hyzip_ja.nls
@@ -0,0 +1,34 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Externalised messages for the VM components of the JCL module.
+# New messages MUST be added at the end of this file.
+# DO NOT delete messages from this file, as it will change their indices.
+# If you wish to remove a message, delete its text, but leave the key in place
+# NLS_MESSAGEFORMAT_NONE
+
+HYNLS.MODULE=ZIPS
+HYNLS.HEADER=hyzipnls.h
+
+# first argument is the name of the zip DLL
+# second argument is a platform error message
+HYNLS_ZIP_UNABLE_TO_OPEN_ZIP_DLL=%1$s \u3092\u30aa\u30fc\u30d7\u30f3\u3067\u304d\u307e\u305b\u3093 (%2$s)
+
+HYNLS_ZIP_MISSING_EXPORT=%s \u3092\u30aa\u30fc\u30d7\u30f3\u3067\u304d\u307e\u305b\u3093 (\u30a8\u30af\u30b9\u30dd\u30fc\u30c8\u304c\u6b20\u843d\u3057\u3066\u3044\u307e\u3059)
+
+
+
Index: modules/luni/src/main/native/hyzip/shared/hyzip_ko.nls
===================================================================
--- modules/luni/src/main/native/hyzip/shared/hyzip_ko.nls
+++ modules/luni/src/main/native/hyzip/shared/hyzip_ko.nls
@@ -0,0 +1,34 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Externalised messages for the VM components of the JCL module.
+# New messages MUST be added at the end of this file.
+# DO NOT delete messages from this file, as it will change their indices.
+# If you wish to remove a message, delete its text, but leave the key in place
+# NLS_MESSAGEFORMAT_NONE
+
+HYNLS.MODULE=ZIPS
+HYNLS.HEADER=hyzipnls.h
+
+# first argument is the name of the zip DLL
+# second argument is a platform error message
+HYNLS_ZIP_UNABLE_TO_OPEN_ZIP_DLL=%1$s\uc744(\ub97c) \uc5f4 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4(%2$s).
+
+HYNLS_ZIP_MISSING_EXPORT=%s\uc744(\ub97c) \uc5f4 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4(\ub0b4\ubcf4\ub0b4\uae30 \ub204\ub77d).
+
+
+
Index: modules/luni/src/main/native/hyzip/shared/hyzip_pl.nls
===================================================================
--- modules/luni/src/main/native/hyzip/shared/hyzip_pl.nls
+++ modules/luni/src/main/native/hyzip/shared/hyzip_pl.nls
@@ -0,0 +1,34 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Externalised messages for the VM components of the JCL module.
+# New messages MUST be added at the end of this file.
+# DO NOT delete messages from this file, as it will change their indices.
+# If you wish to remove a message, delete its text, but leave the key in place
+# NLS_MESSAGEFORMAT_NONE
+
+HYNLS.MODULE=ZIPS
+HYNLS.HEADER=hyzipnls.h
+
+# first argument is the name of the zip DLL
+# second argument is a platform error message
+HYNLS_ZIP_UNABLE_TO_OPEN_ZIP_DLL=Nie mo\u017cna otworzy\u0107 %1$s (%2$s)
+
+HYNLS_ZIP_MISSING_EXPORT=Nie mo\u017cna otworzy\u0107 %s (Brakuje eksportu)
+
+
+
Index: modules/luni/src/main/native/hyzip/shared/hyzip_pt_BR.nls
===================================================================
--- modules/luni/src/main/native/hyzip/shared/hyzip_pt_BR.nls
+++ modules/luni/src/main/native/hyzip/shared/hyzip_pt_BR.nls
@@ -0,0 +1,34 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Externalised messages for the VM components of the JCL module.
+# New messages MUST be added at the end of this file.
+# DO NOT delete messages from this file, as it will change their indices.
+# If you wish to remove a message, delete its text, but leave the key in place
+# NLS_MESSAGEFORMAT_NONE
+
+HYNLS.MODULE=ZIPS
+HYNLS.HEADER=hyzipnls.h
+
+# first argument is the name of the zip DLL
+# second argument is a platform error message
+HYNLS_ZIP_UNABLE_TO_OPEN_ZIP_DLL=Imposs\u00edvel abrir %1$s (%2$s)
+
+HYNLS_ZIP_MISSING_EXPORT=Imposs\u00edvel abrir %s (Exporta\u00e7\u00e3o ausente)
+
+
+
Index: modules/luni/src/main/native/hyzip/shared/hyzip_ru.nls
===================================================================
--- modules/luni/src/main/native/hyzip/shared/hyzip_ru.nls
+++ modules/luni/src/main/native/hyzip/shared/hyzip_ru.nls
@@ -0,0 +1,34 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Externalised messages for the VM components of the JCL module.
+# New messages MUST be added at the end of this file.
+# DO NOT delete messages from this file, as it will change their indices.
+# If you wish to remove a message, delete its text, but leave the key in place
+# NLS_MESSAGEFORMAT_NONE
+
+HYNLS.MODULE=ZIPS
+HYNLS.HEADER=hyzipnls.h
+
+# first argument is the name of the zip DLL
+# second argument is a platform error message
+HYNLS_ZIP_UNABLE_TO_OPEN_ZIP_DLL=\u041d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c %1$s (%2$s)
+
+HYNLS_ZIP_MISSING_EXPORT=\u041d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c %s (\u041e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u044d\u043a\u0441\u043f\u043e\u0440\u0442)
+
+
+
Index: modules/luni/src/main/native/hyzip/shared/hyzip_sk.nls
===================================================================
--- modules/luni/src/main/native/hyzip/shared/hyzip_sk.nls
+++ modules/luni/src/main/native/hyzip/shared/hyzip_sk.nls
@@ -0,0 +1,34 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Externalised messages for the VM components of the JCL module.
+# New messages MUST be added at the end of this file.
+# DO NOT delete messages from this file, as it will change their indices.
+# If you wish to remove a message, delete its text, but leave the key in place
+# NLS_MESSAGEFORMAT_NONE
+
+HYNLS.MODULE=ZIPS
+HYNLS.HEADER=hyzipnls.h
+
+# first argument is the name of the zip DLL
+# second argument is a platform error message
+HYNLS_ZIP_UNABLE_TO_OPEN_ZIP_DLL=%1$s sa ned\u00e1 otvori\u0165 (%2$s)
+
+HYNLS_ZIP_MISSING_EXPORT=%s sa ned\u00e1 otvori\u0165 (ch\u00fdba export)
+
+
+
Index: modules/luni/src/main/native/hyzip/shared/hyzip_sl.nls
===================================================================
--- modules/luni/src/main/native/hyzip/shared/hyzip_sl.nls
+++ modules/luni/src/main/native/hyzip/shared/hyzip_sl.nls
@@ -0,0 +1,34 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Externalised messages for the VM components of the JCL module.
+# New messages MUST be added at the end of this file.
+# DO NOT delete messages from this file, as it will change their indices.
+# If you wish to remove a message, delete its text, but leave the key in place
+# NLS_MESSAGEFORMAT_NONE
+
+HYNLS.MODULE=ZIPS
+HYNLS.HEADER=hyzipnls.h
+
+# first argument is the name of the zip DLL
+# second argument is a platform error message
+HYNLS_ZIP_UNABLE_TO_OPEN_ZIP_DLL=Ni mogo\u010de odpreti %1$s (%2$s)
+
+HYNLS_ZIP_MISSING_EXPORT=Ni mogo\u010de odpreti %s (manjkajo\u010di izvoz)
+
+
+
Index: modules/luni/src/main/native/hyzip/shared/hyzip_tr.nls
===================================================================
--- modules/luni/src/main/native/hyzip/shared/hyzip_tr.nls
+++ modules/luni/src/main/native/hyzip/shared/hyzip_tr.nls
@@ -0,0 +1,34 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Externalised messages for the VM components of the JCL module.
+# New messages MUST be added at the end of this file.
+# DO NOT delete messages from this file, as it will change their indices.
+# If you wish to remove a message, delete its text, but leave the key in place
+# NLS_MESSAGEFORMAT_NONE
+
+HYNLS.MODULE=ZIPS
+HYNLS.HEADER=hyzipnls.h
+
+# first argument is the name of the zip DLL
+# second argument is a platform error message
+HYNLS_ZIP_UNABLE_TO_OPEN_ZIP_DLL=%1$s a\u00e7\u0131lam\u0131yor (%2$s)
+
+HYNLS_ZIP_MISSING_EXPORT=%s a\u00e7\u0131lam\u0131yor (d\u0131\u015fa aktarma eksik)
+
+
+
Index: modules/luni/src/main/native/hyzip/shared/hyzip_zh.nls
===================================================================
--- modules/luni/src/main/native/hyzip/shared/hyzip_zh.nls
+++ modules/luni/src/main/native/hyzip/shared/hyzip_zh.nls
@@ -0,0 +1,34 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Externalised messages for the VM components of the JCL module.
+# New messages MUST be added at the end of this file.
+# DO NOT delete messages from this file, as it will change their indices.
+# If you wish to remove a message, delete its text, but leave the key in place
+# NLS_MESSAGEFORMAT_NONE
+
+HYNLS.MODULE=ZIPS
+HYNLS.HEADER=hyzipnls.h
+
+# first argument is the name of the zip DLL
+# second argument is a platform error message
+HYNLS_ZIP_UNABLE_TO_OPEN_ZIP_DLL=\u65e0\u6cd5\u6253\u5f00 %1$s\uff08%2$s\uff09
+
+HYNLS_ZIP_MISSING_EXPORT=\u65e0\u6cd5\u6253\u5f00 %s\uff08\u7f3a\u5c11\u5bfc\u51fa\uff09
+
+
+
Index: modules/luni/src/main/native/hyzip/shared/hyzip_zh_CN.nls
===================================================================
--- modules/luni/src/main/native/hyzip/shared/hyzip_zh_CN.nls
+++ modules/luni/src/main/native/hyzip/shared/hyzip_zh_CN.nls
@@ -0,0 +1,23 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+HYNLS.MODULE=ZIPS
+HYNLS.HEADER=hyzipnls.h
+
+HYNLS_ZIP_UNABLE_TO_OPEN_ZIP_DLL=\u65e0\u6cd5\u6253\u5f00 %s\uff08%s\uff09
+HYNLS_ZIP_MISSING_EXPORT=\u65e0\u6cd5\u6253\u5f00 %s\uff08\u7f3a\u5c11\u5bfc\u51fa\uff09
+
Index: modules/luni/src/main/native/hyzip/shared/hyzip_zh_TW.nls
===================================================================
--- modules/luni/src/main/native/hyzip/shared/hyzip_zh_TW.nls
+++ modules/luni/src/main/native/hyzip/shared/hyzip_zh_TW.nls
@@ -0,0 +1,34 @@
+#
+# # Licensed to the Apache Software Foundation (ASF) under one or more
+# # contributor license agreements. See the NOTICE file distributed with
+# # this work for additional information regarding copyright ownership.
+# # The ASF licenses this file to You under the Apache License, Version 2.0
+# # (the "License"); you may not use this file except in compliance with
+# # the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Externalised messages for the VM components of the JCL module.
+# New messages MUST be added at the end of this file.
+# DO NOT delete messages from this file, as it will change their indices.
+# If you wish to remove a message, delete its text, but leave the key in place
+# NLS_MESSAGEFORMAT_NONE
+
+HYNLS.MODULE=ZIPS
+HYNLS.HEADER=hyzipnls.h
+
+# first argument is the name of the zip DLL
+# second argument is a platform error message
+HYNLS_ZIP_UNABLE_TO_OPEN_ZIP_DLL=\u7121\u6cd5\u958b\u555f %1$s (%2$s)
+
+HYNLS_ZIP_MISSING_EXPORT=\u7121\u6cd5\u958b\u555f %s\uff08\u907a\u6f0f\u532f\u51fa\uff09
+
+
+
Index: modules/luni/src/main/native/hyzip/shared/zcpool.c
===================================================================
--- modules/luni/src/main/native/hyzip/shared/zcpool.c
+++ modules/luni/src/main/native/hyzip/shared/zcpool.c
@@ -0,0 +1,323 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file
+ * @ingroup ZipSupport
+ * @brief Zip Support for Java VM
+*/
+
+#include
+#include
+#include
+
+#include "hyport.h"
+#include "zipsup.h"
+#include "hypool.h"
+
+#include "hymutex.h"
+
+typedef struct HyZipCachePoolEntry
+{
+ HyZipCache *cache;
+ UDATA referenceCount;
+} HyZipCachePoolEntry;
+
+/* No typedef because an opaque typedef appears in zipsup.h (already included) */
+struct HyZipCachePool
+{
+ HyPool *pool;
+ HyZipCache *desiredCache;
+ I_64 zipTimeStamp;
+ char const *zipFileName;
+ IDATA zipFileNameLength;
+ IDATA zipFileSize;
+ MUTEX mutex;
+};
+
+void zipCachePool_doFindHandler
+PROTOTYPE ((HyZipCachePoolEntry * entry, HyZipCachePool * zcp));
+void zipCachePool_doKillHandler
+PROTOTYPE ((HyZipCachePoolEntry * entry, HyZipCachePool * zcp));
+
+/**
+ * Add a new cache to the pool with reference count of 1.
+ *
+ * When reference count reaches zero the pool will automatically be freed.
+ *
+ * @param[in] zcp the zip cache pool that is being added to.
+ * @param[in] zipCache the zip cache being added.
+ *
+ * @return TRUE if successful, FALSE otherwise.
+ *
+ * @note A cache may only reside in one pool (read: multiple VMs may not share caches with each other).
+*/
+
+BOOLEAN
+zipCachePool_addCache (HyZipCachePool * zcp, HyZipCache * zipCache)
+{
+ HyZipCachePoolEntry *entry;
+
+ if (!zcp || !zipCache)
+ return FALSE;
+
+ MUTEX_ENTER (zcp->mutex);
+
+ entry = pool_newElement (zcp->pool);
+ if (!entry)
+ {
+ MUTEX_EXIT (zcp->mutex);
+ return FALSE;
+ }
+
+ zipCache->cachePool = zcp;
+ zipCache->cachePoolEntry = entry;
+
+ entry->cache = zipCache;
+ entry->referenceCount = 1;
+
+ MUTEX_EXIT (zcp->mutex);
+ return TRUE;
+}
+
+/**
+ * Increment the reference count of a cache in the pool.
+ *
+ * @note Result is undefined if the cache is not actually in the pool!
+ *
+ * @param[in] zcp the zip cache pool that is being added to.
+ * @param[in] zipCache the zip cache being added.
+ *
+ * @return TRUE if successful, FALSE otherwise.
+*/
+
+BOOLEAN
+zipCachePool_addRef (HyZipCachePool * zcp, HyZipCache * zipCache)
+{
+ HyZipCachePoolEntry *entry;
+
+ if (!zcp || !zipCache)
+ return FALSE;
+
+ MUTEX_ENTER (zcp->mutex);
+
+ entry = (HyZipCachePoolEntry *) zipCache->cachePoolEntry;
+ if (!entry)
+ {
+ MUTEX_EXIT (zcp->mutex);
+ return FALSE;
+ }
+
+ entry->referenceCount++;
+
+ MUTEX_EXIT (zcp->mutex);
+ return TRUE;
+}
+
+/**
+ * Scans the pool for a cache with matching zipFileName, zipFileSize and zipTimeStamp.
+ *
+ * The reference count is incremented and the cache is returned if a match is found.
+ *
+ * @param[in] zcp the zip cache pool to search
+ * @param[in] zipFileName the name to test for match
+ * @param[in] zipFileNameLength the length of zipFileName
+ * @param[in] zipFileSize the size to test for match
+ * @param[in] zipTimeStamp the time stamp to test for match
+ *
+ * @return the matching zip cache
+ * @return NULL if no match is found.
+ */
+
+HyZipCache *
+zipCachePool_findCache (HyZipCachePool * zcp, char const *zipFileName,
+ IDATA zipFileNameLength, IDATA zipFileSize,
+ I_64 zipTimeStamp)
+{
+ HyZipCache *zipCache;
+ HyZipCachePoolEntry *entry;
+
+ if (!zcp || !zipFileName)
+ return NULL;
+
+ MUTEX_ENTER (zcp->mutex);
+
+ /* Find a suitable cache */
+ zcp->desiredCache = NULL;
+ zcp->zipFileName = zipFileName;
+ zcp->zipFileSize = zipFileSize;
+ zcp->zipTimeStamp = zipTimeStamp;
+ zcp->zipFileNameLength = zipFileNameLength;
+
+ pool_do (zcp->pool, (void (*)(void *, void *)) zipCachePool_doFindHandler,
+ zcp);
+ zipCache = zcp->desiredCache;
+
+ if (zipCache)
+ {
+ entry = (HyZipCachePoolEntry *) zipCache->cachePoolEntry;
+ entry->referenceCount++;
+ }
+
+ MUTEX_EXIT (zcp->mutex);
+ return zipCache;
+}
+
+/**
+ * Deletes a pool containing shareable zip caches.
+ *
+ * @param[in] zcp the zip cache pool that is being deleted
+ *
+ * @return none
+ *
+ * @note Warning: This also deletes remaining caches in the pool, regardless of their reference counts!
+ *
+ */
+void
+zipCachePool_kill (HyZipCachePool * zcp)
+{
+ void (VMCALL * memFree) (void *, void *);
+ void *userData;
+
+ if (!zcp)
+ return;
+
+ pool_do (zcp->pool, (void (*)(void *, void *)) zipCachePool_doKillHandler,
+ zcp);
+
+ MUTEX_DESTROY (zcp->mutex);
+
+ /* Grab the memFree and userData out of the pool BEFORE we destroy it. */
+ memFree = zcp->pool->memFree;
+ userData = zcp->pool->userData;
+ pool_kill (zcp->pool);
+ memFree (userData, zcp);
+}
+
+/**
+ * Creates a pool to hold shareable zip caches with their reference counts.
+ * This should be called once per VM.
+ *
+ * @param[in] portLib the port library
+ *
+ * @return a zip cache pool or NULL if one cannot be created
+ *
+*/
+
+HyZipCachePool *
+zipCachePool_new (HyPortLibrary * portLib)
+{
+ PORT_ACCESS_FROM_PORT (portLib);
+
+ HyZipCachePool *p = hymem_allocate_memory (sizeof (*p));
+ HyZipCachePool *toReturn = NULL;
+
+ if (p != NULL)
+ {
+ if (MUTEX_INIT (p->mutex))
+ {
+ p->pool = pool_forPortLib (sizeof (HyZipCachePoolEntry), portLib);
+ if (p->pool)
+ {
+ /* All initialization worked so set up to return the pointer */
+ toReturn = p;
+ }
+ else
+ {
+ /* pool discovery failed so give up the mutex */
+ MUTEX_DESTROY (p->mutex);
+ }
+ }
+ if (NULL == toReturn)
+ {
+ /* something went wrong so free the memory */
+ hymem_free_memory (p);
+ }
+ }
+ return toReturn;
+}
+
+/**
+ * Decrements the reference count of a cache in the pool.
+ * If the reference count reaches 0, the cache is removed from the pool and @ref zipCache_kill is called on it.
+ *
+ * @param[in] zcp the zip cache pool
+ * @param[in] zipCache the zip cache whose count is being decremented.
+ *
+ * @return TRUE if the cache was destroyed
+ * @return FALSE if the cache is still in the pool.
+ *
+ */
+
+BOOLEAN
+zipCachePool_release (HyZipCachePool * zcp, HyZipCache * zipCache)
+{
+ HyZipCachePoolEntry *entry;
+
+ if (!zcp || !zipCache)
+ return FALSE;
+
+ MUTEX_ENTER (zcp->mutex);
+
+ entry = (HyZipCachePoolEntry *) zipCache->cachePoolEntry;
+ if (!entry)
+ {
+ /* What the..? */
+ MUTEX_EXIT (zcp->mutex);
+ return FALSE;
+ }
+
+ if (--entry->referenceCount != 0)
+ {
+ MUTEX_EXIT (zcp->mutex);
+ return FALSE;
+ }
+
+ /* Reference count is zero, get rid of the cache */
+ zipCache_kill (entry->cache);
+ pool_removeElement (zcp->pool, entry);
+
+ MUTEX_EXIT (zcp->mutex);
+ return TRUE;
+}
+
+void
+zipCachePool_doFindHandler (HyZipCachePoolEntry * entry, HyZipCachePool * zcp)
+{
+
+ if (zcp->desiredCache)
+ return; /* already done */
+
+ if (entry->cache->zipTimeStamp != zcp->zipTimeStamp)
+ return;
+ if (entry->cache->zipFileSize != zcp->zipFileSize)
+ return;
+ if (memcmp
+ (entry->cache->zipFileName, zcp->zipFileName, zcp->zipFileNameLength))
+ return;
+ if (entry->cache->zipFileName[zcp->zipFileNameLength] != '\0')
+ return;
+
+ /* Looks like we have a match. */
+ zcp->desiredCache = entry->cache;
+}
+
+void
+zipCachePool_doKillHandler (HyZipCachePoolEntry * entry, HyZipCachePool * zcp)
+{
+ zipCache_kill (entry->cache);
+}
Index: modules/luni/src/main/native/hyzip/shared/zipalloc.c
===================================================================
--- modules/luni/src/main/native/hyzip/shared/zipalloc.c
+++ modules/luni/src/main/native/hyzip/shared/zipalloc.c
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "hyport.h"
+
+#include "zlib.h"
+
+#define CDEV_CURRENT_FUNCTION _prototypes_private
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION _prototypes_public
+void *zalloc PROTOTYPE ((void *opaque, U_32 items, U_32 size));
+void zfree PROTOTYPE ((void *opaque, void *address));
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION zalloc
+
+/*
+ ZLib interface to hymem_allocate_memory.
+*/
+void *
+zalloc (void *opaque, U_32 items, U_32 size)
+{
+ PORT_ACCESS_FROM_PORT (((HyPortLibrary *) opaque));
+
+ return hymem_allocate_memory (items * size);
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION zfree
+
+/*
+ ZLib interface to hymem_free_memory.
+*/
+void
+zfree (void *opaque, void *address)
+{
+ PORT_ACCESS_FROM_PORT ((HyPortLibrary *) opaque);
+
+ hymem_free_memory (address);
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION
+
+#undef CDEV_CURRENT_FUNCTION
Index: modules/luni/src/main/native/hyzip/shared/zipcache.c
===================================================================
--- modules/luni/src/main/native/hyzip/shared/zipcache.c
+++ modules/luni/src/main/native/hyzip/shared/zipcache.c
@@ -0,0 +1,920 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file
+ * @ingroup ZipSupport
+ * @brief Zip Support for VM
+*/
+
+#include
+#include
+#include
+#include
+
+#include "hyport.h"
+#include "zipsup.h"
+#include "hypool.h"
+
+#define UDATA_TOP_BIT (((UDATA)1)<<(sizeof(UDATA)*8-1))
+#define ISCLASS_BIT UDATA_TOP_BIT
+#define NOT_FOUND ((UDATA) (~0))
+#define OFFSET_MASK (~ISCLASS_BIT)
+#define IMPLICIT_ENTRY (~ISCLASS_BIT)
+
+/* This should be a multiple of the page size, minus a few UDATAs in case
+ the OS allocator needs header space (so we don't waste a page).
+ If the OS provides a fine-grain allocator (e.g. Windows) then it doesn't really
+ matter if we don't fit in one page, but the KISS principle applies.. */
+#define ACTUAL_CHUNK_SIZE (4096 - 4*sizeof(UDATA) )
+
+typedef struct HaZipChunkHeader
+{
+ struct HaZipChunkHeader *next;
+ U_8 *beginFree; /* UDATA-aligned, points to first free byte */
+ U_8 *endFree; /* unaligned, points to the byte after the last free byte */
+#if defined(ATOMIC_LONG_ACCESS)
+ UDATA padding; /* align to 64 */
+#endif
+
+} HaZipChunkHeader;
+
+typedef struct HyZipFileEntry
+{
+ char *name;
+ UDATA nameLength;
+ UDATA zipFileOffset;
+} HyZipFileEntry;
+
+/* a file record can hold a variable number of file entries. */
+typedef struct HyZipFileRecord
+{
+ struct HyZipFileRecord *next;
+ UDATA entryCount;
+ HyZipFileEntry entry[1];
+} HyZipFileRecord;
+
+typedef struct HaZipDirEntry
+{
+ struct HaZipDirEntry *next;
+ struct HyZipFileRecord *fileList;
+ struct HaZipDirEntry *dirList;
+ char *name;
+ UDATA zipFileOffset;
+#if defined(ATOMIC_LONG_ACCESS)
+ UDATA padding; /* align to 64 */
+#endif
+
+} HaZipDirEntry;
+
+/* trick: a HyZipCache * is a pointer to a HyZipCacheEntry which is the first entry
+ in the first chunk of the cache. This saves us one hymem_allocate_memory
+ (or probably two if the zipName isn't huge) */
+
+typedef struct HyZipCacheEntry
+{
+ HyZipCache info; /* publicly visible part */
+ HaZipChunkHeader *currentChunk;
+ HaZipDirEntry *chunkActiveDir;
+ HaZipDirEntry root;
+} HyZipCacheEntry;
+
+typedef struct HyZipCacheTraversal
+{
+ HyZipCache *zipCache;
+ HyPortLibrary *portLib;
+ HaZipDirEntry *dirEntry;
+ HyZipFileRecord *fileRecord;
+ UDATA fileRecordPos;
+} HyZipCacheTraversal;
+
+void zipCache_freeChunk
+PROTOTYPE ((HyPortLibrary * portLib, HaZipChunkHeader * chunk));
+HaZipDirEntry *zipCache_searchDirListCaseInsensitive
+PROTOTYPE ((HaZipDirEntry * dirEntry, const char *namePtr, UDATA nameSize,
+ BOOLEAN isClass));
+HaZipChunkHeader *zipCache_allocateChunk
+PROTOTYPE ((HyPortLibrary * portLib));
+HyZipFileEntry *zipCache_addToFileList
+PROTOTYPE ((HyZipCacheEntry * zce, HaZipDirEntry * dirEntry,
+ const char *namePtr, IDATA nameSize, BOOLEAN isClass,
+ UDATA elementOffset));
+UDATA *zipCache_reserveEntry
+PROTOTYPE ((HaZipChunkHeader * chunk, UDATA entryBytes, UDATA stringBytes));
+HyZipFileEntry *zipCache_searchFileList
+PROTOTYPE ((HaZipDirEntry * dirEntry, const char *namePtr, UDATA nameSize,
+ BOOLEAN isClass));
+HaZipDirEntry *zipCache_addToDirList
+PROTOTYPE ((HyZipCacheEntry * zce, HaZipDirEntry * dirEntry,
+ const char *namePtr, int nameSize, BOOLEAN isClass));
+HaZipDirEntry *zipCache_searchDirList
+PROTOTYPE ((HaZipDirEntry * dirEntry, const char *namePtr, UDATA nameSize,
+ BOOLEAN isClass));
+IDATA helper_memicmp
+PROTOTYPE ((const void *src1, const void *src2, UDATA length));
+
+/**
+ * Creates a new, empty zip cache for the provided zip file.
+ *
+ * @param[in] portLib the port library
+ * @param[in] zipName the zip file name
+ * @param[in] zipNameLength
+ *
+ * @return the new zip cache if one was successfully created, NULL otherwise
+ *
+*/
+
+HyZipCache *
+zipCache_new (HyPortLibrary * portLib, char *zipName, IDATA zipNameLength)
+{
+ HaZipChunkHeader *chunk;
+ HyZipCacheEntry *zce;
+
+ PORT_ACCESS_FROM_PORT (portLib);
+
+ chunk = zipCache_allocateChunk (portLib);
+ if (!chunk)
+ return NULL;
+
+ zce =
+ (HyZipCacheEntry *) zipCache_reserveEntry (chunk,
+ sizeof (HyZipCacheEntry), 0);
+ if (!zce)
+ {
+ /* ACTUAL_CHUNK_SIZE is so small it can't hold one HyZipCacheEntry?? */
+ zipCache_freeChunk (portLib, chunk);
+ return NULL;
+ }
+
+ zce->info.portLib = portLib;
+ 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))
+ {
+ zce->info.zipFileName = chunk->endFree;
+ }
+ else
+ {
+ zce->info.zipFileName = hymem_allocate_memory (zipNameLength + 1);
+ if (!zce->info.zipFileName)
+ {
+ zipCache_freeChunk (portLib, chunk);
+ return NULL;
+ }
+ }
+ memcpy (zce->info.zipFileName, zipName, zipNameLength);
+ zce->info.zipFileName[zipNameLength] = '\0';
+ zce->info.zipFileSize = zce->info.startCentralDir = -1;
+ zce->info.zipTimeStamp = -1;
+ /* zce->info.cachePool is already NULL */
+ /* zce->info.cachePoolEntry is already NULL */
+ zce->root.zipFileOffset = 1;
+
+ return (HyZipCache *) zce;
+}
+
+/**
+ * Add an association between a file or directory named elementName and offset elementOffset to the zip cache provided
+ *
+ * @param[in] zipCache the zip cache being added to
+ * @param[in] elementName the name of the file or directory element
+ * @param[in] elementOffset the corresponding offset of the element
+ *
+ * @return TRUE if the association was made, FALSE otherwise
+ *
+*/
+
+BOOLEAN
+zipCache_addElement (HyZipCache * zipCache, char *elementName,
+ UDATA elementOffset)
+{
+ HyZipCacheEntry *zce = (HyZipCacheEntry *) zipCache;
+ HaZipDirEntry *dirEntry;
+ HyZipFileEntry *fileEntry;
+ char *curName;
+ IDATA curSize;
+ IDATA prefixSize;
+ BOOLEAN isClass;
+
+ if (!zipCache || !elementName || !elementName[0]
+ || (elementOffset & ISCLASS_BIT)
+ || ((elementOffset & OFFSET_MASK) == IMPLICIT_ENTRY))
+ return FALSE;
+
+ dirEntry = &zce->root;
+
+ curName = elementName;
+ for (;;)
+ {
+ HaZipDirEntry *d;
+
+ /* scan forwards in curName until '/' or NUL */
+ for (curSize = 0; curName[curSize] && (curName[curSize] != '/');
+ curSize++)
+ /* nothing */ ;
+
+ prefixSize = curSize + 1;
+ isClass = FALSE;
+
+ if ((curSize >= 6) && !memcmp (&curName[curSize - 6], ".class", 6))
+ {
+ isClass = TRUE;
+ curSize -= 6;
+ }
+
+ if (!*curName)
+ {
+ /* We ran out of string, which means the elementName was */
+ /* a directory name---in fact, it was the subdir we parsed */
+ /* last time through the loop. */
+
+ if ((dirEntry->zipFileOffset & OFFSET_MASK) != IMPLICIT_ENTRY)
+ {
+ /* Can't add the same directory more than once! */
+ return TRUE;
+ }
+ dirEntry->zipFileOffset =
+ elementOffset | (isClass ? ISCLASS_BIT : 0);
+ return TRUE;
+ }
+
+ if (curName[curSize] != '/')
+ {
+ /* The prefix we're looking at doesn't end with a '/', which means */
+ /* it is really the suffix of the elementName, and it's a filename. */
+
+ fileEntry =
+ zipCache_searchFileList (dirEntry, curName, curSize, isClass);
+ if (fileEntry)
+ {
+ /* We've seen this file before...update the entry to the new offset. */
+ fileEntry->zipFileOffset =
+ elementOffset | (isClass ? ISCLASS_BIT : 0);
+ }
+ else
+ {
+ if (!zipCache_addToFileList
+ (zce, dirEntry, curName, curSize, isClass, elementOffset))
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ /* If we got here, we're looking at a prefix which ends with '/' */
+ /* Treat that prefix as a subdirectory. If it doesn't exist, create it implicitly */
+
+ if (!(d = zipCache_searchDirList (dirEntry, curName, curSize, isClass)))
+ {
+ if (!
+ (d =
+ zipCache_addToDirList (zce, dirEntry, curName, curSize,
+ isClass)))
+ {
+ return FALSE;
+ }
+ }
+ dirEntry = d;
+ curName += prefixSize;
+ }
+}
+
+/**
+ * Returns the offset associated with a file or directory element named elementName
+ * in a zipCache.
+ *
+ * @param[in] zipCache the zip cache we are searching
+ * @param[in] elementName the name of the element of which we want the offset
+ * @param[in] searchDirList when TRUE, search the dir list even if elementName does not end in '/'
+ *
+ * @return the zipCache if a match is found
+ * @return -1 if no element of that name has been explicitly added to the cache.
+ *
+*/
+
+UDATA
+zipCache_findElement (HyZipCache * zipCache, const char *elementName,
+ BOOLEAN searchDirList)
+{
+ HyZipCacheEntry *zce = (HyZipCacheEntry *) zipCache;
+ HaZipDirEntry *dirEntry;
+ HyZipFileEntry *fileEntry;
+ const char *curName;
+ IDATA curSize;
+ IDATA prefixSize;
+ BOOLEAN isClass;
+
+ if (!zipCache || !elementName || !elementName[0])
+ return NOT_FOUND;
+
+ dirEntry = &zce->root;
+
+ curName = elementName;
+ for (;;)
+ {
+
+ /* scan forwards in curName until '/' or NUL */
+ for (curSize = 0; curName[curSize] && (curName[curSize] != '/');
+ curSize++)
+ /* nothing */ ;
+
+ prefixSize = curName[curSize] ? curSize + 1 : curSize;
+ isClass = FALSE;
+
+ if ((curSize >= 6) && !memcmp (&curName[curSize - 6], ".class", 6))
+ {
+ isClass = TRUE;
+ curSize -= 6;
+ }
+
+ if (!*curName)
+ {
+ /* We ran out of string, which means the elementName was */
+ /* a directory name---in fact, it was the subdir we parsed */
+ /* last time through the loop. */
+
+ /* directory may have been implicitly but not explicitly added */
+ if ((dirEntry->zipFileOffset & OFFSET_MASK) == IMPLICIT_ENTRY)
+ return NOT_FOUND; /* if it was never added, it doesn't "really" exist! */
+
+ return dirEntry->zipFileOffset & OFFSET_MASK;
+ }
+
+ if (curName[curSize] != '/')
+ {
+ /* The prefix we're looking at doesn't end with a '/', which means */
+ /* it is really the suffix of the elementName, and it's a filename. */
+
+ fileEntry =
+ zipCache_searchFileList (dirEntry, curName, curSize, isClass);
+ if (fileEntry)
+ {
+ return fileEntry->zipFileOffset & OFFSET_MASK;
+ }
+ if (!searchDirList)
+ {
+ return NOT_FOUND;
+ }
+ }
+
+ /* If we got here, we're looking at a prefix which ends with '/', or searchDirList is TRUE */
+ /* Treat that prefix as a subdirectory. It will exist if elementName was added before. */
+
+ dirEntry = zipCache_searchDirList (dirEntry, curName, curSize, isClass);
+ if (!dirEntry)
+ return NOT_FOUND;
+ curName += prefixSize;
+ }
+}
+
+/**
+ * Deletes a zip cache and frees its resources
+ *
+ * @param[in] zipCache the zip cache to be freed
+ *
+ * @return none
+ *
+ * @see zipCache_new
+ *
+*/
+
+void
+zipCache_kill (HyZipCache * zipCache)
+{
+ HaZipChunkHeader *chunk, *chunk2;
+ HyZipCacheEntry *zce = (HyZipCacheEntry *) zipCache;
+ HyPortLibrary *portLib = zce->info.portLib;
+
+ PORT_ACCESS_FROM_PORT (portLib);
+
+ chunk =
+ (HaZipChunkHeader *) (((U_8 *) zipCache) - sizeof (HaZipChunkHeader));
+
+ if (((UDATA) ((U_8 *) zce->info.zipFileName - (U_8 *) chunk)) >=
+ ACTUAL_CHUNK_SIZE)
+ {
+ /* zce->info.zipFileName points outside the first chunk, therefore it was allocated
+ separately rather than being reserved from the chunk */
+ hymem_free_memory (zce->info.zipFileName);
+ }
+
+ chunk = zce->currentChunk;
+ while (chunk)
+ {
+ chunk2 = chunk->next;
+ zipCache_freeChunk (portLib, chunk);
+ chunk = chunk2;
+ }
+}
+
+/* Allocate a new HaZipDirEntry and insert into dirEntry's dirList. */
+
+HaZipDirEntry *
+zipCache_addToDirList (HyZipCacheEntry * zce, HaZipDirEntry * dirEntry,
+ const char *namePtr, int nameSize, BOOLEAN isClass)
+{
+ HaZipDirEntry *entry;
+ HaZipChunkHeader *chunk = zce->currentChunk;
+ zce->chunkActiveDir = NULL;
+
+ entry =
+ (HaZipDirEntry *) zipCache_reserveEntry (chunk, sizeof (*entry),
+ nameSize + 1);
+ if (!entry)
+ {
+ if (!(chunk = zipCache_allocateChunk (zce->info.portLib)))
+ return NULL;
+ chunk->next = zce->currentChunk;
+ zce->currentChunk = chunk;
+ entry =
+ (HaZipDirEntry *) zipCache_reserveEntry (chunk, sizeof (*entry),
+ nameSize + 1);
+ if (!entry)
+ {
+ /* ACTUAL_CHUNK_SIZE is so small it can't hold one HaZipDirEntry?? */
+ return NULL;
+ }
+ }
+ entry->next = dirEntry->dirList;
+ dirEntry->dirList = entry;
+ entry->zipFileOffset = IMPLICIT_ENTRY | (isClass ? ISCLASS_BIT : 0);
+ entry->name = (char *) chunk->endFree;
+ memcpy (entry->name, namePtr, nameSize);
+ /* chunk->endFree[nameSize] is already zero (NUL) */
+ return entry;
+}
+
+/* Allocate a new zipFileEntry and insert it into dirEntry's fileList. */
+/* If possible, the new file entry will be appended to the active zipFileRecord. */
+/* Otherwise, a new zipFileRecord will be allocated to hold the new zipFileEntry. */
+
+HyZipFileEntry *
+zipCache_addToFileList (HyZipCacheEntry * zce, HaZipDirEntry * dirEntry,
+ const char *namePtr, IDATA nameSize, BOOLEAN isClass,
+ UDATA elementOffset)
+{
+ HyZipFileEntry *entry;
+ HyZipFileRecord *record;
+ HaZipChunkHeader *chunk = zce->currentChunk;
+
+ if (zce->chunkActiveDir == dirEntry)
+ {
+ if (entry =
+ (HyZipFileEntry *) zipCache_reserveEntry (chunk, sizeof (*entry),
+ nameSize + 1))
+ {
+ /* add to end of existing entry */
+ zce->chunkActiveDir->fileList->entryCount++;
+ goto haveEntry;
+ }
+ }
+
+ record =
+ (HyZipFileRecord *) zipCache_reserveEntry (chunk, sizeof (*record),
+ nameSize + 1);
+ if (!record)
+ {
+ if (!(chunk = zipCache_allocateChunk (zce->info.portLib)))
+ return NULL;
+ chunk->next = zce->currentChunk;
+ zce->currentChunk = chunk;
+ zce->chunkActiveDir = NULL;
+ record =
+ (HyZipFileRecord *) zipCache_reserveEntry (chunk, sizeof (*record),
+ nameSize + 1);
+ if (!record)
+ {
+ /* ACTUAL_CHUNK_SIZE is so small it can't hold one zipFileRecord?? */
+ return NULL;
+ }
+ }
+ record->next = dirEntry->fileList;
+ dirEntry->fileList = record;
+
+ zce->chunkActiveDir = dirEntry;
+ record->entryCount = 1;
+ entry = record->entry;
+
+haveEntry:
+ entry->name = (char *) chunk->endFree;
+ memcpy (entry->name, namePtr, nameSize);
+ /* chunk->endFree[nameSize] is already zero (NUL) */
+ entry->nameLength = nameSize;
+ entry->zipFileOffset = elementOffset | (isClass ? ISCLASS_BIT : 0);
+ return entry;
+}
+
+/* Allocate a new chunk and initialize its zipChunkHeader. */
+
+HaZipChunkHeader *
+zipCache_allocateChunk (HyPortLibrary * portLib)
+{
+ HaZipChunkHeader *chunk;
+ PORT_ACCESS_FROM_PORT (portLib);
+
+ chunk = (HaZipChunkHeader *) hymem_allocate_memory (ACTUAL_CHUNK_SIZE);
+ if (!chunk)
+ return NULL;
+ memset (chunk, 0, ACTUAL_CHUNK_SIZE);
+ chunk->beginFree = ((U_8 *) chunk) + sizeof (HaZipChunkHeader);
+ chunk->endFree = ((U_8 *) chunk) + ACTUAL_CHUNK_SIZE;
+ return chunk;
+}
+
+/* Frees a chunk which is no longer used. */
+/* portLib must be the original portLib which was passed to zipCache_allocateChunk. */
+
+void
+zipCache_freeChunk (HyPortLibrary * portLib, HaZipChunkHeader * chunk)
+{
+ PORT_ACCESS_FROM_PORT (portLib);
+
+ hymem_free_memory (chunk);
+}
+
+/* Tries to reserve storage in a chunk for entryBytes of header data, and */
+/* stringBytes of string data. If there is not enough storage, NULL is */
+/* returned and no storage is reserved. If there is enough storage, a */
+/* pointer is returned to the allocated entryBytes, and chunk->bottom points */
+/* to the allocated stringBytes. */
+
+UDATA *
+zipCache_reserveEntry (HaZipChunkHeader * chunk, UDATA entryBytes,
+ UDATA stringBytes)
+{
+ UDATA *entry;
+
+ if (!chunk)
+ return NULL;
+
+ if ((chunk->endFree - chunk->beginFree) <
+ (IDATA) (entryBytes + stringBytes))
+ return NULL;
+
+ entry = (UDATA *) (chunk->beginFree);
+ chunk->beginFree += entryBytes;
+ chunk->endFree -= stringBytes;
+ return entry;
+}
+
+/* Searches the dirList in dirEntry for a directory entry named */
+/* namePtr[0..nameSize-1] with the specified isClass value. */
+
+HaZipDirEntry *
+zipCache_searchDirList (HaZipDirEntry * dirEntry, const char *namePtr,
+ UDATA nameSize, BOOLEAN isClass)
+{
+ HaZipDirEntry *entry;
+
+ if (!dirEntry || !namePtr)
+ return NULL;
+
+ entry = dirEntry->dirList;
+ while (entry)
+ {
+ if (!memcmp (entry->name, namePtr, nameSize) && !entry->name[nameSize])
+ {
+ if (isClass && (entry->zipFileOffset & ISCLASS_BIT))
+ return entry;
+ if (!isClass && !(entry->zipFileOffset & ISCLASS_BIT))
+ return entry;
+ }
+ entry = entry->next;
+ }
+ return NULL;
+}
+
+/* Searches the fileList in dirEntry for a file entry named */
+/* namePtr[0..nameSize-1] with the specified isClass value. */
+
+HyZipFileEntry *
+zipCache_searchFileList (HaZipDirEntry * dirEntry, const char *namePtr,
+ UDATA nameSize, BOOLEAN isClass)
+{
+ HyZipFileRecord *record;
+ HyZipFileEntry *entry;
+ IDATA i;
+
+ if (!dirEntry || !namePtr)
+ return NULL;
+
+ record = dirEntry->fileList;
+ while (record)
+ {
+ for (i = record->entryCount; i--;)
+ {
+ entry = &record->entry[i];
+ if (entry->nameLength == nameSize)
+ {
+ if (!memcmp (entry->name, namePtr, nameSize))
+ {
+ if (isClass && (entry->zipFileOffset & ISCLASS_BIT))
+ return &record->entry[i];
+ if (!isClass && !(entry->zipFileOffset & ISCLASS_BIT))
+ return &record->entry[i];
+ }
+ }
+ }
+ record = record->next;
+ }
+ return NULL;
+}
+
+/**
+ * Searches for a directory named elementName in zipCache and if found provides
+ * a handle to it that can be used to enumerate through all of the directory's files.
+ *
+ * @note The search is CASE-INSENSITIVE (contrast with @ref zipCache_findElement, which is case-sensitive).
+ * @note The search is NOT recursive.
+ *
+ * @param[in] zipCache the zip cache that is being searched
+ * @param[in] directoryName the directory we want to enumerate
+ * @param[out] handle enumerate all the files in directory directoryName on this handle
+ *
+ * @return 0 on success and sets handle
+ * @return -1 if the directory is not found
+ * @return -2 if there is not enough memory to complete this call
+ *
+ * @see zipCache_findElement
+ */
+
+IDATA
+zipCache_enumNew (HyZipCache * zipCache, char *directoryName, void **handle)
+{
+ HyZipCacheEntry *zce = (HyZipCacheEntry *) zipCache;
+ HaZipDirEntry *dirEntry;
+ char *curName;
+ IDATA curSize;
+ IDATA prefixSize;
+ BOOLEAN isClass;
+
+ if (!zipCache || !directoryName || !directoryName[0] || !handle)
+ {
+ return -3;
+ }
+ else
+ {
+ PORT_ACCESS_FROM_PORT (zce->info.portLib);
+
+ dirEntry = &zce->root;
+
+ curName = directoryName;
+ for (;;)
+ {
+
+ /* scan forwards in curName until '/' or NUL */
+ for (curSize = 0; curName[curSize] && (curName[curSize] != '/');
+ curSize++)
+ /* nothing */ ;
+
+ prefixSize = curSize + 1;
+ isClass = FALSE;
+
+ /* Note: CASE-INSENSITIVE HERE */
+ if ((curSize >= 6)
+ && !helper_memicmp (&curName[curSize - 6], ".class", 6))
+ {
+ isClass = TRUE;
+ curSize -= 6;
+ }
+
+ if (!*curName)
+ {
+ /* We ran out of string, which means directoryName was */
+ /* the subdir we parsed last time through the loop. Begin the traversal here. */
+ HyZipCacheTraversal *traversal =
+ hymem_allocate_memory (sizeof (*traversal));
+ if (!traversal)
+ {
+ return -2;
+ }
+ traversal->zipCache = zipCache;
+ traversal->portLib = zce->info.portLib;
+ traversal->dirEntry = dirEntry;
+ traversal->fileRecord = dirEntry->fileList;
+ traversal->fileRecordPos = 0;
+
+ /* ensure an automatically-managed cache doesn't go away while enumerating */
+ if (zce->info.cachePool)
+ {
+ zipCachePool_addRef (zce->info.cachePool, zipCache);
+ }
+
+ *handle = traversal;
+ return 0;
+ }
+
+ if (curName[curSize] != '/')
+ {
+ /* The prefix we're looking at doesn't end with a '/', which means */
+ /* it is really the suffix of the directoryName, and it's a filename. */
+
+ return -1; /* We're not interested in filenames */
+ }
+
+ /* If we got here, we're looking at a prefix which ends with '/' */
+ /* Treat that prefix as a subdirectory. It will exist if directoryName has been
+ added or if any file or directory inside directoryName has been added. */
+
+ dirEntry =
+ zipCache_searchDirListCaseInsensitive (dirEntry, curName, curSize,
+ isClass);
+ if (!dirEntry)
+ {
+ return -1;
+ }
+ curName += prefixSize;
+ }
+ }
+}
+
+/**
+ * Gets the name and offset of the next element in the directory being enumerated.
+ *
+ * If nameBufSize is insufficient to hold the entire name, returns the required size for nameBuf.
+
+ * @note Does NOT skip the element if nameBufSize buffer is of insufficient size to hold the entire name.
+ *
+ * @param[in] handle returned from @ref zipCache_enumNew. Used to enumerate the elements corresponding to the directory name returned by @ref zipCache_enumGetDirName
+ * @param[out] nameBuf holder for element in the directory being enumerated
+ * @param[in] nameBufSize
+ * @param[out] offset the offset of the next element
+ *
+ * @return 0 on success
+ * @return -1 if all the directories have been returned already
+ * @return the required size of nameBuf if nameBufSize is insufficient to hold the entire name (does not skip the element)
+ *
+ * @see zipCache_enumNew
+*
+*/
+IDATA
+zipCache_enumElement (void *handle, char *nameBuf, UDATA nameBufSize,
+ UDATA * offset)
+{
+ HyZipCacheTraversal *traversal = (HyZipCacheTraversal *) handle;
+ HyZipFileEntry *fileEntry;
+ UDATA nameLen;
+
+ if (!traversal || !nameBuf || !nameBufSize)
+ return -3;
+
+ if (!traversal->fileRecord)
+ return -1; /* No more elements */
+
+ fileEntry = &traversal->fileRecord->entry[traversal->fileRecordPos];
+
+ nameLen = fileEntry->nameLength + 1;
+ if (fileEntry->zipFileOffset & ISCLASS_BIT)
+ nameLen += 6;
+ if (nameBufSize < nameLen)
+ {
+ /* Buffer is too small. Return size the caller must allocate to try again. */
+ return nameLen;
+ }
+
+ memcpy (nameBuf, fileEntry->name, fileEntry->nameLength);
+ if (fileEntry->zipFileOffset & ISCLASS_BIT)
+ memcpy (nameBuf + fileEntry->nameLength, ".class", 6);
+ nameBuf[nameLen - 1] = 0;
+ if (offset)
+ *offset = fileEntry->zipFileOffset & OFFSET_MASK;
+
+ /* Advance to the next element */
+ ++traversal->fileRecordPos;
+ if (traversal->fileRecordPos >= traversal->fileRecord->entryCount)
+ {
+ traversal->fileRecord = traversal->fileRecord->next;
+ traversal->fileRecordPos = 0;
+ }
+ return 0;
+}
+
+/**
+ * Gets the name of the directory on which the enumeration is based.
+ *
+ * @param[in] handle handle returned from @ref zipCache_enumNew.
+ * @param[out] nameBuf buffer to hold the directory name
+ * @param[in] nameBufSize
+ *
+ * @return 0 on success
+ * @return -3 on param failures
+ * @return the required size for nameBuf if nameBufSize is insufficient to hold the entire name
+ *
+ */
+
+IDATA
+zipCache_enumGetDirName (void *handle, char *nameBuf, UDATA nameBufSize)
+{
+ HyZipCacheTraversal *traversal = (HyZipCacheTraversal *) handle;
+ HaZipDirEntry *dirEntry;
+ UDATA nameLen;
+
+ if (!traversal || !nameBuf || !nameBufSize)
+ return -3;
+
+ dirEntry = traversal->dirEntry;
+ nameLen = strlen (dirEntry->name) + 1 + 1; /* for '/' and null */
+ if (nameBufSize < nameLen)
+ {
+ /* Buffer is too small. Return size the caller must allocate to try again. */
+ return nameLen;
+ }
+
+ strcpy (nameBuf, dirEntry->name);
+ strcat (nameBuf, "/");
+ return 0;
+}
+
+/**
+ * Frees any resources allocated by @ref zipCache_enumNew.
+ *
+ * @param[in] handle enumerate on this handle
+ *
+ * @return none
+ *
+ * @see zipCache_enumNew
+ */
+
+void
+zipCache_enumKill (void *handle)
+{
+ HyZipCacheTraversal *traversal = (HyZipCacheTraversal *) handle;
+
+ if (!traversal)
+ {
+ return;
+ }
+ else
+ {
+ PORT_ACCESS_FROM_PORT (traversal->portLib);
+
+ if (traversal->zipCache)
+ {
+ zipCachePool_release (traversal->zipCache->cachePool,
+ traversal->zipCache);
+ }
+ hymem_free_memory (traversal);
+ }
+}
+
+/* Searches the dirList in dirEntry for a directory entry named */
+/* namePtr[0..nameSize-1] with the specified isClass value. */
+
+HaZipDirEntry *
+zipCache_searchDirListCaseInsensitive (HaZipDirEntry * dirEntry,
+ const char *namePtr, UDATA nameSize,
+ BOOLEAN isClass)
+{
+ HaZipDirEntry *entry;
+
+ if (!dirEntry || !namePtr)
+ return NULL;
+
+ entry = dirEntry->dirList;
+ while (entry)
+ {
+ if (!helper_memicmp (entry->name, namePtr, nameSize)
+ && !entry->name[nameSize])
+ {
+ if (isClass && (entry->zipFileOffset & ISCLASS_BIT))
+ return entry;
+ if (!isClass && !(entry->zipFileOffset & ISCLASS_BIT))
+ return entry;
+ }
+ entry = entry->next;
+ }
+ return NULL;
+}
+
+/* Returns zero if the two strings are equal over the first length characters. Otherwise,
+ returns 1 or -1 ala stricmp. */
+
+IDATA
+helper_memicmp (const void *src1, const void *src2, UDATA length)
+{
+ char const *s1 = (char const *) src1;
+ char const *s2 = (char const *) src2;
+ UDATA i;
+ for (i = 0; i < length; i++)
+ {
+ if (toupper (s1[i]) > toupper (s2[i]))
+ return 1;
+ if (toupper (s1[i]) < toupper (s2[i]))
+ return -1;
+ }
+ return 0;
+}
Index: modules/luni/src/main/native/hyzip/shared/zipsup.c
===================================================================
--- modules/luni/src/main/native/hyzip/shared/zipsup.c
+++ modules/luni/src/main/native/hyzip/shared/zipsup.c
@@ -0,0 +1,2302 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file
+ * @ingroup ZipSupport
+ * @brief Zip Support for Java VM
+*/
+
+#include
+
+#include "hyport.h"
+#include "zipsup.h"
+#include "hyzipnls.h"
+
+#include "zlib.h"
+
+/* Globals for the zip library */
+UDATA zipDLLDescriptor = 0;
+int (*inflateInit2Func) (void *, int, const char *, int);
+int (*inflateFunc) (void *, int);
+int (*inflateEndFunc) (void *);
+
+#define ZIP_NEXT_U8(value, index) (value = *(index++))
+#define ZIP_NEXT_U16(value, index) ((value = (index[1] << 8) | index[0]), index += 2, value)
+#define ZIP_NEXT_U32(value, index) ((value = ((U_32)index[3] << 24) | ((U_32)index[2] << 16) | ((U_32)index[1] << 8) | (U_32)index[0]), index += 4, value)
+
+#define WORK_BUFFER_SIZE 64000
+
+#define SCAN_CHUNK_SIZE 1024
+
+struct workBuffer
+{
+ HyPortLibrary *portLib;
+ UDATA *bufferStart;
+ UDATA *bufferEnd;
+ UDATA *currentAlloc;
+ UDATA cntr;
+};
+
+#define CDEV_CURRENT_FUNCTION _prototypes_private
+I_32 zip_populateCache
+PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile));
+
+static I_32 inflateData
+PROTOTYPE ((struct workBuffer * workBuf, U_8 * inputBuffer,
+ U_32 inputBufferSize, U_8 * outputBuffer, U_32 outputBufferSize));
+
+I_32 checkZipLibrary PROTOTYPE ((HyPortLibrary * portLib));
+
+I_32 scanForDataDescriptor
+PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile,
+ HyZipEntry * zipEntry));
+void zdatafree PROTOTYPE ((void *opaque, void *address));
+static I_32 readZipEntry
+PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile,
+ HyZipEntry * zipEntry, const char *filename,
+ IDATA * enumerationPointer, IDATA * entryStart,
+ BOOLEAN findDirectory));
+I_32 scanForCentralEnd
+PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile,
+ HyZipCentralEnd * endEntry));
+void *zdataalloc PROTOTYPE ((void *opaque, U_32 items, U_32 size));
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION _prototypes_public
+I_32 zip_getZipEntryData
+PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile, HyZipEntry * entry,
+ U_8 * buffer, U_32 bufferSize));
+I_32 zip_getZipEntryFromOffset
+PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile, HyZipEntry * entry,
+ IDATA offset));
+I_32 zip_establishCache
+PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile));
+void zip_resetZipFile
+PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile,
+ IDATA * nextEntryPointer));
+I_32 zip_getNextZipEntry
+PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile,
+ HyZipEntry * zipEntry, IDATA * nextEntryPointer));
+I_32 zip_getZipEntry
+PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile, HyZipEntry * entry,
+ const char *filename, BOOLEAN findDirectory));
+I_32 zip_getZipEntryExtraField
+PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile, HyZipEntry * entry,
+ U_8 * buffer, U_32 bufferSize));
+void zip_initZipEntry
+PROTOTYPE ((HyPortLibrary * portLib, HyZipEntry * entry));
+I_32 zip_openZipFile
+PROTOTYPE ((HyPortLibrary * portLib, char *filename, HyZipFile * zipFile,
+ HyZipCachePool * cachePool));
+void zip_freeZipEntry
+PROTOTYPE ((HyPortLibrary * portLib, HyZipEntry * entry));
+I_32 VMCALL zip_closeZipFile
+PROTOTYPE ((HyPortLibrary * portLib, struct HyZipFile * zipFile));
+I_32 zip_getZipEntryComment
+PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile, HyZipEntry * entry,
+ U_8 * buffer, U_32 bufferSize));
+
+#undef CDEV_CURRENT_FUNCTION
+
+#include "hythread.h"
+#define ENTER() hythread_monitor_enter(hythread_global_monitor())
+#define EXIT() hythread_monitor_exit(hythread_global_monitor())
+
+#define CDEV_CURRENT_FUNCTION checkZipLibrary
+
+/*
+ Ensure that the zip library is loaded.
+ Return 0 on success, -1 on failure.
+*/
+I_32
+checkZipLibrary (HyPortLibrary * portLib)
+{
+ PORT_ACCESS_FROM_PORT (portLib);
+
+ /* if the library has already been loaded return success/failure */
+ if (zipDLLDescriptor > 1)
+ return 0;
+ if (zipDLLDescriptor == 1)
+ return -1;
+
+ /* open up the zip library by name */
+
+ if (hysl_open_shared_library (HY_ZIP_DLL_NAME, &zipDLLDescriptor, TRUE))
+ goto openFailed;
+
+ /* look up the functions */
+ if (hysl_lookup_name
+ (zipDLLDescriptor, "inflateInit2_", (void *) &inflateInit2Func,
+ "ILILI"))
+ goto loadFailed;
+ if (hysl_lookup_name
+ (zipDLLDescriptor, "inflate", (void *) &inflateFunc, "IPI"))
+ goto loadFailed;
+ if (hysl_lookup_name
+ (zipDLLDescriptor, "inflateEnd", (void *) &inflateEndFunc, "IP"))
+ goto loadFailed;
+
+ /* good to go */
+ return 0;
+
+loadFailed:
+ hysl_close_shared_library (zipDLLDescriptor);
+
+ /* mark the descriptor as a failed load. only report the error once */
+ zipDLLDescriptor = 1;
+
+ /* Unable to open %s (Missing export) */
+ hynls_printf (PORTLIB, HYNLS_WARNING, HYNLS_ZIP_MISSING_EXPORT,
+ HY_ZIP_DLL_NAME);
+
+ return -1;
+
+openFailed:
+ /* mark the descriptor as a failed load. only report the error once */
+ zipDLLDescriptor = 1;
+
+ /* Unable to open %s (%s) */
+ hynls_printf (PORTLIB, HYNLS_WARNING, HYNLS_ZIP_UNABLE_TO_OPEN_ZIP_DLL,
+ HY_ZIP_DLL_NAME, hyerror_last_error_message ());
+ return -1;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION inflateData
+
+/*
+ Returns 0 on success or one of the following:
+ ZIP_ERR_UNSUPPORTED_FILE_TYPE
+ ZIP_ERR_FILE_CORRUPT
+ ZIP_ERR_OUT_OF_MEMORY
+ ZIP_ERR_INTERNAL_ERROR
+*/
+static I_32
+inflateData (struct workBuffer *workBuf, U_8 * inputBuffer,
+ U_32 inputBufferSize, U_8 * outputBuffer, U_32 outputBufferSize)
+{
+ PORT_ACCESS_FROM_PORT (workBuf->portLib);
+
+ z_stream stream;
+ I_32 err;
+
+ stream.next_in = inputBuffer;
+ stream.avail_in = inputBufferSize;
+ stream.next_out = outputBuffer;
+ stream.avail_out = outputBufferSize;
+
+ stream.opaque = workBuf;
+ stream.zalloc = zdataalloc;
+ stream.zfree = zdatafree;
+
+ /* Initialize stream. Pass "-15" as max number of window bits, negated
+ to indicate that no zlib header is present in the data. */
+ err = inflateInit2Func (&stream, -15, ZLIB_VERSION, sizeof (z_stream));
+ if (err != Z_OK)
+ return -1;
+
+ /* Inflate the data. */
+ err = inflateFunc (&stream, Z_SYNC_FLUSH);
+
+ /* Clean up the stream. */
+ inflateEndFunc (&stream);
+
+ /* Check the return code. Did we complete the inflate? */
+ if ((err == Z_STREAM_END) || (err == Z_OK))
+ {
+ if (stream.total_out == outputBufferSize)
+ {
+ return 0;
+ }
+ }
+
+ switch (err)
+ {
+ case Z_OK: /* an error if file is incomplete */
+ case Z_STREAM_END: /* an error if file is incomplete */
+ case Z_ERRNO: /* a random error */
+ case Z_STREAM_ERROR: /* stream inconsistent */
+ case Z_DATA_ERROR: /* corrupted zip */
+ return ZIP_ERR_FILE_CORRUPT;
+
+ case Z_VERSION_ERROR: /* wrong zlib version */
+ case Z_NEED_DICT: /* needs a preset dictionary that we can't provide */
+ return ZIP_ERR_UNSUPPORTED_FILE_TYPE;
+
+ case Z_MEM_ERROR: /* out of memory */
+ return ZIP_ERR_OUT_OF_MEMORY;
+
+ case Z_BUF_ERROR: /* no progress / out of output buffer */
+ default: /* jic */
+ return ZIP_ERR_INTERNAL_ERROR;
+ }
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION scanForCentralEnd
+/*
+ Scan backward from end of file for a central end header. Read from zipFile and update the HyZipCentralEnd provided.
+
+ Returns 0 on success or one of the following:
+ ZIP_ERR_FILE_READ_ERROR
+ ZIP_ERR_FILE_CORRUPT
+*/
+I_32
+scanForCentralEnd (HyPortLibrary * portLib, HyZipFile * zipFile,
+ HyZipCentralEnd * endEntry)
+{
+ U_8 *current;
+ U_8 buffer[SCAN_CHUNK_SIZE];
+ I_32 i, size, state;
+ U_32 dataSize = 0;
+ I_64 seekResult;
+ I_32 fileSize;
+ I_32 bytesAlreadyRead = 0;
+
+ PORT_ACCESS_FROM_PORT (portLib);
+
+ /* Haven't seen anything yet. */
+ state = 0;
+
+ seekResult = hyfile_seek (zipFile->fd, 0, HySeekEnd);
+ if ((seekResult < 0) || (seekResult > HYCONST64 (0x7FFFFFFF)))
+ {
+ zipFile->pointer = -1;
+ return ZIP_ERR_FILE_READ_ERROR;
+ }
+ fileSize = (I_32) seekResult;
+ zipFile->pointer = fileSize;
+
+ while (TRUE)
+ {
+ /* Fill the buffer. */
+ if (bytesAlreadyRead == fileSize)
+ {
+ zipFile->pointer = -1;
+ return ZIP_ERR_FILE_CORRUPT;
+ }
+
+ size = SCAN_CHUNK_SIZE;
+ if (size > fileSize - bytesAlreadyRead)
+ size = fileSize - bytesAlreadyRead;
+ bytesAlreadyRead += size;
+ seekResult =
+ hyfile_seek (zipFile->fd, fileSize - bytesAlreadyRead, HySeekSet);
+ if ((seekResult < 0) || (seekResult > HYCONST64 (0x7FFFFFFF)))
+ {
+ zipFile->pointer = -1;
+ return ZIP_ERR_FILE_READ_ERROR;
+ }
+ zipFile->pointer = (I_32) seekResult;
+
+ if (hyfile_read (zipFile->fd, buffer, size) != size)
+ {
+ zipFile->pointer = -1;
+ return ZIP_ERR_FILE_READ_ERROR;
+ }
+ zipFile->pointer += size;
+
+ /* Scan the buffer (backwards) for CentralEnd signature = PK^E^F. */
+ for (i = size; i--; dataSize++)
+ {
+ switch (state)
+ {
+ case 0:
+ /* Nothing yet. */
+ if (buffer[i] == 6)
+ state = 1;
+ break;
+
+ case 1:
+ /* Seen ^F */
+ if (buffer[i] == 5)
+ state = 2;
+ else
+ state = 0;
+ break;
+
+ case 2:
+ /* Seen ^E^F */
+ if (buffer[i] == 'K')
+ state = 3;
+ else
+ state = 0;
+ break;
+
+ case 3:
+ /* Seen K^E^F */
+ if (buffer[i] == 'P' && dataSize >= 21)
+ {
+ /* Found it. Read the data from the end-of-central-dir record. */
+ current = buffer + i + 4;
+ ZIP_NEXT_U16 (endEntry->diskNumber, current);
+ ZIP_NEXT_U16 (endEntry->dirStartDisk, current);
+ ZIP_NEXT_U16 (endEntry->thisDiskEntries, current);
+ ZIP_NEXT_U16 (endEntry->totalEntries, current);
+ ZIP_NEXT_U32 (endEntry->dirSize, current);
+ ZIP_NEXT_U32 (endEntry->dirOffset, current);
+ ZIP_NEXT_U16 (endEntry->commentLength, current);
+
+ /* Quick test to ensure that the header isn't invalid.
+ Current dataSize is the number of bytes of data scanned, up to the ^H in the stream. */
+ if (dataSize >= (U_32) (21 + endEntry->commentLength))
+ return 0;
+
+ /* Header looked invalid. Pretend we didn't see it and keep scanning.. */
+ }
+ state = 0;
+ break;
+ }
+ }
+ }
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION scanForDataDescriptor
+/*
+ Scan ahead for a data descriptor. Read from zipFile and update the HyZipLocalHeader provided.
+
+ Returns 0 on success or one of the following:
+ ZIP_ERR_FILE_READ_ERROR
+ ZIP_ERR_FILE_CORRUPT
+*/
+I_32
+scanForDataDescriptor (HyPortLibrary * portLib, HyZipFile * zipFile,
+ HyZipEntry * zipEntry)
+{
+ U_8 *current;
+ U_8 buffer[SCAN_CHUNK_SIZE], descriptor[16];
+ I_32 i, size, state;
+ U_32 dataSize, blockPointer;
+ I_64 seekResult;
+
+ PORT_ACCESS_FROM_PORT (portLib);
+
+ /* Skip ahead and read the data descriptor. The compressed size should be 0. */
+ if (zipFile->pointer !=
+ (IDATA) (zipEntry->dataPointer + zipEntry->compressedSize))
+ {
+ seekResult =
+ hyfile_seek (zipFile->fd,
+ zipEntry->dataPointer + zipEntry->compressedSize,
+ HySeekSet);
+ if ((seekResult < 0) || (seekResult > HYCONST64 (0x7FFFFFFF)))
+ {
+ zipFile->pointer = -1;
+ return ZIP_ERR_FILE_READ_ERROR;
+ }
+ zipFile->pointer = (I_32) seekResult;
+ }
+
+ /* Haven't seen anything yet. */
+ blockPointer = dataSize = zipEntry->compressedSize;
+ state = 0;
+
+ /* Scan until we find PK^G^H (otherwise it's an error). */
+ while (1)
+ {
+ /* Fill the buffer. */
+ size = hyfile_read (zipFile->fd, buffer, SCAN_CHUNK_SIZE);
+ if (size == 0)
+ {
+ return ZIP_ERR_FILE_CORRUPT;
+ }
+ else if (size < 0)
+ {
+ zipFile->pointer = -1;
+ return ZIP_ERR_FILE_READ_ERROR;
+ }
+ zipFile->pointer += size;
+ blockPointer += size;
+
+ /* Scan the buffer. */
+ for (i = 0; i < size; i++, dataSize++)
+ {
+ switch (state)
+ {
+ case 0:
+ /* Nothing yet. */
+ if (buffer[i] == 'P')
+ {
+ state = 1;
+ }
+ break;
+
+ case 1:
+ /* Seen P */
+ if (buffer[i] == 'K')
+ {
+ state = 2;
+ }
+ else
+ state = 0;
+ break;
+
+ case 2:
+ /* Seen PK */
+ if (buffer[i] == 7)
+ {
+ state = 3;
+ }
+ else
+ {
+ state = 0;
+ }
+ break;
+
+ case 3:
+ /* Seen PK^G */
+ if (buffer[i] == 8)
+ {
+ /* Found it! Read the descriptor */
+ if (i + 12 < size)
+ {
+ current = &buffer[i + 1];
+ }
+ else
+ {
+ seekResult =
+ hyfile_seek (zipFile->fd,
+ zipEntry->dataPointer + dataSize + 1,
+ HySeekSet);
+ if ((seekResult < 0)
+ || (seekResult > HYCONST64 (0x7FFFFFFF)))
+ {
+ zipFile->pointer = -1;
+ return ZIP_ERR_FILE_READ_ERROR;
+ }
+ zipFile->pointer = (I_32) seekResult;
+ if (hyfile_read (zipFile->fd, descriptor, 12) != 12)
+ {
+ zipFile->pointer = -1;
+ return ZIP_ERR_FILE_READ_ERROR;
+ }
+ zipFile->pointer += 12;
+ current = descriptor;
+ }
+
+ /* Read the data from the descriptor. */
+ ZIP_NEXT_U32 (zipEntry->crc32, current);
+ ZIP_NEXT_U32 (zipEntry->compressedSize, current);
+ ZIP_NEXT_U32 (zipEntry->uncompressedSize, current);
+
+ /* Quick test to ensure that the header isn't invalid.
+ Current dataSize is the number of bytes of data scanned, up to the ^H in the stream. */
+ if (dataSize - 3 == zipEntry->compressedSize)
+ {
+ return 0;
+ }
+
+ /* Header looked invalid. Reset the pointer and continue scanning. */
+ seekResult =
+ hyfile_seek (zipFile->fd,
+ zipEntry->dataPointer + blockPointer,
+ HySeekSet);
+ if ((seekResult < 0)
+ || (seekResult > HYCONST64 (0x7FFFFFFF)))
+ {
+ zipFile->pointer = -1;
+ return ZIP_ERR_FILE_READ_ERROR;
+ }
+ zipFile->pointer = (I_32) seekResult;
+ }
+ else
+ state = 0;
+ break;
+ }
+ }
+ }
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION zip_populateCache
+/*
+ Fill in the cache of a given zip file. This should only be called once during zip_openZipFile!
+
+ Returns 0 on success or one of the following:
+ ZIP_ERR_FILE_READ_ERROR
+ ZIP_ERR_FILE_OPEN_ERROR
+ ZIP_ERR_UNKNOWN_FILE_TYPE
+ ZIP_ERR_UNSUPPORTED_FILE_TYPE
+ ZIP_ERR_OUT_OF_MEMORY
+ ZIP_ERR_INTERNAL_ERROR
+*/
+I_32
+zip_populateCache (HyPortLibrary * portLib, HyZipFile * zipFile)
+{
+ PORT_ACCESS_FROM_PORT (portLib);
+
+ I_32 result = 0;
+ IDATA bufferSize = 65536;
+ IDATA unreadSize = 0;
+ IDATA bufferedSize = 0;
+ IDATA bytesToRead = 0;
+ IDATA filenameCopied;
+ HyZipEntry entry;
+ HyZipCentralEnd endEntry;
+ 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);
+
+ if (zipFile->pointer != startCentralDir)
+ {
+ seekResult = hyfile_seek (zipFile->fd, startCentralDir, HySeekSet);
+ if ((seekResult < 0) || (seekResult > HYCONST64 (0x7FFFFFFF)))
+ {
+ zipFile->pointer = -1;
+ result = ZIP_ERR_FILE_READ_ERROR;
+ goto finished;
+ }
+
+ zipFile->pointer = (I_32) seekResult;
+ if (zipFile->pointer != startCentralDir)
+ {
+ result = ZIP_ERR_FILE_READ_ERROR;
+ zipFile->pointer = -1;
+ goto finished;
+ }
+ }
+
+ /* No point in allocating more than we'll actually need.. */
+ if (bufferSize > unreadSize)
+ bufferSize = unreadSize;
+
+ filename = hymem_allocate_memory (filenameSize);
+ if (!filename)
+ {
+ result = ZIP_ERR_OUT_OF_MEMORY;
+ goto finished;
+ }
+
+ /* Allocate some space to hold central directory goo as we eat through it */
+ buffer = hymem_allocate_memory (bufferSize);
+ if (!buffer && (bufferSize > 4096))
+ {
+ /* Not enough memory, fall back to a smaller buffer! */
+ bufferSize = 4096;
+ buffer = hymem_allocate_memory (bufferSize);
+ }
+ if (!buffer)
+ {
+ result = ZIP_ERR_OUT_OF_MEMORY;
+ goto finished;
+ }
+
+ while (unreadSize)
+ {
+
+ /* Read as much as needed into buffer. */
+ bytesToRead = bufferSize - bufferedSize;
+ if (bytesToRead > unreadSize)
+ bytesToRead = unreadSize;
+ result = hyfile_read (zipFile->fd, buffer + bufferedSize, bytesToRead);
+ if (result < 0)
+ {
+ result = ZIP_ERR_FILE_READ_ERROR;
+ zipFile->pointer = -1;
+ goto finished;
+ }
+ zipFile->pointer += result;
+ unreadSize -= result;
+ bufferedSize += result;
+ current = buffer;
+
+ /* consume entries until we run out. */
+ while (current + 46 < buffer + bufferedSize)
+ {
+ IDATA entryPointer;
+
+ entryPointer =
+ zipFile->pointer + (current - (buffer + bufferedSize));
+
+ sig = 0;
+ ZIP_NEXT_U32 (sig, current);
+ if (sig == ZIP_CentralEnd)
+ {
+ /* We're done here. */
+ result = 0;
+ goto finished;
+ }
+ if (sig != ZIP_CentralHeader)
+ {
+ /* Umm...What the Hell? */
+ result = ZIP_ERR_FILE_CORRUPT;
+ goto finished;
+ }
+
+ /* Read ZIP_CentralHeader entry */
+ ZIP_NEXT_U16 (entry.versionCreated, current);
+ ZIP_NEXT_U16 (entry.versionNeeded, current);
+ ZIP_NEXT_U16 (entry.flags, current);
+ ZIP_NEXT_U16 (entry.compressionMethod, current);
+ ZIP_NEXT_U16 (entry.lastModTime, current);
+ ZIP_NEXT_U16 (entry.lastModDate, current);
+ ZIP_NEXT_U32 (entry.crc32, current);
+ ZIP_NEXT_U32 (entry.compressedSize, current);
+ ZIP_NEXT_U32 (entry.uncompressedSize, current);
+ ZIP_NEXT_U16 (entry.filenameLength, current);
+ ZIP_NEXT_U16 (entry.extraFieldLength, current);
+ ZIP_NEXT_U16 (entry.fileCommentLength, current);
+ current += sizeof (U_16); /* skip disk number field */
+ ZIP_NEXT_U16 (entry.internalAttributes, current);
+ current += sizeof (U_32); /* skip external attributes field */
+ ZIP_NEXT_U32 (localHeaderOffset, current);
+
+ /* Increase filename buffer size if necessary. */
+ if (filenameSize < entry.filenameLength + 1)
+ {
+ hymem_free_memory (filename);
+ filenameSize = entry.filenameLength + 1;
+ filename = hymem_allocate_memory (filenameSize);
+ if (!filename)
+ {
+ result = ZIP_ERR_OUT_OF_MEMORY;
+ goto finished;
+ }
+ }
+
+ filenameCopied = 0;
+ while (filenameCopied < entry.filenameLength)
+ {
+ IDATA size;
+ /* Copy as much of the filename as we can see in the buffer (probably the whole thing). */
+
+ size = entry.filenameLength - filenameCopied;
+ if (size > bufferedSize - (current - buffer))
+ {
+ size = bufferedSize - (current - buffer);
+ }
+ memcpy (filename + filenameCopied, current, size);
+ filenameCopied += size;
+ current += size;
+ if (filenameCopied >= entry.filenameLength)
+ break; /* done */
+
+ /* Otherwise, we ran out of source string. Load another chunk.. */
+ bufferedSize = 0;
+ if (!unreadSize)
+ {
+ /* Central header is supposedly done? Bak */
+ result = ZIP_ERR_FILE_CORRUPT;
+ goto finished;
+ }
+ bytesToRead = bufferSize - bufferedSize;
+ if (bytesToRead > unreadSize)
+ bytesToRead = unreadSize;
+ result =
+ hyfile_read (zipFile->fd, buffer + bufferedSize, bytesToRead);
+ if (result < 0)
+ {
+ result = ZIP_ERR_FILE_READ_ERROR;
+ zipFile->pointer = -1;
+ goto finished;
+ }
+ zipFile->pointer += result;
+ unreadSize -= result;
+ bufferedSize += result;
+ current = buffer;
+ }
+ filename[entry.filenameLength] = '\0'; /* null-terminate */
+
+ if (((entry.compressionMethod == ZIP_CM_Deflated)
+ && (entry.flags & 0x8)) || (entry.fileCommentLength != 0))
+ {
+ /* Either local header doesn't know the compressedSize, or this entry has a file
+ comment. In either case, cache the central header instead of the local header
+ so we can find the information we need later. */
+
+ result =
+ zipCache_addElement (zipFile->cache, (char *) filename,
+ entryPointer);
+
+ }
+ else
+ {
+ result =
+ zipCache_addElement (zipFile->cache, (char *) filename,
+ localHeaderOffset);
+ }
+
+ if (!result)
+ {
+ result = ZIP_ERR_OUT_OF_MEMORY;
+ goto finished;
+ }
+
+ /* Skip the data and comment. */
+ bytesToRead = entry.extraFieldLength + entry.fileCommentLength;
+ if (bufferedSize - (current - buffer) >= bytesToRead)
+ {
+ current += bytesToRead;
+ }
+ else
+ {
+ /* The rest of the buffer is uninteresting. Skip ahead to where the good stuff is */
+ bytesToRead -= (bufferedSize - (current - buffer));
+ current = buffer + bufferedSize;
+ unreadSize -= bytesToRead;
+
+ seekResult = hyfile_seek (zipFile->fd, bytesToRead, HySeekCur);
+ if ((seekResult < 0) || (seekResult > HYCONST64 (0x7FFFFFFF)))
+ {
+ zipFile->pointer = -1;
+ result = ZIP_ERR_FILE_READ_ERROR;
+ goto finished;
+ }
+ zipFile->pointer = (I_32) seekResult;
+ }
+ }
+ bufferedSize -= (current - buffer);
+ memmove (buffer, current, bufferedSize);
+ }
+
+ result = 0;
+
+finished:
+ if (filename)
+ hymem_free_memory (filename);
+ if (buffer)
+ hymem_free_memory (buffer);
+ return result;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION readZipEntry
+/*
+ Read the next zip entry for the zipFile into the zipEntry provided. If filename is non-NULL, it is expected to match
+ the filename read for the entry. If (cachePointer != -1) the filename of the entry will be looked up in the cache (assuming
+ there is one) to help detect use of an invalid cache. If enumerationPointer is non-NULL, sequential access is assumed and
+ either a local zip entry or a data descriptor will be accepted, but a central zip entry will cause ZIP_ERR_NO_MORE_ENTRIES
+ to be returned. If enumerationPointer is NULL, random access is assumed and either a local zip entry or a central zip
+ entry will be accepted.
+
+ Returns 0 on success or one of the following:
+ ZIP_ERR_FILE_READ_ERROR
+ ZIP_ERR_FILE_CORRUPT
+ ZIP_ERR_OUT_OF_MEMORY
+ ZIP_ERR_NO_MORE_ENTRIES
+*/
+static I_32
+readZipEntry (HyPortLibrary * portLib, HyZipFile * zipFile,
+ HyZipEntry * zipEntry, const char *filename,
+ IDATA * enumerationPointer, IDATA * entryStart,
+ BOOLEAN findDirectory)
+{
+ PORT_ACCESS_FROM_PORT (portLib);
+
+ I_32 result;
+ U_8 buffer[46 + 128];
+ U_8 *current;
+ U_32 sig;
+ IDATA readLength;
+ I_64 seekResult;
+ U_8 *readBuffer;
+ IDATA currentEntryPointer, localEntryPointer;
+ IDATA headerSize;
+ IDATA filenameLength = filename ? strlen (filename) : 0;
+
+retry:
+ if (entryStart)
+ *entryStart = zipFile->pointer;
+ 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 */
+ {
+ headerSize = 46; /* central zip header size */
+ }
+ readLength = headerSize + (filename ? filenameLength : 128);
+ if (findDirectory)
+ {
+ /* Extra byte for possible trailing '/' */
+ readLength++;
+ }
+
+ /* Allocate some memory if necessary */
+ if (readLength <= sizeof (buffer))
+ {
+ current = buffer;
+ }
+ else
+ {
+ current = readBuffer = hymem_allocate_memory (readLength);
+ if (!readBuffer)
+ return ZIP_ERR_OUT_OF_MEMORY;
+ }
+
+ currentEntryPointer = localEntryPointer = zipFile->pointer;
+
+ result = hyfile_read (zipFile->fd, current, readLength);
+ if ((result < 22)
+ || (filename
+ && !(result == readLength
+ || (findDirectory && result == (readLength - 1)))))
+ {
+ /* We clearly didn't get enough bytes */
+ result = ZIP_ERR_FILE_READ_ERROR;
+ goto finished;
+ }
+ zipFile->pointer += result;
+ readLength = result; /* If it's not enough, we'll catch that later */
+ ZIP_NEXT_U32 (sig, current);
+
+ if (enumerationPointer)
+ {
+ if ((sig == ZIP_CentralEnd))
+ {
+ result = ZIP_ERR_NO_MORE_ENTRIES;
+ goto finished;
+ }
+ }
+ if ((enumerationPointer || (!zipFile->cache))
+ && (sig == ZIP_DataDescriptor))
+ {
+ /* We failed to predict a data descriptor here. This should be an error (i.e. only happens in malformed zips?)
+ but, but we will silently skip over it */
+ seekResult =
+ hyfile_seek (zipFile->fd, currentEntryPointer + 16, HySeekSet);
+ if ((seekResult < 0) || (seekResult > HYCONST64 (0x7FFFFFFF)))
+ {
+ zipFile->pointer = -1;
+ result = ZIP_ERR_FILE_READ_ERROR;
+ goto finished;
+ }
+ zipFile->pointer = (I_32) seekResult;
+
+ if (zipFile->pointer == currentEntryPointer + 16)
+ {
+ if (readBuffer)
+ {
+ hymem_free_memory (readBuffer);
+ }
+ goto retry;
+ }
+ result = ZIP_ERR_FILE_READ_ERROR;
+ goto finished;
+ }
+
+ if ((sig != ZIP_CentralHeader) && (sig != ZIP_LocalHeader))
+ {
+ /* Unexpected. */
+ result = ZIP_ERR_FILE_CORRUPT;
+ goto finished;
+ }
+ headerSize = ((sig == ZIP_CentralHeader) ? 46 : 30);
+ if (readLength < headerSize)
+ {
+ /* We didn't get the whole header (and none of the filename).. */
+ /* NOTE: this could happen in normal use if the assumed filename length above is <16. Since it's 128, we don't
+ handle the impossible case where we would have to read more header. It could also happen if the caller
+ supplied a filename of length <16 but that only happens when we have a cache (so we'll know the header size)
+ */
+ result = ZIP_ERR_FILE_READ_ERROR;
+ }
+ readLength -= headerSize;
+
+ if (sig == ZIP_CentralHeader)
+ {
+ current += 2; /* skip versionCreated field */
+ }
+ ZIP_NEXT_U16 (zipEntry->versionNeeded, current);
+ ZIP_NEXT_U16 (zipEntry->flags, current);
+ ZIP_NEXT_U16 (zipEntry->compressionMethod, current);
+ ZIP_NEXT_U16 (zipEntry->lastModTime, current);
+ ZIP_NEXT_U16 (zipEntry->lastModDate, current);
+ ZIP_NEXT_U32 (zipEntry->crc32, current);
+ ZIP_NEXT_U32 (zipEntry->compressedSize, current);
+ ZIP_NEXT_U32 (zipEntry->uncompressedSize, current);
+ ZIP_NEXT_U16 (zipEntry->filenameLength, current);
+ ZIP_NEXT_U16 (zipEntry->extraFieldLength, current);
+ zipEntry->fileCommentLength = 0;
+
+ if (sig == ZIP_CentralHeader)
+ {
+ ZIP_NEXT_U16 (zipEntry->fileCommentLength, current);
+ current += 8; /* skip disk number start + internal attrs + external attrs */
+ ZIP_NEXT_U32 (localEntryPointer, current);
+ }
+
+ if (filename)
+ {
+ if (zipFile->cache)
+ {
+ if (!
+ (readLength == zipEntry->filenameLength
+ || (findDirectory
+ && (readLength - 1) == zipEntry->filenameLength)))
+ {
+ /* We knew exactly how much we were supposed to read, and this wasn't it */
+ result = ZIP_ERR_FILE_CORRUPT;
+ goto finished;
+ }
+ }
+ }
+
+ /* Allocate space for filename */
+ if (zipEntry->filenameLength >= ZIP_INTERNAL_MAX)
+ {
+ zipEntry->filename =
+ hymem_allocate_memory (zipEntry->filenameLength + 1);
+ if (!zipEntry->filename)
+ {
+ result = ZIP_ERR_OUT_OF_MEMORY;
+ goto finished;
+ }
+ }
+ else
+ {
+ zipEntry->filename = zipEntry->internalFilename;
+ }
+ if (readLength > zipEntry->filenameLength)
+ {
+ readLength = zipEntry->filenameLength;
+ }
+ memcpy (zipEntry->filename, current, readLength);
+
+ /* Read the rest of the filename if necessary. Allocate space in HyZipEntry for it! */
+ if (readLength < zipEntry->filenameLength)
+ {
+ result =
+ hyfile_read (zipFile->fd, zipEntry->filename + readLength,
+ zipEntry->filenameLength - readLength);
+ if (result != (zipEntry->filenameLength - readLength))
+ {
+ result = ZIP_ERR_FILE_READ_ERROR;
+ goto finished;
+ }
+ zipFile->pointer += result;
+ }
+ zipEntry->filename[zipEntry->filenameLength] = '\0';
+
+ /* If we know what filename is supposed to be, compare it and make sure it matches */
+ /* Note: CASE-SENSITIVE COMPARE because filenames in zips are case sensitive (even on platforms with
+ case-insensitive file systems) */
+ if (filename)
+ {
+ if (!
+ ((findDirectory && zipEntry->filenameLength == (filenameLength + 1)
+ && zipEntry->filename[filenameLength] == '/'
+ && !strncmp ((char *) zipEntry->filename, (const char *) filename,
+ filenameLength))
+ || !strcmp ((const char *) zipEntry->filename,
+ (const char *) filename)))
+ {
+ /* We seem to have read something totally invalid.. */
+ result = ZIP_ERR_FILE_CORRUPT;
+ goto finished;
+ }
+ }
+
+ zipEntry->filenamePointer = currentEntryPointer + headerSize;
+ zipEntry->extraFieldPointer =
+ localEntryPointer + 30 + zipEntry->filenameLength;
+ zipEntry->dataPointer =
+ zipEntry->extraFieldPointer + zipEntry->extraFieldLength;
+ zipEntry->extraField = NULL;
+ zipEntry->fileCommentPointer = 0;
+ zipEntry->fileComment = NULL;
+ zipEntry->data = NULL;
+
+ if (sig == ZIP_CentralHeader)
+ {
+ U_8 buf[2];
+ U_8 *buf2 = buf;
+ U_16 lost;
+ /* Also, we know where the comment is */
+ zipEntry->fileCommentPointer = currentEntryPointer + headerSize +
+ zipEntry->filenameLength + zipEntry->extraFieldLength;
+ if (hyfile_seek (zipFile->fd, localEntryPointer + 28, HySeekSet) ==
+ localEntryPointer + 28)
+ {
+ if (hyfile_read (zipFile->fd, buf, 2) == 2)
+ {
+ ZIP_NEXT_U16 (lost, buf2);
+ zipEntry->dataPointer = zipEntry->extraFieldPointer + lost;
+ zipFile->pointer = localEntryPointer + 30;
+ }
+ }
+ }
+
+ if ((sig == ZIP_LocalHeader)
+ && (zipEntry->compressionMethod == ZIP_CM_Deflated)
+ && (zipEntry->flags & 0x8))
+ {
+ /* What we just read doesn't tell us how big the compressed data is. We have to do a heuristic search for a
+ valid data descriptor at the end of the compressed text */
+ result = scanForDataDescriptor (portLib, zipFile, zipEntry);
+ if (result < 0)
+ goto finished;
+ }
+
+ /* Entry read successfully */
+
+ if (enumerationPointer)
+ {
+ /* Work out where the next entry is supposed to be */
+ *enumerationPointer =
+ zipEntry->fileCommentPointer + zipEntry->fileCommentLength;
+ }
+
+ if (readBuffer)
+ hymem_free_memory (readBuffer);
+ return 0;
+
+finished:
+ if (readBuffer)
+ {
+ hymem_free_memory (readBuffer);
+ }
+ if ((zipEntry->filename)
+ && (zipEntry->filename != zipEntry->internalFilename))
+ {
+ hymem_free_memory (zipEntry->filename);
+ }
+ zipEntry->filename = NULL;
+ if (result == ZIP_ERR_FILE_READ_ERROR)
+ {
+ zipFile->pointer = -1;
+ }
+ return result;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION zip_closeZipFile
+/**
+ * Attempt to close the zipfile.
+ *
+ * @param[in] portLib the port library
+ * @param[in] zipFile The zip file to be closed
+ *
+ * @return 0 on success
+ * @return ZIP_ERR_FILE_CLOSE_ERROR if there is an error closing the file
+ * @return ZIP_ERR_INTERNAL_ERROR if there is an internal error
+ *
+*/
+I_32 VMCALL
+zip_closeZipFile (HyPortLibrary * portLib, struct HyZipFile * zipFile)
+{
+ PORT_ACCESS_FROM_PORT (portLib);
+#if defined(HY_NO_THR)
+ THREAD_ACCESS_FROM_PORT(portLib);
+#endif /* HY_NO_THR */
+ IDATA fd;
+
+ ENTER ();
+
+ fd = zipFile->fd;
+ zipFile->fd = -1;
+
+ if (zipFile->cache && zipFile->cachePool)
+ {
+ zipCachePool_release (zipFile->cachePool, zipFile->cache);
+ zipFile->cache = NULL;
+ }
+ if ((zipFile->filename) && (zipFile->filename != zipFile->internalFilename))
+ {
+ hymem_free_memory (zipFile->filename);
+ }
+ zipFile->filename = NULL;
+
+ if (fd == -1)
+ {
+ EXIT ();
+ return ZIP_ERR_INTERNAL_ERROR;
+ }
+ if (hyfile_close (fd))
+ {
+ EXIT ();
+ return ZIP_ERR_FILE_CLOSE_ERROR;
+ }
+ EXIT ();
+ return 0;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION zip_establishCache
+/**
+ * Called to set up a cache when a zip file is opened with a cachePool but without a cache, or when the
+ * current cache is found to be invalid in some way.
+ *
+ * @param[in] portLib the port library
+ * @param[in] zipFile the zip file for which we want to establish a cache
+ *
+ * The current cache is marked as invalid such that new instances of zip files
+ * won't try to use it and an attempt is made to establish a new cache.
+ *
+ * @return 0 on success
+ * @return ZIP_ERR_FILE_READ_ERROR if there is an error reading from zipFile
+ * @return ZIP_ERR_FILE_OPEN_ERROR if is there is an error opening the file
+ * @return ZIP_ERR_UNKNOWN_FILE_TYPE if the file type is unknown
+ * @return ZIP_ERR_UNSUPPORTED_FILE_TYPE if the file type is unsupported
+ * @return ZIP_ERR_OUT_OF_MEMORY if there is not enough memory to complete this call
+ * @return ZIP_ERR_INTERNAL_ERROR if there was an internal error
+*/
+
+I_32
+zip_establishCache (HyPortLibrary * portLib, HyZipFile * zipFile)
+{
+ PORT_ACCESS_FROM_PORT (portLib);
+ I_32 result;
+ I_64 timeStamp, actualFileSize;
+ IDATA fileSize, filenameLength;
+
+ if (zipFile->cache)
+ {
+ if (zipFile->cachePool)
+ {
+ /* Whack cache timestamp 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 */
+ zipCachePool_release (zipFile->cachePool, zipFile->cache);
+ }
+ zipFile->cache = NULL;
+ }
+ if (!zipFile->cachePool)
+ {
+ return ZIP_ERR_INTERNAL_ERROR;
+ }
+
+ /* Check the cachePool for a suitable cache. */
+ filenameLength = strlen ((const char *) zipFile->filename);
+ timeStamp = hyfile_lastmod ((const char *) zipFile->filename);
+ actualFileSize = hyfile_length ((const char *) zipFile->filename);
+ if ((actualFileSize < 0) || (actualFileSize > HYCONST64 (0x7FFFFFFF)))
+ {
+ return ZIP_ERR_INTERNAL_ERROR;
+ }
+ fileSize = (IDATA) actualFileSize;
+
+ zipFile->cache =
+ zipCachePool_findCache (zipFile->cachePool,
+ (const char *) zipFile->filename, filenameLength,
+ fileSize, timeStamp);
+ if (!zipFile->cache)
+ {
+ /* 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);
+ 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);
+ if (result != 0)
+ {
+ zipCache_kill (zipFile->cache);
+ zipFile->cache = NULL;
+ return result;
+ }
+ if (!zipCachePool_addCache (zipFile->cachePool, zipFile->cache))
+ {
+ zipCache_kill (zipFile->cache);
+ zipFile->cache = NULL;
+ return ZIP_ERR_OUT_OF_MEMORY;
+ }
+ }
+ return 0;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION zip_initZipEntry
+/**
+ * Initialize a zip entry.
+ *
+ * Should be called before the entry is passed to any other zip support functions
+ *
+ * @param[in] portLib the port library
+ * @param[in] entry the zip entry to init
+ *
+ * @return none
+*/
+
+void
+zip_initZipEntry (HyPortLibrary * portLib, HyZipEntry * entry)
+{
+ memset (entry, 0, sizeof (*entry));
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION zip_freeZipEntry
+/**
+ * Free any memory associated with a zip entry.
+ *
+ * @param[in] portLib the port library
+ * @param[in] entry the zip entry we are freeing
+ *
+ * @return none
+ *
+ * @note This does not free the entry itself.
+*/
+
+void
+zip_freeZipEntry (HyPortLibrary * portLib, HyZipEntry * entry)
+{
+ PORT_ACCESS_FROM_PORT (portLib);
+
+ if ((entry->filename) && (entry->filename != entry->internalFilename))
+ {
+ hymem_free_memory (entry->filename);
+ }
+ entry->filename = NULL;
+ if (entry->extraField)
+ {
+ hymem_free_memory (entry->extraField);
+ entry->extraField = NULL;
+ }
+ if (entry->data)
+ {
+ hymem_free_memory (entry->data);
+ entry->data = NULL;
+ }
+ if (entry->fileComment)
+ {
+ hymem_free_memory (entry->fileComment);
+ entry->fileComment = NULL;
+ }
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION zip_getNextZipEntry
+/**
+ * Read the next zip entry at nextEntryPointer into zipEntry.
+ *
+ * Any memory held onto by zipEntry may be lost, and therefore
+ * MUST be freed with @ref zip_freeZipEntry first.
+ *
+ * @param[in] portLib the port library
+ * @param[in] zipFile The zip file being read
+ * @param[out] zipEntry compressed data is placed here
+ * @param[in] nextEntryPointer
+ *
+ * @return 0 on success
+ * @return ZIP_ERR_FILE_READ_ERROR if there is an error reading zipFile
+ * @return ZIP_ERR_FILE_CORRUPT if zipFile is corrupt
+ * @return ZIP_ERR_NO_MORE_ENTRIES if there are no more entries in zipFile
+ * @return ZIP_ERR_OUT_OF_MEMORY if there is not enough memory to complete this call
+ *
+ * @see zip_freeZipEntry
+ *
+*/
+I_32
+zip_getNextZipEntry (HyPortLibrary * portLib, HyZipFile * zipFile,
+ HyZipEntry * zipEntry, IDATA * nextEntryPointer)
+{
+ PORT_ACCESS_FROM_PORT (portLib);
+#if defined(HY_NO_THR)
+ THREAD_ACCESS_FROM_PORT(portLib);
+#endif /* HY_NO_THR */
+ IDATA result;
+ BOOLEAN retryAllowed = TRUE;
+ IDATA pointer;
+ IDATA entryStart;
+ I_64 seekResult;
+
+ ENTER ();
+
+retry:
+ pointer = *nextEntryPointer;
+
+ /* Seek to the entry's position in the file. */
+ if (pointer != zipFile->pointer)
+ {
+ seekResult = hyfile_seek (zipFile->fd, pointer, HySeekSet);
+ if ((seekResult < 0) || (seekResult > HYCONST64 (0x7FFFFFFF)))
+ {
+ zipFile->pointer = -1;
+ EXIT ();
+ return ZIP_ERR_FILE_READ_ERROR;
+ }
+ zipFile->pointer = (I_32) seekResult;
+
+ if (pointer != zipFile->pointer)
+ {
+ zipFile->pointer = -1;
+ EXIT ();
+ return ZIP_ERR_FILE_READ_ERROR;
+ }
+ }
+
+ /* Read the entry */
+ entryStart = *nextEntryPointer;
+ result =
+ readZipEntry (portLib, zipFile, zipEntry, NULL, &pointer, &entryStart,
+ FALSE);
+ if (result != 0)
+ {
+ if (!retryAllowed || (result == ZIP_ERR_NO_MORE_ENTRIES))
+ {
+ EXIT ();
+ return result;
+ }
+ zip_establishCache (portLib, zipFile);
+ retryAllowed = FALSE;
+ goto retry;
+ }
+
+ if (zipFile->cache)
+ {
+ /* Validity check: look up filename in the cache... */
+ result =
+ (IDATA) zipCache_findElement (zipFile->cache,
+ (const char *) zipEntry->filename,
+ 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 */
+ {
+ /* ! Cache contents are not valid. Invalidate it and make a new one */
+ if (!retryAllowed)
+ {
+ EXIT ();
+ return ZIP_ERR_FILE_CORRUPT; /* should never happen! */
+ }
+ result = zip_establishCache (portLib, zipFile);
+ if (result)
+ {
+ /* (silently start operating without a cache if we couldn't make a new one) */
+ }
+ else
+ {
+ retryAllowed = FALSE;
+ goto retry;
+ }
+ }
+ else
+ {
+ /* We know that the central header for this entry contains info that the
+ local header is missing (comment length and/or uncompressed size) */
+ zipEntry->fileCommentPointer = -1;
+ }
+ }
+ }
+
+ *nextEntryPointer = pointer;
+ EXIT ();
+ return 0;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION zip_getZipEntry
+/**
+ * Attempt to find and read the zip entry corresponding to filename.
+ * If found, read the entry into the parameter entry.
+ *
+ * If an uncached entry is found, the filename field will be filled in. This
+ * memory will have to be freed with @ref zip_freeZipEntry.
+ *
+ * @param[in] portLib the port library
+ * @param[in] zipFile the file being read from
+ * @param[out] entry the zip entry found in zipFile is read to here
+ * @param[in] filename the name of the file that corresponds to entry
+ * @param[in] findDirectory when true, match a directory even if filename does not end in '/'.
+ * Note findDirectory is only supported (for the JCL) when there is a cache
+ *
+ * @return 0 on success or one of the following:
+ * @return ZIP_ERR_FILE_READ_ERROR if there is an error reading from zipFile
+ * @return ZIP_ERR_FILE_CORRUPT if zipFile is corrupt
+ * @return ZIP_ERR_ENTRY_NOT_FOUND if a zip entry with name filename was not found
+ * @return ZIP_ERR_OUT_OF_MEMORY if there is not enough memory to complete this call
+ *
+ * @see zip_freeZipEntry
+*/
+
+I_32
+zip_getZipEntry (HyPortLibrary * portLib, HyZipFile * zipFile,
+ HyZipEntry * entry, const char *filename,
+ BOOLEAN findDirectory)
+{
+ PORT_ACCESS_FROM_PORT (portLib);
+#if defined(HY_NO_THR)
+ THREAD_ACCESS_FROM_PORT(portLib);
+#endif /* HY_NO_THR */
+ IDATA result, position;
+ BOOLEAN retryAllowed = TRUE;
+ I_64 seekResult;
+
+ ENTER ();
+
+retry:
+ if (zipFile->cache)
+ {
+ /* Look up filename in the cache. */
+ position =
+ (IDATA) zipCache_findElement (zipFile->cache, filename,
+ findDirectory);
+ if (position == -1)
+ {
+ /* Note: we assume the cache is still valid here */
+ EXIT ();
+ return ZIP_ERR_ENTRY_NOT_FOUND;
+ }
+
+ /* Seek to the entry's position in the file. */
+ if (zipFile->pointer != position)
+ {
+ seekResult = hyfile_seek (zipFile->fd, position, HySeekSet);
+ if ((seekResult < 0) || (seekResult > HYCONST64 (0x7FFFFFFF)))
+ {
+ zipFile->pointer = -1;
+ EXIT ();
+ return ZIP_ERR_FILE_READ_ERROR;
+ }
+ zipFile->pointer = (I_32) seekResult;
+
+ if (zipFile->pointer != position)
+ {
+ zipFile->pointer = -1;
+ EXIT ();
+ return ZIP_ERR_FILE_READ_ERROR;
+ }
+ }
+
+ /* Read the entry */
+ result =
+ readZipEntry (portLib, zipFile, entry, filename, NULL, NULL,
+ findDirectory);
+ if (result != 0)
+ {
+ if (!retryAllowed)
+ {
+ EXIT ();
+ return result;
+ }
+ result = zip_establishCache (portLib, zipFile); /* invalidate existing cache */
+ if (result)
+ {
+ EXIT ();
+ return result;
+ }
+ retryAllowed = FALSE;
+ goto retry;
+ }
+ EXIT ();
+ return 0;
+ }
+ else
+ {
+ /* Uh oh -- random access without a cache (SLOW!) */
+ position = 0;
+ zip_resetZipFile (PORTLIB, zipFile, &position);
+ while (TRUE)
+ {
+
+ if (zipFile->pointer != position)
+ {
+ seekResult = hyfile_seek (zipFile->fd, position, HySeekSet);
+ if ((seekResult < 0) || (seekResult > HYCONST64 (0x7FFFFFFF)))
+ {
+ zipFile->pointer = -1;
+ EXIT ();
+ return ZIP_ERR_FILE_READ_ERROR;
+ }
+ zipFile->pointer = (I_32) seekResult;
+
+ if (zipFile->pointer != position)
+ {
+ zipFile->pointer = -1;
+ EXIT ();
+ return ZIP_ERR_FILE_READ_ERROR;
+ }
+ }
+
+ result =
+ readZipEntry (portLib, zipFile, entry, NULL, &position, NULL,
+ FALSE);
+ if (result || !strcmp ((const char *) entry->filename, filename))
+ {
+ EXIT ();
+ return result;
+ }
+
+ /* No match. Reset for next entry */
+ zip_freeZipEntry (portLib, entry);
+ zip_initZipEntry (portLib, entry);
+ }
+ }
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION zip_getZipEntryData
+/**
+ * Attempt to read and uncompress the data for the zip entry entry.
+ *
+ * If buffer is non-NULL it is used, but not explicitly held onto by the entry.
+ * If buffer is NULL, memory is allocated and held onto by the entry, and thus
+ * should later be freed with @ref zip_freeZipEntry.
+ *
+ * @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 or may not be NULL
+ * @param[in] bufferSize
+
+ * @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_getZipEntryData (HyPortLibrary * portLib, HyZipFile * zipFile,
+ HyZipEntry * entry, U_8 * buffer, U_32 bufferSize)
+{
+ PORT_ACCESS_FROM_PORT (portLib);
+#if defined(HY_NO_THR)
+ THREAD_ACCESS_FROM_PORT(portLib);
+#endif /* HY_NO_THR */
+
+ I_32 result;
+ U_8 *dataBuffer;
+ struct workBuffer wb;
+ I_64 seekResult;
+
+ ENTER ();
+
+ wb.portLib = portLib;
+ wb.bufferStart = wb.bufferEnd = wb.currentAlloc = 0;
+
+ if (buffer)
+ {
+ if (bufferSize < entry->uncompressedSize)
+ {
+ EXIT ();
+ return ZIP_ERR_BUFFER_TOO_SMALL;
+ }
+ dataBuffer = buffer;
+ }
+ else
+ {
+ /* Note that this is the first zalloc. This memory must be available to the calling method and is freed explicitly in zip_freeZipEntry. */
+ /* Note that other allocs freed in zip_freeZipEntry are not alloc'd using zalloc */
+ dataBuffer = zdataalloc (&wb, 1, entry->uncompressedSize);
+ if (!dataBuffer)
+ {
+ EXIT ();
+ return ZIP_ERR_OUT_OF_MEMORY;
+ }
+ entry->data = dataBuffer;
+ }
+
+ if (entry->compressionMethod == ZIP_CM_Stored)
+ {
+ /* No compression - just read the data in. */
+ if (zipFile->pointer != entry->dataPointer)
+ {
+ seekResult =
+ hyfile_seek (zipFile->fd, entry->dataPointer, HySeekSet);
+ if ((seekResult < 0) || (seekResult > HYCONST64 (0x7FFFFFFF)))
+ {
+ zipFile->pointer = -1;
+ result = ZIP_ERR_FILE_READ_ERROR;
+ goto finished;
+ }
+ zipFile->pointer = (I_32) seekResult;
+
+ if (zipFile->pointer != entry->dataPointer)
+ {
+ result = ZIP_ERR_FILE_READ_ERROR;
+ goto finished;
+ }
+ }
+ result = hyfile_read (zipFile->fd, dataBuffer, entry->compressedSize);
+ if (result != (I_32) entry->compressedSize)
+ {
+ result = ZIP_ERR_FILE_READ_ERROR;
+ goto finished;
+ }
+ zipFile->pointer += result;
+ EXIT ();
+ return 0;
+ }
+
+ if (entry->compressionMethod == ZIP_CM_Deflated)
+ {
+ U_8 *readBuffer;
+
+ /* Ensure that the library is loaded. */
+ if (checkZipLibrary (portLib))
+ {
+ result = ZIP_ERR_UNSUPPORTED_FILE_TYPE;
+ goto finished;
+ }
+
+ /* Read the file contents. */
+ readBuffer = zdataalloc (&wb, 1, entry->compressedSize);
+ if (!readBuffer)
+ {
+ result = ZIP_ERR_OUT_OF_MEMORY;
+ goto finished;
+ }
+ if (zipFile->pointer != entry->dataPointer)
+ {
+ seekResult =
+ hyfile_seek (zipFile->fd, entry->dataPointer, HySeekSet);
+ if ((seekResult < 0) || (seekResult > HYCONST64 (0x7FFFFFFF)))
+ {
+ zipFile->pointer = -1;
+ zdatafree (&wb, readBuffer);
+ result = ZIP_ERR_FILE_READ_ERROR;
+ goto finished;
+ }
+ zipFile->pointer = (I_32) seekResult;
+
+ if (zipFile->pointer != entry->dataPointer)
+ {
+ zdatafree (&wb, readBuffer);
+ result = ZIP_ERR_FILE_READ_ERROR;
+ goto finished;
+ }
+ }
+ if (hyfile_read (zipFile->fd, readBuffer, entry->compressedSize) !=
+ (I_32) entry->compressedSize)
+ {
+ zdatafree (&wb, readBuffer);
+ result = ZIP_ERR_FILE_READ_ERROR;
+ goto finished;
+ }
+ zipFile->pointer += (I_32) entry->compressedSize;
+
+ /* Deflate the data. */
+ result =
+ inflateData (&wb, readBuffer, entry->compressedSize, dataBuffer,
+ entry->uncompressedSize);
+ zdatafree (&wb, readBuffer);
+ if (result)
+ goto finished;
+ EXIT ();
+ return 0;
+ }
+
+ /* Whatever this is, we can't decompress it */
+ result = ZIP_ERR_UNSUPPORTED_FILE_TYPE;
+
+finished:
+ if (!buffer)
+ {
+ entry->data = NULL;
+ zdatafree (&wb, dataBuffer);
+ }
+ if (result == ZIP_ERR_FILE_READ_ERROR)
+ {
+ zipFile->pointer = -1;
+ }
+ EXIT ();
+ return result;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION zip_getZipEntryExtraField
+/**
+ * Read the extra field of entry from the zip file filename.
+ *
+ * buffer is used if non-NULL, but is not held onto by entry.
+ *
+ * If buffer is NULL, memory is allocated and held onto by entry, and MUST be freed later with
+ * @ref zip_freeZipEntry.
+ *
+ * @param[in] portLib the port library
+ * @param[in] zipFile the zip file being read from.
+ * @param[in,out] entry the zip entry concerned
+ * @param[in] buffer may or may not be NULL
+ * @param[in] bufferSize
+ *
+ * @return 0 on success or one of the following:
+ * @return ZIP_ERR_FILE_READ_ERROR if there is an error reading from zipFile
+ * @return ZIP_ERR_FILE_CORRUPT if zipFile is corrupt
+ * @return ZIP_ERR_OUT_OF_MEMORY if there is not enough memory to complete this call
+ * @return ZIP_ERR_BUFFER_TOO_SMALL if the buffer was non-Null but not large enough to hold the contents of entry
+ *
+ * @see zip_freeZipEntry
+*/
+I_32
+zip_getZipEntryExtraField (HyPortLibrary * portLib, HyZipFile * zipFile,
+ HyZipEntry * entry, U_8 * buffer, U_32 bufferSize)
+{
+ PORT_ACCESS_FROM_PORT (portLib);
+#if defined(HY_NO_THR)
+ THREAD_ACCESS_FROM_PORT(portLib);
+#endif /* HY_NO_THR */
+
+ I_32 result;
+ U_8 *extraFieldBuffer;
+ I_64 seekResult;
+
+ ENTER ();
+
+ if (entry->extraFieldLength == 0)
+ {
+ EXIT ();
+ return 0;
+ }
+
+ if (buffer)
+ {
+ if (bufferSize < entry->extraFieldLength)
+ {
+ EXIT ();
+ return ZIP_ERR_BUFFER_TOO_SMALL;
+ }
+ extraFieldBuffer = buffer;
+ }
+ else
+ {
+ extraFieldBuffer = hymem_allocate_memory (entry->extraFieldLength);
+ if (!extraFieldBuffer)
+ {
+ EXIT ();
+ return ZIP_ERR_OUT_OF_MEMORY;
+ }
+ entry->extraField = extraFieldBuffer;
+ }
+
+ if (zipFile->pointer != entry->extraFieldPointer)
+ {
+ seekResult =
+ hyfile_seek (zipFile->fd, entry->extraFieldPointer, HySeekSet);
+ if ((seekResult < 0) || (seekResult > HYCONST64 (0x7FFFFFFF)))
+ {
+ zipFile->pointer = -1;
+ result = ZIP_ERR_FILE_READ_ERROR;
+ goto finished;
+ }
+ zipFile->pointer = (I_32) seekResult;
+ if (zipFile->pointer != entry->extraFieldPointer)
+ {
+ result = ZIP_ERR_FILE_READ_ERROR;
+ goto finished;
+ }
+ }
+ result =
+ hyfile_read (zipFile->fd, extraFieldBuffer, entry->extraFieldLength);
+ if (result != (I_32) entry->extraFieldLength)
+ {
+ result = ZIP_ERR_FILE_READ_ERROR;
+ goto finished;
+ }
+ zipFile->pointer += result;
+ EXIT ();
+ return 0;
+
+finished:
+ if (!buffer)
+ {
+ entry->extraField = NULL;
+ hymem_free_memory (extraFieldBuffer);
+ }
+ if (result == ZIP_ERR_FILE_READ_ERROR)
+ zipFile->pointer = -1;
+ EXIT ();
+ return result;
+
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION zip_getZipEntryFilename
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION zip_getZipEntryComment
+/**
+ * Read the file comment for entry.
+ *
+ * If buffer is non-NULL, it is used, but not held onto by entry.
+ *
+ * If buffer is NULL, memory is allocated and
+ * held onto by entry, and thus should later be freed with @ref zip_freeZipEntry.
+ *
+ * @param[in] portLib the port library
+ * @param[in] zipFile the zip file concerned
+ * @param[in] entry the entry who's comment we want
+ * @param[in] buffer may or may not be NULL
+ * @param[in] bufferSize
+
+ * @return 0 on success or one of the following
+ * @return ZIP_ERR_FILE_READ_ERROR if there is an error reading the file comment 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
+*/
+
+I_32
+zip_getZipEntryComment (HyPortLibrary * portLib, HyZipFile * zipFile,
+ HyZipEntry * entry, U_8 * buffer, U_32 bufferSize)
+{
+ PORT_ACCESS_FROM_PORT (portLib);
+#if defined(HY_NO_THR)
+ THREAD_ACCESS_FROM_PORT(portLib);
+#endif /* HY_NO_THR */
+
+ I_32 result;
+ U_8 *fileCommentBuffer;
+ I_64 seekResult;
+
+ ENTER ();
+
+ if (entry->fileCommentLength == 0)
+ {
+ if (entry->fileCommentPointer == -1)
+ {
+ /* TODO: we don't know where the comment is (or even if there is one)! This only happens if you're running
+ without a cache, so too bad for now */
+ }
+ EXIT ();
+ return 0;
+ }
+
+ if (buffer)
+ {
+ if (bufferSize < entry->fileCommentLength)
+ {
+ EXIT ();
+ return ZIP_ERR_BUFFER_TOO_SMALL;
+ }
+ fileCommentBuffer = buffer;
+ }
+ else
+ {
+ fileCommentBuffer = hymem_allocate_memory (entry->fileCommentLength);
+ if (!fileCommentBuffer)
+ {
+ EXIT ();
+ return ZIP_ERR_OUT_OF_MEMORY;
+ }
+ entry->fileComment = fileCommentBuffer;
+ }
+
+ if (zipFile->pointer != entry->fileCommentPointer)
+ {
+ seekResult =
+ hyfile_seek (zipFile->fd, entry->fileCommentPointer, HySeekSet);
+ if ((seekResult < 0) || (seekResult > HYCONST64 (0x7FFFFFFF)))
+ {
+ zipFile->pointer = -1;
+ result = ZIP_ERR_FILE_READ_ERROR;
+ goto finished;
+ }
+ zipFile->pointer = (I_32) seekResult;
+
+ if (zipFile->pointer != entry->fileCommentPointer)
+ {
+ result = ZIP_ERR_FILE_READ_ERROR;
+ goto finished;
+ }
+ }
+ result =
+ hyfile_read (zipFile->fd, fileCommentBuffer, entry->fileCommentLength);
+ if (result != (I_32) entry->fileCommentLength)
+ {
+ result = ZIP_ERR_FILE_READ_ERROR;
+ goto finished;
+ }
+ zipFile->pointer += result;
+ EXIT ();
+ return 0;
+
+finished:
+ if (!buffer)
+ {
+ entry->fileComment = NULL;
+ hymem_free_memory (fileCommentBuffer);
+ }
+ if (result == ZIP_ERR_FILE_READ_ERROR)
+ {
+ zipFile->pointer = -1;
+ }
+ EXIT ();
+ return result;
+
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION zip_openZipFile
+/**
+ * Attempt to open a zip file.
+ *
+ * If the cache pool is non-NULL, the cachePool will be used to find a suitable cache, and if none can be found it will create one and add it to cachePool.
+ * Zip support is responsible for managing the lifetime of the cache.
+ *
+ * @note If cachePool is NULL, zipFile will be opened without a cache.
+ *
+ * @param[in] portLib the port library
+ * @param[in] filename the zip file to open
+ * @param[out] zipFile the zip file structure to populate
+ * @param[in] cachePool the cache pool
+ *
+ * @return 0 on success
+ * @return ZIP_ERR_FILE_OPEN_ERROR if is there is an error opening the file
+ * @return ZIP_ERR_FILE_READ_ERROR if there is an error reading the file
+ * @return ZIP_ERR_FILE_CORRUPT if the file is corrupt
+ * @return ZIP_ERR_UNKNOWN_FILE_TYPE if the file type is not known
+ * @return ZIP_ERR_UNSUPPORTED_FILE_TYPE if the file type is unsupported
+ * @return ZIP_ERR_OUT_OF_MEMORY if we are out of memory
+*/
+I_32
+zip_openZipFile (HyPortLibrary * portLib, char *filename, HyZipFile * zipFile,
+ HyZipCachePool * cachePool)
+{
+ PORT_ACCESS_FROM_PORT (portLib);
+#if defined(HY_NO_THR)
+ THREAD_ACCESS_FROM_PORT(portLib);
+#endif /* HY_NO_THR */
+
+ IDATA fd = -1;
+ I_32 result = 0;
+ I_64 seekResult;
+ U_8 buffer[4];
+ I_32 len;
+
+ ENTER ();
+
+ len = strlen (filename);
+ zipFile->fd = -1;
+ zipFile->type = ZIP_Unknown;
+ zipFile->cache = NULL;
+ zipFile->cachePool = NULL;
+ zipFile->pointer = -1;
+ /* Allocate space for filename */
+ if (len >= ZIP_INTERNAL_MAX)
+ {
+ zipFile->filename = hymem_allocate_memory (len + 1);
+ if (!zipFile->filename)
+ {
+ EXIT ();
+ return ZIP_ERR_OUT_OF_MEMORY;
+ }
+ }
+ else
+ {
+ zipFile->filename = zipFile->internalFilename;
+ }
+
+ strcpy ((char *) zipFile->filename, filename);
+
+ fd = hyfile_open (filename, HyOpenRead, 0);
+ if (fd == -1)
+ {
+ result = ZIP_ERR_FILE_OPEN_ERROR;
+ goto finished;
+ }
+
+ if (hyfile_read (fd, buffer, 4) != 4)
+ {
+ result = ZIP_ERR_FILE_READ_ERROR;
+ goto finished;
+ }
+
+ if ((buffer[0] == 'P') && (buffer[1] == 'K'))
+ {
+ /* If not the central header or local file header, its corrupt */
+ if (!
+ ((buffer[2] == 1 && buffer[3] == 2)
+ || (buffer[2] == 3 && buffer[3] == 4)))
+ {
+ result = ZIP_ERR_FILE_CORRUPT;
+ goto finished;
+ }
+ /* PKZIP file. Back up the pointer to the beginning. */
+ seekResult = hyfile_seek (fd, 0, HySeekSet);
+ if (seekResult != 0)
+ {
+ result = ZIP_ERR_FILE_READ_ERROR;
+ goto finished;
+ }
+
+ zipFile->fd = fd;
+ zipFile->type = ZIP_PKZIP;
+ zipFile->pointer = 0;
+ }
+
+ if ((buffer[0] == 0x1F) && (buffer[1] == 0x8B))
+ {
+ /* GZIP - currently unsupported.
+ zipFile->fd = fd;
+ zipFile->type = ZIP_GZIP;
+ zipFile->pointer = 2;
+ */
+ result = ZIP_ERR_UNSUPPORTED_FILE_TYPE;
+ goto finished;
+ }
+
+ if (zipFile->type == ZIP_Unknown)
+ {
+ result = ZIP_ERR_UNKNOWN_FILE_TYPE;
+ goto finished;
+ }
+
+ result = 0;
+
+ if (cachePool)
+ {
+ zipFile->cachePool = cachePool;
+ result = zip_establishCache (portLib, zipFile);
+ }
+
+finished:
+ if (result == 0)
+ {
+ zipFile->fd = fd;
+ EXIT ();
+ return 0;
+ }
+ if (fd != -1)
+ {
+ hyfile_close (fd);
+ }
+ if ((zipFile->filename) && (zipFile->filename != zipFile->internalFilename))
+ {
+ hymem_free_memory (zipFile->filename);
+ }
+ zipFile->filename = NULL;
+ EXIT ();
+ return result;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION zip_resetZipFile
+/**
+ * Reset nextEntryPointer to the first entry in the file.
+ *
+ * @param[in] portLib the port library
+ * @param[in] zipFile the zip being read from
+ * @param[out] nextEntryPointer will be reset to the first entry in the file
+ *
+ * @return none
+ *
+ *
+*/
+void
+zip_resetZipFile (HyPortLibrary * portLib, HyZipFile * 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 */
+ else
+ {
+ I_32 result;
+ HyZipCentralEnd endEntry;
+ result = scanForCentralEnd (portLib, zipFile, &endEntry);
+ if (result != 0)
+ return;
+ *nextEntryPointer = (IDATA) ((UDATA) endEntry.dirOffset);
+ }
+ }
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION zip_getZipEntryFromOffset
+/**
+ * Attempt to read a zip entry at offset from the zip file provided.
+ * If found, read into entry.
+ *
+ * @note If an uncached entry is found, the filename field will be filled in. This
+ * memory MUST be freed with @ref zip_freeZipEntry.
+ *
+ * @param[in] portLib the port library
+ * @param[in] zipFile the zip file being read
+ * @param[in] offset the offset into the zipFile of the desired zip entry
+ * @param[out] entry the compressed data
+ *
+ * @return 0 on success
+ * @return ZIP_ERR_FILE_READ_ERROR if there is an error reading from @ref zipFile
+ * @return ZIP_ERR_FILE_CORRUPT if @ref zipFile is corrupt
+ * @return ZIP_ERR_ENTRY_NOT_FOUND if the entry is not found
+ * @return ZIP_ERR_OUT_OF_MEMORY if there is not enough memory to complete this call
+ *
+ * @see zip_freeZipEntry
+*/
+I_32
+zip_getZipEntryFromOffset (HyPortLibrary * portLib, HyZipFile * zipFile,
+ HyZipEntry * entry, IDATA 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 (zipFile->pointer != offset)
+ {
+ seekResult = hyfile_seek (zipFile->fd, offset, HySeekSet);
+ if ((seekResult < 0) || (seekResult > HYCONST64 (0x7FFFFFFF)))
+ {
+ zipFile->pointer = -1;
+ EXIT ();
+ return ZIP_ERR_FILE_READ_ERROR;
+ }
+ zipFile->pointer = (I_32) seekResult;
+ if (zipFile->pointer != offset)
+ {
+ zipFile->pointer = -1;
+ EXIT ();
+ return ZIP_ERR_FILE_READ_ERROR;
+ }
+ }
+
+ result = readZipEntry (portLib, zipFile, entry, NULL, NULL, NULL, FALSE);
+ EXIT ();
+ return result;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION zdataalloc
+/*
+ cached alloc management for zip_getZipEntryData.
+*/
+void *
+zdataalloc (void *opaque, U_32 items, U_32 size)
+{
+ UDATA *returnVal = 0;
+ U_32 byteSize = items * size;
+ U_32 allocSize = WORK_BUFFER_SIZE;
+ struct workBuffer *wb = (struct workBuffer *) opaque;
+
+ PORT_ACCESS_FROM_PORT (wb->portLib);
+
+ /* Round to UDATA multiple */
+ byteSize = (byteSize + (sizeof (UDATA) - 1)) & ~(sizeof (UDATA) - 1);
+
+ if (wb->bufferStart == 0)
+ {
+ if (byteSize > WORK_BUFFER_SIZE)
+ {
+ allocSize = byteSize;
+ }
+ wb->bufferStart = hymem_allocate_memory (allocSize);
+ if (wb->bufferStart)
+ {
+ wb->bufferEnd = (UDATA *) ((UDATA) wb->bufferStart + allocSize);
+ wb->currentAlloc = wb->bufferStart;
+ wb->cntr = 0;
+ }
+ }
+
+ if ((wb->bufferStart == 0)
+ || (((UDATA) wb->currentAlloc + byteSize) > (UDATA) wb->bufferEnd))
+ {
+ returnVal = hymem_allocate_memory (byteSize);
+ }
+ else
+ {
+ ++(wb->cntr);
+ returnVal = wb->currentAlloc;
+ wb->currentAlloc = (UDATA *) ((UDATA) wb->currentAlloc + byteSize);
+ }
+ return returnVal;
+}
+
+#undef CDEV_CURRENT_FUNCTION
+
+#define CDEV_CURRENT_FUNCTION zdatafree
+/*
+ cached alloc management for zip_getZipEntryData.
+*/
+void
+zdatafree (void *opaque, void *address)
+{
+ struct workBuffer *wb = (struct workBuffer *) opaque;
+
+ PORT_ACCESS_FROM_PORT (wb->portLib);
+
+ if ((address < (void *) wb->bufferStart)
+ || (address >= (void *) wb->bufferEnd))
+ {
+ hymem_free_memory (address);
+ }
+ else if (--(wb->cntr) == 0)
+ {
+ hymem_free_memory (wb->bufferStart);
+ wb->bufferStart = wb->bufferEnd = wb->currentAlloc = 0;
+ }
+
+}
+
+#undef CDEV_CURRENT_FUNCTION
Index: modules/luni/src/main/native/hyzip/shared/zipsup.h
===================================================================
--- modules/luni/src/main/native/hyzip/shared/zipsup.h
+++ modules/luni/src/main/native/hyzip/shared/zipsup.h
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+* Zip Support Header
+*/
+
+#if !defined(ZIPSUP_H)
+#define ZIPSUP_H
+#if defined(__cplusplus)
+extern "C"
+{
+#endif
+#include "hyport.h"
+#include "hyzip.h"
+
+#define HY_ZIP_DLL_NAME "hyzlib"
+
+ typedef struct HyZipCache
+ {
+ U_8 *zipFileName;
+ IDATA zipFileSize;
+ I_64 zipTimeStamp;
+ IDATA startCentralDir;
+ struct HyPortLibrary *portLib;
+ void *cachePool;
+ void *cachePoolEntry;
+ } HyZipCache;
+
+
+ typedef struct HyZipCentralEnd
+ {
+ U_16 diskNumber;
+ U_16 dirStartDisk;
+ U_16 thisDiskEntries;
+ U_16 totalEntries;
+ U_32 dirSize;
+ U_32 dirOffset;
+ U_16 commentLength;
+ char _hypadding0012[2]; /* 2 bytes of automatic padding */
+ U_8 *comment;
+ } HyZipCentralEnd;
+
+
+ typedef struct HyZipDataDescriptor
+ {
+ U_32 crc32;
+ U_32 compressedSize;
+ U_32 uncompressedSize;
+ } HyZipDataDescriptor;
+
+
+/* HySourceZipSupport*/
+ extern HY_CFUNC I_32 zip_getZipEntryData
+ PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile,
+ HyZipEntry * entry, U_8 * buffer, U_32 bufferSize));
+ extern HY_CFUNC I_32 zip_getZipEntryFromOffset
+ PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile,
+ HyZipEntry * entry, IDATA offset));
+ extern HY_CFUNC I_32 zip_establishCache
+ PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile));
+ extern HY_CFUNC void zip_resetZipFile
+ PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile,
+ IDATA * nextEntryPointer));
+ extern HY_CFUNC I_32 zip_getNextZipEntry
+ PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile,
+ HyZipEntry * zipEntry, IDATA * nextEntryPointer));
+ extern HY_CFUNC I_32 zip_getZipEntry
+ PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile,
+ HyZipEntry * 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));
+ extern HY_CFUNC void zip_initZipEntry
+ PROTOTYPE ((HyPortLibrary * portLib, HyZipEntry * entry));
+ extern HY_CFUNC I_32 zip_openZipFile
+ PROTOTYPE ((HyPortLibrary * portLib, char *filename, HyZipFile * zipFile,
+ HyZipCachePool * cachePool));
+ extern HY_CFUNC void zip_freeZipEntry
+ PROTOTYPE ((HyPortLibrary * portLib, HyZipEntry * entry));
+ struct HyZipFile;
+ extern HY_CFUNC I_32 VMCALL zip_closeZipFile
+ PROTOTYPE ((HyPortLibrary * portLib, struct HyZipFile * zipFile));
+ extern HY_CFUNC I_32 zip_getZipEntryComment
+ PROTOTYPE ((HyPortLibrary * portLib, HyZipFile * zipFile,
+ HyZipEntry * entry, U_8 * buffer, U_32 bufferSize));
+/* HySourceZipCache*/
+ extern HY_CFUNC UDATA zipCache_findElement
+ PROTOTYPE ((HyZipCache * zipCache, const char *elementName,
+ BOOLEAN searchDirList));
+ extern HY_CFUNC void zipCache_kill PROTOTYPE ((HyZipCache * zipCache));
+ 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));
+ extern HY_CFUNC IDATA zipCache_enumNew
+ PROTOTYPE ((HyZipCache * zipCache, char *directoryName, void **handle));
+ extern HY_CFUNC IDATA zipCache_enumElement
+ PROTOTYPE ((void *handle, char *nameBuf, UDATA nameBufSize,
+ UDATA * offset));
+ extern HY_CFUNC void zipCache_enumKill PROTOTYPE ((void *handle));
+ extern HY_CFUNC BOOLEAN zipCache_addElement
+ PROTOTYPE ((HyZipCache * zipCache, char *elementName,
+ UDATA elementOffset));
+/* HySourceZipCachePool*/
+ extern HY_CFUNC BOOLEAN zipCachePool_release
+ PROTOTYPE ((HyZipCachePool * zcp, HyZipCache * zipCache));
+ extern HY_CFUNC void zipCachePool_kill PROTOTYPE ((HyZipCachePool * zcp));
+ extern HY_CFUNC HyZipCache *zipCachePool_findCache
+ PROTOTYPE ((HyZipCachePool * zcp, char const *zipFileName,
+ IDATA zipFileNameLength, IDATA zipFileSize,
+ I_64 zipTimeStamp));
+ extern HY_CFUNC HyZipCachePool *zipCachePool_new
+ PROTOTYPE ((HyPortLibrary * portLib));
+ extern HY_CFUNC BOOLEAN zipCachePool_addCache
+ PROTOTYPE ((HyZipCachePool * zcp, HyZipCache * zipCache));
+ extern HY_CFUNC BOOLEAN zipCachePool_addRef
+ PROTOTYPE ((HyZipCachePool * zcp, HyZipCache * zipCache));
+#if defined(__cplusplus)
+}
+#endif
+#endif /* ZIPSUP_H */
Index: modules/luni/src/main/native/hyzip/unix/DoxygenSupport.txt
===================================================================
--- modules/luni/src/main/native/hyzip/unix/DoxygenSupport.txt
+++ modules/luni/src/main/native/hyzip/unix/DoxygenSupport.txt
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * This file provides the group definitions required to create the Doxygen generated
+ * output for compounds. There is one group per directory (port, pool, thread, etc.).
+ */
+
+/**
+ * @defgroup ZipSupport Zip Support
+ * @brief Zip file support for the Java VM.
+ */
+
+
Index: modules/luni/src/main/native/hyzip/unix/makefile
===================================================================
--- modules/luni/src/main/native/hyzip/unix/makefile
+++ modules/luni/src/main/native/hyzip/unix/makefile
@@ -0,0 +1,27 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# Makefile for module 'hyzip'
+#
+
+include $(HY_HDK)/build/make/defines.mk
+
+INCLUDES += -I../../include/shared
+BUILDFILES = $(SHAREDSUB)hyzip.o $(SHAREDSUB)zcpool.o $(SHAREDSUB)zipalloc.o \
+ $(SHAREDSUB)zipcache.o $(SHAREDSUB)zipsup.o
+LIBNAME = $(LIBPATH)libhyzip.a
+
+include $(HY_HDK)/build/make/rules.mk
Index: modules/luni/src/main/native/hyzip/windows/DoxygenSupport.txt
===================================================================
--- modules/luni/src/main/native/hyzip/windows/DoxygenSupport.txt
+++ modules/luni/src/main/native/hyzip/windows/DoxygenSupport.txt
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * This file provides the group definitions required to create the Doxygen generated
+ * output for compounds. There is one group per directory (port, pool, thread, etc.).
+ */
+
+/**
+ * @defgroup ZipSupport Zip Support
+ * @brief Zip file support for the Java VM.
+ */
+
+
Index: modules/luni/src/main/native/hyzip/windows/makefile
===================================================================
--- modules/luni/src/main/native/hyzip/windows/makefile
+++ modules/luni/src/main/native/hyzip/windows/makefile
@@ -0,0 +1,30 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#
+# Makefile for module 'hyzip'
+#
+
+!include <$(HY_HDK)\build\make\defines.mak>
+
+LIBNAME=$(LIBPATH)hyzip.lib
+
+BUILDFILES = \
+ $(SHAREDSUB)hyzip.obj $(SHAREDSUB)zcpool.obj $(SHAREDSUB)zipalloc.obj \
+ $(SHAREDSUB)zipcache.obj $(SHAREDSUB)zipsup.obj
+
+HYCFLAGS = $(HYCFLAGS) /I$(SHAREDSUB) /I..\..\include\shared /I..\..\include\windows
+
+!include <$(HY_HDK)\build\make\rules.mak>
Index: modules/misc/src/main/native/accessors/unix/makefile
===================================================================
--- modules/misc/src/main/native/accessors/unix/makefile (revision 537917)
+++ modules/misc/src/main/native/accessors/unix/makefile (working copy)
@@ -25,10 +25,12 @@
$(SHAREDSUB)org_apache_harmony_misc_accessors_ObjectAccessorImpl.o \
$(SHAREDSUB)org_apache_harmony_misc_accessors_StringAccessorImpl.o
+ifneq ($(HY_ZIP_API),true)
+MDLLIBFILES += $(LIBPATH)libhyzip.a $(DLLPATH)libhyzlib$(HY_LINKLIB_SUFFIX)
+endif
-MDLLIBFILES += \
- $(LIBPATH)libhyzip.a $(DLLPATH)libhyzlib$(HY_LINKLIB_SUFFIX) \
- $(LIBPATH)libhypool.a $(LIBPATH)libhyfdlibm.a $(LIBPATH)libvmi$(HY_LINKLIB_SUFFIX)
+MDLLIBFILES += $(LIBPATH)libhypool.a $(LIBPATH)libhyfdlibm.a \
+ $(LIBPATH)libvmi$(HY_LINKLIB_SUFFIX)
DLLNAME=../libaccessors$(HY_SHLIB_SUFFIX)
EXPNAME=HYMISC_0.1
Index: modules/nio/src/main/native/nio/unix/makefile
===================================================================
--- modules/nio/src/main/native/nio/unix/makefile (revision 537917)
+++ modules/nio/src/main/native/nio/unix/makefile (working copy)
@@ -24,8 +24,12 @@
BUILDFILES = \
../shared/DirectBufferUtil.o ../shared/AddressUtil.o
+ifneq ($(HY_ZIP_API),true)
+MDLLIBFILES += $(LIBPATH)libhyzip.a
+endif
+
MDLLIBFILES = \
- $(LIBPATH)libhycommon.a $(LIBPATH)libhyzip.a \
+ $(LIBPATH)libhycommon.a \
$(LIBPATH)libhypool.a $(LIBPATH)libhyfdlibm.a
DLLNAME = ../libhynio$(HY_SHLIB_SUFFIX)
Index: modules/nio/src/main/native/nio/windows/makefile
===================================================================
--- modules/nio/src/main/native/nio/windows/makefile (revision 537917)
+++ modules/nio/src/main/native/nio/windows/makefile (working copy)
@@ -31,11 +31,15 @@
SYSLIBFILES = ws2_32.lib Iphlpapi.lib
+!IF "$(HY_ZIP_API)" != "true"
MDLLIBFILES = \
- $(LIBPATH)hycommon$(HY_LINKLIB_SUFFIX) $(LIBPATH)hyzip$(HY_LINKLIB_SUFFIX) $(LIBPATH)hyzlib$(HY_LINKLIB_SUFFIX) \
- $(LIBPATH)hypool$(HY_LINKLIB_SUFFIX) $(LIBPATH)hyfdlibm$(HY_LINKLIB_SUFFIX) $(LIBPATH)hythr$(HY_LINKLIB_SUFFIX) \
- $(LIBPATH)vmi$(HY_LINKLIB_SUFFIX)
-
+ $(LIBPATH)hyzip$(HY_LINKLIB_SUFFIX) $(LIBPATH)hyzlib$(HY_LINKLIB_SUFFIX)
+!ENDIF
+
+MDLLIBFILES = $(LIBPATH)hycommon$(HY_LINKLIB_SUFFIX) \
+ $(LIBPATH)hypool$(HY_LINKLIB_SUFFIX) $(LIBPATH)hyfdlibm$(HY_LINKLIB_SUFFIX) \
+ $(LIBPATH)hythr$(HY_LINKLIB_SUFFIX) $(LIBPATH)vmi$(HY_LINKLIB_SUFFIX)
+
DLLBASE=0x13200000
COMMENT=/comment:"nio component native code. (c) Copyright 1991, 2005 The Apache Software Foundation or its licensors, as applicable."
Index: modules/prefs/src/main/native/prefs/windows/makefile
===================================================================
--- modules/prefs/src/main/native/prefs/windows/makefile (revision 537917)
+++ modules/prefs/src/main/native/prefs/windows/makefile (working copy)
@@ -31,8 +31,12 @@
SYSLIBFILES = ws2_32.lib Iphlpapi.lib
+!IF "$(HY_ZIP_API)" != "true"
+MDLLIBFILES = \
+ $(LIBPATH)hyzip$(HY_LINKLIB_SUFFIX) $(LIBPATH)hyzlib$(HY_LINKLIB_SUFFIX)
+!ENDIF
+
MDLLIBFILES = $(MDLLIBFILES) \
- $(LIBPATH)hyzip$(HY_LINKLIB_SUFFIX) $(LIBPATH)hyzlib$(HY_LINKLIB_SUFFIX) \
$(LIBPATH)hypool$(HY_LINKLIB_SUFFIX) $(LIBPATH)hyfdlibm$(HY_LINKLIB_SUFFIX) \
$(LIBPATH)vmi$(HY_LINKLIB_SUFFIX)
DLLBASE=0x13300000
Index: modules/text/src/main/native/text/unix/makefile
===================================================================
--- modules/text/src/main/native/text/unix/makefile (revision 537917)
+++ modules/text/src/main/native/text/unix/makefile (working copy)
@@ -24,10 +24,14 @@
BUILDFILES = $(SHAREDSUB)text_copyright.o $(SHAREDSUB)BidiWrapper.o
+ifneq ($(HY_ZIP_API),true)
+MDLLIBFILES += $(LIBPATH)libhyzip.a $(DLLPATH)libhyzlib$(HY_LINKLIB_SUFFIX)
+endif
+
MDLLIBFILES += \
$(DLLPATH)libicuuc$(HY_LINKLIB_SUFFIX).34 \
- $(LIBPATH)libhyzip.a $(DLLPATH)libhyzlib$(HY_LINKLIB_SUFFIX) \
- $(LIBPATH)libhypool.a $(LIBPATH)libhyfdlibm.a $(LIBPATH)libvmi$(HY_LINKLIB_SUFFIX)
+ $(LIBPATH)libhypool.a $(LIBPATH)libhyfdlibm.a \
+ $(LIBPATH)libvmi$(HY_LINKLIB_SUFFIX)
DLLNAME = ../libhytext$(HY_SHLIB_SUFFIX)
EXPNAME = HYTEXT_0.1