/* ************************************************************************** */ /* LE - / */ /* / */ /* ft_history.c .:: .:/ . .:: */ /* +:+:+ +: +: +:+:+ */ /* By: rbousset +:+ +: +: +:+ */ /* #+# #+ #+ #+# */ /* Created: 2019/10/30 20:36:05 by rbousset #+# ## ## #+# */ /* Updated: 2019/10/30 20:36:07 by rbousset ### #+. /#+ ###.fr */ /* / */ /* / */ /* ************************************************************************** */ #include #include #include #include #include #include #include #include char *ft_get_last_line(void) { // char *buff; int fd; struct stat info; if ((fd = open("joe-sh_history", O_CREAT | O_RDWR, 0644)) == -1) return (NULL); fstat(fd, &info); return ("qweqwe"); } int ft_history(char *arg) { char *buff; int fd; struct stat info; if (!*arg) return (0); if ((fd = open("joe-sh_history", O_CREAT | O_RDWR, 0644)) == -1) return (1); fstat(fd, &info); if (!(buff = (char*)malloc(info.st_size * sizeof(char)))) return (0); read(fd, buff, info.st_size); ft_putendl_fd(arg, fd); close(fd); return (0); }