1*f7c14bbaSAndroid Build Coastguard Worker /* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ 2*f7c14bbaSAndroid Build Coastguard Worker 3*f7c14bbaSAndroid Build Coastguard Worker #ifndef __LIBBPF_ZIP_H 4*f7c14bbaSAndroid Build Coastguard Worker #define __LIBBPF_ZIP_H 5*f7c14bbaSAndroid Build Coastguard Worker 6*f7c14bbaSAndroid Build Coastguard Worker #include <linux/types.h> 7*f7c14bbaSAndroid Build Coastguard Worker 8*f7c14bbaSAndroid Build Coastguard Worker /* Represents an open zip archive. 9*f7c14bbaSAndroid Build Coastguard Worker * Only basic ZIP files are supported, in particular the following are not 10*f7c14bbaSAndroid Build Coastguard Worker * supported: 11*f7c14bbaSAndroid Build Coastguard Worker * - encryption 12*f7c14bbaSAndroid Build Coastguard Worker * - streaming 13*f7c14bbaSAndroid Build Coastguard Worker * - multi-part ZIP files 14*f7c14bbaSAndroid Build Coastguard Worker * - ZIP64 15*f7c14bbaSAndroid Build Coastguard Worker */ 16*f7c14bbaSAndroid Build Coastguard Worker struct zip_archive; 17*f7c14bbaSAndroid Build Coastguard Worker 18*f7c14bbaSAndroid Build Coastguard Worker /* Carries information on name, compression method, and data corresponding to a 19*f7c14bbaSAndroid Build Coastguard Worker * file in a zip archive. 20*f7c14bbaSAndroid Build Coastguard Worker */ 21*f7c14bbaSAndroid Build Coastguard Worker struct zip_entry { 22*f7c14bbaSAndroid Build Coastguard Worker /* Compression method as defined in pkzip spec. 0 means data is uncompressed. */ 23*f7c14bbaSAndroid Build Coastguard Worker __u16 compression; 24*f7c14bbaSAndroid Build Coastguard Worker 25*f7c14bbaSAndroid Build Coastguard Worker /* Non-null terminated name of the file. */ 26*f7c14bbaSAndroid Build Coastguard Worker const char *name; 27*f7c14bbaSAndroid Build Coastguard Worker /* Length of the file name. */ 28*f7c14bbaSAndroid Build Coastguard Worker __u16 name_length; 29*f7c14bbaSAndroid Build Coastguard Worker 30*f7c14bbaSAndroid Build Coastguard Worker /* Pointer to the file data. */ 31*f7c14bbaSAndroid Build Coastguard Worker const void *data; 32*f7c14bbaSAndroid Build Coastguard Worker /* Length of the file data. */ 33*f7c14bbaSAndroid Build Coastguard Worker __u32 data_length; 34*f7c14bbaSAndroid Build Coastguard Worker /* Offset of the file data within the archive. */ 35*f7c14bbaSAndroid Build Coastguard Worker __u32 data_offset; 36*f7c14bbaSAndroid Build Coastguard Worker }; 37*f7c14bbaSAndroid Build Coastguard Worker 38*f7c14bbaSAndroid Build Coastguard Worker /* Open a zip archive. Returns NULL in case of an error. */ 39*f7c14bbaSAndroid Build Coastguard Worker struct zip_archive *zip_archive_open(const char *path); 40*f7c14bbaSAndroid Build Coastguard Worker 41*f7c14bbaSAndroid Build Coastguard Worker /* Close a zip archive and release resources. */ 42*f7c14bbaSAndroid Build Coastguard Worker void zip_archive_close(struct zip_archive *archive); 43*f7c14bbaSAndroid Build Coastguard Worker 44*f7c14bbaSAndroid Build Coastguard Worker /* Look up an entry corresponding to a file in given zip archive. */ 45*f7c14bbaSAndroid Build Coastguard Worker int zip_archive_find_entry(struct zip_archive *archive, const char *name, struct zip_entry *out); 46*f7c14bbaSAndroid Build Coastguard Worker 47*f7c14bbaSAndroid Build Coastguard Worker #endif 48