Get_next_line(GNL) is the fuction, which returns a line ending with a newline, read from a file descriptor.
-
Get_Next_Line_Tester by Hellio404
git clone https://github.com/kohyounghwan/Get_Next_Line_Tester
-
42TESTERS-GNL by Mazoise
git clone https://github.com/Mazoise/42TESTERS-GNL.git
-
gnlkiller by DontBreakAlex
git clone https://github.com/DontBreakAlex/gnlkiller.git
-
GNL_lover by charMstr
git clone https://github.com/charMstr/GNL_lover.git
-
42cursus_gnl_tests by mrjvs
git clone https://github.com/mrjvs/42cursus_gnl_tests.git
-
gnl-war-machine-v2019 by Alexandre94H
git clone https://github.com/Alexandre94H/gnl-war-machine-v2019.git
- The function(get_next_line) will store, in the parameter "line", a line that has been read from the file descriptors.
- It should be memory leak free.
- What we call a "line that has been read" is a succession of 0 to n characters that end with '\n' (ascii code 0x0a) or with End Of File (EOF).
- The string stored in the parameter "line" should not contained any '\n'.
- The parameter(line) is the address of a pointer to a character that will be used to store the line read.
- The return value can be 1, 0 or -1 depending on whether a line has been read, when the reading has been completed (meaning read has returned 0), or if an error has happened respectively.
- When you've reached the End Of File, you must store the current buffer in "line". If the buffer is empty you must store an empty string in "line".
- When you've reached the End Of File, your function should keep 0 memory allocated with malloc except the last buffer that you should have stored in "line".
- What you've stored in "line" should be free-able.
- Calling your function get_next_line in a loop will therefore allow you to read the text available on a file descriptor one line at a time until the end of the text, no matter the size of either the text or one of its lines.
- Make sure that your function behaves well when it reads from a file, from the standard output, from a redirection etc.
- Finally we consider that get_next_line has an undefined behavior when reading from a binary file.
In addition to the mandatory part, the following rules are added:
- It should work on the file descriptors between several calls of get_next_line.
- It should use a single static variable.