「🔨」 fix: fixed issue with init and cleaned help print
This commit is contained in:
17
src/main.c
17
src/main.c
@ -10,15 +10,28 @@ void init_args_t(args_t *args) {
|
||||
OPT_WHILE {
|
||||
args->opts[i] = false;
|
||||
args->arg[i] = NULL;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void handle_options(args_t *args) {
|
||||
int handle_options(args_t *args, char **av) {
|
||||
// TODO: need to make this function D:
|
||||
if (args->opts[1]) {
|
||||
print_help();
|
||||
return EXIT_SUCCESS;
|
||||
} else if (args->opts[0]) {
|
||||
print_no_host(*av);
|
||||
return EX_USAGE;
|
||||
} else if (args->opts[2]) {
|
||||
printf("adjoly's %s: v%s\n", *av, FT_PING_V);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
int main(int ac, char **av) {
|
||||
args_t args;
|
||||
init_args_t(&args);
|
||||
if (ac > 1) {
|
||||
int ret = opt_parse(av, &args);
|
||||
if (ret == -1)
|
||||
@ -26,7 +39,7 @@ int main(int ac, char **av) {
|
||||
else if (ret != EXIT_SUCCESS)
|
||||
return ret;
|
||||
else
|
||||
handle_options(&args);
|
||||
return handle_options(&args, av);
|
||||
} else {
|
||||
print_no_host(*av);
|
||||
return EX_USAGE;
|
||||
|
Reference in New Issue
Block a user