🏗️」 wip: parsing should be good

This commit is contained in:
2025-08-12 12:37:05 +02:00
parent 4add0312bc
commit 577563da37
6 changed files with 88 additions and 23 deletions

View File

@ -19,12 +19,13 @@ static options_t options[] = {
{"verbose", 'v', "verbose output", 0, GRP},
#undef GRP
#define GRP 2 // AKA bonus
{"count", 'c', "stop after sending NUMBER packets", 1,
GRP},
{"count", 'c', "stop after sending NUMBER packets", 1, GRP},
{"size", 's', "send NUMBER data octets", 1, GRP},
{"timeout", 'w', "stop after N seconds", 1, GRP},
{"ttl", 't', "specify N as time-to-live", 1, GRP},
{"ip-timestamp", 'i', "IP timestamp of type FLAG, which is one of \"tsonly\" and \"tsaddr\"", 1, GRP}
{"ip-timestamp", 'i',
"IP timestamp of type FLAG, which is one of \"tsonly\" and \"tsaddr\"", 1,
GRP}
#undef GRP
};
@ -43,12 +44,17 @@ static options_t options[] = {
} \
args->arg[i] = *(av + 1); \
} \
args->opts[i] = true;
args->opts[i] = true; \
return EXIT_SUCCESS;
typedef enum { MISSING_HOST, INVALID_OPT, NEED_ARG } error_t;
/**
* @brief Can be used to print the help message if no host (or addr) are
* provided
*/
void print_no_host(char *av);
void print_parse_err(error_t err, char *opt);
void print_help(void);
void print_usage(void);

View File

@ -8,6 +8,7 @@
typedef struct {
bool opts[OPT_NB];
char *arg[OPT_NB];
char **hosts;
} args_t;
/**

View File

@ -1 +1,3 @@
#pragma once
extern char *exec_name;