2022-10-02 16:10:53 +00:00
|
|
|
#include <luna.h>
|
2022-10-01 18:59:22 +00:00
|
|
|
#include <stdio.h>
|
2022-10-03 17:00:10 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/syscall.h>
|
|
|
|
#include <unistd.h>
|
2022-10-01 18:59:22 +00:00
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
int fclose(FILE*)
|
|
|
|
{
|
2022-10-02 16:10:53 +00:00
|
|
|
NOT_IMPLEMENTED("fclose");
|
2022-10-01 18:59:22 +00:00
|
|
|
}
|
|
|
|
int fflush(FILE*)
|
|
|
|
{
|
2022-10-02 16:10:53 +00:00
|
|
|
NOT_IMPLEMENTED("fflush");
|
2022-10-01 18:59:22 +00:00
|
|
|
}
|
|
|
|
FILE* fopen(const char*, const char*)
|
|
|
|
{
|
2022-10-02 16:10:53 +00:00
|
|
|
NOT_IMPLEMENTED("fopen");
|
2022-10-01 18:59:22 +00:00
|
|
|
}
|
|
|
|
int fprintf(FILE*, const char*, ...)
|
|
|
|
{
|
2022-10-02 16:10:53 +00:00
|
|
|
NOT_IMPLEMENTED("fprintf");
|
2022-10-01 18:59:22 +00:00
|
|
|
}
|
|
|
|
size_t fread(void*, size_t, size_t, FILE*)
|
|
|
|
{
|
2022-10-02 16:10:53 +00:00
|
|
|
NOT_IMPLEMENTED("fread");
|
2022-10-01 18:59:22 +00:00
|
|
|
}
|
|
|
|
int fseek(FILE*, long, int)
|
|
|
|
{
|
2022-10-02 16:10:53 +00:00
|
|
|
NOT_IMPLEMENTED("fseek");
|
2022-10-01 18:59:22 +00:00
|
|
|
}
|
|
|
|
long ftell(FILE*)
|
|
|
|
{
|
2022-10-02 16:10:53 +00:00
|
|
|
NOT_IMPLEMENTED("ftell");
|
2022-10-01 18:59:22 +00:00
|
|
|
}
|
|
|
|
size_t fwrite(const void*, size_t, size_t, FILE*)
|
|
|
|
{
|
2022-10-02 16:10:53 +00:00
|
|
|
NOT_IMPLEMENTED("fwrite");
|
2022-10-01 18:59:22 +00:00
|
|
|
}
|
|
|
|
void setbuf(FILE*, char*)
|
|
|
|
{
|
2022-10-02 16:10:53 +00:00
|
|
|
NOT_IMPLEMENTED("setbuf");
|
2022-10-01 18:59:22 +00:00
|
|
|
}
|
|
|
|
int vfprintf(FILE*, const char*, va_list)
|
|
|
|
{
|
2022-10-02 16:10:53 +00:00
|
|
|
NOT_IMPLEMENTED("vfprintf");
|
2022-10-01 18:59:22 +00:00
|
|
|
}
|
2022-10-03 17:00:10 +00:00
|
|
|
int puts(const char* s)
|
|
|
|
{
|
2022-10-03 17:05:04 +00:00
|
|
|
long nwritten = syscall(SYS_write, s, strlen(s));
|
2022-10-08 10:06:09 +00:00
|
|
|
if (nwritten < 0) return -1;
|
2022-10-03 17:05:04 +00:00
|
|
|
nwritten += syscall(SYS_write, "\n", 1);
|
2022-10-07 16:19:06 +00:00
|
|
|
return (int)nwritten;
|
2022-10-03 17:00:10 +00:00
|
|
|
}
|
2022-10-03 17:59:33 +00:00
|
|
|
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;
|
|
|
|
}
|
2022-10-01 18:59:22 +00:00
|
|
|
}
|