aboutsummaryrefslogtreecommitdiffstats
path: root/src/common.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-11-13 06:22:16 +0100
committerMattias Andrée <maandree@operamail.com>2014-11-13 06:22:16 +0100
commitc55cb366fe86b9b203ac7c7b9c3538b30f91a305 (patch)
tree35f9f35e39eaf1fff699b8aa2da0e7768cf00b79 /src/common.c
parent...and pave (diff)
downloadsha3sum-c55cb366fe86b9b203ac7c7b9c3538b30f91a305.tar.gz
sha3sum-c55cb366fe86b9b203ac7c7b9c3538b30f91a305.tar.bz2
sha3sum-c55cb366fe86b9b203ac7c7b9c3538b30f91a305.tar.xz
parse the command line
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/common.c')
-rw-r--r--src/common.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/common.c b/src/common.c
index a1afe28..f75657a 100644
--- a/src/common.c
+++ b/src/common.c
@@ -42,6 +42,11 @@
+static char* restrict hashsum = NULL;
+static char* restrict hexsum = NULL;
+
+
+
/**
* Print the checksum of a file
*
@@ -62,8 +67,6 @@ int print_checksum(const char* restrict filename, libkeccak_generalised_spec_t*
libkeccak_spec_t spec;
libkeccak_state_t state;
int r, fd;
- static char* restrict hashsum = NULL;
- static char* restrict hexsum = NULL;
size_t length;
if (r = libkeccak_degeneralise_spec(gspec, &spec), r)
@@ -120,6 +123,9 @@ int print_checksum(const char* restrict filename, libkeccak_generalised_spec_t*
return USER_ERROR("unknown error in algorithm parameters");
}
+ if (squeezes <= 0)
+ return USER_ERROR("the squeeze count be be positive");
+
if (verbose)
{
fprintf(stderr, "rate: %li\n", gspec->bitrate);
@@ -175,9 +181,12 @@ int print_checksum(const char* restrict filename, libkeccak_generalised_spec_t*
}
}
- free(hashsum);
- free(hexsum);
-
return 0;
}
+
+void cleanup(void)
+{
+ free(hashsum), hashsum = NULL;
+ free(hexsum), hexsum = NULL;
+}