modules/archive/src/main/native/zip/shared/zipsup.c File Reference


Detailed Description

Zip Support for Java VM.

#include <string.h>
#include "hyport.h"
#include "zipsup.h"
#include "hyzipnls.h"
#include "zlib.h"
#include "hythread.h"

Functions

I_32 zip_getZipEntryData (HyPortLibrary *portLib, HyZipFile *zipFile, HyZipEntry *entry, U_8 *buffer, U_32 bufferSize)
 Attempt to read and uncompress the data for the zip entry entry.
I_32 zip_getZipEntryFromOffset (HyPortLibrary *portLib, HyZipFile *zipFile, HyZipEntry *entry, IDATA offset)
 Attempt to read a zip entry at offset from the zip file provided.
I_32 zip_establishCache (HyPortLibrary *portLib, HyZipFile *zipFile)
 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.
void zip_resetZipFile (HyPortLibrary *portLib, HyZipFile *zipFile, IDATA *nextEntryPointer)
 Reset nextEntryPointer to the first entry in the file.
I_32 zip_getNextZipEntry (HyPortLibrary *portLib, HyZipFile *zipFile, HyZipEntry *zipEntry, IDATA *nextEntryPointer)
 Read the next zip entry at nextEntryPointer into zipEntry.
I_32 zip_getZipEntryExtraField (HyPortLibrary *portLib, HyZipFile *zipFile, HyZipEntry *entry, U_8 *buffer, U_32 bufferSize)
 Read the extra field of entry from the zip file filename.
void zip_initZipEntry (HyPortLibrary *portLib, HyZipEntry *entry)
 Initialize a zip entry.
I_32 zip_openZipFile (HyPortLibrary *portLib, char *filename, HyZipFile *zipFile, HyZipCachePool *cachePool)
 Attempt to open a zip file.
void zip_freeZipEntry (HyPortLibrary *portLib, HyZipEntry *entry)
 Free any memory associated with a zip entry.
I_32 VMCALL zip_closeZipFile (HyPortLibrary *portLib, struct HyZipFile *zipFile)
 Attempt to close the zipfile.
I_32 zip_getZipEntryComment (HyPortLibrary *portLib, HyZipFile *zipFile, HyZipEntry *entry, U_8 *buffer, U_32 bufferSize)
 Read the file comment for entry.
I_32 zip_getZipEntry (HyPortLibrary *portLib, HyZipFile *zipFile, HyZipEntry *entry, const char *filename, BOOLEAN findDirectory)
 Attempt to find and read the zip entry corresponding to filename.


Function Documentation

I_32 VMCALL zip_closeZipFile ( HyPortLibrary portLib,
struct HyZipFile *  zipFile 
)

Attempt to close the zipfile.

Parameters:
[in] portLib the port library
[in] zipFile The zip file to be closed
Returns:
0 on success

ZIP_ERR_FILE_CLOSE_ERROR if there is an error closing the file

ZIP_ERR_INTERNAL_ERROR if there is an internal error

I_32 zip_establishCache ( HyPortLibrary portLib,
HyZipFile *  zipFile 
)

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.

Parameters:
[in] portLib the port library
[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.

Returns:
0 on success

ZIP_ERR_FILE_READ_ERROR if there is an error reading from zipFile

ZIP_ERR_FILE_OPEN_ERROR if is there is an error opening the file

ZIP_ERR_UNKNOWN_FILE_TYPE if the file type is unknown

ZIP_ERR_UNSUPPORTED_FILE_TYPE if the file type is unsupported

ZIP_ERR_OUT_OF_MEMORY if there is not enough memory to complete this call

ZIP_ERR_INTERNAL_ERROR if there was an internal error

void zip_freeZipEntry ( HyPortLibrary portLib,
HyZipEntry *  entry 
)

Free any memory associated with a zip entry.

Parameters:
[in] portLib the port library
[in] entry the zip entry we are freeing
Returns:
none
Note:
This does not free the entry itself.

I_32 zip_getNextZipEntry ( HyPortLibrary portLib,
HyZipFile *  zipFile,
HyZipEntry *  zipEntry,
IDATA *  nextEntryPointer 
)

Read the next zip entry at nextEntryPointer into zipEntry.

Any memory held onto by zipEntry may be lost, and therefore MUST be freed with zip_freeZipEntry first.

Parameters:
[in] portLib the port library
[in] zipFile The zip file being read
[out] zipEntry compressed data is placed here
[in] nextEntryPointer 
Returns:
0 on success

ZIP_ERR_FILE_READ_ERROR if there is an error reading zipFile

ZIP_ERR_FILE_CORRUPT if zipFile is corrupt

ZIP_ERR_NO_MORE_ENTRIES if there are no more entries in zipFile

ZIP_ERR_OUT_OF_MEMORY if there is not enough memory to complete this call

See also:
zip_freeZipEntry

I_32 zip_getZipEntry ( HyPortLibrary portLib,
HyZipFile *  zipFile,
HyZipEntry *  entry,
const char *  filename,
BOOLEAN  findDirectory 
)

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 zip_freeZipEntry.

Parameters:
[in] portLib the port library
[in] zipFile the file being read from
[out] entry the zip entry found in zipFile is read to here
[in] filename the name of the file that corresponds to entry
[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
Returns:
0 on success or one of the following:

ZIP_ERR_FILE_READ_ERROR if there is an error reading from zipFile

ZIP_ERR_FILE_CORRUPT if zipFile is corrupt

ZIP_ERR_ENTRY_NOT_FOUND if a zip entry with name filename was not found

ZIP_ERR_OUT_OF_MEMORY if there is not enough memory to complete this call

See also:
zip_freeZipEntry

I_32 zip_getZipEntryComment ( HyPortLibrary portLib,
HyZipFile *  zipFile,
HyZipEntry *  entry,
U_8 *  buffer,
U_32  bufferSize 
)

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 zip_freeZipEntry.

Parameters:
[in] portLib the port library
[in] zipFile the zip file concerned
[in] entry the entry who's comment we want
[in] buffer may or may not be NULL
[in] bufferSize 
Returns:
0 on success or one of the following

ZIP_ERR_FILE_READ_ERROR if there is an error reading the file comment from zipEntry

ZIP_ERR_FILE_CORRUPT if zipFile is corrupt

ZIP_ERR_ENTRY_NOT_FOUND if entry is not found

ZIP_ERR_OUT_OF_MEMORY if there is not enough memory to complete this call

ZIP_ERR_BUFFER_TOO_SMALL if buffer is too small to hold the comment for zipFile

I_32 zip_getZipEntryData ( HyPortLibrary portLib,
HyZipFile *  zipFile,
HyZipEntry *  entry,
U_8 *  buffer,
U_32  bufferSize 
)

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 zip_freeZipEntry.

Parameters:
[in] portLib the port library
[in] zipFile the zip file being read from.
[in,out] entry the zip entry
[in] buffer may or may not be NULL
[in] bufferSize 
Returns:
0 on success

ZIP_ERR_FILE_READ_ERROR if there is an error reading from zipEntry

ZIP_ERR_FILE_CORRUPT if zipFile is corrupt

ZIP_ERR_ENTRY_NOT_FOUND if entry is not found

ZIP_ERR_OUT_OF_MEMORY if there is not enough memory to complete this call

ZIP_ERR_BUFFER_TOO_SMALL if buffer is too small to hold the comment for zipFile

See also:
zip_freeZipEntry

I_32 zip_getZipEntryExtraField ( HyPortLibrary portLib,
HyZipFile *  zipFile,
HyZipEntry *  entry,
U_8 *  buffer,
U_32  bufferSize 
)

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 zip_freeZipEntry.

Parameters:
[in] portLib the port library
[in] zipFile the zip file being read from.
[in,out] entry the zip entry concerned
[in] buffer may or may not be NULL
[in] bufferSize 
Returns:
0 on success or one of the following:

ZIP_ERR_FILE_READ_ERROR if there is an error reading from zipFile

ZIP_ERR_FILE_CORRUPT if zipFile is corrupt

ZIP_ERR_OUT_OF_MEMORY if there is not enough memory to complete this call

ZIP_ERR_BUFFER_TOO_SMALL if the buffer was non-Null but not large enough to hold the contents of entry

See also:
zip_freeZipEntry

I_32 zip_getZipEntryFromOffset ( HyPortLibrary portLib,
HyZipFile *  zipFile,
HyZipEntry *  entry,
IDATA  offset 
)

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 zip_freeZipEntry.
Parameters:
[in] portLib the port library
[in] zipFile the zip file being read
[in] offset the offset into the zipFile of the desired zip entry
[out] entry the compressed data
Returns:
0 on success

ZIP_ERR_FILE_READ_ERROR if there is an error reading from zipFile

ZIP_ERR_FILE_CORRUPT if zipFile is corrupt

ZIP_ERR_ENTRY_NOT_FOUND if the entry is not found

ZIP_ERR_OUT_OF_MEMORY if there is not enough memory to complete this call

See also:
zip_freeZipEntry

void zip_initZipEntry ( HyPortLibrary portLib,
HyZipEntry *  entry 
)

Initialize a zip entry.

Should be called before the entry is passed to any other zip support functions

Parameters:
[in] portLib the port library
[in] entry the zip entry to init
Returns:
none

I_32 zip_openZipFile ( HyPortLibrary portLib,
char *  filename,
HyZipFile *  zipFile,
HyZipCachePool *  cachePool 
)

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.
Parameters:
[in] portLib the port library
[in] filename the zip file to open
[out] zipFile the zip file structure to populate
[in] cachePool the cache pool
Returns:
0 on success

ZIP_ERR_FILE_OPEN_ERROR if is there is an error opening the file

ZIP_ERR_FILE_READ_ERROR if there is an error reading the file

ZIP_ERR_FILE_CORRUPT if the file is corrupt

ZIP_ERR_UNKNOWN_FILE_TYPE if the file type is not known

ZIP_ERR_UNSUPPORTED_FILE_TYPE if the file type is unsupported

ZIP_ERR_OUT_OF_MEMORY if we are out of memory

void zip_resetZipFile ( HyPortLibrary portLib,
HyZipFile *  zipFile,
IDATA *  nextEntryPointer 
)

Reset nextEntryPointer to the first entry in the file.

Parameters:
[in] portLib the port library
[in] zipFile the zip being read from
[out] nextEntryPointer will be reset to the first entry in the file
Returns:
none


Genereated on Tue Dec 9 14:12:59 2008 by Doxygen.

(c) Copyright 2005, 2008 The Apache Software Foundation or its licensors, as applicable.