aboutsummaryrefslogtreecommitdiffstats
path: root/src/common.h
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-11-13 06:49:00 +0100
committerMattias Andrée <maandree@operamail.com>2014-11-13 06:49:00 +0100
commitae04fb053eebfe53924b095b774dfc5b9cd88e4c (patch)
treef91094406f1729d44ede60171a0bda5067055b59 /src/common.h
parentparse the command line (diff)
downloadsha3sum-ae04fb053eebfe53924b095b774dfc5b9cd88e4c.tar.gz
sha3sum-ae04fb053eebfe53924b095b774dfc5b9cd88e4c.tar.bz2
sha3sum-ae04fb053eebfe53924b095b774dfc5b9cd88e4c.tar.xz
misc
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/common.h')
-rw-r--r--src/common.h27
1 files changed, 26 insertions, 1 deletions
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 <libkeccak.h>
+#include <argparser.h>
+
+
+
+/**
+ * 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