Just some bare bones (not even all) of the project.
authorLukas Jiriste <ljiriste@student.42prague.com>
Fri, 29 Sep 2023 13:51:03 +0000 (15:51 +0200)
committerLukas Jiriste <ljiriste@student.42prague.com>
Fri, 29 Sep 2023 13:51:03 +0000 (15:51 +0200)
.gitmodules [new file with mode: 0644]
Libft [new submodule]
Makefile [new file with mode: 0644]
src/main.c [new file with mode: 0644]
test_files/test1 [new file with mode: 0644]

diff --git a/.gitmodules b/.gitmodules
new file mode 100644 (file)
index 0000000..0d9b2a7
--- /dev/null
@@ -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 (submodule)
index 0000000..ddbbb7c
--- /dev/null
+++ b/Libft
@@ -0,0 +1 @@
+Subproject commit ddbbb7c8475d0ea607f847ddfba7e094217d7333
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/main.c b/src/main.c
new file mode 100644 (file)
index 0000000..235710e
--- /dev/null
@@ -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 (file)
index 0000000..7466d6a
--- /dev/null
@@ -0,0 +1,5 @@
+Just
+a
+simple
+test
+.