libmpm

morphux C package management library
Log | Files | Refs | Submodules | README | LICENSE | git clone https://git.ne02ptzero.me/git/libmpm

commit 5b59b6ade93b2b1536faa9c634b9d721e3196f97
parent 9a5520207a79d1ec95d2ce6823ccf87c1020973e
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Fri,  5 May 2017 19:32:26 +0200

Add(Packer): Add function packer_read_archive_header

Diffstat:
Minc/packer.h | 9+++++++++
Msrc/packer.c | 14++++++++++++++
2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/inc/packer.h b/inc/packer.h @@ -154,4 +154,13 @@ bool packer_create_archive(packer_t *ctx, const char *archive_path); */ bool packer_read_archive_in_memory(packer_t *ctx); +/*! + * \brief Read the header of a .mpx archive, and stock it in memory + * + * \param[in,out] ctx Already initialized packer_t struct + * + * \return True on success, false on failure + */ +bool packer_read_archive_header(packer_t *ctx); + #endif /* PACKER_H */ diff --git a/src/packer.c b/src/packer.c @@ -831,3 +831,17 @@ cleanup: free(archive); return ret; } + +bool packer_read_archive_header(packer_t *ctx) { + char *archive = NULL; + bool ret; + int cur = 0; + + archive = mpm_read_file_from_fn(ctx->str); + if (archive == NULL) + return false; + + ret = read_package_header(archive, ctx, &cur); + free(archive); + return ret; +}