From: Lukas Jiriste Date: Fri, 29 Sep 2023 13:51:03 +0000 (+0200) Subject: Just some bare bones (not even all) of the project. X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=fa229178b5f6228a47627793318c713ce48ceb03;p=42%2Fgnl_tester.git Just some bare bones (not even all) of the project. --- fa229178b5f6228a47627793318c713ce48ceb03 diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..0d9b2a7 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "Libft"] + path = Libft + url = git://78.102.58.167/Libft diff --git a/Libft b/Libft new file mode 160000 index 0000000..ddbbb7c --- /dev/null +++ b/Libft @@ -0,0 +1 @@ +Subproject commit ddbbb7c8475d0ea607f847ddfba7e094217d7333 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e69de29 diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..235710e --- /dev/null +++ b/src/main.c @@ -0,0 +1,64 @@ +#define TEST_DIR "./test_files/" +#define RESULT_DIR "./results/" +#define SEPARATOR "---------------------\n" + +int my_open(const char *fname) +{ + int fd; + char *path; + + path = ft_strdup(TEST_DIR); + ft_strncat_alloc(&path, fname); + fd = open(path, O_RDONLY); + return (fd); +} + +int create_res_file(const char *fname) +{ + int fd; + char *path; + + path = ft_strdup(RESULT_DIR); + ft_strncat_alloc(&path, fname); + fd = open(path, O_WRONLY | O_CREAT); + return (fd); +} + +void test_gnl(int testfd, int resfd) +{ + char *line; + + line = get_next_line(testfd); + while (line) + { + ft_pustr_fd(resfd, line); + ft_putstr_fd(resfd, SEPARATOR); + free(line); + line = get_next_line(testfd); + } + return ; +} + +int main(int argc, char **argv) +{ + int i; + int testfd; + int resfd; + + if (argc < 2) + { + ft_printf("%s\n", "Error: Not enough arguments."); + return (-1); + } + i = 1; + while (i < argc) + { + test = my_open(argv[i]); + result = create_res_file(argv[i]); + test_gnl(testfd, resfd); + close(testfd); + close(resfd); + ++i; + } + return (0); +} diff --git a/test_files/test1 b/test_files/test1 new file mode 100644 index 0000000..7466d6a --- /dev/null +++ b/test_files/test1 @@ -0,0 +1,5 @@ +Just +a +simple +test +.