move functions

This commit is contained in:
2025-04-26 19:53:55 +02:00
parent 621b9fc4ee
commit 4e344d945e
5 changed files with 100 additions and 72 deletions

42
srcs/main.c Normal file
View File

@ -0,0 +1,42 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_ping.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/24 00:03:56 by tomoron #+# #+# */
/* Updated: 2025/04/26 17:08:50 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
#include "includes/ft_ping.h"
void show_help(t_settings *set, char *name)
{
set->stop = 1;
write(1, "Usage: ", 7);
write(1, name, strlen(name));
write(1, HELP_MESSAGE, sizeof(HELP_MESSAGE));
}
int main(int argc, char **argv)
{
t_settings settings;
settings = parse_args(argc, argv);
if(settings.stop || settings.err)
{
free_hosts(settings.hosts);
return((settings.err != 0) * 64);
}
if(!settings.hosts)
{
fprintf(stderr, "%s: missing host operand\n", argv[0]);
return(64);
}
send_pings(settings);
free_hosts(settings.hosts);
return(0);
}