-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_next_line_multiple.c
31 lines (29 loc) · 1.26 KB
/
get_next_line_multiple.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_next_line_multiple.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nle-roux <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/10 13:27:27 by nle-roux #+# #+# */
/* Updated: 2023/11/26 17:00:47 by nle-roux ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *get_next_line_multiple(int fd)
{
static char *content[FD_OPEN_LIMIT];
char *line;
if (fd < 0 || BUFFER_SIZE <= 0)
return (NULL);
content[fd] = ft_gnl_read(fd, content[fd]);
if (!*content[fd])
{
free(content[fd]);
content[fd] = NULL;
return (NULL);
}
line = ft_gnl_extract_line(content[fd]);
content[fd] = ft_gnl_remove_line(content[fd]);
return (line);
}