{"id":27151644,"url":"https://github.com/0xromjobert/get_next_line","last_synced_at":"2025-04-08T14:54:48.756Z","repository":{"id":180514422,"uuid":"647911023","full_name":"0xromjobert/get_next_line","owner":"0xromjobert","description":"get_next_line is a 42 school project designed to read from a file descriptor and learn to use static variables","archived":false,"fork":false,"pushed_at":"2023-08-16T18:41:34.000Z","size":3248,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-31T18:46:55.612Z","etag":null,"topics":["c","linked-list","static-variables"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/0xromjobert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-31T19:43:38.000Z","updated_at":"2023-07-11T19:16:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"c392e2c4-9bf8-4af9-a8c8-5880bf3f641c","html_url":"https://github.com/0xromjobert/get_next_line","commit_stats":null,"previous_names":["romz8/get_next_line","0xromjobert/get_next_line"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xromjobert%2Fget_next_line","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xromjobert%2Fget_next_line/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xromjobert%2Fget_next_line/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xromjobert%2Fget_next_line/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0xromjobert","download_url":"https://codeload.github.com/0xromjobert/get_next_line/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247866107,"owners_count":21009239,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","linked-list","static-variables"],"created_at":"2025-04-08T14:54:48.046Z","updated_at":"2025-04-08T14:54:48.750Z","avatar_url":"https://github.com/0xromjobert.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# get_next_line\n\nThis 42 school project is aimed at reading a line from a file descriptor.\nIf called in a loop, `get_next_line` should return the entire content one line at a time, until the end of the file is reached.\nWhen compiling it, we should be able to modify the buffer size.\n\n## Status\nFinished : 14-06-2023.  \n\nGrade : 125/100.\n\n## Usage\n### compiling Mandatory part\n```shell\ncc get_next_line.c get_next_line.h get_next_line_utils.c main_for_test/main.c\n```\n### compiling Bonus part\n```shell\ncc *_bonus.c main_for_test/main_bonus.c\n```\n\n`BUFFER_SIZE` can be changed at compilation using the command `-D BUFFER_SIZE`. For instance to read byte-by-byte:\n```shell\ncc -D BUFFER_SIZE=1 get_next_line.c get_next_line.h get_next_line_utils.c main_for_test/main.c\n```\n### Execution \n\nTo test with a file :  `./a.out` to execute. \nOtherwise in case of manual input test, you will need to use `main_manual_input.c` execute with `./a.out /dev/tty`\nand then entire your text - stop at any moment with `ctrc + c`\n\n## Example of test result expected\nhere is result of the bonus expected : one line from each fd at a time.\n![test resutls](/img/test.png)\n## Explanation of the program\nWe are using linked lists as a static variable to read each `buffer_size` number of bytes from the file (mapped by the `fd`) into each node as long as there is text or we encounter a `\\n`. we then handle the last node to only keep the characters placed after `\\n` that were read in the last buffer. \nWe then clear the list, make it match the new node with characters after the `\\n`, so that next call of `get_next_line()` will build the next linked list on top of the previous call words happenign after the `\\n` ... and so on until we reach end of file.\n\n![flow chart](/img/flow_chart.png)\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xromjobert%2Fget_next_line","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0xromjobert%2Fget_next_line","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xromjobert%2Fget_next_line/lists"}