/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* parsing.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2026/03/23 14:49:36 by rparodi #+# #+# */ /* Updated: 2026/03/30 12:22:07 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "parsing.h" #include "macro.h" #include "struct.h" #include #include static const char *_find_target(int argc, char **argv) { const char *target = NULL; for (int i = optind; i < argc; i++) { if (argv[i][0] != '-') { target = argv[i]; } } if (target == NULL || target[0] == '\0') { dprintf(2, "%s: missing host operand \n Try 'ping --help' or 'ping --usage' for more information.", argv[0]); exit(64); } return (target); } void parsing_args(int argc, char **argv, t_flags *flags) { if (argc == 1) { dprintf(2, "%s: missing host operand \n Try 'ping --help' or 'ping --usage' for more information.", argv[0]); exit(64); } check_flags(argc, argv, flags); check_target(_find_target(argc, argv)); SUCCESS_LOG("PARSING finished with success"); }