Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/include/zip_api.h
5985 views
1
/*******************************************************************************
2
* Copyright (c) 1991, 2017 IBM Corp. and others
3
*
4
* This program and the accompanying materials are made available under
5
* the terms of the Eclipse Public License 2.0 which accompanies this
6
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
7
* or the Apache License, Version 2.0 which accompanies this distribution and
8
* is available at https://www.apache.org/licenses/LICENSE-2.0.
9
*
10
* This Source Code may also be made available under the following
11
* Secondary Licenses when the conditions for such availability set
12
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
13
* General Public License, version 2 with the GNU Classpath
14
* Exception [1] and GNU General Public License, version 2 with the
15
* OpenJDK Assembly Exception [2].
16
*
17
* [1] https://www.gnu.org/software/classpath/license.html
18
* [2] http://openjdk.java.net/legal/assembly-exception.html
19
*
20
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
21
*******************************************************************************/
22
23
#ifndef zip_api_h
24
#define zip_api_h
25
26
/**
27
* @file zip_api.h
28
* @brief Public API for the ZIP module.
29
*
30
* This file contains public function prototypes and
31
* type definitions for the ZIP module.
32
*
33
*/
34
35
#include "j9cfg.h"
36
#include "j9comp.h"
37
#include "pool_api.h"
38
#include "j9port.h"
39
#include "zipsup.h"
40
#include "omrhookable.h"
41
42
#ifdef __cplusplus
43
extern "C" {
44
#endif
45
46
/* Empty set of options */
47
#define J9ZIP_OPEN_NO_FLAGS 0
48
49
/* Read the central directory and cache the information. */
50
#define J9ZIP_OPEN_READ_CACHE_DATA 1
51
52
/* Accept the file as a zip file even if it does not start with a local header */
53
#define J9ZIP_OPEN_ALLOW_NONSTANDARD_ZIP 2
54
55
/* Empty set of options */
56
#define J9ZIP_GETENTRY_NO_FLAGS 0
57
58
/* Match a directory even if filename does not end in '/'. Supported (for the JCL) only when there is a cache. */
59
#define J9ZIP_GETENTRY_FIND_DIRECTORY 1
60
61
/* Do extra work to read the data pointer. If false the dataPointer will be 0. */
62
#define J9ZIP_GETENTRY_READ_DATA_POINTER 2
63
64
/* Look for the entry using the central directory without a cache. This handles non-standard ZIP files. */
65
#define J9ZIP_GETENTRY_USE_CENTRAL_DIRECTORY 4
66
67
typedef struct J9ZipFunctionTable {
68
void (*zip_freeZipComment)(J9PortLibrary * portLib, U_8 * commentString);
69
void (*zip_freeZipEntry)(J9PortLibrary * portLib, J9ZipEntry * entry);
70
I_32 (*zip_getNextZipEntry)(J9PortLibrary* portLib, J9ZipFile* zipFile, J9ZipEntry* zipEntry, IDATA* nextEntryPointer, BOOLEAN readDataPointer);
71
I_32 (*zip_getZipComment)(J9PortLibrary* portLib, J9ZipFile *zipFile, U_8 ** commentString, UDATA * commentLength);
72
I_32 (*zip_getZipEntry)(J9PortLibrary *portLib, J9ZipFile *zipFile, J9ZipEntry *entry, const char *filename, IDATA fileNameLength, U_32 flags);
73
I_32 (*zip_getZipEntryComment)(J9PortLibrary * portLib, J9ZipFile * zipFile, J9ZipEntry * entry, U_8 * buffer, U_32 bufferSize);
74
I_32 (*zip_getZipEntryData)(J9PortLibrary* portLib, J9ZipFile* zipFile, J9ZipEntry* entry, U_8* buffer, U_32 bufferSize);
75
I_32 (*zip_getZipEntryExtraField)(J9PortLibrary* portLib, J9ZipFile* zipFile, J9ZipEntry* entry, U_8* buffer, U_32 bufferSize);
76
I_32 (*zip_getZipEntryFromOffset)(J9PortLibrary * portLib, J9ZipFile * zipFile, J9ZipEntry * entry, IDATA offset, BOOLEAN readDataPointer);
77
I_32 (*zip_getZipEntryRawData)(J9PortLibrary* portLib, J9ZipFile* zipFile, J9ZipEntry* entry, U_8* buffer, U_32 bufferSize, U_32 offset);
78
void (*zip_initZipEntry)(J9PortLibrary* portLib, J9ZipEntry* entry);
79
I_32 (*zip_openZipFile)(J9PortLibrary *portLib, char *filename, J9ZipFile *zipFile, J9ZipCachePool *cachePool, U_32 flags);
80
I_32 (*zip_releaseZipFile)(J9PortLibrary* portLib, struct J9ZipFile* zipFile);
81
void (*zip_resetZipFile)(J9PortLibrary* portLib, J9ZipFile* zipFile, IDATA *nextEntryPointer);
82
} J9ZipFunctionTable;
83
84
/* ---------------- zcpool.c ---------------- */
85
86
/**
87
* @brief
88
* @param *zcp
89
* @param *zipCache
90
* @return BOOLEAN
91
*/
92
BOOLEAN zipCachePool_addCache(J9ZipCachePool *zcp, J9ZipCache *zipCache);
93
94
95
/**
96
* @brief
97
* @param *zcp
98
* @param *zipCache
99
* @return BOOLEAN
100
*/
101
BOOLEAN zipCachePool_addRef(J9ZipCachePool *zcp, J9ZipCache *zipCache);
102
103
104
/**
105
* @brief
106
* @param *zcp
107
* @param *zipFileName
108
* @param zipFileNameLength
109
* @param zipFileSize
110
* @param zipTimeStamp
111
* @return J9ZipCache *
112
*/
113
J9ZipCache * zipCachePool_findCache(J9ZipCachePool *zcp, char const *zipFileName, IDATA zipFileNameLength, IDATA zipFileSize, I_64 zipTimeStamp);
114
115
116
/**
117
* @brief
118
* @param *zcp
119
* @return void
120
*/
121
void zipCachePool_kill(J9ZipCachePool *zcp);
122
123
/**
124
* Get the list of core Zipfile functions. Initializes the zip library if necessary.
125
* @param portLib port library
126
* @param libDir directory containing the zlib
127
* @return table of functions or null if the zip library cannot be initialized.
128
*/
129
J9ZipFunctionTable *getZipFunctions(J9PortLibrary *portLib, void *libDir);
130
131
/**
132
* @brief
133
* @param portLib
134
* @return J9ZipCachePool *
135
*/
136
J9ZipCachePool *zipCachePool_new(J9PortLibrary * portLib, void * userData);
137
138
139
/**
140
* @brief
141
* @param *zcp
142
* @param *zipCache
143
* @return BOOLEAN
144
*/
145
BOOLEAN zipCachePool_release(J9ZipCachePool *zcp, J9ZipCache *zipCache);
146
147
/* ---------------- zipalloc.c ---------------- */
148
149
#if (defined(J9VM_OPT_ZLIB_SUPPORT))
150
/**
151
* @brief
152
* @param opaque
153
* @param items
154
* @param size
155
* @return void*
156
*/
157
void* zalloc(void* opaque, U_32 items, U_32 size);
158
#endif /* J9VM_OPT_ZLIB_SUPPORT */
159
160
161
#if (defined(J9VM_OPT_ZLIB_SUPPORT))
162
/**
163
* @brief
164
* @param opaque
165
* @param address
166
* @return void
167
*/
168
void zfree(void* opaque, void* address);
169
#endif /* J9VM_OPT_ZLIB_SUPPORT */
170
171
/* ---------------- zipcache.c ---------------- */
172
173
/**
174
* @brief
175
* @param zipCache
176
* @param *elementName
177
* @param elementNameLength
178
* @param elementOffset
179
* @return BOOLEAN
180
*/
181
BOOLEAN
182
zipCache_addElement(J9ZipCache * zipCache, char *elementName, IDATA elementNameLength, UDATA elementOffset);
183
184
185
/**
186
* @brief
187
* @param *handle
188
* @param *nameBuf
189
* @param nameBufSize
190
* @param offset
191
* @return IDATA
192
*/
193
IDATA
194
zipCache_enumElement(void *handle, char *nameBuf, UDATA nameBufSize, UDATA * offset);
195
196
197
/**
198
* @brief
199
* @param *handle
200
* @param *nameBuf
201
* @param nameBufSize
202
* @return IDATA
203
*/
204
IDATA
205
zipCache_enumGetDirName(void *handle, char *nameBuf, UDATA nameBufSize);
206
207
208
/**
209
* @brief
210
* @param *handle
211
* @return void
212
*/
213
void
214
zipCache_enumKill(void *handle);
215
216
217
/**
218
* @brief
219
* @param zipCache
220
* @param *directoryName
221
* @param **handle
222
* @return IDATA
223
*/
224
IDATA
225
zipCache_enumNew(J9ZipCache * zipCache, char *directoryName, void **handle);
226
227
228
/**
229
* @brief
230
* @param zipCache
231
* @param *elementName
232
* @param elementNameLength
233
* @param searchDirList
234
* @return UDATA
235
*/
236
UDATA
237
zipCache_findElement(J9ZipCache * zipCache, const char *elementName, IDATA elementNameLength, BOOLEAN searchDirList);
238
239
240
/**
241
* @brief
242
* @param zipCache
243
* @return void
244
*/
245
void
246
zipCache_kill(J9ZipCache * zipCache);
247
248
249
/**
250
* @brief
251
* @param portLib
252
* @param zipName
253
* @param zipNameLength
254
* @param zipFileSize
255
* @param zipTimeStamp
256
* @return J9ZipCache *
257
*/
258
J9ZipCache *
259
zipCache_new(J9PortLibrary * portLib, char *zipName, IDATA zipNameLength, IDATA zipFileSize, I_64 zipTimeStamp);
260
261
262
/**
263
* @brief
264
* @param zipCache
265
* @param startCentralDir
266
*/
267
void zipCache_setStartCentralDir(J9ZipCache * zipCache, IDATA startCentralDir);
268
269
270
/**
271
* @brief
272
* @param zipCache
273
* @return BOOLEAN
274
*/
275
BOOLEAN
276
zipCache_hasData(J9ZipCache * zipCache);
277
278
279
#if defined(J9VM_OPT_SHARED_CLASSES)
280
/**
281
* @brief
282
* @param zipCache
283
* @return UDATA
284
*/
285
UDATA
286
zipCache_cacheSize(J9ZipCache * zipCache);
287
#endif
288
289
290
#if defined(J9VM_OPT_SHARED_CLASSES)
291
/**
292
* @brief
293
* @param zipCache
294
* @param cacheData
295
* @return BOOLEAN
296
*/
297
BOOLEAN
298
zipCache_copy(J9ZipCache * zipCache, void *cacheData, UDATA dataSize);
299
#endif
300
301
302
#if defined(J9VM_OPT_SHARED_CLASSES)
303
/**
304
* @brief
305
* @param zipCache
306
* @param cacheData
307
* @return void
308
*/
309
void
310
zipCache_useCopiedCache(J9ZipCache * zipCache, void *cacheData);
311
#endif
312
313
314
#if defined(J9VM_OPT_SHARED_CLASSES)
315
/**
316
* @brief
317
* @param zipCache
318
* @return BOOLEAN
319
*/
320
BOOLEAN
321
zipCache_isCopied(J9ZipCache * zipCache);
322
#endif
323
324
325
#if defined(J9VM_OPT_SHARED_CLASSES)
326
/**
327
* @brief
328
* @param zipCache
329
* @return const char *
330
*/
331
const char *
332
zipCache_uniqueId(J9ZipCache * zipCache);
333
#endif
334
335
struct J9ZipFile;
336
/**
337
* @brief
338
* @param portLib
339
* @param zipFile
340
* @return I_32
341
*/
342
I_32
343
zip_releaseZipFile(J9PortLibrary* portLib, struct J9ZipFile* zipFile);
344
345
346
/**
347
* @brief
348
* @param portLib
349
* @param dir
350
* @return I_32
351
*/
352
I_32 initZipLibrary (J9PortLibrary* portLib, char *dir);
353
354
/**
355
* @brief
356
* @param portLib
357
* @param filename
358
* @param cachePool
359
* @param cache
360
* @return I_32
361
*/
362
I_32
363
zip_searchCache(J9PortLibrary * portLib, char *filename, J9ZipCachePool *cachePool, J9ZipCache **cache);
364
365
/**
366
* @brief
367
* @param portLib
368
* @param zipFile
369
* @param cache
370
* @param cachePool
371
* @return I_32
372
*/
373
I_32
374
zip_setupCache(J9PortLibrary * portLib, J9ZipFile *zipFile, J9ZipCache *cache, J9ZipCachePool *cachePool);
375
376
377
/**
378
* @brief
379
* @param portLib
380
* @param zipFile
381
* @return I_32
382
*/
383
I_32
384
zip_readCacheData(J9PortLibrary * portLib, J9ZipFile *zipFile);
385
386
387
/**
388
* @brief
389
* @param portLib
390
* @param entry
391
* @return void
392
*/
393
void
394
zip_freeZipEntry(J9PortLibrary * portLib, J9ZipEntry * entry);
395
396
397
/**
398
* @brief
399
* @param portLib
400
* @param zipFile
401
* @param zipEntry
402
* @param nextEntryPointer
403
* @param readDataPointer
404
* @return I_32
405
*/
406
I_32
407
zip_getNextZipEntry(J9PortLibrary* portLib, J9ZipFile* zipFile, J9ZipEntry* zipEntry, IDATA* nextEntryPointer, BOOLEAN readDataPointer);
408
409
410
/**
411
* @brief
412
* @param portLib
413
* @param zipFile
414
* @param entry
415
* @param *filename
416
* @param filenameLength
417
* @param flags
418
* @return I_32
419
*/
420
I_32
421
zip_getZipEntry(J9PortLibrary *portLib, J9ZipFile *zipFile, J9ZipEntry *entry, const char *filename, IDATA filenameLength, U_32 flags);
422
423
424
/**
425
* @brief
426
* @param portLib
427
* @param zipFile
428
* @param entry
429
* @param buffer
430
* @param bufferSize
431
* @return I_32
432
*/
433
I_32
434
zip_getZipEntryComment(J9PortLibrary * portLib, J9ZipFile * zipFile, J9ZipEntry * entry, U_8 * buffer,
435
U_32 bufferSize);
436
437
/* @brief
438
* @param[in] portLib
439
* @param[in] zipFile
440
* @param[in/out]pointer to commentString
441
* @param[out] pointer to commentLength
442
* @return I32
443
*/
444
I_32
445
zip_getZipComment(J9PortLibrary * portLib, J9ZipFile * zipFile, U_8 ** commentString, UDATA * commentLength);
446
447
448
/*
449
* @brief
450
* @param[in] portLib
451
* @param[in] commentString
452
*
453
*/
454
void
455
zip_freeZipComment(J9PortLibrary * portLib, U_8 * commentString);
456
457
/**
458
* @brief
459
* @param portLib
460
* @param zipFile
461
* @param entry
462
* @param buffer
463
* @param bufferSize
464
* @return I_32
465
*/
466
I_32
467
zip_getZipEntryData(J9PortLibrary* portLib, J9ZipFile* zipFile, J9ZipEntry* entry, U_8* buffer, U_32 bufferSize);
468
469
470
/**
471
* @brief
472
* @param portLib
473
* @param zipFile
474
* @param entry
475
* @param buffer
476
* @param bufferSize
477
* @param offset
478
* @return I_32
479
*/
480
I_32
481
zip_getZipEntryRawData(J9PortLibrary* portLib, J9ZipFile* zipFile, J9ZipEntry* entry, U_8* buffer, U_32 bufferSize, U_32 offset);
482
483
484
/**
485
* @brief
486
* @param portLib
487
* @param zipFile
488
* @param entry
489
* @param buffer
490
* @param bufferSize
491
* @return I_32
492
*/
493
I_32
494
zip_getZipEntryExtraField(J9PortLibrary* portLib, J9ZipFile* zipFile, J9ZipEntry* entry, U_8* buffer, U_32 bufferSize);
495
496
497
/**
498
* @brief
499
* @param portLib
500
* @param zipFile
501
* @param entry
502
* @param offset
503
* @param readDataPointer
504
* @return I_32
505
*/
506
I_32
507
zip_getZipEntryFromOffset(J9PortLibrary * portLib, J9ZipFile * zipFile, J9ZipEntry * entry, IDATA offset, BOOLEAN readDataPointer);
508
509
510
/**
511
* @brief
512
* @param portLib
513
* @param entry
514
* @return void
515
*/
516
void
517
zip_initZipEntry(J9PortLibrary* portLib, J9ZipEntry* entry);
518
519
520
/**
521
* @brief
522
* @param portLib
523
* @param *cachePool
524
* @return UDATA
525
*/
526
J9HookInterface**
527
zip_getVMZipCachePoolHookInterface(J9ZipCachePool *cachePool);
528
529
/**
530
* @brief
531
* @param javaVM
532
* @param *cachePool
533
* @return void
534
*/
535
IDATA
536
zip_initZipCachePoolHookInterface(J9PortLibrary* portLib, J9ZipCachePool *cachePool);
537
538
/**
539
* @brief
540
* @param *cachePool
541
* @return void
542
*/
543
void
544
zip_shutdownZipCachePoolHookInterface(J9ZipCachePool *cachePool);
545
546
/**
547
* @brief
548
* @param portLib
549
* @param filename
550
* @param zipFile
551
* @param cachePool
552
* @param flags
553
* @return I_32
554
*/
555
I_32
556
zip_openZipFile(J9PortLibrary *portLib, char *filename, J9ZipFile *zipFile, J9ZipCachePool *cachePool, U_32 flags);
557
558
559
/**
560
* @brief
561
* @param portLib
562
* @param zipFile
563
* @param *nextEntryPointer
564
* @return void
565
*/
566
void
567
zip_resetZipFile(J9PortLibrary* portLib, J9ZipFile* zipFile, IDATA *nextEntryPointer);
568
569
570
void
571
zip_triggerZipLoadHook (J9PortLibrary* portLib, const char* filename, UDATA newState, J9ZipCachePool *cachePool);
572
573
#ifdef __cplusplus
574
}
575
#endif
576
577
#endif /* zip_api_h */
578
579