< prev index next >

src/java.base/share/native/libzip/zip_util.c

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 879,889 **** * Opens a zip file for reading. Returns the jzfile object or NULL * if an error occurred. If a zip error occurred then *msg will be * set to the error message text if msg != 0. Otherwise, *msg will be * set to NULL. Caller doesn't need to free the error message. */ ! jzfile * JNICALL ZIP_Open(const char *name, char **pmsg) { jzfile *file = ZIP_Open_Generic(name, pmsg, O_RDONLY, 0); if (file == NULL && pmsg != NULL && *pmsg != NULL) { free(*pmsg); --- 879,889 ---- * Opens a zip file for reading. Returns the jzfile object or NULL * if an error occurred. If a zip error occurred then *msg will be * set to the error message text if msg != 0. Otherwise, *msg will be * set to NULL. Caller doesn't need to free the error message. */ ! JNIEXPORT jzfile * JNICALL ZIP_Open(const char *name, char **pmsg) { jzfile *file = ZIP_Open_Generic(name, pmsg, O_RDONLY, 0); if (file == NULL && pmsg != NULL && *pmsg != NULL) { free(*pmsg);
*** 893,903 **** } /* * Closes the specified zip file object. */ ! void JNICALL ZIP_Close(jzfile *zip) { MLOCK(zfiles_lock); if (--zip->refs > 0) { /* Still more references so just return */ --- 893,903 ---- } /* * Closes the specified zip file object. */ ! JNIEXPORT void JNICALL ZIP_Close(jzfile *zip) { MLOCK(zfiles_lock); if (--zip->refs > 0) { /* Still more references so just return */
*** 1092,1102 **** * Free the given jzentry. * In fact we maintain a one-entry cache of the most recently used * jzentry for each zip. This optimizes a common access pattern. */ ! void JNICALL ZIP_FreeEntry(jzfile *jz, jzentry *ze) { jzentry *last; ZIP_Lock(jz); last = jz->cache; --- 1092,1102 ---- * Free the given jzentry. * In fact we maintain a one-entry cache of the most recently used * jzentry for each zip. This optimizes a common access pattern. */ ! JNIEXPORT void JNICALL ZIP_FreeEntry(jzfile *jz, jzentry *ze) { jzentry *last; ZIP_Lock(jz); last = jz->cache;
*** 1113,1123 **** /* * Returns the zip entry corresponding to the specified name, or * NULL if not found. */ ! jzentry * ZIP_GetEntry(jzfile *zip, char *name, jint ulen) { if (ulen == 0) { return ZIP_GetEntry2(zip, name, (jint)strlen(name), JNI_FALSE); } --- 1113,1123 ---- /* * Returns the zip entry corresponding to the specified name, or * NULL if not found. */ ! JNIEXPORT jzentry * JNICALL ZIP_GetEntry(jzfile *zip, char *name, jint ulen) { if (ulen == 0) { return ZIP_GetEntry2(zip, name, (jint)strlen(name), JNI_FALSE); }
*** 1236,1246 **** /* * Returns the n'th (starting at zero) zip file entry, or NULL if the * specified index was out of range. */ ! jzentry * JNICALL ZIP_GetNextEntry(jzfile *zip, jint n) { jzentry *result; if (n < 0 || n >= zip->total) { return 0; --- 1236,1246 ---- /* * Returns the n'th (starting at zero) zip file entry, or NULL if the * specified index was out of range. */ ! JNIEXPORT jzentry * JNICALL ZIP_GetNextEntry(jzfile *zip, jint n) { jzentry *result; if (n < 0 || n >= zip->total) { return 0;
*** 1252,1271 **** } /* * Locks the specified zip file for reading. */ ! void ZIP_Lock(jzfile *zip) { MLOCK(zip->lock); } /* * Unlocks the specified zip file. */ ! void ZIP_Unlock(jzfile *zip) { MUNLOCK(zip->lock); } --- 1252,1271 ---- } /* * Locks the specified zip file for reading. */ ! JNIEXPORT void JNICALL ZIP_Lock(jzfile *zip) { MLOCK(zip->lock); } /* * Unlocks the specified zip file. */ ! JNIEXPORT void JNICALL ZIP_Unlock(jzfile *zip) { MUNLOCK(zip->lock); }
*** 1308,1318 **** * then a zip error occurred and zip->msg contains the error text. * * The current implementation does not support reading an entry that * has the size bigger than 2**32 bytes in ONE invocation. */ ! jint ZIP_Read(jzfile *zip, jzentry *entry, jlong pos, void *buf, jint len) { jlong entry_size; jlong start; --- 1308,1318 ---- * then a zip error occurred and zip->msg contains the error text. * * The current implementation does not support reading an entry that * has the size bigger than 2**32 bytes in ONE invocation. */ ! JNIEXPORT jint JNICALL ZIP_Read(jzfile *zip, jzentry *entry, jlong pos, void *buf, jint len) { jlong entry_size; jlong start;
*** 1437,1447 **** /* * The current implementation does not support reading an entry that * has the size bigger than 2**32 bytes in ONE invocation. */ ! jzentry * JNICALL ZIP_FindEntry(jzfile *zip, char *name, jint *sizeP, jint *nameLenP) { jzentry *entry = ZIP_GetEntry(zip, name, 0); if (entry) { *sizeP = (jint)entry->size; --- 1437,1447 ---- /* * The current implementation does not support reading an entry that * has the size bigger than 2**32 bytes in ONE invocation. */ ! JNIEXPORT jzentry * JNICALL ZIP_FindEntry(jzfile *zip, char *name, jint *sizeP, jint *nameLenP) { jzentry *entry = ZIP_GetEntry(zip, name, 0); if (entry) { *sizeP = (jint)entry->size;
*** 1454,1464 **** * Reads a zip file entry into the specified byte array * When the method completes, it releases the jzentry. * Note: this is called from the separately delivered VM (hotspot/classic) * so we have to be careful to maintain the expected behaviour. */ ! jboolean JNICALL ZIP_ReadEntry(jzfile *zip, jzentry *entry, unsigned char *buf, char *entryname) { char *msg; char tmpbuf[1024]; --- 1454,1464 ---- * Reads a zip file entry into the specified byte array * When the method completes, it releases the jzentry. * Note: this is called from the separately delivered VM (hotspot/classic) * so we have to be careful to maintain the expected behaviour. */ ! JNIEXPORT jboolean JNICALL ZIP_ReadEntry(jzfile *zip, jzentry *entry, unsigned char *buf, char *entryname) { char *msg; char tmpbuf[1024];
*** 1513,1523 **** ZIP_FreeEntry(zip, entry); return JNI_TRUE; } ! jboolean JNICALL ZIP_InflateFully(void *inBuf, jlong inLen, void *outBuf, jlong outLen, char **pmsg) { z_stream strm; int i = 0; memset(&strm, 0, sizeof(z_stream)); --- 1513,1523 ---- ZIP_FreeEntry(zip, entry); return JNI_TRUE; } ! JNIEXPORT jboolean JNICALL ZIP_InflateFully(void *inBuf, jlong inLen, void *outBuf, jlong outLen, char **pmsg) { z_stream strm; int i = 0; memset(&strm, 0, sizeof(z_stream));
< prev index next >