/* 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; }