circuitpython/shared/memzip/memzip.h
Damien George 4d546713ec shared: Introduce new top-level dir and move 1st party lib code there.
This commit moves all first-party code developed for this project from lib/
to shared/, so that lib/ now only contains third-party code.

The following directories are moved as-is from lib to shared:

    lib/libc            -> shared/libc
    lib/memzip          -> shared/memzip
    lib/netutils        -> shared/netutils
    lib/timeutils       -> shared/timeutils
    lib/upytesthelper   -> shared/upytesthelper

All files in lib/embed/ have been moved to shared/libc/.

lib/mp-readline has been moved to shared/readline.

lib/utils has been moved to shared/runtime, with the exception of
lib/utils/printf.c which has been moved to shared/libc/printf.c.

Signed-off-by: Damien George <damien@micropython.org>
2021-07-12 17:07:36 +10:00

84 lines
2.2 KiB
C

#pragma pack(push, 1)
#define MEMZIP_FILE_HEADER_SIGNATURE 0x04034b50
typedef struct
{
uint32_t signature;
uint16_t version;
uint16_t flags;
uint16_t compression_method;
uint16_t last_mod_time;
uint16_t last_mod_date;
uint32_t crc32;
uint32_t compressed_size;
uint32_t uncompressed_size;
uint16_t filename_len;
uint16_t extra_len;
/* char filename[filename_len] */
/* uint8_t extra[extra_len] */
} MEMZIP_FILE_HDR;
#define MEMZIP_CENTRAL_DIRECTORY_SIGNATURE 0x02014b50
typedef struct
{
uint32_t signature;
uint16_t version_made_by;
uint16_t version_read_with;
uint16_t flags;
uint16_t compression_method;
uint16_t last_mod_time;
uint16_t last_mod_date;
uint32_t crc32;
uint32_t compressed_size;
uint32_t uncompressed_size;
uint16_t filename_len;
uint16_t extra_len;
uint16_t disk_num;
uint16_t internal_file_attributes;
uint32_t external_file_attributes;
uint32_t file_header_offset;
/* char filename[filename_len] */
/* uint8_t extra[extra_len] */
} MEMZIP_CENTRAL_DIRECTORY_HDR;
#define MEMZIP_END_OF_CENTRAL_DIRECTORY_SIGNATURE 0x06054b50
typedef struct
{
uint32_t signature;
uint16_t disk_num;
uint16_t central_directory_disk;
uint16_t num_central_directories_this_disk;
uint16_t total_central_directories;
uint32_t central_directory_size;
uint32_t central_directory_offset;
uint16_t comment_len;
/* char comment[comment_len] */
} MEMZIP_END_OF_CENTRAL_DIRECTORY;
#pragma pack(pop)
typedef enum {
MZ_OK = 0, /* (0) Succeeded */
MZ_NO_FILE, /* (1) Could not find the file. */
MZ_FILE_COMPRESSED, /* (2) File is compressed (expecting uncompressed) */
} MEMZIP_RESULT;
typedef struct {
uint32_t file_size;
uint16_t last_mod_date;
uint16_t last_mod_time;
uint8_t is_dir;
} MEMZIP_FILE_INFO;
MEMZIP_RESULT memzip_locate(const char *filename, void **data, size_t *len);
MEMZIP_RESULT memzip_stat(const char *path, MEMZIP_FILE_INFO *info);