zip.h 1.2 KB

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