Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jotavare/get_next_line
Create a function that enables reading content line by line from a file descriptor.
https://github.com/jotavare/get_next_line
buffer c gdb get-next-line gnl makefile norminette static-variables text valgrind
Last synced: about 2 months ago
JSON representation
Create a function that enables reading content line by line from a file descriptor.
- Host: GitHub
- URL: https://github.com/jotavare/get_next_line
- Owner: jotavare
- License: mit
- Created: 2022-12-30T20:51:46.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-06-26T23:01:51.000Z (6 months ago)
- Last Synced: 2024-06-27T02:42:14.120Z (6 months ago)
- Topics: buffer, c, gdb, get-next-line, gnl, makefile, norminette, static-variables, text, valgrind
- Language: C
- Homepage:
- Size: 1.3 MB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
About •
How to use •
Mandatory •
Bonus •
Norminette •
Contributing •
License## ABOUT
This project taught me how to read from a file descriptor and use static variables. This function retrieves a single line from a specified file descriptor. When called in a loop, get_next_line returns all the contents of the file, one line at a time until the end of the file is reached. Additionally, this function can be compiled with any buffer size specified.- [Subject](https://github.com/jotavare/get_next_line/blob/master/subject/en_subject_get_next_line.pdf) `PDF`
- [References](https://github.com/jotavare/42-resources#01-get_next_line) `GitHub`## HOW TO USE
#### 1º - Clone the repository
```git
git clone [email protected]:jotavare/get_next_line.git
```#### 2º - Enter the project folder
```bash
cd get_next_line/get_next_line
```#### 3º - Compile the mandatory or bonus files
> The program should always be compiled with the flags below.
```bash
[Flags] -Wall -Wextra -Werror
[Mandatory] cc [Flags] main.c get_next_line.c get_next_line_utils.c
[Bonus] cc [Flags] main.c get_next_line_bonus.c get_next_line_utils_bonus.c
```#### 4º - BUFFER_SIZE can be specified at compilation to override the default BUFFER_SIZE
> get_next_line should be able to compile with and without the -D BUFFER_SIZE=[SIZE] flag.
```bash
[Flags] -Wall -Wextra -Werror -D BUFFER_SIZE=[SIZE]
[Mandatory] cc [Flags] main.c get_next_line.c get_next_line_utils.c
[Bonus] cc [Flags] main.c get_next_line_bonus.c get_next_line_utils_bonus.c
```#### 5º - Execution with one or multiple file descriptors/standard input
```bash
./a.out [text.txt]
./a.out [text1.txt] [text2.txt]
```## MANDATORY
- [x] Read from one file descriptor, one line at a time.
- [x] Needs to return the line that was read. If empty or error, return `NULL`.
- [x] Should work as expected reading from a file or standard input.
- [x] Returned line should include the terminating `\n` character, except if it's the end of the file and the line does not end with `\n`.
- [x] The `get_next_line.h` header file should include at least the `get_next_line()` function.
- [x] All adicional functions should be included in `get_next_line_utils.c` file, libft is not allowed.
- [x] To define the buffer size for `read()`, add the option to the compiled file `-D BUFFER_SIZE=[SIZE]`.## BONUS
- [x] Use only one static variable.
- [x] Manage multiple file descriptors at the same time.
- [x] Bonus files should include a suffix `_bonus.[c/h]`.## NORMINETTE
> At 42 School, it is expected that almost every project is written following the Norm, which is the coding standard of the school.```
- No for, do...while, switch, case, goto, ternary operators, or variable-length arrays allowed;
- Each function must be a maximum of 25 lines, not counting the function's curly brackets;
- Each line must be at most 80 columns wide, with comments included;
- A function can take 4 named parameters maximum;
- No assigns and declarations in the same line (unless static);
- You can't declare more than 5 variables per function;
- ...
```* [42 Norms](https://github.com/42School/norminette/blob/master/pdf/en.norm.pdf) - Information about 42 code norms. `PDF`
* [Norminette](https://github.com/42School/norminette) - Tool to respect the code norm, made by 42. `GitHub`
* [42 Header](https://github.com/42Paris/42header) - 42 header for Vim. `GitHub`## CONTRIBUTING
If you find any issues or have suggestions for improvements, feel free to fork the repository and open an issue or submit a pull request.
## LICENSE
This project is available under the MIT License. For further details, please refer to the [LICENSE](https://github.com/jotavare/get_next_line/blob/master/LICENSE) file.