show ping response lines and stats lines

This commit is contained in:
2025-05-02 01:17:18 +02:00
parent b4afb26076
commit e3a2901370
8 changed files with 233 additions and 117 deletions

63
srcs/waitlist_utils.c Normal file
View File

@ -0,0 +1,63 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* waitlist_utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/01 17:38:58 by tomoron #+# #+# */
/* Updated: 2025/05/02 01:06:21 by tomoron ### ########.fr */
/* */
/* ************************************************************************** */
#include "includes/ft_ping.h"
void waitlist_add(t_waitlist **waitlist, t_waitlist *elem)
{
t_waitlist *cur;
cur = *waitlist;
while(cur && cur->next)
cur = cur->next;
if(cur)
cur->next = elem;
else
*waitlist = elem;
}
void waitlist_free(t_waitlist *lst)
{
t_waitlist *tmp;
while(lst)
{
tmp = lst->next;
free(lst);
lst = tmp;
}
}
void waitlist_remove(t_waitlist **lst, uint16_t seq, t_settings *set, t_stats *stats)
{
t_waitlist *prev;
t_waitlist *cur;
prev = 0;
cur = *lst;
while(cur && cur->seq != seq)
{
printf("%d, %d\n", cur->seq, seq);
prev = cur;
cur = cur->next;
}
if(!cur)
return ;
if(!prev)
*lst = cur->next;
else
prev->next = cur->next;
show_ping_res_line(cur, set, seq, stats);
free(cur);
}