#include #include #include #include #include #include #include extern "C" { int puts(const char* s) { int nwritten = fputs(s, stdout); if (nwritten < 0) return -1; if (putchar('\n') < 0) return -1; return nwritten + 1; } int fputs(const char* s, FILE* stream) { int result = (int)fwrite(s, strlen(s), 1, stream); if (ferror(stream)) return -1; return result; } int fputc(int c, FILE* stream) { char chr = (char)c; fwrite(&chr, 1, 1, stream); if (ferror(stream)) { return -1; } return c; } int putc(int c, FILE* stream) { return fputc(c, stream); } int putchar(int c) { return fputc(c, stdout); } void perror(const char* s) { int savederr = errno; // This was necessary before, but even more now since we clear errno on successful syscalls now. if (s && *s) { fprintf(stderr, "%s: ", s); } fprintf(stderr, "%s\n", strerror(savederr)); } int remove(const char*) { NOT_IMPLEMENTED("remove"); } int sscanf(const char*, const char*, ...) { NOT_IMPLEMENTED("sscanf"); } int fscanf(FILE*, const char*, ...) { NOT_IMPLEMENTED("fscanf"); } int rename(const char*, const char*) { NOT_IMPLEMENTED("rename"); } FILE* tmpfile() { errno = ENOTSUP; return NULL; } }