sbase

suckless unix tools
git clone git://git.2f30.org/sbase.git
Log | Files | Refs | README | LICENSE

commit 18b6e4016108182834d08f54c15daad3a459da9f
parent 7727530b534581f64ff00d1bc41b3198103e5e11
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sun, 23 Mar 2014 12:30:34 +0100

crypt: error status code if an error occured in a file series

Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>

Diffstat:
util/crypt.c | 12++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/util/crypt.c b/util/crypt.c @@ -10,6 +10,7 @@ cryptmain(int argc, char *argv[], struct crypt_ops *ops, uint8_t *md, size_t sz) { FILE *fp; + int ret = EXIT_SUCCESS; if (argc == 0) { cryptsum(ops, stdin, "<stdin>", md); @@ -18,15 +19,18 @@ cryptmain(int argc, char *argv[], for (; argc > 0; argc--) { if((fp = fopen(*argv, "r")) == NULL) { weprintf("fopen %s:", *argv); + ret = EXIT_FAILURE; continue; } - cryptsum(ops, fp, *argv, md); - mdprint(md, *argv, sz); + if(cryptsum(ops, fp, *argv, md) == 1) + ret = EXIT_FAILURE; + else + mdprint(md, *argv, sz); fclose(fp); argv++; } } - return EXIT_SUCCESS; + return ret; } int @@ -40,7 +44,7 @@ cryptsum(struct crypt_ops *ops, FILE *fp, const char *f, while ((n = fread(buf, 1, sizeof(buf), fp)) > 0) ops->update(ops->s, buf, n); if (ferror(fp)) { - eprintf("read error: %s:", f); + weprintf("read error: %s:", f); return 1; } ops->sum(ops->s, md);