2022-10-08 10:42:25 +00:00
|
|
|
#include <errno.h>
|
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"
|
|
|
|
{
|
2022-10-03 17:00:10 +00:00
|
|
|
int puts(const char* s)
|
|
|
|
{
|
2022-10-11 19:12:19 +00:00
|
|
|
long nwritten = fwrite(s, strlen(s), 1, stdout);
|
2022-10-08 10:06:09 +00:00
|
|
|
if (nwritten < 0) return -1;
|
2022-10-11 19:12:19 +00:00
|
|
|
nwritten += fwrite("\n", 1, 1, stdout);
|
2022-10-07 16:19:06 +00:00
|
|
|
return (int)nwritten;
|
2022-10-03 17:00:10 +00:00
|
|
|
}
|
2022-10-08 10:42:25 +00:00
|
|
|
void perror(const char* s) // FIXME: Print to stderr, whenever we have an stderr.
|
|
|
|
{
|
2022-10-10 19:08:57 +00:00
|
|
|
int savederr =
|
|
|
|
errno; // This was necessary before, but even more now since we clear errno on successful syscalls now.
|
2022-10-08 10:42:25 +00:00
|
|
|
if (s && *s) { printf("%s: ", s); }
|
2022-10-10 19:08:57 +00:00
|
|
|
printf("%s\n", strerror(savederr));
|
2022-10-08 10:42:25 +00:00
|
|
|
}
|
2022-10-01 18:59:22 +00:00
|
|
|
}
|