diff options
author | James Buren <braewoods+rb@braewoods.net> | 2021-07-05 17:08:55 +0000 |
---|---|---|
committer | James Buren <braewoods+rb@braewoods.net> | 2021-07-05 19:30:05 +0000 |
commit | b87e75f768eba3ccdf422a5082c91097a0b72b5b (patch) | |
tree | 5770da0da23e9a176010fa1e422e8b85743793d8 /firmware/include | |
parent | 2acf8db3e14e8c81f27cb0cea5b366678693c7b3 (diff) |
zip: import initial module
This provides rudimentary support for parsing the contents of a ZIP
file. For now this just supports uncompressed file entries but DEFLATE
support is planned. This also only implements a low level public API
so more work will be needed to make it usable by application code.
Change-Id: Ia68b3078e5276666a0e5023f4bc7a9f94272738a
Diffstat (limited to 'firmware/include')
-rw-r--r-- | firmware/include/zip.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/firmware/include/zip.h b/firmware/include/zip.h new file mode 100644 index 0000000000..e58466dff0 --- /dev/null +++ b/firmware/include/zip.h @@ -0,0 +1,64 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2021 by James Buren + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifndef _ZIP_H_ +#define _ZIP_H_ + +#include <stdbool.h> +#include <stdint.h> +#include <time.h> + +enum { + ZIP_PASS_SHALLOW, + ZIP_PASS_START, + ZIP_PASS_DATA, + ZIP_PASS_END, +}; + +struct zip; + +struct zip_args { + uint16_t entry; + uint16_t entries; + char* name; + uint32_t file_size; + time_t modts; + void* block; + uint32_t block_size; + uint32_t read_size; +}; + +typedef int (*zip_callback) (const struct zip_args* args, int pass, void* ctx); + +// open a handle for the given full file name path +struct zip* zip_open(const char* name, bool try_mem); + +// quick read of only directory index +int zip_read_shallow(struct zip* z, zip_callback cb, void* ctx); + +// slow read of whole archive +// this can also pickup where a successful shallow read leftoff +int zip_read_deep(struct zip* z, zip_callback cb, void* ctx); + +// returns system resources +void zip_close(struct zip* z); + +#endif |