blob: 10f683a5baf8603657aa9e7267101382a097013f (
plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
/* ************************************************************************** */
/* LE - / */
/* / */
/* ft_history.c .:: .:/ . .:: */
/* +:+:+ +: +: +:+:+ */
/* By: rbousset <marvin@le-101.fr> +:+ +: +: +:+ */
/* #+# #+ #+ #+# */
/* Created: 2019/10/30 20:36:05 by rbousset #+# ## ## #+# */
/* Updated: 2019/10/30 20:36:07 by rbousset ### #+. /#+ ###.fr */
/* / */
/* / */
/* ************************************************************************** */
#include <libft.h>
#include <minishell.h>
#include <stdlib.h>
#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 *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);
}
|