zipsup.h File Reference


Detailed Description

Zip Support Header.

#include "hyport.h"

Data Structures

struct  HyZipCache
struct  HyZipCentralEnd
struct  HyZipDataDescriptor
struct  HyZipEntry
struct  HyZipFile

Functions

HY_CFUNC void zipCache_kill (HyZipCache *zipCache)
 Deletes a zip cache and frees its resources.
HY_CFUNC IDATA zipCache_enumGetDirName (void *handle, char *nameBuf, UDATA nameBufSize)
 Gets the name of the directory on which the enumeration is based.
HY_CFUNC HyZipCache * zipCache_new (HyPortLibrary *portLib, char *zipName, IDATA zipNameLength)
 Creates a new, empty zip cache for the provided zip file.
HY_CFUNC IDATA zipCache_enumNew (HyZipCache *zipCache, char *directoryName, void **handle)
 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.
HY_CFUNC IDATA zipCache_enumElement (void *handle, char *nameBuf, UDATA nameBufSize, UDATA *offset)
 Gets the name and offset of the next element in the directory being enumerated.
HY_CFUNC void zipCache_enumKill (void *handle)
 Frees any resources allocated by zipCache_enumNew.
HY_CFUNC BOOLEAN zipCache_addElement (HyZipCache *zipCache, char *elementName, UDATA elementOffset)
 Add an association between a file or directory named elementName and offset elementOffset to the zip cache provided.
HY_CFUNC BOOLEAN zipCachePool_release (HyZipCachePool *zcp, HyZipCache *zipCache)
 Decrements the reference count of a cache in the pool.
HY_CFUNC void zipCachePool_kill (HyZipCachePool *zcp)
 Deletes a pool containing shareable zip caches.
HY_CFUNC HyZipCache * zipCachePool_findCache (HyZipCachePool *zcp, char const *zipFileName, IDATA zipFileNameLength, IDATA zipFileSize, I_64 zipTimeStamp)
 Scans the pool for a cache with matching zipFileName, zipFileSize and zipTimeStamp.
HY_CFUNC HyZipCachePool * zipCachePool_new (HyPortLibrary *portLib)
 Creates a pool to hold shareable zip caches with their reference counts.
HY_CFUNC BOOLEAN zipCachePool_addCache (HyZipCachePool *zcp, HyZipCache *zipCache)
 Add a new cache to the pool with reference count of 1.
HY_CFUNC BOOLEAN zipCachePool_addRef (HyZipCachePool *zcp, HyZipCache *zipCache)
 Increment the reference count of a cache in the pool.


Function Documentation

HY_CFUNC BOOLEAN zipCache_addElement HyZipCache *  zipCache,
char *  elementName,
UDATA  elementOffset
 

Add an association between a file or directory named elementName and offset elementOffset to the zip cache provided.

Parameters:
[in] zipCache the zip cache being added to
[in] elementName the name of the file or directory element
[in] offset the corresponding offset of the element
Returns:
TRUE if the association was made, FALSE otherwise

HY_CFUNC IDATA zipCache_enumElement void *  handle,
char *  nameBuf,
UDATA  nameBufSize,
UDATA *  offset
 

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.
Parameters:
[in] handle returned from zipCache_enumNew. Used to enumerate the elements corresponding to the directory name returned by zipCache_enumGetDirName
[out] nameBuf holder for element in the directory being enumerated
[in] nameBufSize 
[out] offset the offset of the next element
Returns:
0 on success

-1 if all the directories have been returned already

the required size of nameBuf if nameBufSize is insuffient to hold the entire name (does not skip the element)

See also:
zipCache_enumNew

HY_CFUNC IDATA zipCache_enumGetDirName void *  handle,
char *  nameBuf,
UDATA  nameBufSize
 

Gets the name of the directory on which the enumeration is based.

Parameters:
[in] handle handle returned from zipCache_enumNew.
[out] nameBuf buffer to hold the directory name
[in] nameBufSize 
Returns:
0 on success

-3 on param failures

the required size for nameBuf if nameBufSize is insufficient to hold the entire name

HY_CFUNC void zipCache_enumKill void *  handle  ) 
 

Frees any resources allocated by zipCache_enumNew.

Parameters:
[in] handle enumerate on this handle
Returns:
none
See also:
zipCache_enumNew

HY_CFUNC IDATA zipCache_enumNew HyZipCache *  zipCache,
char *  directoryName,
void **  handle
 

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 zipCache_findElement, which is case-sensitive).

The search is NOT recursive.

Parameters:
[in] zipCache the zip cache that is being searched
[in] directoryName the directory we want to enumerate
[out] handle enumerate all the files in directory directoryName on this handle
Returns:
0 on success and sets handle

-1 if the directory is not found

-2 if there is not enough memory to complete this call

See also:
zipCache_findElement

HY_CFUNC void zipCache_kill HyZipCache *  zipCache  ) 
 

Deletes a zip cache and frees its resources.

Parameters:
[in] zipCache the zip cache to be freed
Returns:
none
See also:
zipCache_new

HY_CFUNC HyZipCache* zipCache_new HyPortLibrary portLib,
char *  zipName,
IDATA  zipNameLength
 

Creates a new, empty zip cache for the provided zip file.

Parameters:
[in] portLib the port library
[in] zipName the zip file name
[in] zipNameLength 
Returns:
the new zip cache if one was succesfully created, NULL otherwise

HY_CFUNC BOOLEAN zipCachePool_addCache HyZipCachePool *  zcp,
HyZipCache *  zipCache
 

Add a new cache to the pool with reference count of 1.

When reference count reaches zero the pool will automatically be freed.

Parameters:
[in] zcp the zip cache pool that is being added to.
[in] zipCache the zip cache being added.
Returns:
TRUE if successful, FALSE otherwise.
Note:
A cache may only reside in one pool (read: multiple VMs may not share caches with each other).

HY_CFUNC BOOLEAN zipCachePool_addRef HyZipCachePool *  zcp,
HyZipCache *  zipCache
 

Increment the reference count of a cache in the pool.

Note:
Result is undefined if the cache is not actually in the pool!
Parameters:
[in] zcp the zip cache pool that is being added to.
[in] the zip cache being added.
Returns:
TRUE if successful, FALSE otherwise.

HY_CFUNC HyZipCache* zipCachePool_findCache HyZipCachePool *  zcp,
char const *  zipFileName,
IDATA  zipFileNameLength,
IDATA  zipFileSize,
I_64  zipTimeStamp
 

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.

Parameters:
[in] zcp the zip cache pool to search
[in] zipFileName the name to test for match
[in] zipFileNameLength the length of zipFileName
[in] zipFileSize the size to test for match
[in] zipTimeStamp the time stamp to test for match
Returns:
the matching zip cache

NULL if no match is found.

HY_CFUNC void zipCachePool_kill HyZipCachePool *  zcp  ) 
 

Deletes a pool containing shareable zip caches.

Parameters:
[in] zcp the zip cache pool that is being deleted
Returns:
none
Note:
Warning: This also deletes remaining caches in the pool, regardless of their reference counts!

HY_CFUNC HyZipCachePool* zipCachePool_new HyPortLibrary portLib  ) 
 

Creates a pool to hold shareable zip caches with their reference counts.

This should be called once per VM.

Parameters:
[in] portLib the port library
Returns:
a zip cache pool or NULL if one cannot be created

HY_CFUNC BOOLEAN zipCachePool_release HyZipCachePool *  zcp,
HyZipCache *  zipCache
 

Decrements the reference count of a cache in the pool.

If the reference count reaches 0, the cache is removed from the pool and zipCache_kill is called on it.

Parameters:
[in] zcp the zip cache pool
[in] zipCache the zip cache whose count is being decremented.
Returns:
TRUE if the cache was destroyed

FALSE if the cache is still in the pool.


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