From ae04fb053eebfe53924b095b774dfc5b9cd88e4c Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 13 Nov 2014 06:49:00 +0100 Subject: misc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/common.h | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'src/common.h') diff --git a/src/common.h b/src/common.h index 76cd4da..7c35e3c 100644 --- a/src/common.h +++ b/src/common.h @@ -21,6 +21,22 @@ #include +#include + + + +/** + * Wrapper for `run` that also initialises the command line parser + * + * @param algo The name of the hashing algorithm, must be a string literal + * @param prog The name of program, must be a string literal + * @param suffix The message suffix + */ +#define RUN(algo, prog, suffix) \ + (args_init(algo " checksum calculator", \ + prog " [options...] [--] [files...]", NULL, \ + NULL, 1, 0, args_standard_abbreviations), \ + run(argc, argv, &spec, suffix)) @@ -59,7 +75,16 @@ int print_checksum(const char* restrict filename, libkeccak_generalised_spec_t* const char* restrict execname); -void cleanup(void); +/** + * Parse the command line and calculate the hashes of the selected files + * + * @param argc The first argument from `main` + * @param argv The second argument from `main` + * @param spec The default algorithm parameters + * @param suffix Message suffix + * @return An appropriate exit value + */ +int run(int argc, char* argv[], libkeccak_generalised_spec_t* restrict spec, const char* restrict suffix); #endif -- cgit v1.2.3-70-g09d2