aboutsummaryrefslogtreecommitdiffstats
path: root/cmdline_other.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--cmdline_other.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/cmdline_other.c b/cmdline_other.c
new file mode 100644
index 0000000..167bc84
--- /dev/null
+++ b/cmdline_other.c
@@ -0,0 +1,60 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+
+static int
+parseopt_algorithm(void *config_, char *opt, char *val)
+{
+ struct config *config = config_;
+ if (val)
+ return 0;
+ config->algorithms = ereallocarray(config->algorithms, config->nalgorithms + 1U, sizeof(*config->algorithms));
+ memset(&config->algorithms[config->nalgorithms], 0, sizeof(*config->algorithms));
+ config->algorithms[config->nalgorithms].algostr = opt;
+ config->algorithms[config->nalgorithms].result = NULL;
+ config->nalgorithms++;
+ return 1;
+}
+
+
+int
+cmdline_other(int argc, char **argv, enum command command, struct config *config)
+{
+ char *arg;
+
+ ARGBEGIN {
+ case 'b': /* binary input (compat) */
+ case 't': /* text input (compat) */
+ config->hexinput = 0;
+ break;
+
+ case 'c':
+ config->verify = 1;
+ break;
+
+ case 'w':
+ config->warn_improper_format = 1;
+ break;
+
+ case 'z':
+ config->format &= (enum format)~WITH_LF;
+ config->format |= WITH_NUL;
+ break;
+
+ case 'W':
+ arg = parseopts(config, ARG(), &parseopt_algorithm);
+ if (*arg)
+ eprintf("unsupported -W options: %s", arg);
+ break;
+
+ case 'a':
+ if (command != ANYSUM || *parseopts(config, ARG(), &parseopt_algorithm))
+ usage();
+ break;
+
+ default:
+ usage();
+ } ARGEND;
+
+ return argc;
+}