-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
65 lines (55 loc) · 1.98 KB
/
main.c
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
55
56
57
58
59
60
61
62
63
64
65
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apuchill <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/06 17:31:30 by apuchill #+# #+# */
/* Updated: 2020/05/02 13:44:16 by apuchill ### ########.fr */
/* */
/* ************************************************************************** */
#include "../get_next_line.h"
#include <stdio.h>
#include <fcntl.h>
#define MAIN(string) "\033[1m\033[38;5;199m" string "\033[0m"
#define MAIN_1(string) "\033[35m" string "\033[0m"
#define HEADER_1(string) "\033[38;5;43m" string "\033[0m"
#define HEADER_2(string) "\033[38;5;75m" string "\033[0m"
#define HIGHLIGHT(string) "\033[38;5;191m" string "\033[0m"
void test(int fd)
{
char *line;
int ret;
int i;
line = NULL;
printf("> fd = %d\n", fd);
i = 1;
ret = 1;
while (ret == 1)
{
ret = get_next_line(fd, &line);
printf(HEADER_2("• Line n.%d ") HEADER_1("[RET=%d]: ") "\"%s\"\n", i, ret, line);
free(line);
line = NULL;
i++;
}
close(fd);
}
int main(void)
{
printf(MAIN("=== • Program started • ===\n"));
printf(MAIN_1("=== empty file ===\n"));
int fda;
fda = open("txt_files/t_empty.txt", O_RDONLY);
test(fda);
printf(MAIN_1("=== \\n file ===\n"));
int fdb;
fdb = open("txt_files/t_n.txt", O_RDONLY);
test(fdb);
printf(MAIN_1("=== Le Petit Prince ===\n"));
int fdc;
fdc = open("txt_files/t_ptiprinc.txt", O_RDONLY);
test(fdc);
printf(MAIN("=== • Program ended • ===\n\n"));
}