summaryrefslogtreecommitdiffstats
path: root/src/ft_history.c
diff options
context:
space:
mode:
authorRudy Bousset <rbousset@z2r5p6.le-101.fr>2019-11-01 15:20:41 +0100
committerRudy Bousset <rbousset@z2r5p6.le-101.fr>2019-11-01 15:20:41 +0100
commit9f5b079ed0b2d315eab2c1870f7946d58893f0ca (patch)
treee99675d940e97a2e2a9c98f43a4652d536f4a471 /src/ft_history.c
parentchanges (diff)
download42-minishell-9f5b079ed0b2d315eab2c1870f7946d58893f0ca.tar.gz
42-minishell-9f5b079ed0b2d315eab2c1870f7946d58893f0ca.tar.bz2
42-minishell-9f5b079ed0b2d315eab2c1870f7946d58893f0ca.tar.xz
42-minishell-9f5b079ed0b2d315eab2c1870f7946d58893f0ca.tar.zst
42-minishell-9f5b079ed0b2d315eab2c1870f7946d58893f0ca.zip
YO PICKED THE WRONG FOOL, HOUSE
Diffstat (limited to 'src/ft_history.c')
-rw-r--r--src/ft_history.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/ft_history.c b/src/ft_history.c
index 6a82a16..10f683a 100644
--- a/src/ft_history.c
+++ b/src/ft_history.c
@@ -17,18 +17,37 @@
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+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 c;
+ char *buff;
int fd;
- int r;
+ struct stat info;
+ if (!*arg)
+ return (0);
if ((fd = open("joe-sh_history", O_CREAT | O_RDWR, 0644)) == -1)
return (1);
- while ((r = read(fd, &c, 1)) != EOF)
- puts(&c);
+ 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);