blob: 5da37346113128fa4d4a2d4f086677d38e9b57f6 (
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
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/10 09:27:41 by cacharle #+# #+# */
/* Updated: 2019/10/27 19:08:20 by cacharle ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <limits.h>
#include "get_next_line.h"
int main(int argc, char **argv)
{
int i;
int fd;
char *line;
int ret;
printf("limit fdmax %d\n", OPEN_MAX);
if (argc != 2)
{
printf("You forgot the filename");
exit(1);
}
printf("BUFFER_SIZE = %d\n", BUFFER_SIZE);
fd = open(argv[1], O_RDONLY);
i = 0;
while ((ret = get_next_line(fd, &line)) == LINE_READ)
{
printf("%3d [%s]\n", ++i, line);
free(line);
}
if (ret == -1)
printf("error\n");
else if (ret == 0)
printf("EOF\n");
close(fd);
return (0);
}
|