2023-03-28 09:55:08 -04:00
|
|
|
/* ************************************************************************** */
|
|
|
|
/* */
|
|
|
|
/* ::: :::::::: */
|
|
|
|
/* fd.c :+: :+: :+: */
|
|
|
|
/* +:+ +:+ +:+ */
|
|
|
|
/* By: cchauvet <cchauvet@student.42angouleme.fr +#+ +:+ +#+ */
|
|
|
|
/* +#+#+#+#+#+ +#+ */
|
|
|
|
/* Created: 2023/03/27 13:39:58 by cchauvet #+# #+# */
|
2023-03-29 13:07:57 -04:00
|
|
|
/* Updated: 2023/03/29 18:51:58 by cchauvet ### ########.fr */
|
2023-03-28 09:55:08 -04:00
|
|
|
/* */
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
2023-03-10 06:32:39 -05:00
|
|
|
#include "./utils.h"
|
2023-03-13 14:29:20 -04:00
|
|
|
#include <stdio.h>
|
2023-03-10 06:32:39 -05:00
|
|
|
|
|
|
|
void ft_closer(int fds[2])
|
|
|
|
{
|
|
|
|
if (fds[0] > 2)
|
2023-03-13 14:29:20 -04:00
|
|
|
{
|
2023-03-10 06:32:39 -05:00
|
|
|
close(fds[0]);
|
2023-03-13 14:29:20 -04:00
|
|
|
}
|
2023-03-10 06:32:39 -05:00
|
|
|
if (fds[1] > 2)
|
2023-03-13 14:29:20 -04:00
|
|
|
{
|
2023-03-10 06:32:39 -05:00
|
|
|
close(fds[1]);
|
2023-03-13 14:29:20 -04:00
|
|
|
}
|
2023-03-10 06:32:39 -05:00
|
|
|
}
|
|
|
|
|
2023-03-29 13:07:57 -04:00
|
|
|
void ft_mega_closer(int fds1[2], int fds2[2])
|
|
|
|
{
|
|
|
|
ft_closer(fds1);
|
|
|
|
ft_closer(fds2);
|
|
|
|
}
|
|
|
|
|
2023-03-10 06:32:39 -05:00
|
|
|
void ft_add_fd(int fds[2], int fd)
|
|
|
|
{
|
|
|
|
if (fds[0] == -1)
|
|
|
|
fds[0] = fd;
|
|
|
|
else
|
|
|
|
fds[1] = fd;
|
|
|
|
}
|