51 lines
1.4 KiB
C
51 lines
1.4 KiB
C
#ifndef PING_CLI_H
|
|
#define PING_CLI_H
|
|
|
|
#include "ft_ping.h"
|
|
|
|
#define CLI_SUCCESS 0
|
|
#define CLI_ERROR 1
|
|
#define CLI_EXIT_SUCCESS -1
|
|
|
|
|
|
typedef int (*t_option_handler)(const char *arg, t_ping_config *config);
|
|
|
|
typedef enum e_option_arg_type
|
|
{
|
|
OPT_ARG_NONE = 0,
|
|
OPT_ARG_INT,
|
|
OPT_ARG_UINT,
|
|
OPT_ARG_SECONDS,
|
|
OPT_ARG_BYTES,
|
|
OPT_ARG_TTL,
|
|
OPT_ARG_STRING
|
|
} t_option_arg_type;
|
|
|
|
typedef struct s_option_descriptor
|
|
{
|
|
char short_opt;
|
|
const char *long_opt;
|
|
int has_arg;
|
|
t_option_handler handler;
|
|
t_option_arg_type arg_type;
|
|
const char *description;
|
|
} t_option_descriptor;
|
|
|
|
extern const t_option_descriptor g_options[];
|
|
|
|
int cli_handle_count(const char *arg, t_ping_config *config);
|
|
int cli_handle_flood(const char *arg, t_ping_config *config);
|
|
int cli_handle_help(const char *arg, t_ping_config *config);
|
|
int cli_handle_interval(const char *arg, t_ping_config *config);
|
|
int cli_handle_quiet(const char *arg, t_ping_config *config);
|
|
int cli_handle_size(const char *arg, t_ping_config *config);
|
|
int cli_handle_timeout(const char *arg, t_ping_config *config);
|
|
int cli_handle_ttl(const char *arg, t_ping_config *config);
|
|
int cli_handle_version(const char *arg, t_ping_config *config);
|
|
int cli_handle_verbose(const char *arg, t_ping_config *config);
|
|
|
|
int cli_parse_uint64(const char *s, uint64_t *out);
|
|
int cli_parse_float(const char *s, float *out);
|
|
const char *get_optstr(void);
|
|
|
|
#endif
|