diff options
author | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2024-10-14 22:44:52 +0200 |
---|---|---|
committer | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2024-12-20 15:35:58 +0100 |
commit | 7193114b152d3a5b714a22f54ed89950c0ba9aba (patch) | |
tree | 7d42317b3ca11239e9135ea13d7788f924cc107c /asl/print.cpp | |
parent | f011d871ef3af26c8f4e19de2c8d781c601ceffb (diff) |
Use libc instead of Win32
Diffstat (limited to 'asl/print.cpp')
-rw-r--r-- | asl/print.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/asl/print.cpp b/asl/print.cpp new file mode 100644 index 0000000..6e43bb3 --- /dev/null +++ b/asl/print.cpp @@ -0,0 +1,31 @@ +#include "asl/print.hpp"
+
+#include <cstdio>
+
+// @Todo Optimize this, maybe make buffered
+class ConsoleWriter : public asl::writer
+{
+ FILE* m_handle;
+
+public:
+ explicit ConsoleWriter(FILE* handle)
+ : m_handle{handle}
+ {}
+
+ void write(const char* str, int64_t len) override
+ {
+ fwrite(str, 1, static_cast<size_t>(len), m_handle);
+ }
+};
+
+asl::writer* asl::print_internals::get_stdout_writer()
+{
+ static ConsoleWriter writer{stdout};
+ return &writer;
+}
+
+asl::writer* asl::print_internals::get_stderr_writer()
+{
+ static ConsoleWriter writer{stderr};
+ return &writer;
+}
|