/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* m_loop_counter.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: rbousset +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/14 17:19:27 by rbousset #+# #+# */ /* Updated: 2020/02/14 17:19:29 by rbousset ### ########lyon.fr */ /* */ /* ************************************************************************** */ #include #include #include "c_init.h" #include "m_prompt.h" #include "s_struct.h" char *m_counter_line_backslash(int fd, unsigned char psx, char *l, t_msh *msh) { char *counter_line; if (fd == STDIN_FILENO) c_gnl(fd, &counter_line, psx, msh); else get_next_line(fd, &counter_line); l = ft_nrealloc(l, ft_strlen(l) + 1, ft_strlen(l) + ft_strlen(counter_line)); ft_memcpy(l + ft_strlen(l) - 1, counter_line, ft_strlen(counter_line) + 1); ft_memdel((void*)&counter_line); return (l); } char *m_counter_line_pipes(int fd, unsigned char psx, char *line, t_msh *msh) { char *counter_line; if (fd == STDIN_FILENO) c_gnl(fd, &counter_line, psx, msh); else get_next_line(fd, &counter_line); if (counter_line[0] != C_NUL) { line = ft_nrealloc(line, ft_strlen(line) + 1, ft_strlen(line) + ft_strlen(counter_line) + 1); ft_memcpy(line + ft_strlen(line), counter_line, ft_strlen(counter_line) + 1); } ft_memdel((void*)&counter_line); return (line); } char *m_counter_line_quotes(int fd, unsigned char psx, char *line, t_msh *msh) { char *counter_line; if (fd == STDIN_FILENO) c_gnl(fd, &counter_line, psx, msh); else get_next_line(fd, &counter_line); if (counter_line[0] != C_NUL) { line = ft_nrealloc(line, ft_strlen(line) + 1, ft_strlen(line) + ft_strlen(counter_line) + 2); line[ft_strlen(line) + 1] = '\0'; line[ft_strlen(line)] = '\n'; ft_memcpy(line + ft_strlen(line), counter_line, ft_strlen(counter_line) + 1); } ft_memdel((void*)&counter_line); return (line); }