aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCabergs Charles <cacharle@w-r4-p5.s19.be>2019-10-08 08:23:40 +0200
committerCabergs Charles <cacharle@w-r4-p5.s19.be>2019-10-08 08:23:40 +0200
commit8e2add1a6c7a923f16162af6b47df577163f7151 (patch)
tree4f62c7582dc4b62ee81ce6efd64c3b9648792e21
parente851a2a0f58cd15c6eba46805e8890613430ffe1 (diff)
downloadget_next_line-8e2add1a6c7a923f16162af6b47df577163f7151.tar.gz
get_next_line-8e2add1a6c7a923f16162af6b47df577163f7151.tar.bz2
get_next_line-8e2add1a6c7a923f16162af6b47df577163f7151.zip
Added Makefile and subject.pdf
-rw-r--r--.gitignore3
-rw-r--r--Makefile44
-rw-r--r--get_next_line.c70
-rw-r--r--subject.en.pdfbin1754321 -> 1366391 bytes
4 files changed, 85 insertions, 32 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..cfaf1c3
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+*.o
+a.out
+get_next_line
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..7e09e9d
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,44 @@
+# **************************************************************************** #
+# #
+# ::: :::::::: #
+# Makefile :+: :+: :+: #
+# +:+ +:+ +:+ #
+# By: cacharle <marvin@42.fr> +#+ +:+ +#+ #
+# +#+#+#+#+#+ +#+ #
+# Created: 2019/10/08 08:11:00 by cacharle #+# #+# #
+# Updated: 2019/10/08 08:21:06 by cacharle ### ########.fr #
+# #
+# **************************************************************************** #
+
+LIBFTPATH = ./libft
+
+CC = gcc
+CCFLAGS = -Wall -Wextra #-Werror
+LDFALGS = -L./libft -lft
+INCLFLAGS = -I./libft
+
+NAME = get_next_line
+SRC = get_next_line.c
+OBJ = $(SRC:.c=.o)
+INCLUDE = get_next_line.h
+
+$(RM) = rm -f
+
+# Makefile must not relink ??
+
+all: $(NAME)
+
+$(NAME): $(OBJ) $(INCLUDE)
+ make -C $(LIBFTPATH)
+ $(CC) $(LDFLAGS) $(CCFLAGS) -o $(NAME) $(OBJ)
+
+%.o: %.c
+ $(CC) $(INCLFLAGS) $(CCFLAGS) -c -o $@ $<
+
+clean:
+ $(RM) $(OBJ)
+
+fclean: clean
+ $(RM) $(NAME)
+
+re: fclean all
diff --git a/get_next_line.c b/get_next_line.c
index a5c2288..39305f5 100644
--- a/get_next_line.c
+++ b/get_next_line.c
@@ -5,43 +5,49 @@
static unsigned int cursor;
-static void *ft_memcat(void *ptr, void *tail,
- unsigned int size, unsigned int tail_size);
+/* static void *ft_memcat(void *ptr, void *tail, */
+/* unsigned int size, unsigned int tail_size); */
int get_next_line(const int fd, char **line)
{
- unsigned int newline_i;
- char buf[BUFF_SIZE];
-
- if (read(fd, buf, BUFF_SIZE) < 0)
- return (-1);
- if ((*line = ft_strnew(0)) == NULL)
- return (-1);
- newline_i = 0;
- while (buf[newline_i])
- {
- while (buf[newline_i] != '\n')
- newline_i++;
- ft_memcat(*line, buf, 0, newline_i);
- if (read(fd, buf, BUFF_SIZE) < 0)
- return (-1);
- }
+ /* unsigned int newline_i; */
+ /* char buf[BUFF_SIZE]; */
+ /* */
+ /* if (read(fd, buf, BUFF_SIZE) < 0) */
+ /* return (-1); */
+ /* if ((*line = ft_strnew(0)) == NULL) */
+ /* return (-1); */
+ /* newline_i = 0; */
+ /* while (buf[newline_i]) */
+ /* { */
+ /* while (buf[newline_i] != '\n') */
+ /* newline_i++; */
+ /* ft_memcat(*line, buf, 0, newline_i); */
+ /* if (read(fd, buf, BUFF_SIZE) < 0) */
+ /* return (-1); */
+ /* } */
return (0);
}
+/* */
+/* static void *ft_memcat(void *ptr, void *tail, */
+/* unsigned int size, unsigned int tail_size) */
+/* { */
+/* void *copy; */
+/* */
+/* if ((copy = malloc(size)) == NULL) */
+/* return (NULL); */
+/* ft_memcpy(copy, ptr, size); */
+/* free(ptr); */
+/* if ((ptr = malloc(size + tail_size)) == NULL) */
+/* return (NULL); */
+/* ft_memcpy(ptr, copy, size); */
+/* free(copy); */
+/* ft_memcpy(ptr + size, tail, tail_size); */
+/* return (ptr); */
+/* } */
-static void *ft_memcat(void *ptr, void *tail,
- unsigned int size, unsigned int tail_size)
+int main()
{
- void *copy;
-
- if ((copy = malloc(size)) == NULL)
- return (NULL);
- ft_memcpy(copy, ptr, size);
- free(ptr);
- if ((ptr = malloc(size + tail_size)) == NULL)
- return (NULL);
- ft_memcpy(ptr, copy, size);
- free(copy);
- ft_memcpy(ptr + size, tail, tail_size);
- return (ptr);
+ printf("test\n");
+ return 0;
}
diff --git a/subject.en.pdf b/subject.en.pdf
index 02525fa..da9882a 100644
--- a/subject.en.pdf
+++ b/subject.en.pdf
Binary files differ