add -? arg support

This commit is contained in:
2025-08-18 15:51:26 +02:00
parent 01c4d7cc51
commit 853f7ef2c3
2 changed files with 22 additions and 13 deletions

View File

@ -32,7 +32,7 @@ Send ICMP ECHO_REQUEST packets to network hosts.\n\
-W, --linger=N Number of seconds to wait for response\n\ -W, --linger=N Number of seconds to wait for response\n\
-v, --verbose Enable verbose mode\n\ -v, --verbose Enable verbose mode\n\
\n\ \n\
-h, --help Print this usage info\n" -h, -?, --help Print this usage info\n"
extern int g_stop; extern int g_stop;

View File

@ -6,7 +6,7 @@
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */ /* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/26 17:01:53 by tomoron #+# #+# */ /* Created: 2025/04/26 17:01:53 by tomoron #+# #+# */
/* Updated: 2025/08/15 02:16:12 by tomoron ### ########.fr */ /* Updated: 2025/08/18 15:50:29 by tomoron ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "includes/ft_ping.h" #include "includes/ft_ping.h"
@ -76,6 +76,7 @@ int check_values(t_settings *set, char *name)
void init_settings(t_settings *set) void init_settings(t_settings *set)
{ {
char *tmp; char *tmp;
tmp = set->name; tmp = set->name;
bzero(set, sizeof(t_settings)); bzero(set, sizeof(t_settings));
set->name = tmp; set->name = tmp;
@ -100,6 +101,14 @@ int parse_args(int argc, char **argv, t_settings *set)
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
for(int i = 1; i < argc; i++)
{
if(!strcmp(argv[i], "-?"))
{
show_help(set);
return (1);
}
}
unsetenv("POSIXLY_CORRECT"); unsetenv("POSIXLY_CORRECT");
init_settings(set); init_settings(set);