#include #include //max_length and return value include null-terminator uint32_t read_line(fs_handle handle, uint32_t max_length, void *buffer) { int index = 0; while (++index < max_length) { if (!fs_read(handle, 1, buffer + index - 1) || (*(uint8_t *)(buffer + index - 1) == '\n')) break; } *(uint8_t *)(buffer + index - 1) = '\0'; return index; }