Luna/libs/libc/src/stdio.cpp

80 lines
1.7 KiB
C++

#include <luna.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/syscall.h>
#include <unistd.h>
extern "C"
{
int fclose(FILE*)
{
NOT_IMPLEMENTED("fclose");
}
int fflush(FILE*)
{
NOT_IMPLEMENTED("fflush");
}
FILE* fopen(const char*, const char*)
{
NOT_IMPLEMENTED("fopen");
}
int fprintf(FILE*, const char*, ...)
{
NOT_IMPLEMENTED("fprintf");
}
size_t fread(void*, size_t, size_t, FILE*)
{
NOT_IMPLEMENTED("fread");
}
int fseek(FILE*, long, int)
{
NOT_IMPLEMENTED("fseek");
}
long ftell(FILE*)
{
NOT_IMPLEMENTED("ftell");
}
size_t fwrite(const void*, size_t, size_t, FILE*)
{
NOT_IMPLEMENTED("fwrite");
}
void setbuf(FILE*, char*)
{
NOT_IMPLEMENTED("setbuf");
}
int vfprintf(FILE*, const char*, va_list)
{
NOT_IMPLEMENTED("vfprintf");
}
int puts(const char* s)
{
long nwritten = syscall(SYS_write, s, strlen(s));
nwritten += syscall(SYS_write, "\n", 1);
return (int)nwritten;
}
int snprintf(char* str, size_t max, const char* format, ...)
{
va_list ap;
va_start(ap, format);
int written = vsnprintf(str, max, format, ap);
va_end(ap);
return written;
}
int sprintf(char* str, const char* format, ...)
{
va_list ap;
va_start(ap, format);
int written = vsprintf(str, format, ap);
va_end(ap);
return written;
}
int printf(const char* format, ...)
{
va_list ap;
va_start(ap, format);
int written = vprintf(format, ap);
va_end(ap);
return written;
}
}