Transform readline into a globally accessible function.

This commit is contained in:
Enrico Fraccaroli (Galfurian)
2023-08-30 15:38:24 -04:00
parent 78c1ff4bd4
commit ecf5907f83
3 changed files with 73 additions and 36 deletions
+14
View File
@@ -0,0 +1,14 @@
/// @file readline.h
/// @brief
/// @copyright (c) 2014-2023 This file is distributed under the MIT License.
/// See LICENSE.md for details.
#include "stddef.h"
/// @brief Reads a line from the file.
/// @param fd the file descriptor.
/// @param buffer the buffer where we place the line.
/// @param buflen the length of the buffer.
/// @param readlen the amount we read, if negative, we did not encounter a newline.
/// @return 0 if we are done reading, 1 if we encountered a newline, -1 if otherwise.
int readline(int fd, char *buffer, size_t buflen, ssize_t *read_len);