#include #include "internal/ping/cli_handlers.h" #include "internal/cli/options.h" /* Forward declarations */ static inline const char * option_arg_type_to_str(enum option_arg_type type); /* -------------------- */ void print_help(void) { printf("ft_ping - Send ICMP ECHO_REQUEST to network hosts\n"); printf("Usage: ft_ping [options] \n\n"); printf("Options:\n"); for (size_t i = 0; i < PING_OPT_LEN; ++i) { const struct option_descriptor *opt = &g_options[i]; const char *argstr = option_arg_type_to_str(opt->arg_type); printf(" -%c, --%-10s %-8s %s\n", opt->short_opt, opt->long_opt, argstr[0] ? argstr : "", opt->description ); } } static inline const char * option_arg_type_to_str(enum option_arg_type type) { switch (type) { case OPT_ARG_NONE: return ""; case OPT_ARG_INT: return ""; case OPT_ARG_UINT: return ""; case OPT_ARG_SECONDS: return ""; case OPT_ARG_BYTES: return ""; case OPT_ARG_TTL: return ""; case OPT_ARG_STRING: return ""; default: return ""; } }