Add unchange to ziptool_regress and use it in test case.
diff --git a/regress/add_from_file_unchange.test b/regress/add_from_file_unchange.test
index 4950bda..dff1c2f 100644
--- a/regress/add_from_file_unchange.test
+++ b/regress/add_from_file_unchange.test
@@ -1,4 +1,4 @@
# add file to zip, but revert before closing
return 0
-args -- testfile.zip add_file testfile.txt testfile.txt 0 -1 unchange_all
+args -- testfile.zip add_file testfile.txt testfile.txt 0 -1 unchange 0
file testfile.txt testfile.txt testfile.txt
diff --git a/regress/ziptool_regress.c b/regress/ziptool_regress.c
index 0b7f109..ee440d2 100644
--- a/regress/ziptool_regress.c
+++ b/regress/ziptool_regress.c
@@ -13,6 +13,7 @@
static int add_nul(int argc, char *argv[]);
static int cancel(int argc, char *argv[]);
+static int unchange_one(int argc, char *argv[]);
static int unchange_all(int argc, char *argv[]);
static int zin_close(int argc, char *argv[]);
@@ -36,6 +37,7 @@
#define DISPATCH_REGRESS \
{"add_nul", 2, "name length", "add NUL bytes", add_nul}, \
{"cancel", 1, "limit", "cancel writing archive when limit% have been written (calls print_progress)", cancel}, \
+ {"unchange", 1, "index", "revert changes for entry", unchange_one}, \
{"unchange_all", 0, "", "revert all changes", unchange_all}, \
{ "zin_close", 1, "index", "close input zip_source (for internal tests)", zin_close }
@@ -83,6 +85,22 @@
return 0;
}
+
+static int
+unchange_one(int argc, char *argv[]) {
+ zip_uint64_t idx;
+
+ idx = strtoull(argv[0], NULL, 10);
+
+ if (zip_unchange(za, idx) < 0) {
+ fprintf(stderr, "can't revert changes for entry %" PRIu64 ": %s", idx, zip_strerror(za));
+ return -1;
+ }
+
+ return 0;
+}
+
+
static int
cancel_callback(zip_t *archive, void *ud) {
if (progress_userdata.percentage >= progress_userdata.limit) {