From: Jonathan Dieter Date: Tue, 5 Jun 2018 11:08:14 +0000 (+0300) Subject: Some new functions and cleanup of old functions X-Git-Tag: archive/raspbian/1.1.9+ds1-1+rpi1~1^2~256 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=3f07ba7a51ec140ca41e9fbe4a1b194f125e2e90;p=zchunk.git Some new functions and cleanup of old functions Signed-off-by: Jonathan Dieter --- diff --git a/include/zck.h b/include/zck.h index c1b45d7..5d59124 100644 --- a/include/zck.h +++ b/include/zck.h @@ -160,6 +160,16 @@ char *zck_get_range_char(zckRange *range) int zck_get_fd(zckCtx *zck) __attribute__ ((warn_unused_result)); +/* Return number of missing chunks (-1 if error) */ +int zck_missing_chunks(zckCtx *zck) + __attribute__ ((warn_unused_result)); +/* Return number of failed chunks (-1 if error) */ +int zck_failed_chunks(zckCtx *zck) + __attribute__ ((warn_unused_result)); +/* Reset failed chunks to become missing */ +int zck_reset_failed_chunks(zckCtx *zck) + __attribute__ ((warn_unused_result)); + /******************************************************************* * The functions should be all you need to read and write a zchunk * file. After this point are advanced functions with an unstable @@ -182,6 +192,9 @@ ssize_t zck_get_header_length(zckCtx *zck) /* Get data length */ ssize_t zck_get_data_length(zckCtx *zck) __attribute__ ((warn_unused_result)); +/* Get file length */ +ssize_t zck_get_length(zckCtx *zck) + __attribute__ ((warn_unused_result)); /* Get index digest */ char *zck_get_header_digest(zckCtx *zck) __attribute__ ((warn_unused_result)); @@ -277,7 +290,7 @@ typedef struct zckDL { void *wdata; zck_wcb header_cb; void *hdrdata; - zckRange info; + zckRange *range; zckDLPriv *priv; struct zckCtx *zck; } zckDL; @@ -288,14 +301,14 @@ typedef struct zckDL { /* Get any matching chunks from src and put them in the right place in tgt */ int zck_copy_chunks(zckCtx *src, zckCtx *tgt) __attribute__ ((warn_unused_result)); -/* Free any resources in zckRange */ -void zck_range_close(zckRange *info); +/* Free zckRange */ +void zck_range_free(zckRange **info); /* Get range string from start and end location */ char *zck_get_range(size_t start, size_t end) __attribute__ ((warn_unused_result)); /* Get the minimum size needed to download in order to know how large the header * is */ -int get_min_download_size() +int zck_get_min_download_size() __attribute__ ((warn_unused_result)); /******************************************************************* diff --git a/src/lib/zck.c b/src/lib/zck.c index 2923b66..76f40bb 100644 --- a/src/lib/zck.c +++ b/src/lib/zck.c @@ -55,7 +55,7 @@ } /* If lead format changes, this needs to be changed */ -int PUBLIC get_min_download_size() { +int PUBLIC zck_get_min_download_size() { /* Lead + hash type + hash digest + header size */ return 5 + MAX_COMP_SIZE*2 + get_max_hash_size(); } @@ -416,6 +416,10 @@ ssize_t PUBLIC zck_get_data_length(zckCtx *zck) { return idx->start + idx->comp_length; } +ssize_t PUBLIC zck_get_length(zckCtx *zck) { + return zck_get_header_length(zck) + zck_get_data_length(zck); +} + int zck_get_tmp_fd() { int temp_fd; char *fname = NULL;