zip_util.h revision ada1678a4262b208a7b87391f520a7767d25287c
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
/*
* Prototypes for zip file support
*/
#ifndef _ZIP_H_
#define _ZIP_H_
#include <jni.h>
#include "zlib.h"
/*
* Header signatures
*/
/*
* Header sizes including signatures
*/
#define LOCHDR 30
#define EXTHDR 16
#define CENHDR 46
#define ENDHDR 22
/*
* Header field access macros
*/
#define CH(b, n) (((unsigned char *)(b))[n])
/*
* Macros for getting local file (LOC) header fields
*/
/*
* Macros for getting extra local (EXT) header fields
*/
/*
* Macros for getting central directory header (CEN) fields
*/
/*
* Macros for getting end of central directory header (END) fields
*/
/*
* Supported compression methods
*/
#define STORED 0
#define DEFLATED 8
/*
*
* - Zip files larger than MAX_INT bytes are not supported.
* - Zip file entries larger than INT_MAX bytes are not supported.
* - Maximum number of entries is INT_MAX.
* - jzentry time and crc fields are signed even though they really
* represent unsigned quantities.
* - If csize is zero then entry is uncompressed.
* - If extra != 0 then the first two bytes are the length of the extra
* data in intel byte order.
* - If pos is negative then is position of entry LOC header. It is set
* to position of entry data once it is first read.
*/
typedef struct jzentry { /* Zip file entry */
char *name; /* entry name */
char *comment; /* optional zip file comment */
} jzentry;
/*
* In-memory hash table cell.
* In a typical sytem we have a *lot* of these, as we have one for
* every entry in every activee JAR.
* Note that in order to save space we don't keep the name in memory,
* but merely remember a 32 bit hash.
*/
typedef struct jzcell {
unsigned int hash; /* 32 bit hashcode on name */
unsigned short nelen; /* length of name and extra data */
unsigned short next; /* hash chain: index into jzfile->entries */
unsigned short elen; /* length of extra data in CEN */
} jzcell;
/*
* Descriptor for a ZIP file.
*/
typedef struct jzfile { /* Zip file */
char *name; /* zip file name */
int fd; /* open file descriptor */
void *lock; /* read lock */
char *comment; /* zip file comment */
char *msg; /* zip error message */
unsigned short *table; /* Hash chain heads: indexes into entries */
/* Information on metadata names in META-INF directory */
char **metanames; /* array of meta names (may have null names) */
/* If there are any per-entry comments, they are in the comments array */
char **comments;
} jzfile;
/*
* We impose arbitrary but reasonable limit on ZIP files.
*/
/*
* Typical size of entry name
*/
#define ZIP_TYPNAMELEN 512
/*
* Index representing end of hash chain
*/
#define ZIP_ENDCHAIN 0xFFFF
jzentry *
jzentry *
jzfile *
#endif /* !_ZIP_H_ */