ft_ssl/includes/internal/cmd/digest_cmd.h

84 lines
1.6 KiB
C

#ifndef FT_SSL_CMD_DIGEST_H
#define FT_SSL_CMD_DIGEST_H
#include <getopt.h>
#include <cli.h>
#include "internal/cli/cli_handlers.h"
#include "internal/cmd/command.h"
#define DIGEST_OPTION_LIST \
X( \
'h', \
"help", \
no_argument, \
cli_handle_help, \
OPT_ARG_NONE, \
"Display this help and exit", \
0 \
) \
X( \
'V', \
"version", \
no_argument, \
cli_handle_version, \
OPT_ARG_NONE, \
"Display version information and exit", \
0 \
) \
X( \
'p', \
"stdin", \
no_argument, \
cli_handle_p, \
OPT_ARG_NONE, \
"Echo stdin to stdout and append checksum to output", \
0 \
) \
X( \
'q', \
"quiet", \
no_argument, \
cli_handle_q, \
OPT_ARG_NONE, \
"Quiet mode: only print the digest", \
0 \
) \
X( \
'r', \
"reverse", \
no_argument, \
cli_handle_r, \
OPT_ARG_NONE, \
"Reverse the output format (digest then filename)", \
0 \
) \
X( \
's', \
"string", \
required_argument, \
cli_handle_s, \
OPT_ARG_STRING, \
"Hash a string", \
CLI_OPT_F_REPEATABLE \
)
#undef X
#define X(short_opt, long_opt, has_arg, handler, arg_type, desc, flags) + 1
enum { DIGEST_OPT_LEN = (0 DIGEST_OPTION_LIST) };
#undef X
#define X(short_opt, long_opt, has_arg, handler, arg_type, desc, flags) \
+ (1 * (has_arg == no_argument) \
+ (2 * (has_arg == required_argument) \
+ (3 * (has_arg == optional_argument))))
enum { DIGEST_OPTSTR_LEN = (2 DIGEST_OPTION_LIST) };
/* +2 for ':' to disable getopt error messages and \0 */
#undef X
extern const struct option_descriptor g_digest_opts[];
int digest_run(int argc, char **argv,
const struct command_descriptor *self);
#endif