Files
Espresso/lib/stdio.c

63 lines
851 B
C
Raw Permalink Normal View History

2025-06-17 15:50:07 -05:00
#include <drivers/ps2_keyboard.h>
#include <fs/vfs.h>
#include <stdio.h>
extern bool ps2keyboard_initialized;
char getchar(void)
{
if (ps2keyboard_initialized)
{
return get_char();
}
return '\0';
}
char* getstring(void)
{
if (ps2keyboard_initialized)
{
return get_string();
}
return "HELLO\0";
}
2025-07-01 20:39:38 -05:00
/*char* fgets(char* buf, int n, FILE file)
2025-06-17 15:50:07 -05:00
{
if (!buf || n <= 1 || file < 1)
{
return NULL;
}
int total_read = 0;
char c;
while (total_read < n - 1)
{
2025-07-01 20:39:38 -05:00
int bytes = 0*//*read_file(file, &c, 1)*/;
2025-06-17 15:50:07 -05:00
2025-07-01 20:39:38 -05:00
/*if (bytes <= 0)
2025-06-17 15:50:07 -05:00
{
2025-07-01 20:39:38 -05:00
break; *//* EOF or error */
/*}
2025-06-17 15:50:07 -05:00
buf[total_read++] = c;
if (c == '\n')
{
2025-07-01 20:39:38 -05:00
break; *//* Stop at newline */
/*}
2025-06-17 15:50:07 -05:00
}
if (total_read == 0)
{
2025-07-01 20:39:38 -05:00
return NULL; *//* Nothing read (e.g. EOF) */
/*}
2025-06-17 15:50:07 -05:00
buf[total_read] = '\0';
return buf;
2025-07-01 20:39:38 -05:00
}*/