net-tools/includes/internal/cli/options.h
2026-03-12 16:11:26 +01:00

108 lines
1.9 KiB
C

#ifndef PING_CLI_OPT_H
#define PING_CLI_OPT_H
#include <getopt.h>
#define CLI_OPTIONS_LIST \
X( \
'h', \
"help", \
no_argument, \
cli_handle_help, \
OPT_ARG_NONE, \
"Display this help and exit" \
) \
X( \
'V', \
"version", \
no_argument, \
cli_handle_version, \
OPT_ARG_NONE, \
"Display version information and exit" \
) \
X( \
'v', \
"verbose", \
no_argument, \
cli_handle_verbose, \
OPT_ARG_NONE, \
"Verbose output" \
) \
X( \
'q', \
"quiet", \
no_argument, \
cli_handle_quiet, \
OPT_ARG_NONE, \
"Quiet mode (only show summary)" \
) \
X( \
'c', \
"count", \
required_argument, \
cli_handle_count, \
OPT_ARG_UINT, \
"Stop after sending N packets" \
) \
X( \
'i', \
"interval", \
required_argument, \
cli_handle_interval, \
OPT_ARG_SECONDS, \
"Wait N seconds between packets" \
) \
X( \
't', \
"ttl", \
required_argument, \
cli_handle_ttl, \
OPT_ARG_TTL, \
"Set Time To Live" \
) \
X( \
's', \
"size", \
required_argument, \
cli_handle_size, \
OPT_ARG_BYTES, \
"Packet size in bytes" \
) \
X( \
'W', \
"timeout", \
required_argument, \
cli_handle_timeout, \
OPT_ARG_SECONDS, \
"Timeout for replies in seconds" \
) \
X( \
'w', \
"deadline", \
required_argument, \
cli_handle_deadline, \
OPT_ARG_SECONDS, \
"Exit after N seconds regardless of packets sent/received" \
) \
X( \
'f', \
"flood", \
no_argument, \
cli_handle_flood, \
OPT_ARG_NONE, \
"Flood mode" \
)
#undef X
#define X(short_opt, long_opt, has_arg, handler, arg_type, desc) + 1
enum { CLI_OPT_LEN = (0 CLI_OPTIONS_LIST) };
#undef X
#define X(short_opt, long_opt, has_arg, handler, arg_type, desc) \
+ (1 * (has_arg == no_argument) \
+ (2 * (has_arg == required_argument) \
+ (3 * (has_arg == optional_argument))))
enum { CLI_OPT_STR_LEN = (1 CLI_OPTIONS_LIST) };
/* +1 for ':' to disable getopt error messages */
#endif