Some new functions and cleanup of old functions
authorJonathan Dieter <jdieter@gmail.com>
Tue, 5 Jun 2018 11:08:14 +0000 (14:08 +0300)
committerJonathan Dieter <jdieter@gmail.com>
Tue, 5 Jun 2018 11:08:14 +0000 (14:08 +0300)
Signed-off-by: Jonathan Dieter <jdieter@gmail.com>
include/zck.h
src/lib/zck.c

index c1b45d7aec69e83f8df43bebc629ffd39ade5e69..5d5912487f7b51f582b4bb87d957f5ac9b844902 100644 (file)
@@ -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));
 
 /*******************************************************************
index 2923b6696bf2d8452abd778627468218d0cf8cdf..76f40bbc886abfcb13f5747861647bb99825f6ea 100644 (file)
@@ -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;