From 2ba78cf22f6f0f7c488d0d4cb606c05a841474f2 Mon Sep 17 00:00:00 2001 From: Aki Date: Tue, 15 Feb 2022 00:14:59 +0100 Subject: Exported infamous Print to FoundationEx --- FoundationEx/CMakeLists.txt | 1 + FoundationEx/Utils.cpp | 39 +++++++++++++++++++++++++++++++++++++++ FoundationEx/Utils.h | 17 +++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 FoundationEx/Utils.cpp create mode 100644 FoundationEx/Utils.h (limited to 'FoundationEx') diff --git a/FoundationEx/CMakeLists.txt b/FoundationEx/CMakeLists.txt index 8672619..c2b546b 100644 --- a/FoundationEx/CMakeLists.txt +++ b/FoundationEx/CMakeLists.txt @@ -4,6 +4,7 @@ add_library( STATIC MemDebug.cpp Text.cpp + Utils.cpp ) target_include_directories( FoundationEx diff --git a/FoundationEx/Utils.cpp b/FoundationEx/Utils.cpp new file mode 100644 index 0000000..8a9f157 --- /dev/null +++ b/FoundationEx/Utils.cpp @@ -0,0 +1,39 @@ +/* Starshatter: The Open Source Project + Copyright (c) 2021-2022, Starshatter: The Open Source Project Contributors + Copyright (c) 2011-2012, Starshatter OpenSource Distribution Contributors + Copyright (c) 1997-2006, Destroyer Studios LLC. +*/ + +#include +#include + + +FILE* ErrLog = nullptr; + + +void AssignErrLog(FILE * out) +{ + ErrLog = out; +} + + +int CloseErrLog() +{ + if (ErrLog) + return fclose(Errlog); + return 0; +} + + +void Print(const char* fmt, ...) +{ + if (!ErrLog) return; + va_list args; + va_start(args, fmt); + vfprintf_s(ErrLog, fmt, args); + fflush(ErrLog); + va_end(args); +} + + +#endif // Utils_h diff --git a/FoundationEx/Utils.h b/FoundationEx/Utils.h new file mode 100644 index 0000000..da7b66d --- /dev/null +++ b/FoundationEx/Utils.h @@ -0,0 +1,17 @@ +/* Starshatter: The Open Source Project + Copyright (c) 2021-2022, Starshatter: The Open Source Project Contributors + Copyright (c) 2011-2012, Starshatter OpenSource Distribution Contributors + Copyright (c) 1997-2006, Destroyer Studios LLC. +*/ + +#ifndef Utils_h +#define Utils_h + +#include + + +void AssignErrLog(FILE * out); +void CloseErrLog(); +void Print(const char* fmt, ...); + +#endif // Utils_h -- cgit v1.1