dedup

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

commit 444786bf6ec93a0d2cdce9bcb5b87dd67a18281f
parent ed0383fb3d1d39ea20fe1e58f2b6c3cdaf66a042
Author: sin <sin@2f30.org>
Date:   Fri,  3 May 2019 14:20:01 +0100

Add error reporting functions

Diffstat:
Mblock.c | 26++++++++++++++++++++++++++
Mblock.h | 2++
2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/block.c b/block.c @@ -3,6 +3,7 @@ #include <sys/stat.h> #include <fcntl.h> +#include <stdarg.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> @@ -10,6 +11,9 @@ #include "block.h" +#define NERRBUF 128 +static char errbuf[NERRBUF]; + int bcreat(char *path, int mode, struct bparam *bpar, struct bctx **bctx) { @@ -153,3 +157,25 @@ bparamdef(void) return &bpar; } + +void +bseterr(char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + vsnprintf(errbuf, NERRBUF, fmt, ap); + va_end(ap); +} + +void +berr(char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + fprintf(stderr, ": %s\n", errbuf); + va_end(ap); + exit(1); +} diff --git a/block.h b/block.h @@ -42,6 +42,8 @@ extern int bcheck(struct bctx *, unsigned char *); extern int bsync(struct bctx *); extern int bclose(struct bctx *); extern struct bparam *bparamdef(void); +extern void bseterr(char *, ...); +extern void berr(char *, ...); /* bcompat.c */ extern int punchhole(int, off_t, off_t);