1 /*
2 * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 /*
27 * Prototypes for zip file support
28 */
29
30 #ifndef _ZIP_H_
31 #define _ZIP_H_
32
33 /*
34 * Header signatures
35 */
36 #define PKZIP_SIGNATURE_AT(p, b2, b3) \
37 (((p)[0] == 'P') & ((p)[1] == 'K') & ((p)[2] == b2) & ((p)[3] == b3))
38 #define CENSIG_AT(p) PKZIP_SIGNATURE_AT(p, 1, 2)
39 #define LOCSIG_AT(p) PKZIP_SIGNATURE_AT(p, 3, 4)
40 #define ENDSIG_AT(p) PKZIP_SIGNATURE_AT(p, 5, 6)
41 #define EXTSIG_AT(p) PKZIP_SIGNATURE_AT(p, 7, 8)
42 #define ZIP64_ENDSIG_AT(p) PKZIP_SIGNATURE_AT(p, 6, 6)
43 #define ZIP64_LOCSIG_AT(p) PKZIP_SIGNATURE_AT(p, 6, 7)
44
45 /*
46 * Header sizes including signatures
47 */
48
49 #define LOCHDR 30
50 #define EXTHDR 16
51 #define CENHDR 46
52 #define ENDHDR 22
222 char *msg; /* zip error message */
223 jzcell *entries; /* array of hash cells */
224 jint total; /* total number of entries */
225 jint *table; /* Hash chain heads: indexes into entries */
226 jint tablelen; /* number of hash heads */
227 struct jzfile *next; /* next zip file in search list */
228 jzentry *cache; /* we cache the most recently freed jzentry */
229 /* Information on metadata names in META-INF directory */
230 char **metanames; /* array of meta names (may have null names) */
231 jint metacurrent; /* the next empty slot in metanames array */
232 jint metacount; /* number of slots in metanames array */
233 jlong lastModified; /* last modified time */
234 jlong locpos; /* position of first LOC header (usually 0) */
235 } jzfile;
236
237 /*
238 * Index representing end of hash chain
239 */
240 #define ZIP_ENDCHAIN ((jint)-1)
241
242 jzentry * JNICALL
243 ZIP_FindEntry(jzfile *zip, char *name, jint *sizeP, jint *nameLenP);
244
245 jboolean JNICALL
246 ZIP_ReadEntry(jzfile *zip, jzentry *entry, unsigned char *buf, char *entrynm);
247
248 jzentry * JNICALL
249 ZIP_GetNextEntry(jzfile *zip, jint n);
250
251 jzfile * JNICALL
252 ZIP_Open(const char *name, char **pmsg);
253
254 jzfile *
255 ZIP_Open_Generic(const char *name, char **pmsg, int mode, jlong lastModified);
256
257 jzfile *
258 ZIP_Get_From_Cache(const char *name, char **pmsg, jlong lastModified);
259
260 jzfile *
261 ZIP_Put_In_Cache(const char *name, ZFILE zfd, char **pmsg, jlong lastModified);
262
263 jzfile *
264 ZIP_Put_In_Cache0(const char *name, ZFILE zfd, char **pmsg, jlong lastModified, jboolean usemmap);
265
266 void JNICALL
267 ZIP_Close(jzfile *zip);
268
269 jzentry * ZIP_GetEntry(jzfile *zip, char *name, jint ulen);
270 void ZIP_Lock(jzfile *zip);
271 void ZIP_Unlock(jzfile *zip);
272 jint ZIP_Read(jzfile *zip, jzentry *entry, jlong pos, void *buf, jint len);
273 void JNICALL
274 ZIP_FreeEntry(jzfile *zip, jzentry *ze);
275 jlong ZIP_GetEntryDataOffset(jzfile *zip, jzentry *entry);
276 jzentry * ZIP_GetEntry2(jzfile *zip, char *name, jint ulen, jboolean addSlash);
277
278 jboolean JNICALL
279 ZIP_InflateFully(void *inBuf, jlong inLen, void *outBuf, jlong outLen, char **pmsg);
280
281 #endif /* !_ZIP_H_ */
|
1 /*
2 * Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 /*
27 * Prototypes for zip file support
28 */
29
30 #ifndef _ZIP_H_
31 #define _ZIP_H_
32
33 #include "jni.h"
34
35 /*
36 * Header signatures
37 */
38 #define PKZIP_SIGNATURE_AT(p, b2, b3) \
39 (((p)[0] == 'P') & ((p)[1] == 'K') & ((p)[2] == b2) & ((p)[3] == b3))
40 #define CENSIG_AT(p) PKZIP_SIGNATURE_AT(p, 1, 2)
41 #define LOCSIG_AT(p) PKZIP_SIGNATURE_AT(p, 3, 4)
42 #define ENDSIG_AT(p) PKZIP_SIGNATURE_AT(p, 5, 6)
43 #define EXTSIG_AT(p) PKZIP_SIGNATURE_AT(p, 7, 8)
44 #define ZIP64_ENDSIG_AT(p) PKZIP_SIGNATURE_AT(p, 6, 6)
45 #define ZIP64_LOCSIG_AT(p) PKZIP_SIGNATURE_AT(p, 6, 7)
46
47 /*
48 * Header sizes including signatures
49 */
50
51 #define LOCHDR 30
52 #define EXTHDR 16
53 #define CENHDR 46
54 #define ENDHDR 22
224 char *msg; /* zip error message */
225 jzcell *entries; /* array of hash cells */
226 jint total; /* total number of entries */
227 jint *table; /* Hash chain heads: indexes into entries */
228 jint tablelen; /* number of hash heads */
229 struct jzfile *next; /* next zip file in search list */
230 jzentry *cache; /* we cache the most recently freed jzentry */
231 /* Information on metadata names in META-INF directory */
232 char **metanames; /* array of meta names (may have null names) */
233 jint metacurrent; /* the next empty slot in metanames array */
234 jint metacount; /* number of slots in metanames array */
235 jlong lastModified; /* last modified time */
236 jlong locpos; /* position of first LOC header (usually 0) */
237 } jzfile;
238
239 /*
240 * Index representing end of hash chain
241 */
242 #define ZIP_ENDCHAIN ((jint)-1)
243
244 JNIEXPORT jzentry * JNICALL
245 ZIP_FindEntry(jzfile *zip, char *name, jint *sizeP, jint *nameLenP);
246
247 JNIEXPORT jboolean JNICALL
248 ZIP_ReadEntry(jzfile *zip, jzentry *entry, unsigned char *buf, char *entrynm);
249
250 JNIEXPORT jzentry * JNICALL
251 ZIP_GetNextEntry(jzfile *zip, jint n);
252
253 JNIEXPORT jzfile * JNICALL
254 ZIP_Open(const char *name, char **pmsg);
255
256 jzfile *
257 ZIP_Open_Generic(const char *name, char **pmsg, int mode, jlong lastModified);
258
259 jzfile *
260 ZIP_Get_From_Cache(const char *name, char **pmsg, jlong lastModified);
261
262 jzfile *
263 ZIP_Put_In_Cache(const char *name, ZFILE zfd, char **pmsg, jlong lastModified);
264
265 jzfile *
266 ZIP_Put_In_Cache0(const char *name, ZFILE zfd, char **pmsg, jlong lastModified, jboolean usemmap);
267
268 JNIEXPORT void JNICALL
269 ZIP_Close(jzfile *zip);
270
271 JNIEXPORT jzentry * JNICALL
272 ZIP_GetEntry(jzfile *zip, char *name, jint ulen);
273 JNIEXPORT void JNICALL
274 ZIP_Lock(jzfile *zip);
275 JNIEXPORT void JNICALL
276 ZIP_Unlock(jzfile *zip);
277 JNIEXPORT jint JNICALL
278 ZIP_Read(jzfile *zip, jzentry *entry, jlong pos, void *buf, jint len);
279 JNIEXPORT void JNICALL
280 ZIP_FreeEntry(jzfile *zip, jzentry *ze);
281 jlong ZIP_GetEntryDataOffset(jzfile *zip, jzentry *entry);
282 jzentry * ZIP_GetEntry2(jzfile *zip, char *name, jint ulen, jboolean addSlash);
283
284 JNIEXPORT jboolean JNICALL
285 ZIP_InflateFully(void *inBuf, jlong inLen, void *outBuf, jlong outLen, char **pmsg);
286
287 #endif /* !_ZIP_H_ */
|