diff options
author | Cameron Katri <me@cameronkatri.com> | 2022-06-13 23:07:11 -0400 |
---|---|---|
committer | Cameron Katri <me@cameronkatri.com> | 2022-06-13 23:07:11 -0400 |
commit | 6a5be2524f0d31a601687e8b5d09b9af92848dac (patch) | |
tree | 5b972137814a4fb71eb29a1ee5520ca196d5b9f9 /remove.c | |
parent | 5c02858affbcccd66f1f994c5a8cc475ea503591 (diff) | |
download | trustcache-6a5be2524f0d31a601687e8b5d09b9af92848dac.tar.gz trustcache-6a5be2524f0d31a601687e8b5d09b9af92848dac.tar.zst trustcache-6a5be2524f0d31a601687e8b5d09b9af92848dac.zip |
Unify writing of trustcache to new function
Diffstat (limited to 'remove.c')
-rw-r--r-- | remove.c | 17 |
1 files changed, 2 insertions, 15 deletions
@@ -96,23 +96,10 @@ tcremove(int argc, char **argv) hash[j] = 0; } - if ((f = fopen(argv[0], "wb")) == NULL) { - fprintf(stderr, "%s: %s\n", argv[0], strerror(errno)); + if (writetrustcache(cache, argv[0]) == -1) return 1; - } - - cache.version = htole32(cache.version); - cache.num_entries = htole32(cache.num_entries); - fwrite(&cache, sizeof(struct trust_cache) - sizeof(struct trust_cache_entry1*), 1, f); - cache.version = le32toh(cache.version); - cache.num_entries = le32toh(cache.num_entries); - for (uint32_t i = 0; i < cache.num_entries; i++) { - if (cache.version == 0) - fwrite(&cache.hashes[i], sizeof(trust_cache_hash0), 1, f); - else if (cache.version == 1) - fwrite(&cache.entries[i], sizeof(struct trust_cache_entry1), 1, f); - } + free(cache.entries); printf("Removed %i %s\n", numremoved, numremoved == 1 ? "entry" : "entries"); |