Skip to content
Snippets Groups Projects
Commit c0229ed9 authored by Byron Lathi's avatar Byron Lathi
Browse files

add a null character when stopped early

parent fd4d7595
No related branches found
No related tags found
No related merge requests found
#include <types.h>
#include <lib.h>
#include <Devices/keyboard.h>
#include "terminal.h"
int32_t terminal_read(int32_t fd, void* buf, int32_t nbytes){
return -1;
int bytes_read = 0;
while (bytes_read < nbytes) {
uint8_t key = keyboard_get_key();
if (key == '\n') {
*((uint8_t*)buf + bytes_read) = '\0';
break;
}
*((uint8_t*)buf + bytes_read) = key;
bytes_read++;
}
return 0;
}
int32_t terminal_write(int32_t fd, const void* buf, int32_t nbytes)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment