dedup

data deduplication program
git clone git://git.2f30.org/dedup.git
Log | Files | Refs | README | LICENSE

commit 0b8ebd8c3ba33a27f9d04d031eeedf979c4a83bb
parent c764e111ff91c26bed375f5cf2484221d0144c78
Author: sin <sin@2f30.org>
Date:   Wed, 17 Apr 2019 15:16:13 +0100

Add functions to list supported hashes/compressors

Diffstat:
Mcompress.c | 10++++++++++
Mdedup.c | 8++++++++
Mdedup.h | 2++
Mhash.c | 10++++++++++
4 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/compress.c b/compress.c @@ -2,6 +2,7 @@ #include <err.h> #include <stdint.h> +#include <stdio.h> #include <string.h> #include <strings.h> @@ -111,3 +112,12 @@ compr_type2name(int type) return NULL; return algo->name; } + +void +compr_list(int fd) +{ + struct algomap *algo; + + for (algo = &algomap[0]; algo->name != NULL; algo++) + dprintf(fd, "%s\n", algo->name); +} diff --git a/dedup.c b/dedup.c @@ -594,12 +594,20 @@ main(int argc, char *argv[]) ARGBEGIN { case 'H': hash_name = EARGF(usage()); + if (strcmp(hash_name, "?") == 0) { + hash_list(STDERR_FILENO); + return 0; + } hash_algo = hash_name2type(hash_name); if (hash_algo < 0) errx(1, "unknown hash: %s", hash_name); break; case 'Z': compr_name = EARGF(usage()); + if (strcmp(compr_name, "?") == 0) { + compr_list(STDERR_FILENO); + return 0; + } compr_algo = compr_name2type(compr_name); if (compr_algo < 0) errx(1, "unknown compressor: %s", compr_name); diff --git a/dedup.h b/dedup.h @@ -145,6 +145,7 @@ size_t decompr(struct compr_ctx *ctx, const void *in, void *out, int compr_final(struct compr_ctx *ctx); int compr_name2type(char *name); char *compr_type2name(int type); +void compr_list(int fd); /* hash-blake2b.c */ int blake2bi(struct hash_ctx *ctx, size_t n); @@ -172,6 +173,7 @@ int hash_update(struct hash_ctx *ctx, const void *buf, size_t n); int hash_final(struct hash_ctx *ctx, void *buf, size_t n); int hash_name2type(char *name); char *hash_type2name(int type); +void hash_list(int fd); /* icache.c */ struct icache *alloc_icache(void); diff --git a/hash.c b/hash.c @@ -1,6 +1,7 @@ #include <sys/types.h> #include <stdint.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> @@ -93,3 +94,12 @@ hash_type2name(int type) return NULL; return algo->name; } + +void +hash_list(int fd) +{ + struct algomap *algo; + + for (algo = &algomap[0]; algo->name != NULL; algo++) + dprintf(fd, "%s\n", algo->name); +}