static int st_read(int cs) { char buf[BUF_LEN]; int r; while ((r = read(cs, buf, BUF_LEN - 1)) > 0) { buf[r] = '\0'; ft_treat(buf); ft_bzero(buf, BUF_LEN); } if (-1 == close(cs)) return (ft_error("Cant close client socket")); return (OK); }
int ft_str_is_null(int ret, int fd, char **str, char **line) { char *tmp; while (ft_strchr(*line, 10) == NULL && ret > 0) { tmp = ft_strnew(BUFF_SIZE); ret = read(fd, tmp, BUFF_SIZE); *line = ft_treat(line, ret, tmp); } if (ft_strchr(*line, 10) != NULL) { *str = ft_put_in_str(0, 0, line, *str); return (1); } if (ft_strchr(*line, 10) == NULL && ret == 0 && *line[0] != '\0') ret = 1; return (ret); }