Fixed the Logging system to actually be able to handle errors. Database is also fixed to use directories.
This commit is contained in:
parent
2734cc00fb
commit
f030ac62ae
@ -9,26 +9,53 @@
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
class Log;
|
||||
|
||||
typedef void (*LogRaisedCb)(const Log &);
|
||||
typedef void (*LogOutputCb)(const Array<Log> &);
|
||||
|
||||
enum class LogType : UInt_8
|
||||
{
|
||||
SUCCESS,
|
||||
ERR,
|
||||
WARN,
|
||||
INFO
|
||||
};
|
||||
|
||||
/// A helper class for holding error information and handling them.
|
||||
/// @tparam T The character data type to use.
|
||||
/// @tparam N The number data type to use.
|
||||
class Log
|
||||
{
|
||||
private:
|
||||
static void (*logCb)(const Log&);
|
||||
static void DefaultRaisedCb(const Log &log);
|
||||
|
||||
static void DefaultOutputCb(const Array<Log> &logs);
|
||||
|
||||
static LogRaisedCb raisedCb;
|
||||
static LogOutputCb outputCb;
|
||||
static Array<Log> logs;
|
||||
static Log lastLog;
|
||||
static bool immediate;
|
||||
LogType type;
|
||||
Array<Str_8> tags;
|
||||
UInt_64 code;
|
||||
Str_8 msg;
|
||||
|
||||
public:
|
||||
static void SetCallback(void (*newLogCb)(const Log&));
|
||||
static void SetRaisedCallback(LogRaisedCb newCb);
|
||||
|
||||
static void Raise(const Log& log);
|
||||
static void SetOutputCallback(LogOutputCb newCb);
|
||||
|
||||
static void OnExit();
|
||||
|
||||
static void Raise(Log log);
|
||||
|
||||
/// Retrieves the last log raised.
|
||||
static Log GetLastLog();
|
||||
|
||||
static void EnableImmediateMode(bool enable);
|
||||
|
||||
/// Default members initialization.
|
||||
Log();
|
||||
|
||||
@ -36,18 +63,22 @@ namespace ehs
|
||||
/// @param [in] tags The tags to associate this log with.
|
||||
/// @param [in] code The unique code to use.
|
||||
/// @param [in] msg Detailed information about what happened.
|
||||
Log(std::initializer_list<Str_8> tags, const UInt_64 code, const Str_8& msg);
|
||||
Log(LogType type, const std::initializer_list<Str_8> &tags, UInt_64 code, Str_8 msg);
|
||||
|
||||
/// Initializes members with the given information.
|
||||
/// @param [in] tags The tags to associate this log with.
|
||||
/// @param [in] code The unique code to use.
|
||||
/// @param [in] msg Detailed information about what happened.
|
||||
Log(Array<Str_8>& tags, const UInt_64 code, const Str_8& msg);
|
||||
Log(LogType type, Array<Str_8> tags, UInt_64 code, Str_8 msg);
|
||||
|
||||
Log(Log &&log) noexcept;
|
||||
|
||||
/// Copies all members from the given log.
|
||||
/// @param [in] log The log to copy from.
|
||||
Log(const Log &log);
|
||||
|
||||
Log &operator=(Log &&log) noexcept;
|
||||
|
||||
/// Copies all members from the given log.
|
||||
/// @param [in] log The log to copy from.
|
||||
/// @returns The log that has been assigned to.
|
||||
@ -65,10 +96,12 @@ namespace ehs
|
||||
bool operator!=(const Log log);
|
||||
*/
|
||||
|
||||
LogType GetType() const;
|
||||
|
||||
/// Checks whether or not this log has the given tags.
|
||||
/// @param [in] tags The tags to look for.
|
||||
/// @returns True if all tags were found, otherwise false.
|
||||
bool HasTags(const std::initializer_list<Str_8> tags) const;
|
||||
bool HasTags(const std::initializer_list<Str_8> &tags) const;
|
||||
|
||||
/// Checks whether or not this log has the given tags.
|
||||
/// @param [in] tags The tags to look for.
|
||||
@ -82,7 +115,7 @@ namespace ehs
|
||||
|
||||
/// Retrieves all the tags.
|
||||
/// @returns The result.
|
||||
Array<Str_8> GetTags() const;
|
||||
const Array<Str_8> &GetTags() const;
|
||||
|
||||
UInt_64 GetCode() const;
|
||||
|
||||
@ -101,16 +134,20 @@ namespace ehs
|
||||
|
||||
#ifndef EHS_LOG_INT
|
||||
#ifdef EHS_DEBUG
|
||||
#define EHS_LOG_INT(type, code, msg) Log::Raise({{type, GetAcronym_8(), EHS_FILE, EHS_FUNC, Str_8::FromNum((UInt_32)EHS_LINE)}, code, msg})
|
||||
#define EHS_LOG_INT(type, code, msg) ehs::Log::Raise({type, {ehs::GetAcronym_8(), EHS_FILE, EHS_FUNC, ehs::Str_8::FromNum((ehs::UInt_32)EHS_LINE)}, code, msg})
|
||||
#else
|
||||
#define EHS_LOG_INT(type, code, msg) Log::Raise({{type, GetAcronym_8(), EHS_FUNC}, code, msg})
|
||||
#define EHS_LOG_INT(type, code, msg) ehs::Log::Raise({type, {ehs::GetAcronym_8(), EHS_FUNC}, code, msg})
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef EHS_LOG
|
||||
#ifdef EHS_DEBUG
|
||||
#define EHS_LOG(type, code, msg) ehs::Log::Raise({{type, ehs::GetAppName_8(), EHS_FILE, EHS_FUNC, ehs::Str_8::FromNum((ehs::UInt_32)EHS_LINE)}, code, msg})
|
||||
#define EHS_LOG(type, code, msg) ehs::Log::Raise({type, {ehs::GetAppName_8(), EHS_FILE, EHS_FUNC, ehs::Str_8::FromNum((ehs::UInt_32)EHS_LINE)}, code, msg})
|
||||
#else
|
||||
#define EHS_LOG(type, code, msg) ehs::Log::Raise({{type, ehs::GetAppName_8(), EHS_FUNC}, code, msg})
|
||||
#define EHS_LOG(type, code, msg) ehs::Log::Raise({type, {ehs::GetAppName_8(), EHS_FUNC}, code, msg})
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef EHS_LOG_SUCCESS
|
||||
#define EHS_LOG_SUCCESS() ehs::Log::Raise({})
|
||||
#endif
|
@ -130,7 +130,7 @@ namespace ehs
|
||||
case 3:
|
||||
return h;
|
||||
default:
|
||||
EHS_LOG_INT("Error", 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Rectangle.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Rectangle.");
|
||||
return x;
|
||||
}
|
||||
}
|
||||
@ -148,7 +148,7 @@ namespace ehs
|
||||
case 3:
|
||||
return h;
|
||||
default:
|
||||
EHS_LOG_INT("Error", 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Rectangle.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Rectangle.");
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ namespace ehs
|
||||
{
|
||||
if (index >= size)
|
||||
{
|
||||
EHS_LOG_INT("Warning", 0, "Cannot insert value at " + Str_8::FromNum(index) + " because it is outside of array range of " + size + ".");
|
||||
EHS_LOG_INT(LogType::WARN, 0, "Cannot insert value at " + Str_8::FromNum(index) + " because it is outside of array range of " + size + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1075,7 +1075,7 @@ namespace ehs
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T, typename O>
|
||||
template<typename T = Char_8, typename O = UInt_64>
|
||||
Str<T, O> ReadStr(O size = 0)
|
||||
{
|
||||
bool sizeKnown = size;
|
||||
|
@ -229,7 +229,7 @@ namespace ehs
|
||||
case 1:
|
||||
return y;
|
||||
default:
|
||||
EHS_LOG_INT("Error", 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 3.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 3.");
|
||||
return x;
|
||||
}
|
||||
}
|
||||
@ -243,7 +243,7 @@ namespace ehs
|
||||
case 1:
|
||||
return y;
|
||||
default:
|
||||
EHS_LOG_INT("Error", 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 3.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 3.");
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ namespace ehs
|
||||
case 2:
|
||||
return z;
|
||||
default:
|
||||
EHS_LOG_INT("Error", 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 3.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 3.");
|
||||
return x;
|
||||
}
|
||||
}
|
||||
@ -282,7 +282,7 @@ namespace ehs
|
||||
case 2:
|
||||
return z;
|
||||
default:
|
||||
EHS_LOG_INT("Error", 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 3.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 3.");
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ namespace ehs
|
||||
case 3:
|
||||
return w;
|
||||
default:
|
||||
EHS_LOG_INT("Error", 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 4.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 4.");
|
||||
return x;
|
||||
}
|
||||
}
|
||||
@ -297,7 +297,7 @@ namespace ehs
|
||||
case 3:
|
||||
return w;
|
||||
default:
|
||||
EHS_LOG_INT("Error", 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 4.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 4.");
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
@ -12,13 +12,14 @@ namespace ehs
|
||||
Str_8 id;
|
||||
Version version;
|
||||
Array<DbTable> tables;
|
||||
Str_8 dir;
|
||||
|
||||
public:
|
||||
Database();
|
||||
|
||||
Database(Str_8 id, const Version& version);
|
||||
|
||||
Database(const Str_8& filePath);
|
||||
Database(Str_8 filePath);
|
||||
|
||||
Database(Database&& db) noexcept;
|
||||
|
||||
@ -48,6 +49,8 @@ namespace ehs
|
||||
|
||||
DbTable* GetTable(const Str_8& id) const;
|
||||
|
||||
void Save(const Str_8& directory) const;
|
||||
Str_8 GetDirectory() const;
|
||||
|
||||
void Save(Str_8 directory);
|
||||
};
|
||||
}
|
@ -8,12 +8,16 @@
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
class Database;
|
||||
|
||||
class DbTable
|
||||
{
|
||||
private:
|
||||
friend class Database;
|
||||
friend class DbVar;
|
||||
friend class DbObject;
|
||||
|
||||
Database *parent;
|
||||
UInt_64 hashId;
|
||||
Str_8 id;
|
||||
Array<DbVarTmpl> varTmpls;
|
||||
@ -55,8 +59,8 @@ namespace ehs
|
||||
private:
|
||||
DbVarTmpl *GetVariableTemplate(UInt_64 hashId) const;
|
||||
|
||||
void Serialize(Serializer<UInt_64>& data) const;
|
||||
void Serialize(const Str_8 &dir, Serializer<UInt_64>& data) const;
|
||||
|
||||
void Deserialize(Serializer<UInt_64>& data);
|
||||
void Deserialize(const Str_8 &dir, Serializer<UInt_64>& data);
|
||||
};
|
||||
}
|
||||
|
@ -9,5 +9,9 @@ namespace ehs
|
||||
{
|
||||
public:
|
||||
static Array<Str_8> GetAllFiles(const Str_8 &dir);
|
||||
|
||||
static void CreateRecursive(Str_8 dir);
|
||||
|
||||
static void Create(const Str_8 &dir);
|
||||
};
|
||||
}
|
@ -8,5 +8,9 @@ namespace ehs
|
||||
{
|
||||
public:
|
||||
static Array<Str_8> GetAllFiles(const Str_8 &dir);
|
||||
|
||||
static void CreateRecursive(Str_8 dir);
|
||||
|
||||
static void Create(const Str_8 &dir);
|
||||
};
|
||||
}
|
24
src/EHS.cpp
24
src/EHS.cpp
@ -97,30 +97,10 @@ namespace ehs
|
||||
}
|
||||
}
|
||||
|
||||
void LogRaised(const ehs::Log& log)
|
||||
{
|
||||
ehs::Array<ehs::Str_8> tags = log.GetTags();
|
||||
|
||||
ehs::Str_8 result = "{";
|
||||
|
||||
for (ehs::UInt_32 i = 0; i < tags.Size(); ++i)
|
||||
{
|
||||
result += tags[i];
|
||||
if (i != tags.Size() - 1)
|
||||
result += ", ";
|
||||
}
|
||||
|
||||
result += "} (" + ehs::Str_8::FromNum(log.GetCode()) + "): " + log.GetMsg();
|
||||
|
||||
ehs::Console::Write_8(result);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
ehs::Console::Attach();
|
||||
|
||||
ehs::Log::SetCallback(LogRaised);
|
||||
|
||||
ehs::Audio::AddCodec({
|
||||
"Waveform Audio",
|
||||
"wav",
|
||||
@ -165,9 +145,11 @@ int main()
|
||||
|
||||
const ehs::SInt_32 code = Main(&ehs::appName, &ehs::appVerId, &ehs::appVer);
|
||||
if (code)
|
||||
EHS_LOG("Warning", 0, "Executable exited with code #" + ehs::Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT(ehs::LogType::WARN, 0, "Executable exited with code #" + ehs::Str_8::FromNum(code) + ".");
|
||||
|
||||
ehs::GarbageCollector::Stop();
|
||||
|
||||
ehs::Log::OnExit();
|
||||
|
||||
return code;
|
||||
}
|
@ -60,7 +60,7 @@ namespace ehs
|
||||
/*
|
||||
if (Has(obj))
|
||||
{
|
||||
EHS_LOG_INT("Warning", 1, obj->GetTypeId() + " object with address of, \"" + Str_8::FromNum<USize>((USize)obj) + "\" is already in garbage.");
|
||||
EHS_LOG_INT(LogType::WARN, 1, obj->GetTypeId() + " object with address of, \"" + Str_8::FromNum<USize>((USize)obj) + "\" is already in garbage.");
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
139
src/Log.cpp
139
src/Log.cpp
@ -1,51 +1,119 @@
|
||||
#include "ehs/Log.h"
|
||||
|
||||
#include "ehs/io/Console.h"
|
||||
#include "ehs/io/File.h"
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
void (*Log::logCb)(const Log&) = nullptr;
|
||||
Log Log::lastLog;
|
||||
|
||||
void Log::SetCallback(void (*newLogCb)(const Log&))
|
||||
void Log::DefaultRaisedCb(const Log &log)
|
||||
{
|
||||
logCb = newLogCb;
|
||||
Console::Write_8(log.ToStr());
|
||||
}
|
||||
|
||||
void Log::Raise(const Log& log)
|
||||
void Log::DefaultOutputCb(const Array<Log> &logs)
|
||||
{
|
||||
if (logCb)
|
||||
logCb(log);
|
||||
File output("Logs.txt", Mode::WRITE, Disposition::CREATE_PERSISTENT);
|
||||
output.SeekBeginning();
|
||||
|
||||
lastLog = log;
|
||||
for (UInt_64 i = 0; i < logs.Size(); ++i)
|
||||
output.WriteStr_8(logs[i].ToStr() + "\n");
|
||||
}
|
||||
|
||||
LogRaisedCb Log::raisedCb = DefaultRaisedCb;
|
||||
LogOutputCb Log::outputCb = DefaultOutputCb;
|
||||
Array<Log> Log::logs;
|
||||
Log Log::lastLog;
|
||||
bool Log::immediate = false;
|
||||
|
||||
void Log::SetRaisedCallback(const LogRaisedCb newCb)
|
||||
{
|
||||
raisedCb = newCb;
|
||||
}
|
||||
|
||||
void Log::SetOutputCallback(const LogOutputCb newCb)
|
||||
{
|
||||
outputCb = newCb;
|
||||
}
|
||||
|
||||
void Log::OnExit()
|
||||
{
|
||||
if (lastLog.GetType() != LogType::SUCCESS)
|
||||
logs.Push(lastLog);
|
||||
|
||||
lastLog = {};
|
||||
|
||||
if (outputCb)
|
||||
outputCb(logs);
|
||||
}
|
||||
|
||||
void Log::Raise(Log log)
|
||||
{
|
||||
if (log.GetType() == LogType::INFO || (log.GetType() != LogType::SUCCESS && immediate))
|
||||
if (raisedCb)
|
||||
raisedCb(log);
|
||||
|
||||
if (lastLog.GetType() != LogType::SUCCESS)
|
||||
logs.Push((Log&&)lastLog);
|
||||
|
||||
lastLog = (Log&&)log;
|
||||
}
|
||||
|
||||
Log Log::GetLastLog()
|
||||
{
|
||||
Log result = lastLog;
|
||||
lastLog = Log();
|
||||
lastLog = {};
|
||||
return result;
|
||||
}
|
||||
|
||||
void Log::EnableImmediateMode(const bool enable)
|
||||
{
|
||||
immediate = enable;
|
||||
}
|
||||
|
||||
Log::Log()
|
||||
: code(0)
|
||||
: type(LogType::SUCCESS), code(0)
|
||||
{
|
||||
}
|
||||
|
||||
Log::Log(std::initializer_list<Str_8> tags, const UInt_64 code, const Str_8& msg)
|
||||
: tags(tags.size()), code(code), msg(msg)
|
||||
Log::Log(LogType type, const std::initializer_list<Str_8> &tags, const UInt_64 code, Str_8 msg)
|
||||
: type(type), tags(tags.size()), code(code), msg((Str_8&&)msg)
|
||||
{
|
||||
UInt_64 i = 0;
|
||||
for (auto v = tags.begin(); v != tags.end(); ++v)
|
||||
this->tags[i++] = *v;
|
||||
}
|
||||
|
||||
Log::Log(Array<Str_8>& tags, const UInt_64 code, const Str_8& msg)
|
||||
: tags(tags), code(code), msg(msg)
|
||||
Log::Log(LogType type, Array<Str_8> tags, const UInt_64 code, Str_8 msg)
|
||||
: type(type), tags((Array<Str_8>&&)tags), code(code), msg((Str_8&&)msg)
|
||||
{
|
||||
}
|
||||
|
||||
Log::Log(const Log& log)
|
||||
: tags(log.tags), code(log.code), msg(log.msg)
|
||||
Log::Log(Log &&log) noexcept
|
||||
: type(log.type), tags((Array<Str_8>&&)log.tags), code(log.code), msg((Str_8&&)log.msg)
|
||||
{
|
||||
log.type = LogType::INFO;
|
||||
log.code = 0;
|
||||
}
|
||||
|
||||
Log::Log(const Log &log)
|
||||
: type(log.type), tags(log.tags), code(log.code), msg(log.msg)
|
||||
{
|
||||
}
|
||||
|
||||
Log & Log::operator=(Log &&log) noexcept
|
||||
{
|
||||
if (this == &log)
|
||||
return *this;
|
||||
|
||||
type = log.type;
|
||||
tags = (Array<Str_8>&&)log.tags;
|
||||
code = log.code;
|
||||
msg = (Str_8&&)log.msg;
|
||||
|
||||
log.type = LogType::INFO;
|
||||
log.code = 0;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Log& Log::operator=(const Log &log)
|
||||
@ -53,6 +121,7 @@ namespace ehs
|
||||
if (this == &log)
|
||||
return *this;
|
||||
|
||||
type = log.type;
|
||||
tags = log.tags;
|
||||
code = log.code;
|
||||
msg = log.msg;
|
||||
@ -72,7 +141,12 @@ namespace ehs
|
||||
}
|
||||
*/
|
||||
|
||||
bool Log::HasTags(const std::initializer_list<Str_8> tags) const
|
||||
LogType Log::GetType() const
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
bool Log::HasTags(const std::initializer_list<Str_8> &tags) const
|
||||
{
|
||||
UInt_64 i = 0;
|
||||
UInt_64 c = 0;
|
||||
@ -110,7 +184,7 @@ namespace ehs
|
||||
return false;
|
||||
}
|
||||
|
||||
Array<Str_8> Log::GetTags() const
|
||||
const Array<Str_8> &Log::GetTags() const
|
||||
{
|
||||
return tags;
|
||||
}
|
||||
@ -127,7 +201,32 @@ namespace ehs
|
||||
|
||||
Str_8 Log::ToStr() const
|
||||
{
|
||||
Str_8 result = "[";
|
||||
Str_8 result = "<";
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case LogType::SUCCESS:
|
||||
{
|
||||
result += "Success";
|
||||
break;
|
||||
}
|
||||
case LogType::ERR:
|
||||
{
|
||||
result += "Error";
|
||||
break;
|
||||
}
|
||||
case LogType::WARN:
|
||||
{
|
||||
result += "Warning";
|
||||
break;
|
||||
}
|
||||
case LogType::INFO:
|
||||
{
|
||||
result += "Information";
|
||||
}
|
||||
}
|
||||
|
||||
result += ">[";
|
||||
|
||||
for (UInt_64 i = 0; i < tags.Size(); ++i)
|
||||
{
|
||||
|
@ -189,7 +189,7 @@ namespace ehs
|
||||
{
|
||||
if (working)
|
||||
{
|
||||
EHS_LOG_INT("Warning", 0, "Attempted to give work while task is still working.");
|
||||
EHS_LOG_INT(LogType::WARN, 0, "Attempted to give work while task is still working.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include "ehs/db/Database.h"
|
||||
|
||||
#include "ehs/io/Directory_LNX.h"
|
||||
#include "ehs/io/File.h"
|
||||
|
||||
namespace ehs
|
||||
@ -13,9 +15,25 @@ namespace ehs
|
||||
{
|
||||
}
|
||||
|
||||
Database::Database(const Str_8& filePath)
|
||||
Database::Database(Str_8 filePath)
|
||||
{
|
||||
filePath = filePath.ReplaceAll("\\", "/");
|
||||
|
||||
UInt_64 i = 0;
|
||||
if (filePath.Find("/", &i, SearchPattern::RIGHT_LEFT))
|
||||
dir = filePath.Sub(0, i);
|
||||
else
|
||||
dir = "./";
|
||||
|
||||
File file(filePath, Mode::READ, Disposition::OPEN);
|
||||
|
||||
Log log = Log::GetLastLog();
|
||||
if (log.GetType() == LogType::ERR && log.GetCode() == 0)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Database file not found at, \"" + filePath + "\".");
|
||||
return;
|
||||
}
|
||||
|
||||
id = file.GetName();
|
||||
hashId = id.Hash_64();
|
||||
Serializer<UInt_64> data = file.ReadSerializer_64(Endianness::LE, file.Size());
|
||||
@ -25,19 +43,30 @@ namespace ehs
|
||||
tables.Resize(data.Read<UInt_64>());
|
||||
|
||||
for (UInt_64 i = 0; i < tables.Size(); ++i)
|
||||
tables[i].Deserialize(data);
|
||||
{
|
||||
tables[i].parent = this;
|
||||
tables[i].Deserialize(dir, data);
|
||||
}
|
||||
|
||||
EHS_LOG_SUCCESS();
|
||||
}
|
||||
|
||||
Database::Database(Database&& db) noexcept
|
||||
: hashId(db.hashId), id((Str_8&&)db.id), version(db.version), tables((Array<DbTable>&&)db.tables)
|
||||
: hashId(db.hashId), id((Str_8&&)db.id), version(db.version), tables((Array<DbTable>&&)db.tables),
|
||||
dir((Str_8&&)db.dir)
|
||||
{
|
||||
for (UInt_64 i = 0; i < tables.Size(); ++i)
|
||||
tables[i].parent = this;
|
||||
|
||||
db.hashId = 0;
|
||||
db.version = {0, 0, 0};
|
||||
}
|
||||
|
||||
Database::Database(const Database& db)
|
||||
: hashId(db.hashId), id(db.id), version(db.version), tables(db.tables)
|
||||
: hashId(db.hashId), id(db.id), version(db.version), tables(db.tables), dir(db.dir)
|
||||
{
|
||||
for (UInt_64 i = 0; i < tables.Size(); ++i)
|
||||
tables[i].parent = this;
|
||||
}
|
||||
|
||||
Database& Database::operator=(Database&& db) noexcept
|
||||
@ -48,7 +77,12 @@ namespace ehs
|
||||
hashId = db.hashId;
|
||||
id = (Str_8&&)db.id;
|
||||
version = db.version;
|
||||
|
||||
tables = (Array<DbTable>&&)db.tables;
|
||||
for (UInt_64 i = 0; i < tables.Size(); ++i)
|
||||
tables[i].parent = this;
|
||||
|
||||
dir = (Str_8&&)db.dir;
|
||||
|
||||
db.hashId = 0;
|
||||
db.version = {0, 0, 0};
|
||||
@ -64,7 +98,12 @@ namespace ehs
|
||||
hashId = db.hashId;
|
||||
id = db.id;
|
||||
version = db.version;
|
||||
|
||||
tables = db.tables;
|
||||
for (UInt_64 i = 0; i < tables.Size(); ++i)
|
||||
tables[i].parent = this;
|
||||
|
||||
dir = db.dir;
|
||||
|
||||
return *this;
|
||||
}
|
||||
@ -116,7 +155,9 @@ namespace ehs
|
||||
|
||||
tables.Push(DbTable((Str_8&&)id));
|
||||
|
||||
return &tables[tables.End()];
|
||||
DbTable *tbl = &tables[tables.End()];
|
||||
tbl->parent = this;
|
||||
return tbl;
|
||||
}
|
||||
|
||||
DbTable* Database::GetTable(UInt_64 hashId) const
|
||||
@ -133,16 +174,25 @@ namespace ehs
|
||||
return GetTable(id.Hash_64());
|
||||
}
|
||||
|
||||
void Database::Save(const Str_8& directory) const
|
||||
Str_8 Database::GetDirectory() const
|
||||
{
|
||||
return dir;
|
||||
}
|
||||
|
||||
void Database::Save(Str_8 directory)
|
||||
{
|
||||
dir = (Str_8&&)directory;
|
||||
|
||||
Serializer<UInt_64> data(Endianness::LE);
|
||||
data.WriteVersion(version);
|
||||
data.Write(tables.Size());
|
||||
|
||||
for (UInt_64 i = 0; i < tables.Size(); ++i)
|
||||
tables[i].Serialize(data);
|
||||
Directory::CreateRecursive(dir);
|
||||
|
||||
File file(directory + "/" + id + ".ehd", Mode::WRITE, Disposition::CREATE_PERSISTENT);
|
||||
for (UInt_64 i = 0; i < tables.Size(); ++i)
|
||||
tables[i].Serialize(dir, data);
|
||||
|
||||
File file(dir + "/" + id + ".ehd", Mode::WRITE, Disposition::CREATE_PERSISTENT);
|
||||
file.WriteSerializer_64(data);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include "ehs/db/DbObject.h"
|
||||
#include "ehs/db/DbTable.h"
|
||||
#include "ehs/Serializer.h"
|
||||
#include "ehs/db/Database.h"
|
||||
#include "ehs/io/Directory_LNX.h"
|
||||
#include "ehs/io/File.h"
|
||||
|
||||
namespace ehs
|
||||
@ -100,7 +102,9 @@ namespace ehs
|
||||
for (UInt_64 i = 0; i < vars.Size(); ++i)
|
||||
vars[i].Serialize(data);
|
||||
|
||||
File file(parent->GetId() + "/" + Str_8::FromNum(id) + ".eho", Mode::WRITE, Disposition::CREATE_PERSISTENT);
|
||||
Directory::CreateRecursive(parent->parent->GetDirectory() + "/" + parent->GetId());
|
||||
|
||||
File file(parent->parent->GetDirectory() + "/" + parent->GetId() + "/" + Str_8::FromNum(id) + ".eho", Mode::WRITE, Disposition::CREATE_PERSISTENT);
|
||||
file.SeekBeginning();
|
||||
file.WriteSerializer_64(data);
|
||||
}
|
||||
@ -110,7 +114,7 @@ namespace ehs
|
||||
if (IsLoaded())
|
||||
return;
|
||||
|
||||
File file(parent->GetId() + "/" + Str_8::FromNum(id) + ".eho", Mode::READ, Disposition::OPEN);
|
||||
File file(parent->parent->GetDirectory() + "/" + parent->GetId() + "/" + Str_8::FromNum(id) + ".eho", Mode::READ, Disposition::OPEN);
|
||||
Serializer<UInt_64> data = file.ReadSerializer_64(Endianness::LE, file.Size());
|
||||
file.Release();
|
||||
|
||||
|
@ -1,28 +1,30 @@
|
||||
#include "ehs/db/DbTable.h"
|
||||
#include "ehs/db/Database.h"
|
||||
#include "ehs/io/Directory.h"
|
||||
#include "ehs/io/File_UNX.h"
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
DbTable::DbTable()
|
||||
: hashId(0)
|
||||
: parent(nullptr), hashId(0)
|
||||
{
|
||||
}
|
||||
|
||||
DbTable::DbTable(Str_8 id)
|
||||
: hashId(id.Hash_64()), id((Str_8&&)id)
|
||||
: parent(nullptr), hashId(id.Hash_64()), id((Str_8&&)id)
|
||||
{
|
||||
}
|
||||
|
||||
DbTable::DbTable(DbTable&& table) noexcept
|
||||
: hashId(table.hashId), id((Str_8&&)table.id), varTmpls((Array<DbVarTmpl>&&)table.varTmpls),
|
||||
: parent(table.parent), hashId(table.hashId), id((Str_8&&)table.id), varTmpls((Array<DbVarTmpl>&&)table.varTmpls),
|
||||
objects((Array<DbObject>&&)table.objects)
|
||||
{
|
||||
table.parent = nullptr;
|
||||
table.hashId = 0;
|
||||
}
|
||||
|
||||
DbTable::DbTable(const DbTable& table)
|
||||
: hashId(table.hashId), id(table.id), varTmpls(table.varTmpls), objects(table.objects)
|
||||
: parent(nullptr), hashId(table.hashId), id(table.id), varTmpls(table.varTmpls), objects(table.objects)
|
||||
{
|
||||
}
|
||||
|
||||
@ -31,14 +33,16 @@ namespace ehs
|
||||
if (this == &table)
|
||||
return *this;
|
||||
|
||||
parent = table.parent;
|
||||
hashId = table.hashId;
|
||||
id = (Str_8&&)table.id;
|
||||
varTmpls = (Array<DbVarTmpl>&&)table.varTmpls;
|
||||
objects = (Array<DbObject>&&)table.objects;
|
||||
|
||||
objects = (Array<DbObject>&&)table.objects;
|
||||
for (UInt_64 i = 0; i < objects.Size(); ++i)
|
||||
objects[i].parent = this;
|
||||
|
||||
table.parent = nullptr;
|
||||
table.hashId = 0;
|
||||
|
||||
return *this;
|
||||
@ -49,11 +53,12 @@ namespace ehs
|
||||
if (this == &table)
|
||||
return *this;
|
||||
|
||||
parent = nullptr;
|
||||
hashId = table.hashId;
|
||||
id = table.id;
|
||||
varTmpls = table.varTmpls;
|
||||
objects = table.objects;
|
||||
|
||||
objects = table.objects;
|
||||
for (UInt_64 i = 0; i < objects.Size(); ++i)
|
||||
objects[i].parent = this;
|
||||
|
||||
@ -158,7 +163,7 @@ namespace ehs
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void DbTable::Serialize(Serializer<UInt_64>& data) const
|
||||
void DbTable::Serialize(const Str_8 &dir, Serializer<UInt_64>& data) const
|
||||
{
|
||||
data.WriteStr(id);
|
||||
data.Write(varTmpls.Size());
|
||||
@ -166,11 +171,14 @@ namespace ehs
|
||||
for (UInt_64 i = 0; i < varTmpls.Size(); ++i)
|
||||
varTmpls[i].Serialize(data);
|
||||
|
||||
if (objects.Size())
|
||||
Directory::Create(dir + "/" + id);
|
||||
|
||||
for (UInt_64 i = 0; i < objects.Size(); ++i)
|
||||
objects[i].Save();
|
||||
}
|
||||
|
||||
void DbTable::Deserialize(Serializer<UInt_64>& data)
|
||||
void DbTable::Deserialize(const Str_8 &dir, Serializer<UInt_64>& data)
|
||||
{
|
||||
id = data.ReadStr<Char_8, UInt_64>();
|
||||
hashId = id.Hash_64();
|
||||
@ -180,7 +188,7 @@ namespace ehs
|
||||
for (UInt_64 i = 0; i < varTmpls.Size(); ++i)
|
||||
varTmpls[i].Deserialize(data);
|
||||
|
||||
Array<Str_8> files = Directory::GetAllFiles(id);
|
||||
Array<Str_8> files = Directory::GetAllFiles(dir + "/" + id);
|
||||
for (UInt_64 i = 0; i < files.Size(); ++i)
|
||||
{
|
||||
if (File::ParseExt_8(files[i]) != "eho")
|
||||
|
@ -9,7 +9,7 @@ namespace ehs
|
||||
}
|
||||
|
||||
DbVarTmpl::DbVarTmpl()
|
||||
: hashId(0), size(0), def(nullptr)
|
||||
: hashId(0), def(nullptr), size(0)
|
||||
{
|
||||
}
|
||||
|
||||
@ -40,12 +40,12 @@ namespace ehs
|
||||
|
||||
hashId = varTmpl.hashId;
|
||||
id = (Str_8&&)varTmpl.id;
|
||||
size = varTmpl.size;
|
||||
def = varTmpl.def;
|
||||
size = varTmpl.size;
|
||||
|
||||
varTmpl.hashId = 0;
|
||||
varTmpl.size = 0;
|
||||
varTmpl.def = nullptr;
|
||||
varTmpl.size = 0;
|
||||
|
||||
return *this;
|
||||
}
|
||||
@ -59,8 +59,8 @@ namespace ehs
|
||||
|
||||
hashId = varTmpl.hashId;
|
||||
id = varTmpl.id;
|
||||
size = varTmpl.size;
|
||||
def = new Byte[varTmpl.size];
|
||||
size = varTmpl.size;
|
||||
|
||||
Util::Copy(def, varTmpl.def, varTmpl.size);
|
||||
|
||||
@ -106,6 +106,14 @@ namespace ehs
|
||||
|
||||
size = 0;
|
||||
data.ReadArray(def, &size);
|
||||
delete[] def;
|
||||
|
||||
if (!size)
|
||||
{
|
||||
def = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
def = new Byte[size];
|
||||
data.ReadArray(def, &size);
|
||||
}
|
||||
|
@ -1,9 +1,23 @@
|
||||
#include "ehs/io/BaseDirectory.h"
|
||||
|
||||
#include "ehs/Log.h"
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
Array<Str_8> BaseDirectory::GetAllFiles(const Str_8 &dir)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 0, "The feature is not supported for this operating system.");
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
void BaseDirectory::CreateRecursive(Str_8 dir)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 0, "The feature is not supported for this operating system.");
|
||||
}
|
||||
|
||||
void BaseDirectory::Create(const Str_8 &dir)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 0, "The feature is not supported for this operating system.");
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ namespace ehs
|
||||
UInt_64 written = Write(&((Byte*)str)[total], size - total);
|
||||
if (!written)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
Str_8::FromNum(size) + ").");
|
||||
break;
|
||||
}
|
||||
@ -74,7 +74,7 @@ namespace ehs
|
||||
UInt_64 written = Write(&str.ToBytes()[total], str.Size(true) - total);
|
||||
if (!written)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
Str_8::FromNum(str.Size()) + ").");
|
||||
break;
|
||||
}
|
||||
@ -96,7 +96,7 @@ namespace ehs
|
||||
UInt_64 written = Write(&((Byte*)str)[total], size - total);
|
||||
if (!written)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
Str_8::FromNum(size) + ").");
|
||||
break;
|
||||
}
|
||||
@ -118,7 +118,7 @@ namespace ehs
|
||||
UInt_64 written = Write(&str.ToBytes()[total], str.Size(true) - total);
|
||||
if (!written)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
Str_8::FromNum(str.Size()) + ").");
|
||||
break;
|
||||
}
|
||||
@ -140,7 +140,7 @@ namespace ehs
|
||||
UInt_64 written = Write(&((Byte*)str)[total], size - total);
|
||||
if (!written)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
Str_8::FromNum(size) + ").");
|
||||
break;
|
||||
}
|
||||
@ -162,7 +162,7 @@ namespace ehs
|
||||
UInt_64 written = Write(&str.ToBytes()[total], str.Size(true) - total);
|
||||
if (!written)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
Str_8::FromNum(str.Size()) + ").");
|
||||
break;
|
||||
}
|
||||
@ -184,7 +184,7 @@ namespace ehs
|
||||
UInt_64 written = Write(&vec[total], vec.Size() - total);
|
||||
if (!written)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
Str_8::FromNum(vec.Size()) + ").");
|
||||
break;
|
||||
}
|
||||
@ -206,7 +206,7 @@ namespace ehs
|
||||
UInt_64 written = Write(&arr[total], arr.Size() - total);
|
||||
if (!written)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
Str_8::FromNum(arr.Size()) + ").");
|
||||
break;
|
||||
}
|
||||
@ -228,7 +228,7 @@ namespace ehs
|
||||
UInt_64 written = Write(&ser[total], ser.Size() - total);
|
||||
if (!written)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
Str_8::FromNum(ser.Size()) + ").");
|
||||
break;
|
||||
}
|
||||
@ -250,7 +250,7 @@ namespace ehs
|
||||
UInt_64 written = Write(&ser[total], ser.Size() - total);
|
||||
if (!written)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
Str_8::FromNum(ser.Size()) + ").");
|
||||
break;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ namespace ehs
|
||||
nullptr);
|
||||
if (hdl == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to create handle at COM" + Str_8::FromNum(port) + " with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to create handle at COM" + Str_8::FromNum(port) + " with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ namespace ehs
|
||||
|
||||
if (!GetCommState(hdl, &dcb))
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Failed to retrieve COM" + Str_8::FromNum(port) + " state with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to retrieve COM" + Str_8::FromNum(port) + " state with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
UnInitialize();
|
||||
return;
|
||||
}
|
||||
@ -46,7 +46,7 @@ namespace ehs
|
||||
|
||||
if (!SetCommState(hdl, &dcb))
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Failed to set COM" + Str_8::FromNum(port) + " state with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to set COM" + Str_8::FromNum(port) + " state with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
UnInitialize();
|
||||
return;
|
||||
}
|
||||
@ -63,7 +63,7 @@ namespace ehs
|
||||
if (hdl)
|
||||
{
|
||||
if (!CloseHandle(hdl))
|
||||
EHS_LOG_INT("Error", 0, "Failed to close COM" + Str_8::FromNum(port) + " handle with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to close COM" + Str_8::FromNum(port) + " handle with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
hdl = nullptr;
|
||||
}
|
||||
@ -77,7 +77,7 @@ namespace ehs
|
||||
|
||||
if (!WaitCommEvent(hdl, (DWORD*)&event, nullptr))
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to wait for COM" + Str_8::FromNum(port) + " event with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to wait for COM" + Str_8::FromNum(port) + " event with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
UnInitialize();
|
||||
}
|
||||
|
||||
@ -91,7 +91,7 @@ namespace ehs
|
||||
|
||||
if (!TransmitCommChar(hdl, data))
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to transmit character to COM" + Str_8::FromNum(port) + " with error #" +
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to transmit character to COM" + Str_8::FromNum(port) + " with error #" +
|
||||
Str_8::FromNum(GetLastError()) + ".");
|
||||
UnInitialize();
|
||||
}
|
||||
@ -103,7 +103,7 @@ namespace ehs
|
||||
|
||||
if (!WriteFile(hdl, (void*)data, (DWORD)size, (DWORD*)&sent, nullptr))
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to receive data from COM" + Str_8::FromNum(port) + " with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to receive data from COM" + Str_8::FromNum(port) + " with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
UnInitialize();
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ namespace ehs
|
||||
|
||||
if (!ReadFile(hdl, (void*)data, (DWORD)size, (DWORD*)&received, nullptr))
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to receive data from COM" + Str_8::FromNum(port) + " with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to receive data from COM" + Str_8::FromNum(port) + " with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
UnInitialize();
|
||||
}
|
||||
|
||||
@ -127,7 +127,7 @@ namespace ehs
|
||||
{
|
||||
if (!FlushFileBuffers(hdl))
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to flush data for COM" + Str_8::FromNum(port) + " with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to flush data for COM" + Str_8::FromNum(port) + " with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
UnInitialize();
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ namespace ehs
|
||||
{
|
||||
//DWORD code = WaitForSingleObject(hdlIn, 15000);
|
||||
//if (code == WAIT_FAILED || code == WAIT_TIMEOUT || code == WAIT_ABANDONED)
|
||||
// EHS_LOG_INT("Error", 0, "Failed to wait for console input.");
|
||||
// EHS_LOG_INT(LogType::ERR, 0, "Failed to wait for console input.");
|
||||
|
||||
isConsole = true;
|
||||
}
|
||||
@ -63,10 +63,10 @@ namespace ehs
|
||||
hdlOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
||||
if (WaitForSingleObject(hdlIn, EHS_INFINITE) == WAIT_FAILED)
|
||||
EHS_LOG_INT("Error", 2, "Failed to wait for console input.");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to wait for console input.");
|
||||
|
||||
//if (!SetConsoleActiveScreenBuffer(hdlOut))
|
||||
// EHS_LOG_INT("Error", 3, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
// EHS_LOG_INT(LogType::ERR, 3, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
isConsole = true;
|
||||
#endif
|
||||
@ -78,15 +78,15 @@ namespace ehs
|
||||
{
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (!FreeConsole())
|
||||
EHS_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
int code = close(hdlOut);
|
||||
if (code == -1)
|
||||
EHS_LOG_INT("Error", 0, "Failed to free the console output with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to free the console output with error #" + Str_8::FromNum(errno) + ".");
|
||||
|
||||
code = close(hdlIn);
|
||||
if (code == -1)
|
||||
EHS_LOG_INT("Error", 0, "Failed to free the console input with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to free the console input with error #" + Str_8::FromNum(errno) + ".");
|
||||
#endif
|
||||
|
||||
hdlOut = 0;
|
||||
@ -118,7 +118,7 @@ namespace ehs
|
||||
{
|
||||
DWORD written = 0;
|
||||
if (!WriteConsoleW(hdlOut, &r[offset], (DWORD)r.Size() - offset, &written, nullptr))
|
||||
EHS_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
offset += written;
|
||||
}
|
||||
@ -136,7 +136,7 @@ namespace ehs
|
||||
{
|
||||
DWORD written = 0;
|
||||
if (!WriteFile(hdlOut, &((Char_8*)r)[offset], (DWORD)r.Size(true) - offset, &written, nullptr))
|
||||
EHS_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
offset += written;
|
||||
}
|
||||
@ -152,7 +152,7 @@ namespace ehs
|
||||
ssize_t written = write(hdlOut, result, result.Size(true));
|
||||
if (written == -1)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to write to console with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to write to console with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
offset += written;
|
||||
@ -178,7 +178,7 @@ namespace ehs
|
||||
{
|
||||
DWORD written = 0;
|
||||
if (!WriteConsoleW(hdlOut, &r[offset], (DWORD)r.Size() - offset, &written, nullptr))
|
||||
EHS_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
offset += written;
|
||||
}
|
||||
@ -196,7 +196,7 @@ namespace ehs
|
||||
{
|
||||
DWORD written = 0;
|
||||
if (!WriteFile(hdlOut, &((Char_8*)r)[offset], (DWORD)r.Size(true) - offset, &written, nullptr))
|
||||
EHS_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
offset += written;
|
||||
}
|
||||
@ -212,7 +212,7 @@ namespace ehs
|
||||
ssize_t written = write(hdlOut, result, result.Size(true));
|
||||
if (written == -1)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to write to console with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to write to console with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
offset += written;
|
||||
@ -236,7 +236,7 @@ namespace ehs
|
||||
{
|
||||
DWORD written = 0;
|
||||
if (!WriteConsoleW(hdlOut, &r[offset], (DWORD)r.Size() - offset, &written, nullptr))
|
||||
EHS_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
offset += written;
|
||||
}
|
||||
@ -254,7 +254,7 @@ namespace ehs
|
||||
{
|
||||
DWORD written = 0;
|
||||
if (!WriteFile(hdlOut, &r[offset], (DWORD)r.Size() - offset, &written, nullptr))
|
||||
EHS_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
offset += written;
|
||||
}
|
||||
@ -270,7 +270,7 @@ namespace ehs
|
||||
ssize_t written = write(hdlOut, result, result.Size());
|
||||
if (written == -1)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to write to console with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to write to console with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
offset += written;
|
||||
@ -299,7 +299,7 @@ namespace ehs
|
||||
|
||||
if (!ReadConsoleW(hdlIn, &result[offset], (DWORD)bufferSize, &read, nullptr))
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
return U"";
|
||||
}
|
||||
@ -329,7 +329,7 @@ namespace ehs
|
||||
|
||||
if (!ReadFile(hdlIn, &result[offset], (DWORD)bufferSize, &read, nullptr))
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
return U"";
|
||||
}
|
||||
@ -355,7 +355,7 @@ namespace ehs
|
||||
read = ::read(hdlIn, input, bufferSize);
|
||||
if (read == -1)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to read from console with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to read from console with error #" + Str_8::FromNum(errno) + ".");
|
||||
return result;
|
||||
}
|
||||
result.Push(input, read);
|
||||
@ -388,7 +388,7 @@ namespace ehs
|
||||
|
||||
if (!ReadConsoleW(hdlIn, &result[offset], (DWORD)bufferSize, &read, nullptr))
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
return L"";
|
||||
}
|
||||
@ -418,7 +418,7 @@ namespace ehs
|
||||
|
||||
if (!ReadFile(hdlIn, &result[offset], (DWORD)bufferSize, &read, nullptr))
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
return L"";
|
||||
}
|
||||
@ -444,7 +444,7 @@ namespace ehs
|
||||
read = ::read(hdlIn, input, bufferSize);
|
||||
if (read == -1)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to read from console with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to read from console with error #" + Str_8::FromNum(errno) + ".");
|
||||
return result;
|
||||
}
|
||||
result.Push(input, read);
|
||||
@ -477,7 +477,7 @@ namespace ehs
|
||||
|
||||
if (!ReadConsoleW(hdlIn, &result[offset], (DWORD)bufferSize, &read, nullptr))
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
return "";
|
||||
}
|
||||
@ -507,7 +507,7 @@ namespace ehs
|
||||
|
||||
if (!ReadFile(hdlIn, &result[offset], (DWORD)bufferSize, &read, nullptr))
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
return "";
|
||||
}
|
||||
@ -533,7 +533,7 @@ namespace ehs
|
||||
read = ::read(hdlIn, input, bufferSize);
|
||||
if (read == -1)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to read from console with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to read from console with error #" + Str_8::FromNum(errno) + ".");
|
||||
return result;
|
||||
}
|
||||
result.Push(input, read);
|
||||
@ -573,7 +573,7 @@ namespace ehs
|
||||
ssize_t written = write(hdlOut, code, sizeof(code));
|
||||
if (written == -1)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to clear console with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to clear console with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
offset += written;
|
||||
@ -586,7 +586,7 @@ namespace ehs
|
||||
{
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (!SetConsoleTitleW(UTF::To_16(title)))
|
||||
EHS_LOG_INT("Error", 0, "Failed to set console title with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to set console title with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
Str_32 code = U"\033]0;" + title + U"\007";
|
||||
UInt_64 offset = 0;
|
||||
@ -594,7 +594,7 @@ namespace ehs
|
||||
ssize_t written = write(hdlOut, code, code.Size(true));
|
||||
if (written == -1)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to set console title with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to set console title with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
offset += written;
|
||||
@ -607,7 +607,7 @@ namespace ehs
|
||||
{
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (!SetConsoleTitleW(title))
|
||||
EHS_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
Str_16 code = L"\033]0;" + title + L"\007";
|
||||
UInt_64 offset = 0;
|
||||
@ -615,7 +615,7 @@ namespace ehs
|
||||
ssize_t written = write(hdlOut, code, code.Size(true));
|
||||
if (written == -1)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to set console title with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to set console title with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
offset += written;
|
||||
@ -628,7 +628,7 @@ namespace ehs
|
||||
{
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (!SetConsoleTitleW(UTF::To_16(title)))
|
||||
EHS_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
Str_8 code = "\033]0;" + title + "\007";
|
||||
UInt_64 offset = 0;
|
||||
@ -636,7 +636,7 @@ namespace ehs
|
||||
ssize_t written = write(hdlOut, code, code.Size());
|
||||
if (written == -1)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to set console title with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to set console title with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
offset += written;
|
||||
@ -788,7 +788,7 @@ namespace ehs
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
void* hdl = FindWindowW(nullptr, GetTitle_16());
|
||||
if (hdl == nullptr)
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve native handle with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to retrieve native handle with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
return hdl;
|
||||
#else
|
||||
|
@ -2,6 +2,8 @@
|
||||
#include "ehs/Log.h"
|
||||
|
||||
#include <dirent.h>
|
||||
#include <cerrno>
|
||||
#include <sys/stat.h>
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
@ -9,10 +11,16 @@ namespace ehs
|
||||
{
|
||||
Array<Str_8> result;
|
||||
|
||||
DIR* hdl = opendir(dir);
|
||||
if (!dir)
|
||||
if (!dir.Size())
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to open directory, \"" + dir + "\".");
|
||||
EHS_LOG_INT(LogType::WARN, 2, "The given directory was empty.");
|
||||
return result;
|
||||
}
|
||||
|
||||
DIR* hdl = opendir(dir);
|
||||
if (!hdl)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 3, "Failed to open directory, \"" + dir + "\".");
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -21,8 +29,55 @@ namespace ehs
|
||||
if (entry->d_type == DT_REG)
|
||||
result.Push(entry->d_name);
|
||||
|
||||
closedir(hdl);
|
||||
if (closedir(hdl) == -1)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 4, "Failed to close directory, \"" + dir + "\".");
|
||||
return result;
|
||||
}
|
||||
|
||||
EHS_LOG_SUCCESS();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void Directory::CreateRecursive(Str_8 dir)
|
||||
{
|
||||
dir = dir.ReplaceAll("\\", "/");
|
||||
|
||||
const Vector<Str_8> dirs = dir.Split("/");
|
||||
|
||||
for (UInt_64 i = 0; i < dirs.Size(); ++i)
|
||||
{
|
||||
const Str_8 final = (Str_8&&)dirs[i];
|
||||
for (UInt_64 x = 0; x < i; ++x)
|
||||
dirs[i] += dirs[x] + "/";
|
||||
|
||||
dirs[i] += final;
|
||||
|
||||
if (mkdir(dirs[i], S_IRWXU | S_IRWXG | S_IRWXO) == -1)
|
||||
{
|
||||
if (const SInt_32 code = errno; code != EEXIST)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to create directory, \"" + dirs[i] + "\" with error #" + Str_8::FromNum(code) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EHS_LOG_SUCCESS();
|
||||
}
|
||||
|
||||
void Directory::Create(const Str_8 &dir)
|
||||
{
|
||||
if (mkdir(dir, S_IRWXU | S_IRWXG | S_IRWXO) == -1)
|
||||
{
|
||||
if (const SInt_32 code = errno; code != EEXIST)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to create directory with error #" + Str_8::FromNum(code) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
EHS_LOG_SUCCESS();
|
||||
}
|
||||
}
|
||||
|
@ -83,14 +83,14 @@ namespace ehs
|
||||
hdl = inotify_init();
|
||||
if (hdl < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to initialize inotify.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to initialize inotify.");
|
||||
return;
|
||||
}
|
||||
|
||||
int flags = fcntl(hdl, F_GETFL, 0);
|
||||
if (flags == -1)
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Failed to retrieve flags with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to retrieve flags with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -98,14 +98,14 @@ namespace ehs
|
||||
|
||||
if (fcntl(hdl, F_SETFL, flags) == -1)
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Failed to set flags with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to set flags with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
wd = inotify_add_watch( hdl, filePath, IN_MODIFY | IN_DELETE_SELF | IN_MOVE_SELF | IN_ACCESS);
|
||||
if (wd < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 3, "Failed to add watch.");
|
||||
EHS_LOG_INT(LogType::ERR, 3, "Failed to add watch.");
|
||||
close(hdl);
|
||||
hdl = -1;
|
||||
return;
|
||||
@ -137,7 +137,7 @@ namespace ehs
|
||||
{
|
||||
UInt_8 code = errno;
|
||||
if (code != EWOULDBLOCK)
|
||||
EHS_LOG_INT("Error", 0, "Failed to read with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to read with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ namespace ehs
|
||||
return;
|
||||
|
||||
if (!CloseHandle(hdl))
|
||||
EHS_LOG_INT("Error", 0, "Failed to close file at file path, \"" + filePath + "\", with error #" + GetLastError() + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to close file at file path, \"" + filePath + "\", with error #" + GetLastError() + ".");
|
||||
}
|
||||
|
||||
FileMonitor::FileMonitor()
|
||||
@ -82,7 +82,7 @@ namespace ehs
|
||||
hdl = CreateFileW(UTF::To_16(filePath), GENERIC_READ, FILE_SHARE_READ,
|
||||
nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
if (hdl == INVALID_HANDLE_VALUE)
|
||||
EHS_LOG_INT("Error", 0, "Failed to open file at file path, \"" + filePath + "\", with error #" + GetLastError() + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to open file at file path, \"" + filePath + "\", with error #" + GetLastError() + ".");
|
||||
}
|
||||
|
||||
void FileMonitor::Release()
|
||||
@ -91,7 +91,7 @@ namespace ehs
|
||||
return;
|
||||
|
||||
if (!CloseHandle(hdl))
|
||||
EHS_LOG_INT("Error", 0, "Failed to close file at file path, \"" + filePath + "\", with error #" + GetLastError() + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to close file at file path, \"" + filePath + "\", with error #" + GetLastError() + ".");
|
||||
|
||||
hdl = nullptr;
|
||||
}
|
||||
|
@ -13,10 +13,10 @@ namespace ehs
|
||||
File::~File()
|
||||
{
|
||||
if (map != MAP_FAILED && munmap(map, mapSize) == -1)
|
||||
EHS_LOG_INT("Error", 0, "Failed to unmap with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to unmap with error #" + Str_8::FromNum(errno) + ".");
|
||||
|
||||
if (hdl >= 0 && close(hdl) == -1)
|
||||
EHS_LOG_INT("Error", 0, "Failed to close file handle with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to close file handle with error #" + Str_8::FromNum(errno) + ".");
|
||||
}
|
||||
|
||||
File::File()
|
||||
@ -64,21 +64,29 @@ namespace ehs
|
||||
hdl = open64(path, linuxMode | linuxDisp, S_IRUSR | S_IWUSR);
|
||||
if (hdl == -1)
|
||||
{
|
||||
SInt_32 code = errno;
|
||||
const SInt_32 code = errno;
|
||||
if (code == EEXIST && (disposition == Disposition::CREATE_PERSISTENT || disposition == Disposition::OPEN_PERSISTENT))
|
||||
{
|
||||
hdl = open64(path, linuxMode, S_IRUSR | S_IWUSR);
|
||||
if (hdl == -1)
|
||||
EHS_LOG_INT("Error", 0, strerror(errno));
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 1, strerror(errno));
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (code == ENOENT)
|
||||
EHS_LOG_INT("Error", 0, "File at filepath, \"" + filePath + "\" not found.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "File at filepath, \"" + filePath + "\" not found.");
|
||||
else
|
||||
EHS_LOG_INT("Error", 0, strerror(code));
|
||||
EHS_LOG_INT(LogType::ERR, 1, strerror(code));
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
EHS_LOG_SUCCESS();
|
||||
}
|
||||
|
||||
File::File(File&& file) noexcept
|
||||
@ -137,12 +145,12 @@ namespace ehs
|
||||
void File::Release()
|
||||
{
|
||||
if (IsMapped() && munmap(map, mapSize) == -1)
|
||||
EHS_LOG_INT("Error", 0, "Failed to unmap with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to unmap with error #" + Str_8::FromNum(errno) + ".");
|
||||
map = MAP_FAILED;
|
||||
mapSize = 0;
|
||||
|
||||
if (IsValid() && close(hdl) == -1)
|
||||
EHS_LOG_INT("Error", 0, "Failed to close file handle with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to close file handle with error #" + Str_8::FromNum(errno) + ".");
|
||||
hdl = -1;
|
||||
}
|
||||
|
||||
@ -178,7 +186,7 @@ namespace ehs
|
||||
map = mmap64(nullptr, size, linuxMode, MAP_SHARED, hdl, (off64_t)offset);
|
||||
if (map == MAP_FAILED)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to map with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to map with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -191,7 +199,7 @@ namespace ehs
|
||||
return;
|
||||
|
||||
if (munmap(map, mapSize) == -1)
|
||||
EHS_LOG_INT("Error", 0, "Failed to unmap with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to unmap with error #" + Str_8::FromNum(errno) + ".");
|
||||
|
||||
map = MAP_FAILED;
|
||||
mapSize = 0;
|
||||
@ -203,7 +211,7 @@ namespace ehs
|
||||
return;
|
||||
|
||||
if (msync((void*)map, mapSize, MS_SYNC) == -1)
|
||||
EHS_LOG_INT("Error", 0, "Failed to flush view with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to flush view with error #" + Str_8::FromNum(errno) + ".");
|
||||
}
|
||||
|
||||
UInt_64 File::Write(const Byte *const data, const UInt_64 size)
|
||||
@ -214,7 +222,7 @@ namespace ehs
|
||||
SInt_64 written = 0;
|
||||
written = write(hdl, data, size);
|
||||
if (written == -1)
|
||||
EHS_LOG_INT("Error", 0, "Failed to write to file, \"" + path + "\", with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to write to file, \"" + path + "\", with error #" + Str_8::FromNum(errno) + ".");
|
||||
|
||||
return (UInt_64)written;
|
||||
}
|
||||
@ -227,7 +235,7 @@ namespace ehs
|
||||
SInt_64 read = 0;
|
||||
read = ::read(hdl, data, (size_t)size);
|
||||
if (read == -1)
|
||||
EHS_LOG_INT("Error", 0, "Failed to read from file, \"" + path + "\", with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to read from file, \"" + path + "\", with error #" + Str_8::FromNum(errno) + ".");
|
||||
|
||||
return (UInt_64)read;
|
||||
}
|
||||
@ -238,7 +246,7 @@ namespace ehs
|
||||
return;
|
||||
|
||||
if (lseek64(hdl, (off64_t)index, SEEK_SET) == -1)
|
||||
EHS_LOG_INT("Error", 0, "Failed to seek with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to seek with error #" + Str_8::FromNum(errno) + ".");
|
||||
}
|
||||
|
||||
void File::SeekBeginning()
|
||||
@ -247,7 +255,7 @@ namespace ehs
|
||||
return;
|
||||
|
||||
if (lseek64(hdl, 0, SEEK_SET) == -1)
|
||||
EHS_LOG_INT("Error", 0, "Failed to seek with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to seek with error #" + Str_8::FromNum(errno) + ".");
|
||||
}
|
||||
|
||||
void File::SeekEnd()
|
||||
@ -256,7 +264,7 @@ namespace ehs
|
||||
return;
|
||||
|
||||
if (lseek64(hdl, 0, SEEK_END) == -1)
|
||||
EHS_LOG_INT("Error", 0, "Failed to seek with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to seek with error #" + Str_8::FromNum(errno) + ".");
|
||||
}
|
||||
|
||||
void File::Truncate(const UInt_64 size)
|
||||
@ -265,7 +273,7 @@ namespace ehs
|
||||
return;
|
||||
|
||||
if (ftruncate64(hdl, (off64_t)size) == -1)
|
||||
EHS_LOG_INT("Error", 0, "Failed to truncate with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to truncate with error #" + Str_8::FromNum(errno) + ".");
|
||||
}
|
||||
|
||||
UInt_64 File::Size() const
|
||||
@ -273,7 +281,7 @@ namespace ehs
|
||||
struct stat64 info = {};
|
||||
|
||||
if (fstat64(hdl, &info) == -1)
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve file size with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to retrieve file size with error #" + Str_8::FromNum(errno) + ".");
|
||||
|
||||
return info.st_size;
|
||||
}
|
||||
@ -302,6 +310,6 @@ namespace ehs
|
||||
path = filePath.Sub(0, index);
|
||||
|
||||
if (rename(filePath, path + newName) == -1)
|
||||
EHS_LOG_INT("Error", 0, "Failed to rename file with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to rename file with error #" + Str_8::FromNum(errno) + ".");
|
||||
}
|
||||
}
|
||||
|
@ -5,13 +5,13 @@ namespace ehs
|
||||
File::~File()
|
||||
{
|
||||
if (view && !UnmapViewOfFile(view))
|
||||
EHS_LOG_INT("Error", 0, "Failed to unmap view with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to unmap view with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
if (map != INVALID_HANDLE_VALUE && !CloseHandle(map))
|
||||
EHS_LOG_INT("Error", 0, "Failed to unmap with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to unmap with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
if (hdl != INVALID_HANDLE_VALUE && !CloseHandle(hdl))
|
||||
EHS_LOG_INT("Error", 0, "Failed to close file handle with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to close file handle with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
}
|
||||
|
||||
File::File()
|
||||
@ -62,12 +62,14 @@ namespace ehs
|
||||
{
|
||||
DWORD code = GetLastError();
|
||||
if (code == ERROR_FILE_NOT_FOUND)
|
||||
EHS_LOG_INT("Error", 1, "File not found at path, \"" + path + "\".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "File not found at path, \"" + path + "\".");
|
||||
else if (code != ERROR_SUCCESS)
|
||||
EHS_LOG_INT("Error", 2, "Failed to create handle for file, \"" + path + "\", with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to create handle for file, \"" + path + "\", with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
EHS_LOG_SUCCESS();
|
||||
}
|
||||
|
||||
File::File(File&& file) noexcept
|
||||
@ -132,16 +134,16 @@ namespace ehs
|
||||
void File::Release()
|
||||
{
|
||||
if (view && !UnmapViewOfFile(view))
|
||||
EHS_LOG_INT("Error", 0, "Failed to unmap view with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to unmap view with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
view = nullptr;
|
||||
viewSize = 0;
|
||||
|
||||
if (IsMapped() && !CloseHandle(map))
|
||||
EHS_LOG_INT("Error", 0, "Failed to unmap with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to unmap with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
map = INVALID_HANDLE_VALUE;
|
||||
|
||||
if (IsValid() && !CloseHandle(hdl))
|
||||
EHS_LOG_INT("Error", 0, "Failed to close file handle with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to close file handle with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
hdl = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
@ -177,7 +179,7 @@ namespace ehs
|
||||
map = CreateFileMappingW(hdl, nullptr, winMode, 0, 0, nullptr);
|
||||
if (!map)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to create map handle with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to create map handle with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -197,10 +199,10 @@ namespace ehs
|
||||
view = (Byte*)MapViewOfFile(map, winMode, ((DWORD*)&offset)[1], (DWORD)offset, size);
|
||||
if (!view)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to map view with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to map view with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
if (!CloseHandle(map))
|
||||
EHS_LOG_INT("Error", 0, "Failed to unmap with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to unmap with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
map = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
@ -213,12 +215,12 @@ namespace ehs
|
||||
return;
|
||||
|
||||
if (!UnmapViewOfFile(view))
|
||||
EHS_LOG_INT("Error", 0, "Failed to unmap view with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to unmap view with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
view = nullptr;
|
||||
viewSize = 0;
|
||||
|
||||
if (!CloseHandle(map))
|
||||
EHS_LOG_INT("Error", 0, "Failed to unmap with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to unmap with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
map = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
@ -228,7 +230,7 @@ namespace ehs
|
||||
return;
|
||||
|
||||
if (!FlushViewOfFile(view, viewSize))
|
||||
EHS_LOG_INT("Error", 0, "Failed to flush view with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to flush view with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
}
|
||||
|
||||
UInt_64 File::Write(const Byte *const data, const UInt_64 size)
|
||||
@ -239,7 +241,7 @@ namespace ehs
|
||||
SInt_64 written = 0;
|
||||
|
||||
if (!WriteFile(hdl, data, (DWORD)size, (DWORD*)&written, nullptr))
|
||||
EHS_LOG_INT("Error", 0, "Failed to write to file, \"" + path + "\", with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to write to file, \"" + path + "\", with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
return (UInt_64)written;
|
||||
}
|
||||
@ -252,7 +254,7 @@ namespace ehs
|
||||
SInt_64 read = 0;
|
||||
|
||||
if (!ReadFile(hdl, data, (DWORD)size, (DWORD*)&read, nullptr))
|
||||
EHS_LOG_INT("Error", 0, "Failed to read from file, \"" + path + "\", with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to read from file, \"" + path + "\", with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
return (UInt_64)read;
|
||||
}
|
||||
@ -263,7 +265,7 @@ namespace ehs
|
||||
return;
|
||||
|
||||
if (SetFilePointer(hdl, (LONG)index, (PLONG)&((UInt_32*)&index)[1], FILE_BEGIN) == INVALID_SET_FILE_POINTER)
|
||||
EHS_LOG_INT("Error", 0, "Failed to seek with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to seek with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
}
|
||||
|
||||
void File::SeekBeginning()
|
||||
@ -272,7 +274,7 @@ namespace ehs
|
||||
return;
|
||||
|
||||
if (SetFilePointer(hdl, 0, nullptr, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
|
||||
EHS_LOG_INT("Error", 0, "Failed to seek with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to seek with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
}
|
||||
|
||||
void File::SeekEnd()
|
||||
@ -281,7 +283,7 @@ namespace ehs
|
||||
return;
|
||||
|
||||
if (SetFilePointer(hdl, 0, nullptr, FILE_END) == INVALID_SET_FILE_POINTER)
|
||||
EHS_LOG_INT("Error", 0, "Failed to seek with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to seek with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
}
|
||||
|
||||
void File::Truncate(const UInt_64 size)
|
||||
@ -292,7 +294,7 @@ namespace ehs
|
||||
Seek(size);
|
||||
|
||||
if (!::SetEndOfFile(hdl))
|
||||
EHS_LOG_INT("Error", 0, "Failed to set end of file with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to set end of file with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
SeekBeginning();
|
||||
}
|
||||
@ -305,7 +307,7 @@ namespace ehs
|
||||
LARGE_INTEGER size = {};
|
||||
|
||||
if (!GetFileSizeEx(hdl, &size))
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve file size with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to retrieve file size with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
return (UInt_64)size.QuadPart;
|
||||
}
|
||||
@ -329,7 +331,7 @@ namespace ehs
|
||||
path = filePath.Sub(0, index);
|
||||
|
||||
if (!MoveFileW(filePath, path + newName))
|
||||
EHS_LOG_INT("Error", 0, "Failed to rename file with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to rename file with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
}
|
||||
|
||||
void File::Rename_8(const Str_8& filePath, const Str_8& newName)
|
||||
|
@ -27,7 +27,7 @@ namespace ehs
|
||||
Version ver = fData.ReadVersion();
|
||||
if (ver != Version(1, 0, 0))
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "The Event Horizon Font file, \"" + filePath + "\", must be version 1.0.0, but was version " +
|
||||
EHS_LOG_INT(LogType::ERR, 2, "The Event Horizon Font file, \"" + filePath + "\", must be version 1.0.0, but was version " +
|
||||
Str_8::FromNum(ver.major) + "." + Str_8::FromNum(ver.minor) + "." +
|
||||
Str_8::FromNum(ver.patch) + ".");
|
||||
return;
|
||||
|
@ -12,7 +12,7 @@ namespace ehs
|
||||
Str_8 riffId = data.ReadStr<Char_8, UInt_64>(4);
|
||||
if (riffId != "RIFF")
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "File at file path, \"" + filePath + "\", is not a valid RIFF file.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "File at file path, \"" + filePath + "\", is not a valid RIFF file.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ namespace ehs
|
||||
Str_8 riffId = data.ReadStr<Char_8, UInt_64>(4);
|
||||
if (riffId != "RIFF")
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Data is not in RIFF format.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Data is not in RIFF format.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -65,32 +65,32 @@ namespace ehs
|
||||
{
|
||||
if (!IsValid())
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Cannot initialize with an invalid object.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Cannot initialize with an invalid object.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsInitialized())
|
||||
{
|
||||
EHS_LOG_INT("Warning", 1, "Object is already initialized.");
|
||||
EHS_LOG_INT(LogType::WARN, 1, "Object is already initialized.");
|
||||
return;
|
||||
}
|
||||
|
||||
hdl = open("/dev/bus/usb/" + Str_8::FromNum(GetBus()) + "/" + Str_8::FromNum(GetAddress()), O_RDWR);
|
||||
if (hdl == -1)
|
||||
EHS_LOG_INT("Error", 2, "Failed to connect to USB device.");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to connect to USB device.");
|
||||
}
|
||||
|
||||
void Usb::Release()
|
||||
{
|
||||
if (!IsValid())
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Cannot release with an invalid object.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Cannot release with an invalid object.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsInitialized())
|
||||
{
|
||||
EHS_LOG_INT("Warning", 1, "Object is already released.");
|
||||
EHS_LOG_INT(LogType::WARN, 1, "Object is already released.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ namespace ehs
|
||||
|
||||
if (GetRawInputData((HRAWINPUT)lParam, RID_INPUT, data, &dwSize, sizeof(RAWINPUTHEADER)) != dwSize)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Getting raw input returned incorrect size.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Getting raw input returned incorrect size.");
|
||||
delete[] data;
|
||||
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
@ -113,7 +113,7 @@ namespace ehs
|
||||
|
||||
if (GetRawInputDeviceInfo(raw->header.hDevice, RIDI_DEVICENAME, deviceName, &bufferSize) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve device name.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to retrieve device name.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -139,7 +139,7 @@ namespace ehs
|
||||
|
||||
if (GetRawInputDeviceInfo(raw->header.hDevice, RIDI_DEVICENAME, deviceName, &bufferSize) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Failed to retrieve device name.");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to retrieve device name.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -202,7 +202,7 @@ namespace ehs
|
||||
if (win->cursorConstrained)
|
||||
{
|
||||
if (!ClipCursor(nullptr))
|
||||
EHS_LOG_INT("Error", 0, "Failed to free cursor after losing focus with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to free cursor after losing focus with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
}
|
||||
|
||||
win->ih.ResetAllStates();
|
||||
@ -220,7 +220,7 @@ namespace ehs
|
||||
|
||||
if (!GetClientRect(win->GetHdl(), &client))
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve client scale with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to retrieve client scale with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
@ -228,7 +228,7 @@ namespace ehs
|
||||
|
||||
if (!ClientToScreen(win->GetHdl(), &pos))
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Failed to retrieve client's absolute position with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to retrieve client's absolute position with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
@ -239,7 +239,7 @@ namespace ehs
|
||||
|
||||
if (!ClientToScreen(win->GetHdl(), &scale))
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Failed to retrieve client's absolute scale with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to retrieve client's absolute scale with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
@ -248,7 +248,7 @@ namespace ehs
|
||||
|
||||
if (!ClipCursor(&client))
|
||||
{
|
||||
EHS_LOG_INT("Error", 3, "Failed to confine cursor with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 3, "Failed to confine cursor with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
}
|
||||
@ -347,7 +347,7 @@ namespace ehs
|
||||
wcex.lpszClassName = title;
|
||||
|
||||
if (!RegisterClassExW(&wcex))
|
||||
EHS_LOG_INT("Error", 0, "Failed to register window.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to register window.");
|
||||
|
||||
hdl = CreateWindowExW(
|
||||
0,
|
||||
@ -362,7 +362,7 @@ namespace ehs
|
||||
|
||||
if (!hdl)
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Failed to create window.");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to create window.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -391,7 +391,7 @@ namespace ehs
|
||||
|
||||
if (RegisterRawInputDevices(rid, 2, sizeof(rid[0])) == false)
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Failed to register raw input devices.");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to register raw input devices.");
|
||||
|
||||
return;
|
||||
}
|
||||
@ -434,7 +434,7 @@ namespace ehs
|
||||
void Window::SetTitle_32(const Str_32& title)
|
||||
{
|
||||
if (!SetWindowTextW(hdl, UTF::To_16(title)))
|
||||
EHS_LOG_INT("Error", 0, "Failed to set window title with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to set window title with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
}
|
||||
|
||||
Str_32 Window::GetTitle_32() const
|
||||
@ -445,7 +445,7 @@ namespace ehs
|
||||
DWORD err = GetLastError();
|
||||
if (err)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve the window's title length with error #" + Str_8::FromNum(err) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to retrieve the window's title length with error #" + Str_8::FromNum(err) + ".");
|
||||
|
||||
return {};
|
||||
}
|
||||
@ -459,7 +459,7 @@ namespace ehs
|
||||
DWORD err = GetLastError();
|
||||
if (err)
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Failed to retrieve the window's title length with error #" + Str_8::FromNum(err) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to retrieve the window's title length with error #" + Str_8::FromNum(err) + ".");
|
||||
|
||||
return {};
|
||||
}
|
||||
@ -471,7 +471,7 @@ namespace ehs
|
||||
void Window::SetTitle_16(const Str_16& title)
|
||||
{
|
||||
if (!SetWindowTextW(hdl, title))
|
||||
EHS_LOG_INT("Error", 0, "Failed to set window title with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to set window title with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
}
|
||||
|
||||
Str_16 Window::GetTitle_16() const
|
||||
@ -482,7 +482,7 @@ namespace ehs
|
||||
DWORD err = GetLastError();
|
||||
if (err)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve the window's title length with error #" + Str_8::FromNum(err) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to retrieve the window's title length with error #" + Str_8::FromNum(err) + ".");
|
||||
|
||||
return {};
|
||||
}
|
||||
@ -496,7 +496,7 @@ namespace ehs
|
||||
DWORD err = GetLastError();
|
||||
if (err)
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Failed to retrieve the window's title length with error #" + Str_8::FromNum(err) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to retrieve the window's title length with error #" + Str_8::FromNum(err) + ".");
|
||||
|
||||
return {};
|
||||
}
|
||||
@ -508,7 +508,7 @@ namespace ehs
|
||||
void Window::SetTitle_8(const Str_8& title)
|
||||
{
|
||||
if (!SetWindowTextW(hdl, UTF::To_16(title)))
|
||||
EHS_LOG_INT("Error", 0, "Failed to set window title with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to set window title with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
}
|
||||
|
||||
Str_8 Window::GetTitle_8() const
|
||||
@ -519,7 +519,7 @@ namespace ehs
|
||||
DWORD err = GetLastError();
|
||||
if (err)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve the window's title length with error #" + Str_8::FromNum(err) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to retrieve the window's title length with error #" + Str_8::FromNum(err) + ".");
|
||||
|
||||
return {};
|
||||
}
|
||||
@ -533,7 +533,7 @@ namespace ehs
|
||||
DWORD err = GetLastError();
|
||||
if (err)
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Failed to retrieve the window's title length with error #" + Str_8::FromNum(err) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to retrieve the window's title length with error #" + Str_8::FromNum(err) + ".");
|
||||
|
||||
return {};
|
||||
}
|
||||
@ -547,7 +547,7 @@ namespace ehs
|
||||
Handle icon = LoadImageW(nullptr, UTF::To_16(filePath), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE);
|
||||
if (!icon)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to load icon at file path, \"" + filePath + "\" with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to load icon at file path, \"" + filePath + "\" with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -634,7 +634,7 @@ namespace ehs
|
||||
RECT rect = {};
|
||||
|
||||
if (!GetClientRect(hdl, &rect))
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve client size with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to retrieve client size with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
return {(UInt_32)rect.right, (UInt_32)rect.bottom};
|
||||
}
|
||||
@ -677,7 +677,7 @@ namespace ehs
|
||||
|
||||
if (!GetClientRect(GetHdl(), &client))
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve client scale with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to retrieve client scale with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -685,7 +685,7 @@ namespace ehs
|
||||
|
||||
if (!ClientToScreen(GetHdl(), &pos))
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Failed to retrieve client's absolute position with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to retrieve client's absolute position with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -696,7 +696,7 @@ namespace ehs
|
||||
|
||||
if (!ClientToScreen(GetHdl(), &scale))
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Failed to retrieve client's absolute scale with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to retrieve client's absolute scale with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -705,7 +705,7 @@ namespace ehs
|
||||
|
||||
if (!ClipCursor(&client))
|
||||
{
|
||||
EHS_LOG_INT("Error", 3, "Failed to confine cursor with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 3, "Failed to confine cursor with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ namespace ehs
|
||||
display = wl_display_connect(nullptr);
|
||||
if (!display)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to connect to display server.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to connect to display server.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -87,7 +87,7 @@ namespace ehs
|
||||
|
||||
if (!compositor || !xdgShell)
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Can't find required interfaces.");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Can't find required interfaces.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -98,7 +98,7 @@ namespace ehs
|
||||
surface = wl_compositor_create_surface(compositor);
|
||||
if (!surface)
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Can't create surface.");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Can't create surface.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ namespace ehs
|
||||
server = xcb_connect(nullptr, nullptr);
|
||||
if (xcb_connection_has_error(server))
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to connect to display server.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to connect to display server.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@ namespace ehs
|
||||
{
|
||||
xcb_disconnect(server);
|
||||
|
||||
EHS_LOG_INT("Warning", 1, "Failed to query for XCB XInput extension.");
|
||||
EHS_LOG_INT(LogType::WARN, 1, "Failed to query for XCB XInput extension.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -159,7 +159,7 @@ namespace ehs
|
||||
{
|
||||
xcb_disconnect(server);
|
||||
|
||||
EHS_LOG_INT("Warning", 2, "XCB XInput extension is not available.");
|
||||
EHS_LOG_INT(LogType::WARN, 2, "XCB XInput extension is not available.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -459,7 +459,7 @@ namespace ehs
|
||||
if (!reply || reply->status != XCB_GRAB_STATUS_SUCCESS)
|
||||
{
|
||||
free(reply);
|
||||
EHS_LOG_INT("Error", 0, "Failed to constrain cursor.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to constrain cursor.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -522,7 +522,7 @@ namespace ehs
|
||||
xcb_get_geometry_reply_t *geom = xcb_get_geometry_reply(server, geom_cookie, nullptr);
|
||||
if (!geom)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve window position.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to retrieve window position.");
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -548,7 +548,7 @@ namespace ehs
|
||||
xcb_get_geometry_reply_t *geom = xcb_get_geometry_reply(server, geom_cookie, nullptr);
|
||||
if (!geom)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve window scale.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to retrieve window scale.");
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -569,7 +569,7 @@ namespace ehs
|
||||
|
||||
if (clipboard_atom == XCB_ATOM_NONE || utf8_string_atom == XCB_ATOM_NONE || property_atom == XCB_ATOM_NONE)
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Failed to retrieve atoms.");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to retrieve atoms.");
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -604,7 +604,7 @@ namespace ehs
|
||||
const xcb_atom_t clipboard_atom = RetrieveAtom(false, "CLIPBOARD");
|
||||
if (clipboard_atom == XCB_ATOM_NONE)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve atom.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to retrieve atom.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -683,7 +683,7 @@ namespace ehs
|
||||
|
||||
if (!device_reply)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to query primary devices.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to query primary devices.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -715,7 +715,7 @@ namespace ehs
|
||||
|
||||
if (!device_reply)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to query device name from the id, \"" + Str_8::FromNum(id) + "\".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to query device name from the id, \"" + Str_8::FromNum(id) + "\".");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ namespace ehs
|
||||
const AudioCodec* codec = GetCodec(ext);
|
||||
if (!codec)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ namespace ehs
|
||||
const AudioCodec* codec = GetCodec(ext);
|
||||
if (!codec)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -332,7 +332,7 @@ namespace ehs
|
||||
}
|
||||
else
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Conversion from " + Str_8::FromNum(channels) + " channels, to 2 channels is unsupported.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Conversion from " + Str_8::FromNum(channels) + " channels, to 2 channels is unsupported.");
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -363,7 +363,7 @@ namespace ehs
|
||||
}
|
||||
else
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Conversion from " + Str_8::FromNum(channels) + " channels, to 6 channels is unsupported.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Conversion from " + Str_8::FromNum(channels) + " channels, to 6 channels is unsupported.");
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -394,7 +394,7 @@ namespace ehs
|
||||
}
|
||||
else
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Conversion from " + Str_8::FromNum(channels) + " channels, to 8 channels is unsupported.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Conversion from " + Str_8::FromNum(channels) + " channels, to 8 channels is unsupported.");
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -779,7 +779,7 @@ namespace ehs
|
||||
}
|
||||
else
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Conversion from " + Str_8::FromNum(channels) + " channels, to " +
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Conversion from " + Str_8::FromNum(channels) + " channels, to " +
|
||||
Str_8::FromNum(newChannels) + " channels is unsupported.");
|
||||
return;
|
||||
}
|
||||
@ -878,7 +878,7 @@ namespace ehs
|
||||
}
|
||||
else
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Conversion from " + Str_8::FromNum(channels) + " channels, to " +
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Conversion from " + Str_8::FromNum(channels) + " channels, to " +
|
||||
Str_8::FromNum(newChannels) + " channels is unsupported.");
|
||||
|
||||
return result;
|
||||
@ -901,7 +901,7 @@ namespace ehs
|
||||
const AudioCodec* codec = GetCodec(ext);
|
||||
if (!codec)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1927,7 +1927,7 @@ namespace ehs
|
||||
Version version = in.ReadVersion();
|
||||
if (version != Version(1, 0, 0))
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Incompatible audio file version.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Incompatible audio file version.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1954,14 +1954,14 @@ namespace ehs
|
||||
|
||||
if (riff.GetType() != "WAVE")
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Data is not in WAVE format.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Data is not in WAVE format.");
|
||||
return false;
|
||||
}
|
||||
|
||||
RIFF_Chunk fmt = riff.GetChunk("fmt ");
|
||||
if (!fmt.IsValid())
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Wave does not have a format chunk.");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Wave does not have a format chunk.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1970,59 +1970,59 @@ namespace ehs
|
||||
RIFF_Chunk dChunk = riff.GetChunk("data");
|
||||
if (!dChunk.IsValid())
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Wave does not have a data chunk.");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Wave does not have a data chunk.");
|
||||
return false;
|
||||
}
|
||||
|
||||
UInt_16 compression = fmtSer.Read<UInt_16>();
|
||||
if (compression == 0x2)
|
||||
{
|
||||
EHS_LOG_INT("Error", 3, "Microsoft ADPCM compression unsupported.");
|
||||
EHS_LOG_INT(LogType::ERR, 3, "Microsoft ADPCM compression unsupported.");
|
||||
return false;
|
||||
}
|
||||
else if (compression == 0x6)
|
||||
{
|
||||
EHS_LOG_INT("Error", 4, "ITU G.711 a-law compression unsupported.");
|
||||
EHS_LOG_INT(LogType::ERR, 4, "ITU G.711 a-law compression unsupported.");
|
||||
return false;
|
||||
}
|
||||
else if (compression == 0x7)
|
||||
{
|
||||
EHS_LOG_INT("Error", 5, "ITU G.711 µ-law compression unsupported.");
|
||||
EHS_LOG_INT(LogType::ERR, 5, "ITU G.711 µ-law compression unsupported.");
|
||||
return false;
|
||||
}
|
||||
else if (compression == 0x11)
|
||||
{
|
||||
EHS_LOG_INT("Error", 6, "IMA ADPCM compression unsupported.");
|
||||
EHS_LOG_INT(LogType::ERR, 6, "IMA ADPCM compression unsupported.");
|
||||
return false;
|
||||
}
|
||||
else if (compression == 0x16)
|
||||
{
|
||||
EHS_LOG_INT("Error", 7, "TU G.723 ADPCM (Yamaha) compression unsupported.");
|
||||
EHS_LOG_INT(LogType::ERR, 7, "TU G.723 ADPCM (Yamaha) compression unsupported.");
|
||||
return false;
|
||||
}
|
||||
else if (compression == 0x31)
|
||||
{
|
||||
EHS_LOG_INT("Error", 8, "GSM 6.10 compression unsupported.");
|
||||
EHS_LOG_INT(LogType::ERR, 8, "GSM 6.10 compression unsupported.");
|
||||
return false;
|
||||
}
|
||||
else if (compression == 0x40)
|
||||
{
|
||||
EHS_LOG_INT("Error", 9, "ITU G.721 ADPCM compression unsupported.");
|
||||
EHS_LOG_INT(LogType::ERR, 9, "ITU G.721 ADPCM compression unsupported.");
|
||||
return false;
|
||||
}
|
||||
else if (compression == 0x50)
|
||||
{
|
||||
EHS_LOG_INT("Error", 10, "MPEG compression unsupported.");
|
||||
EHS_LOG_INT(LogType::ERR, 10, "MPEG compression unsupported.");
|
||||
return false;
|
||||
}
|
||||
else if (compression == 0xFFFF)
|
||||
{
|
||||
EHS_LOG_INT("Error", 11, "Experimental compression unsupported.");
|
||||
EHS_LOG_INT(LogType::ERR, 11, "Experimental compression unsupported.");
|
||||
return false;
|
||||
}
|
||||
else if (compression != 0x1 && compression != 0x3)
|
||||
{
|
||||
EHS_LOG_INT("Error", 12, "Wave has unknown compression of " + Str_8::FromNum(compression) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 12, "Wave has unknown compression of " + Str_8::FromNum(compression) + ".");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ namespace ehs
|
||||
{
|
||||
if (!encodeCb)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Encoding is not supported for the " + id + " format.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Encoding is not supported for the " + id + " format.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ namespace ehs
|
||||
{
|
||||
if (!decodeCb)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Decoding is not supported for the " + id + " format.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Decoding is not supported for the " + id + " format.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ namespace ehs
|
||||
|
||||
if (snd_pcm_hw_params_set_access(hdl, params, SND_PCM_ACCESS_MMAP_INTERLEAVED) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to set access.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to set access.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@ namespace ehs
|
||||
}
|
||||
default:
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Invalid data type.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Invalid data type.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -125,7 +125,7 @@ namespace ehs
|
||||
{
|
||||
if (snd_pcm_hw_params_set_channels_near(hdl, params, &channels) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Failed to set channels.");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to set channels.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -134,26 +134,26 @@ namespace ehs
|
||||
{
|
||||
if (snd_pcm_hw_params_set_rate_near(hdl, params, &sampleRate, nullptr) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Failed to set sample rate.");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to set sample rate.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (snd_pcm_hw_params_set_period_time_near(hdl, params, &period, nullptr) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 3, "Failed to set period.");
|
||||
EHS_LOG_INT(LogType::ERR, 3, "Failed to set period.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (snd_pcm_hw_params_set_buffer_time_near(hdl, params, &latency, nullptr) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 4, "Failed to set latency.");
|
||||
EHS_LOG_INT(LogType::ERR, 4, "Failed to set latency.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (snd_pcm_hw_params(hdl, params) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 5, "Failed to apply hardware parameters.");
|
||||
EHS_LOG_INT(LogType::ERR, 5, "Failed to apply hardware parameters.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -162,7 +162,7 @@ namespace ehs
|
||||
snd_pcm_format_t format;
|
||||
if (snd_pcm_hw_params_get_format(params, &format) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 6, "Failed to retrieve audio device properties.");
|
||||
EHS_LOG_INT(LogType::ERR, 6, "Failed to retrieve audio device properties.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -200,7 +200,7 @@ namespace ehs
|
||||
}
|
||||
default:
|
||||
{
|
||||
EHS_LOG_INT("Error", 7, "Format unsupported.");
|
||||
EHS_LOG_INT(LogType::ERR, 7, "Format unsupported.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -210,7 +210,7 @@ namespace ehs
|
||||
{
|
||||
if (snd_pcm_hw_params_get_channels(params, &channels) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 8, "Failed to retrieve channel count.");
|
||||
EHS_LOG_INT(LogType::ERR, 8, "Failed to retrieve channel count.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -220,14 +220,14 @@ namespace ehs
|
||||
int dir;
|
||||
if (snd_pcm_hw_params_get_rate(params, &sampleRate, &dir) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 9, "Failed to retrieve sample rate.");
|
||||
EHS_LOG_INT(LogType::ERR, 9, "Failed to retrieve sample rate.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (snd_pcm_hw_params_get_buffer_size(params, &maxFrames) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 10, "Failed to retrieve buffer size.");
|
||||
EHS_LOG_INT(LogType::ERR, 10, "Failed to retrieve buffer size.");
|
||||
}
|
||||
|
||||
snd_pcm_sw_params_t* swParams = nullptr;
|
||||
@ -235,31 +235,31 @@ namespace ehs
|
||||
|
||||
if (snd_pcm_sw_params_current(hdl, swParams) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 11, "Failed to retrieve software parameters.");
|
||||
EHS_LOG_INT(LogType::ERR, 11, "Failed to retrieve software parameters.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (snd_pcm_sw_params_set_silence_threshold(hdl, swParams, maxFrames) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 12, "Failed to set silence threshold.");
|
||||
EHS_LOG_INT(LogType::ERR, 12, "Failed to set silence threshold.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (snd_pcm_sw_params_set_silence_size(hdl, swParams, maxFrames) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 12, "Failed to set silence size.");
|
||||
EHS_LOG_INT(LogType::ERR, 12, "Failed to set silence size.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (snd_pcm_sw_params(hdl, swParams) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 13, "Failed to set software parameters.");
|
||||
EHS_LOG_INT(LogType::ERR, 13, "Failed to set software parameters.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (snd_pcm_prepare(hdl) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 14, "Failed to prepare audio stream.");
|
||||
EHS_LOG_INT(LogType::ERR, 14, "Failed to prepare audio stream.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -281,10 +281,10 @@ namespace ehs
|
||||
snd_pcm_state_t state = snd_pcm_state(hdl);
|
||||
if (state == SND_PCM_STATE_XRUN)
|
||||
{
|
||||
EHS_LOG_INT("Warning", 0, "Buffer overrun/underrun occurred.");
|
||||
EHS_LOG_INT(LogType::WARN, 0, "Buffer overrun/underrun occurred.");
|
||||
if (snd_pcm_recover(hdl, -EPIPE, 0) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Failed to recover from buffer overrun/underrun.");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to recover from buffer overrun/underrun.");
|
||||
return 0;
|
||||
}
|
||||
return GetAvailFrames();
|
||||
@ -293,7 +293,7 @@ namespace ehs
|
||||
{
|
||||
if (snd_pcm_start(hdl) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Failed to start audio stream.");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to start audio stream.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -305,10 +305,10 @@ namespace ehs
|
||||
{
|
||||
if (frames == -EPIPE)
|
||||
{
|
||||
EHS_LOG_INT("Warning", 3, "Buffer overrun/underrun occurred.");
|
||||
EHS_LOG_INT(LogType::WARN, 3, "Buffer overrun/underrun occurred.");
|
||||
if (snd_pcm_recover(hdl, -EPIPE, 1) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 4, "Failed to recover from buffer overrun/underrun.");
|
||||
EHS_LOG_INT(LogType::ERR, 4, "Failed to recover from buffer overrun/underrun.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -316,7 +316,7 @@ namespace ehs
|
||||
}
|
||||
else
|
||||
{
|
||||
EHS_LOG_INT("Error", 5, "Failed to retrieve available frames with error #" + Str_8::FromNum(frames) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 5, "Failed to retrieve available frames with error #" + Str_8::FromNum(frames) + ".");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -329,7 +329,7 @@ namespace ehs
|
||||
const snd_pcm_channel_area_t* areas;
|
||||
if (snd_pcm_mmap_begin(hdl, &areas, offset, frames) < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to map audio buffer.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to map audio buffer.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -341,7 +341,7 @@ namespace ehs
|
||||
snd_pcm_sframes_t committed = snd_pcm_mmap_commit(hdl, offset, frames);
|
||||
if (committed < 0)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to commit mapped audio buffer.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to commit mapped audio buffer.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -366,7 +366,7 @@ namespace ehs
|
||||
}
|
||||
else
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Wrong value for the audio device type.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Wrong value for the audio device type.");
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ namespace ehs
|
||||
HRESULT r = client->Stop();
|
||||
if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to stop audio with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to stop audio with error #" + Str_8::FromNum(r) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@ namespace ehs
|
||||
|
||||
HRESULT r = hdl->Activate(__uuidof(IAudioClient), CLSCTX_ALL, nullptr, (void**)&client);
|
||||
if (FAILED(r))
|
||||
EHS_LOG_INT("Error", 0, "Failed to create audio client with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to create audio client with error #" + Str_8::FromNum(r) + ".");
|
||||
|
||||
WAVEFORMATEXTENSIBLE* format;
|
||||
client->GetMixFormat((WAVEFORMATEX**)&format);
|
||||
@ -146,7 +146,7 @@ namespace ehs
|
||||
{
|
||||
if (r == AUDCLNT_E_UNSUPPORTED_FORMAT)
|
||||
{
|
||||
EHS_LOG_INT("Error", 1,
|
||||
EHS_LOG_INT(LogType::ERR, 1,
|
||||
"The audio device, \"" + GetName_8() + "\" doesn't support the format {" +
|
||||
Str_8::FromNum(format->Format.wBitsPerSample) + "-bit, " +
|
||||
Str_8::FromNum(format->Format.nSamplesPerSec) + "Hz, " +
|
||||
@ -154,14 +154,14 @@ namespace ehs
|
||||
);
|
||||
}
|
||||
else
|
||||
EHS_LOG_INT("Error", 2, "Failed to retrieve supported audio format with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to retrieve supported audio format with error #" + Str_8::FromNum(r) + ".");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (match)
|
||||
{
|
||||
EHS_LOG_INT("Error", 3,
|
||||
EHS_LOG_INT(LogType::ERR, 3,
|
||||
"The audio device, \"" + GetName_8() + "\" doesn't support the format {" +
|
||||
Str_8::FromNum(format->Format.wBitsPerSample) + "-bit, " +
|
||||
Str_8::FromNum(format->Format.nSamplesPerSec) + "Hz, " +
|
||||
@ -185,78 +185,78 @@ namespace ehs
|
||||
|
||||
if (r == AUDCLNT_E_ALREADY_INITIALIZED)
|
||||
{
|
||||
EHS_LOG_INT("Error", 5, "Audio client is already initialized.");
|
||||
EHS_LOG_INT(LogType::ERR, 5, "Audio client is already initialized.");
|
||||
return;
|
||||
}
|
||||
else if (r == AUDCLNT_E_WRONG_ENDPOINT_TYPE)
|
||||
{
|
||||
EHS_LOG_INT("Error", 6, "The AUDCLNT_STREAMFLAGS_LOOPBACK flag is set but the endpoint device is a capture device, not a rendering device.");
|
||||
EHS_LOG_INT(LogType::ERR, 6, "The AUDCLNT_STREAMFLAGS_LOOPBACK flag is set but the endpoint device is a capture device, not a rendering device.");
|
||||
return;
|
||||
}
|
||||
else if (r == AUDCLNT_E_BUFFER_SIZE_ERROR)
|
||||
{
|
||||
EHS_LOG_INT("Error", 7, "Indicates that the buffer duration value requested by an exclusive-mode client is out of range. The requested duration value for pull mode must not be greater than 5000 milliseconds; for push mode the duration value must not be greater than 2 seconds.");
|
||||
EHS_LOG_INT(LogType::ERR, 7, "Indicates that the buffer duration value requested by an exclusive-mode client is out of range. The requested duration value for pull mode must not be greater than 5000 milliseconds; for push mode the duration value must not be greater than 2 seconds.");
|
||||
return;
|
||||
}
|
||||
else if (r == AUDCLNT_E_CPUUSAGE_EXCEEDED)
|
||||
{
|
||||
EHS_LOG_INT("Error", 8, "The audio endpoint device has been unplugged, or the audio hardware or associated hardware resources have been reconfigured, disabled, removed, or otherwise made unavailable for use.");
|
||||
EHS_LOG_INT(LogType::ERR, 8, "The audio endpoint device has been unplugged, or the audio hardware or associated hardware resources have been reconfigured, disabled, removed, or otherwise made unavailable for use.");
|
||||
return;
|
||||
}
|
||||
else if (r == AUDCLNT_E_DEVICE_IN_USE)
|
||||
{
|
||||
EHS_LOG_INT("Error", 9, "The endpoint device is already in use. Either the device is being used in exclusive mode, or the device is being used in shared mode and the caller asked to use the device in exclusive mode.");
|
||||
EHS_LOG_INT(LogType::ERR, 9, "The endpoint device is already in use. Either the device is being used in exclusive mode, or the device is being used in shared mode and the caller asked to use the device in exclusive mode.");
|
||||
return;
|
||||
}
|
||||
else if (r == AUDCLNT_E_ENDPOINT_CREATE_FAILED)
|
||||
{
|
||||
EHS_LOG_INT("Error", 10, "The method failed to create the audio endpoint for the render or the capture device. This can occur if the audio endpoint device has been unplugged, or the audio hardware or associated hardware resources have been reconfigured, disabled, removed, or otherwise made unavailable for use.");
|
||||
EHS_LOG_INT(LogType::ERR, 10, "The method failed to create the audio endpoint for the render or the capture device. This can occur if the audio endpoint device has been unplugged, or the audio hardware or associated hardware resources have been reconfigured, disabled, removed, or otherwise made unavailable for use.");
|
||||
return;
|
||||
}
|
||||
else if (r == AUDCLNT_E_INVALID_DEVICE_PERIOD)
|
||||
{
|
||||
EHS_LOG_INT("Error", 11, "Indicates that the device period requested by an exclusive-mode client is greater than 5000 milliseconds.");
|
||||
EHS_LOG_INT(LogType::ERR, 11, "Indicates that the device period requested by an exclusive-mode client is greater than 5000 milliseconds.");
|
||||
return;
|
||||
}
|
||||
else if (r == AUDCLNT_E_UNSUPPORTED_FORMAT)
|
||||
{
|
||||
EHS_LOG_INT("Error", 12, "The audio engine (shared mode) or audio endpoint device (exclusive mode) does not support the specified format.");
|
||||
EHS_LOG_INT(LogType::ERR, 12, "The audio engine (shared mode) or audio endpoint device (exclusive mode) does not support the specified format.");
|
||||
return;
|
||||
}
|
||||
else if (r == AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED)
|
||||
{
|
||||
EHS_LOG_INT("Error", 13, "The caller is requesting exclusive-mode use of the endpoint device, but the user has disabled exclusive-mode use of the device.");
|
||||
EHS_LOG_INT(LogType::ERR, 13, "The caller is requesting exclusive-mode use of the endpoint device, but the user has disabled exclusive-mode use of the device.");
|
||||
return;
|
||||
}
|
||||
else if (r == AUDCLNT_E_BUFDURATION_PERIOD_NOT_EQUAL)
|
||||
{
|
||||
EHS_LOG_INT("Error", 14, "The AUDCLNT_STREAMFLAGS_EVENTCALLBACK flag is set but parameters hnsBufferDuration and hnsPeriodicity are not equal.");
|
||||
EHS_LOG_INT(LogType::ERR, 14, "The AUDCLNT_STREAMFLAGS_EVENTCALLBACK flag is set but parameters hnsBufferDuration and hnsPeriodicity are not equal.");
|
||||
return;
|
||||
}
|
||||
else if (r == AUDCLNT_E_SERVICE_NOT_RUNNING)
|
||||
{
|
||||
EHS_LOG_INT("Error", 15, "The Windows audio service is not running.");
|
||||
EHS_LOG_INT(LogType::ERR, 15, "The Windows audio service is not running.");
|
||||
return;
|
||||
}
|
||||
else if (r == E_POINTER)
|
||||
{
|
||||
EHS_LOG_INT("Error", 16, "Parameter pFormat is NULL.");
|
||||
EHS_LOG_INT(LogType::ERR, 16, "Parameter pFormat is NULL.");
|
||||
return;
|
||||
}
|
||||
else if (r == E_INVALIDARG)
|
||||
{
|
||||
EHS_LOG_INT("Error", 17, "Parameter pFormat points to an invalid format description; or the AUDCLNT_STREAMFLAGS_LOOPBACK flag is set but ShareMode is not equal to AUDCLNT_SHAREMODE_SHARED; or the AUDCLNT_STREAMFLAGS_CROSSPROCESS flag is set but ShareMode is equal to AUDCLNT_SHAREMODE_EXCLUSIVE.\n"
|
||||
EHS_LOG_INT(LogType::ERR, 17, "Parameter pFormat points to an invalid format description; or the AUDCLNT_STREAMFLAGS_LOOPBACK flag is set but ShareMode is not equal to AUDCLNT_SHAREMODE_SHARED; or the AUDCLNT_STREAMFLAGS_CROSSPROCESS flag is set but ShareMode is equal to AUDCLNT_SHAREMODE_EXCLUSIVE.\n"
|
||||
"A prior call to SetClientProperties was made with an invalid category for audio/render streams.");
|
||||
return;
|
||||
}
|
||||
else if (r == E_OUTOFMEMORY)
|
||||
{
|
||||
EHS_LOG_INT("Error", 18, "Out of memory.");
|
||||
EHS_LOG_INT(LogType::ERR, 18, "Out of memory.");
|
||||
return;
|
||||
}
|
||||
else if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 19, "Failed to initialize audio stream with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 19, "Failed to initialize audio stream with error #" + Str_8::FromNum(r) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -265,7 +265,7 @@ namespace ehs
|
||||
r = client->GetService(__uuidof(IAudioRenderClient), (void**)&playbackClient);
|
||||
if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 27, "Failed to retrieve audio render client with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 27, "Failed to retrieve audio render client with error #" + Str_8::FromNum(r) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -274,7 +274,7 @@ namespace ehs
|
||||
r = client->GetService(__uuidof(IAudioCaptureClient), (void**)&captureClient);
|
||||
if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 28, "Failed to retrieve audio capture client with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 28, "Failed to retrieve audio capture client with error #" + Str_8::FromNum(r) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -282,14 +282,14 @@ namespace ehs
|
||||
r = client->GetBufferSize((UINT32*)&maxFrames);
|
||||
if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 29, "Failed to retrieve buffer size with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 29, "Failed to retrieve buffer size with error #" + Str_8::FromNum(r) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
r = client->Start();
|
||||
if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 30, "Failed to start audio with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 30, "Failed to start audio with error #" + Str_8::FromNum(r) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -318,7 +318,7 @@ namespace ehs
|
||||
HRESULT r = client->Stop();
|
||||
if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to stop audio with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to stop audio with error #" + Str_8::FromNum(r) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -340,9 +340,9 @@ namespace ehs
|
||||
{
|
||||
HRESULT r = client->GetCurrentPadding(&sampleSize);
|
||||
if (r == AUDCLNT_E_DEVICE_INVALIDATED)
|
||||
EHS_LOG_INT("Error", 0, "The audio device has been invalidated.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "The audio device has been invalidated.");
|
||||
else if (FAILED(r))
|
||||
EHS_LOG_INT("Error", 1, "Failed to retrieve samples padding with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to retrieve samples padding with error #" + Str_8::FromNum(r) + ".");
|
||||
|
||||
sampleSize = maxFrames - sampleSize;
|
||||
}
|
||||
@ -350,9 +350,9 @@ namespace ehs
|
||||
{
|
||||
HRESULT r = captureClient->GetNextPacketSize(&sampleSize);
|
||||
if (r == AUDCLNT_E_DEVICE_INVALIDATED)
|
||||
EHS_LOG_INT("Error", 0, "The audio device has been invalidated.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "The audio device has been invalidated.");
|
||||
else if (FAILED(r))
|
||||
EHS_LOG_INT("Error", 1, "Failed to retrieve samples size with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to retrieve samples size with error #" + Str_8::FromNum(r) + ".");
|
||||
}
|
||||
|
||||
return sampleSize;
|
||||
@ -367,19 +367,19 @@ namespace ehs
|
||||
|
||||
HRESULT r = client->GetCurrentPadding((UINT32*)&offset);
|
||||
if (r == AUDCLNT_E_DEVICE_INVALIDATED)
|
||||
EHS_LOG_INT("Error", 0, "The audio device has been invalidated.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "The audio device has been invalidated.");
|
||||
else if (FAILED(r))
|
||||
EHS_LOG_INT("Error", 1, "Failed to retrieve samples padding with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to retrieve samples padding with error #" + Str_8::FromNum(r) + ".");
|
||||
|
||||
if (playbackClient)
|
||||
{
|
||||
r = playbackClient->GetBuffer(*frames, &buffer);
|
||||
if (r == AUDCLNT_E_BUFFER_TOO_LARGE)
|
||||
EHS_LOG_INT("Error", 0, "The given frame size, " + Str_8::FromNum(*frames) + ", must be less than or equal to, " + Str_8::FromNum(maxFrames - *offset) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "The given frame size, " + Str_8::FromNum(*frames) + ", must be less than or equal to, " + Str_8::FromNum(maxFrames - *offset) + ".");
|
||||
else if (r == AUDCLNT_E_DEVICE_INVALIDATED)
|
||||
EHS_LOG_INT("Error", 1, "The audio device has been invalidated.");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "The audio device has been invalidated.");
|
||||
else if (FAILED(r))
|
||||
EHS_LOG_INT("Error", 2, "Failed to retrieve buffer with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to retrieve buffer with error #" + Str_8::FromNum(r) + ".");
|
||||
}
|
||||
else if (captureClient)
|
||||
{
|
||||
@ -387,9 +387,9 @@ namespace ehs
|
||||
|
||||
r = captureClient->GetBuffer(&buffer, (UINT32*)frames, (DWORD*)&flags, nullptr, nullptr);
|
||||
if (r == AUDCLNT_E_DEVICE_INVALIDATED)
|
||||
EHS_LOG_INT("Error", 1, "The audio device has been invalidated.");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "The audio device has been invalidated.");
|
||||
else if (FAILED(r))
|
||||
EHS_LOG_INT("Error", 2, "Failed to retrieve buffer with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to retrieve buffer with error #" + Str_8::FromNum(r) + ".");
|
||||
}
|
||||
|
||||
return buffer;
|
||||
@ -404,17 +404,17 @@ namespace ehs
|
||||
{
|
||||
HRESULT r = playbackClient->ReleaseBuffer(frames, 0);
|
||||
if (r == AUDCLNT_E_DEVICE_INVALIDATED)
|
||||
EHS_LOG_INT("Error", 0, "The audio device has been invalidated.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "The audio device has been invalidated.");
|
||||
else if (FAILED(r))
|
||||
EHS_LOG_INT("Error", 1, "Failed to release buffer with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to release buffer with error #" + Str_8::FromNum(r) + ".");
|
||||
}
|
||||
else if (captureClient)
|
||||
{
|
||||
HRESULT r = captureClient->ReleaseBuffer(frames);
|
||||
if (r == AUDCLNT_E_DEVICE_INVALIDATED)
|
||||
EHS_LOG_INT("Error", 0, "The audio device has been invalidated.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "The audio device has been invalidated.");
|
||||
else if (FAILED(r))
|
||||
EHS_LOG_INT("Error", 1, "Failed to release buffer with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to release buffer with error #" + Str_8::FromNum(r) + ".");
|
||||
}
|
||||
}
|
||||
|
||||
@ -429,7 +429,7 @@ namespace ehs
|
||||
HRESULT r = hdl->OpenPropertyStore(STGM_READ, &pProps);
|
||||
if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve interface name with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to retrieve interface name with error #" + Str_8::FromNum(r) + ".");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -462,7 +462,7 @@ namespace ehs
|
||||
HRESULT r = hdl->OpenPropertyStore(STGM_READ, &pProps);
|
||||
if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve name with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to retrieve name with error #" + Str_8::FromNum(r) + ".");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -496,7 +496,7 @@ namespace ehs
|
||||
HRESULT r = CoInitialize(nullptr);
|
||||
if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to initialize COM with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to initialize COM with error #" + Str_8::FromNum(r) + ".");
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -504,7 +504,7 @@ namespace ehs
|
||||
r = CoCreateInstance(__uuidof(MMDeviceEnumerator), nullptr, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void**)&enumerator);
|
||||
if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Failed to initialize WASAPI with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to initialize WASAPI with error #" + Str_8::FromNum(r) + ".");
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -512,7 +512,7 @@ namespace ehs
|
||||
r = enumerator->GetDefaultAudioEndpoint((EDataFlow)type, eConsole, &deviceHdl);
|
||||
if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Failed to retrieve default audio output device with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to retrieve default audio output device with error #" + Str_8::FromNum(r) + ".");
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -531,7 +531,7 @@ namespace ehs
|
||||
HRESULT r = CoInitialize(nullptr);
|
||||
if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to initialize COM with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to initialize COM with error #" + Str_8::FromNum(r) + ".");
|
||||
return devices;
|
||||
}
|
||||
|
||||
@ -539,7 +539,7 @@ namespace ehs
|
||||
r = CoCreateInstance(__uuidof(MMDeviceEnumerator), nullptr, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void**)&enumerator);
|
||||
if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Failed to initialize WASAPI with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to initialize WASAPI with error #" + Str_8::FromNum(r) + ".");
|
||||
return devices;
|
||||
}
|
||||
|
||||
@ -547,7 +547,7 @@ namespace ehs
|
||||
r = enumerator->EnumAudioEndpoints((EDataFlow)type, (DWORD)state, &collection);
|
||||
if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Failed to retrieve audio device collection with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to retrieve audio device collection with error #" + Str_8::FromNum(r) + ".");
|
||||
return devices;
|
||||
}
|
||||
|
||||
@ -555,7 +555,7 @@ namespace ehs
|
||||
r = collection->GetCount((UINT*)&count);
|
||||
if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 3, "Failed to retrieve audio device count with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 3, "Failed to retrieve audio device count with error #" + Str_8::FromNum(r) + ".");
|
||||
return devices;
|
||||
}
|
||||
|
||||
@ -566,7 +566,7 @@ namespace ehs
|
||||
r = collection->Item(i, &deviceHdl);
|
||||
if (FAILED(r))
|
||||
{
|
||||
EHS_LOG_INT("Error", 4, "Failed to retrieve audio device with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 4, "Failed to retrieve audio device with error #" + Str_8::FromNum(r) + ".");
|
||||
return devices;
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ namespace ehs
|
||||
const ImgCodec* codec = GetCodec(ext);
|
||||
if (!codec)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -877,7 +877,7 @@ namespace ehs
|
||||
const ImgCodec* codec = GetCodec(ext);
|
||||
if (!codec)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1560,7 +1560,7 @@ namespace ehs
|
||||
Str_8 imgType = in.ReadStr<Char_8, UInt_64>(4);
|
||||
if (imgType != "qoif")
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Given data is not in the qoif format.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Given data is not in the qoif format.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1653,7 +1653,7 @@ namespace ehs
|
||||
UInt_8 colorType = ihdrData->Read<UInt_8>();
|
||||
if (colorType == 3)
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Color type of " + Str_8::FromNum(colorType) + " is unsupported.");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Color type of " + Str_8::FromNum(colorType) + " is unsupported.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1670,21 +1670,21 @@ namespace ehs
|
||||
UInt_8 compression = ihdrData->Read<UInt_8>();
|
||||
if (compression)
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Compression method of " + Str_8::FromNum(compression) + " is unsupported.");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Compression method of " + Str_8::FromNum(compression) + " is unsupported.");
|
||||
return false;
|
||||
}
|
||||
|
||||
UInt_8 filter = ihdrData->Read<UInt_8>();
|
||||
if (filter)
|
||||
{
|
||||
EHS_LOG_INT("Error", 3, "Filter method of " + Str_8::FromNum(filter) + " is unsupported.");
|
||||
EHS_LOG_INT(LogType::ERR, 3, "Filter method of " + Str_8::FromNum(filter) + " is unsupported.");
|
||||
return false;
|
||||
}
|
||||
|
||||
UInt_8 interlaced = ihdrData->Read<UInt_8>();
|
||||
if (interlaced)
|
||||
{
|
||||
EHS_LOG_INT("Error", 4, "Interlacing method of " + Str_8::FromNum(interlaced) + " is unsupported.");
|
||||
EHS_LOG_INT(LogType::ERR, 4, "Interlacing method of " + Str_8::FromNum(interlaced) + " is unsupported.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1709,7 +1709,7 @@ namespace ehs
|
||||
int code = inflateInit(&strm);
|
||||
if (code != Z_OK)
|
||||
{
|
||||
EHS_LOG_INT("Error", 5, "Failed to initialize zlib inflate with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 5, "Failed to initialize zlib inflate with error #" + Str_8::FromNum(code) + ".");
|
||||
delete[] buffer;
|
||||
return false;
|
||||
}
|
||||
@ -1719,7 +1719,7 @@ namespace ehs
|
||||
code = inflate(&strm, Z_NO_FLUSH);
|
||||
if (code != Z_STREAM_END && code != Z_OK)
|
||||
{
|
||||
EHS_LOG_INT("Error", 6, "Failed to zlib inflate with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 6, "Failed to zlib inflate with error #" + Str_8::FromNum(code) + ".");
|
||||
delete[] buffer;
|
||||
return false;
|
||||
}
|
||||
@ -1728,7 +1728,7 @@ namespace ehs
|
||||
code = inflateEnd(&strm);
|
||||
if (code != Z_OK)
|
||||
{
|
||||
EHS_LOG_INT("Error", 7, "Failed to uninitialize zlib inflate with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 7, "Failed to uninitialize zlib inflate with error #" + Str_8::FromNum(code) + ".");
|
||||
delete[] buffer;
|
||||
return false;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ namespace ehs
|
||||
{
|
||||
if (!encoder)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Encoding is not supported for the " + id + " format.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Encoding is not supported for the " + id + " format.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ namespace ehs
|
||||
{
|
||||
if (!decoder)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Decoding is not supported for the " + id + " format.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Decoding is not supported for the " + id + " format.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ namespace ehs
|
||||
Array<Byte, UInt_64> seq = data.ReadArray<Byte, UInt_64>(8);
|
||||
if (seq != pngSeq)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "File at file path, \"" + filePath + "\", is not a valid PNG file.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "File at file path, \"" + filePath + "\", is not a valid PNG file.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ namespace ehs
|
||||
const MdlCodec* codec = GetCodec(ext);
|
||||
if (!codec)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -203,7 +203,7 @@ namespace ehs
|
||||
const MdlCodec* codec = GetCodec(ext);
|
||||
if (!codec)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -248,7 +248,7 @@ namespace ehs
|
||||
Version ver = data.ReadVersion();
|
||||
if (ver != Version(1, 0, 0))
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Cannot decode EHM file version " + Str_8::FromNum(ver.major) + "." +
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Cannot decode EHM file version " + Str_8::FromNum(ver.major) + "." +
|
||||
Str_8::FromNum(ver.minor) + "." + Str_8::FromNum(ver.patch) +
|
||||
", must be version 0.0.0.");
|
||||
return false;
|
||||
@ -293,7 +293,7 @@ namespace ehs
|
||||
Bone* parent = skeleton.GetBone(parentId);
|
||||
if (!parent)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Invalid bone order.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Invalid bone order.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ namespace ehs
|
||||
{
|
||||
if (!encoder)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Encoding is not supported for the " + id + " format.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Encoding is not supported for the " + id + " format.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -99,7 +99,7 @@ namespace ehs
|
||||
{
|
||||
if (!decoder)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Decoding is not supported for the " + id + " format.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Decoding is not supported for the " + id + " format.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ namespace ehs
|
||||
UInt_64 sent = Send((Byte*)&str[offset], size - offset);
|
||||
if (!sent)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to send data.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to send data.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -269,7 +269,7 @@ namespace ehs
|
||||
UInt_64 received = Receive((Byte*)&buffer[offset], contentLength - offset);
|
||||
if (!received)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to receive data.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to receive data.");
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -292,7 +292,7 @@ namespace ehs
|
||||
UInt_64 received = Receive((Byte*)&hexSize[offset], 1);
|
||||
if (!received)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to receive data.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to receive data.");
|
||||
return 0;
|
||||
}
|
||||
else if (hexSize[offset] == '\r')
|
||||
@ -322,7 +322,7 @@ namespace ehs
|
||||
UInt_64 received = Receive((Byte*)&buffer[offset], chunkSize + 2 - offset);
|
||||
if (!received)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to receive data.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to receive data.");
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ namespace ehs
|
||||
Int_32 wsaCode = WSAStartup(MAKEWORD(2, 2), &data);
|
||||
if (wsaCode)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to start WSA with error #" + Str_8::FromNum(wsaCode) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to start WSA with error #" + Str_8::FromNum(wsaCode) + ".");
|
||||
return {};
|
||||
}
|
||||
#endif
|
||||
@ -30,14 +30,14 @@ namespace ehs
|
||||
Int_32 code = getaddrinfo(hostname, nullptr, nullptr, &result);
|
||||
if (code)
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Failed to resolve host with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to resolve host with error #" + Str_8::FromNum(code) + ".");
|
||||
return {};
|
||||
}
|
||||
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (WSACleanup() == SOCKET_ERROR)
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
return {};
|
||||
}
|
||||
#endif
|
||||
|
@ -130,7 +130,7 @@ namespace ehs
|
||||
int err = SSL_accept(client->sslHdl);
|
||||
if (!err)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed SSL handshake with error #" + Str_8::FromNum(SSL_get_error(client->sslHdl, err)) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed SSL handshake with error #" + Str_8::FromNum(SSL_get_error(client->sslHdl, err)) + ".");
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -158,7 +158,7 @@ namespace ehs
|
||||
{
|
||||
int code = SSL_get_error(sslHdl, written);
|
||||
ERR_print_errors_fp(stderr);
|
||||
EHS_LOG_INT("Error", 0, "Failed to send data with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to send data with error #" + Str_8::FromNum(code) + ".");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -172,7 +172,7 @@ namespace ehs
|
||||
{
|
||||
int code = SSL_get_error(sslHdl, received);
|
||||
ERR_print_errors_fp(stderr);
|
||||
EHS_LOG_INT("Error", 0, "Failed to receive data with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to receive data with error #" + Str_8::FromNum(code) + ".");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -184,13 +184,13 @@ namespace ehs
|
||||
X509 *cert = d2i_X509(nullptr, &data, (long)size);
|
||||
if (!cert)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Invalid certificate.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Invalid certificate.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (SSL_CTX_use_certificate(ctx, cert) != 1)
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Failed to use certificate.");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to use certificate.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -202,13 +202,13 @@ namespace ehs
|
||||
EVP_PKEY *key = d2i_PrivateKey(EVP_PKEY_RSA, nullptr, &data, (long)size);
|
||||
if (!key)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Invalid private key.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Invalid private key.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (SSL_CTX_use_PrivateKey(ctx, key) != 1)
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Failed to use private key.");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to use private key.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ namespace ehc
|
||||
int wsaCode = WSAStartup(MAKEWORD(2, 2), &data);
|
||||
if (wsaCode)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "WSAStartup failed with the error #" + Str_8::FromNum(wsaCode) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "WSAStartup failed with the error #" + Str_8::FromNum(wsaCode) + ".");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@ -130,11 +130,11 @@ namespace ehc
|
||||
code = errno;
|
||||
#endif
|
||||
|
||||
EHS_LOG_INT("Error", 1, "Failed to create socket with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to create socket with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (WSACleanup() == SOCKET_ERROR)
|
||||
EHS_LOG_INT("Error", 2, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
#endif
|
||||
|
||||
return;
|
||||
@ -182,18 +182,18 @@ namespace ehc
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
code = closesocket(hdl);
|
||||
if (code == SOCKET_ERROR)
|
||||
EHS_LOG_INT("Error", 0, "Failed to close socket with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to close socket with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
code = close(hdl);
|
||||
if (code == -1)
|
||||
EHS_LOG_INT("Error", 0, "Failed to close socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to close socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
#endif
|
||||
|
||||
hdl = EHS_INVALID_SOCKET;
|
||||
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (WSACleanup() == SOCKET_ERROR)
|
||||
EHS_LOG_INT("Error", 1, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
#endif
|
||||
|
||||
bound = false;
|
||||
@ -246,7 +246,7 @@ namespace ehc
|
||||
if (msg.Size())
|
||||
dcMsg += " Reason: " + msg;
|
||||
|
||||
EHS_LOG_INT("Info", 0, dcMsg);
|
||||
EHS_LOG_INT(LogType::INFO, 0, dcMsg);
|
||||
|
||||
Serializer<> payload(Endianness::LE);
|
||||
payload.WriteStr(msg);
|
||||
@ -389,7 +389,7 @@ namespace ehc
|
||||
sPayload.Write(Status::IN_REMOTE_QUEUE);
|
||||
sPayload.Write(end->GetQueueSlot());
|
||||
|
||||
EHS_LOG_INT("Info", 1, end->GetId() + " connected and is in queue slot " + end->GetQueueSlot() + ".");
|
||||
EHS_LOG_INT(LogType::INFO, 1, end->GetId() + " connected and is in queue slot " + end->GetQueueSlot() + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -401,7 +401,7 @@ namespace ehc
|
||||
sPayload.Write(Status::ACTIVE);
|
||||
sPayload.Write(0);
|
||||
|
||||
EHS_LOG_INT("Info", 1, end->GetId() + " connected.");
|
||||
EHS_LOG_INT(LogType::INFO, 1, end->GetId() + " connected.");
|
||||
}
|
||||
|
||||
end->Send(false, true, false, internalSys, connectedOp, sPayload);
|
||||
@ -429,7 +429,7 @@ namespace ehc
|
||||
else
|
||||
msg += ".";
|
||||
|
||||
EHS_LOG_INT("Info", 2, msg);
|
||||
EHS_LOG_INT(LogType::INFO, 2, msg);
|
||||
}
|
||||
else if (!header.ensure && header.endpointId && header.system == internalSys && header.op == rejectedOp)
|
||||
{
|
||||
@ -438,7 +438,7 @@ namespace ehc
|
||||
|
||||
Str_8 msg = payload.ReadStr<Char_8, UInt_64>();
|
||||
if (msg.Size())
|
||||
EHS_LOG_INT("Info", 3, msg);
|
||||
EHS_LOG_INT(LogType::INFO, 3, msg);
|
||||
}
|
||||
else if (!header.ensure && header.endpointId && header.system == internalSys && header.op == disconnectOp)
|
||||
{
|
||||
@ -462,7 +462,7 @@ namespace ehc
|
||||
if (msg.Size())
|
||||
dcMsg += " Reason: " + msg;
|
||||
|
||||
EHS_LOG_INT("Info", 4, dcMsg);
|
||||
EHS_LOG_INT(LogType::INFO, 4, dcMsg);
|
||||
|
||||
RemoveEndpoint(header.disposition, end->GetHashId());
|
||||
|
||||
@ -493,11 +493,11 @@ namespace ehc
|
||||
if (activeCb)
|
||||
activeCb(this, end);
|
||||
|
||||
EHS_LOG_INT("Info", 5, "Your connection status to " + end->GetId() + " has now become active.");
|
||||
EHS_LOG_INT(LogType::INFO, 5, "Your connection status to " + end->GetId() + " has now become active.");
|
||||
}
|
||||
else if (end->GetStatus() == Status::IN_REMOTE_QUEUE && newStatus == Status::IN_REMOTE_QUEUE)
|
||||
{
|
||||
EHS_LOG_INT("Info", 5, "Your queue slot for " + end->GetId() + " is now " + newSlot + ".");
|
||||
EHS_LOG_INT(LogType::INFO, 5, "Your queue slot for " + end->GetId() + " is now " + newSlot + ".");
|
||||
}
|
||||
|
||||
end->SetStatus(newStatus);
|
||||
@ -548,7 +548,7 @@ namespace ehc
|
||||
|
||||
if (dropPackets && !header.ensure && header.id < end->GetNextRecvId())
|
||||
{
|
||||
EHS_LOG_INT("Info", 6, "Old packet intentionally dropped.");
|
||||
EHS_LOG_INT(LogType::INFO, 6, "Old packet intentionally dropped.");
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -568,7 +568,7 @@ namespace ehc
|
||||
}
|
||||
else
|
||||
{
|
||||
EHS_LOG_INT("Info", 7, "Corrupted packet.");
|
||||
EHS_LOG_INT(LogType::INFO, 7, "Corrupted packet.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -853,7 +853,7 @@ namespace ehc
|
||||
{
|
||||
if (hdl == EHS_INVALID_SOCKET)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Attempted to toggle blocking while socket is not initialized.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Attempted to toggle blocking while socket is not initialized.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -862,10 +862,10 @@ namespace ehc
|
||||
|
||||
int result = ioctlsocket(hdl, FIONBIO, &r);
|
||||
if (result != NO_ERROR)
|
||||
EHS_LOG_INT("Error", 1, "Failed to toggle non-blocking mode with error #" + Str_8::FromNum(result) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to toggle non-blocking mode with error #" + Str_8::FromNum(result) + ".");
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
if (fcntl(hdl, F_SETFL, O_NONBLOCK, blocking) == -1)
|
||||
EHS_LOG_INT("Error", 1, "Failed to toggle non-blocking mode with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to toggle non-blocking mode with error #" + Str_8::FromNum(errno) + ".");
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -874,7 +874,7 @@ namespace ehc
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
u_long r = 0;
|
||||
if (ioctlsocket(hdl, FIONREAD, &r) == SOCKET_ERROR)
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve socket info.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to retrieve socket info.");
|
||||
|
||||
return (bool)r;
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
@ -1043,7 +1043,7 @@ namespace ehc
|
||||
{
|
||||
if (endpoints[i]->GetTimeout() >= maxTimeout)
|
||||
{
|
||||
EHS_LOG_INT("Info", 0, "Failed to connect to, \"" + endpoints[i]->GetAddress() + ":" + Str_8::FromNum(endpoints[i]->GetPort()) + "\".");
|
||||
EHS_LOG_INT(LogType::INFO, 0, "Failed to connect to, \"" + endpoints[i]->GetAddress() + ":" + Str_8::FromNum(endpoints[i]->GetPort()) + "\".");
|
||||
|
||||
delete endpoints[i];
|
||||
|
||||
@ -1059,7 +1059,7 @@ namespace ehc
|
||||
{
|
||||
if (endpoints[i]->GetTimeout() >= maxTimeout)
|
||||
{
|
||||
EHS_LOG_INT("Info", 6, endpoints[i]->GetId() + " timed out.");
|
||||
EHS_LOG_INT(LogType::INFO, 6, endpoints[i]->GetId() + " timed out.");
|
||||
|
||||
if (disconnectedCb)
|
||||
disconnectedCb(this, endpoints[i]);
|
||||
@ -1120,7 +1120,7 @@ namespace ehc
|
||||
Int_32 code = inet_pton(AF_INET6, address, &result.sin6_addr);
|
||||
if (!code)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "The given address, \"" + address + "\" is not valid.");
|
||||
return;
|
||||
}
|
||||
else if (code == -1)
|
||||
@ -1133,7 +1133,7 @@ namespace ehc
|
||||
dCode = errno;
|
||||
#endif
|
||||
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1147,13 +1147,13 @@ namespace ehc
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (code == SOCKET_ERROR)
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to bind socket with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
return;
|
||||
}
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
if (code == -1)
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to bind socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@ -1172,7 +1172,7 @@ namespace ehc
|
||||
code = inet_pton(AF_INET, address, &result.sin_addr);
|
||||
if (!code)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "The given address, \"" + address + "\" is not valid.");
|
||||
return;
|
||||
}
|
||||
else if (code == -1)
|
||||
@ -1185,7 +1185,7 @@ namespace ehc
|
||||
dCode = errno;
|
||||
#endif
|
||||
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1199,13 +1199,13 @@ namespace ehc
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (code == SOCKET_ERROR)
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to bind socket with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
return;
|
||||
}
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
if (code == -1)
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to bind socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@ -1215,13 +1215,13 @@ namespace ehc
|
||||
{
|
||||
if (hdl == EHS_INVALID_SOCKET)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Attempted to receive while socket is not initialized.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Attempted to receive while socket is not initialized.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (type == AddrType::IPV4 && size > EHS_IPV4_UDP_PAYLOAD)
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Attempted to receive with a buffer size of, \"" + Str_8::FromNum(size)
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Attempted to receive with a buffer size of, \"" + Str_8::FromNum(size)
|
||||
+ "\", that exceeds, \"" + Str_8::FromNum(EHS_IPV4_UDP_PAYLOAD) + ".");
|
||||
}
|
||||
|
||||
@ -1238,13 +1238,13 @@ namespace ehc
|
||||
{
|
||||
UnInitialize();
|
||||
|
||||
EHS_LOG_INT("Error", 2, "The buffer size, \"" + Str_8::FromNum(size) + "\" is too small.");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "The buffer size, \"" + Str_8::FromNum(size) + "\" is too small.");
|
||||
}
|
||||
else if (code != WSAECONNRESET && code != WSAEWOULDBLOCK)
|
||||
{
|
||||
UnInitialize();
|
||||
|
||||
EHS_LOG_INT("Error", 3, "Failed to receive with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 3, "Failed to receive with error #" + Str_8::FromNum(code) + ".");
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -1258,7 +1258,7 @@ namespace ehc
|
||||
{
|
||||
UnInitialize();
|
||||
|
||||
EHS_LOG_INT("Error", 2, "Failed to receive with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to receive with error #" + Str_8::FromNum(code) + ".");
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -1280,7 +1280,7 @@ namespace ehc
|
||||
code = errno;
|
||||
#endif
|
||||
|
||||
EHS_LOG_INT("Error", 2, "Failed to convert IPv6 address with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to convert IPv6 address with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
return received;
|
||||
}
|
||||
@ -1302,7 +1302,7 @@ namespace ehc
|
||||
code = errno;
|
||||
#endif
|
||||
|
||||
EHS_LOG_INT("Error", 2, "Failed to convert IPv4 address with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to convert IPv4 address with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
return (UInt_16)received;
|
||||
}
|
||||
|
@ -18,11 +18,11 @@ namespace ehs
|
||||
if (connection)
|
||||
{
|
||||
if (shutdown(hdl, SHUT_RDWR) == -1)
|
||||
EHS_LOG_INT("Error", 0, "Failed to shutdown socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to shutdown socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
}
|
||||
|
||||
if (close(hdl) == -1)
|
||||
EHS_LOG_INT("Error", 1, "Failed to close socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to close socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
}
|
||||
|
||||
TCP::TCP()
|
||||
@ -89,7 +89,7 @@ namespace ehs
|
||||
{
|
||||
UInt_32 code = errno;
|
||||
|
||||
EHS_LOG_INT("Error", 1, "Failed to create socket with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to create socket with error #" + Str_8::FromNum(code) + ".");
|
||||
}
|
||||
}
|
||||
|
||||
@ -101,11 +101,11 @@ namespace ehs
|
||||
if (connection)
|
||||
{
|
||||
if (shutdown(hdl, SHUT_RDWR) == -1)
|
||||
EHS_LOG_INT("Error", 0, "Failed to shutdown socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to shutdown socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
}
|
||||
|
||||
if (close(hdl) == -1)
|
||||
EHS_LOG_INT("Error", 1, "Failed to close socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to close socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
|
||||
connection = false;
|
||||
bound = false;
|
||||
@ -138,7 +138,7 @@ namespace ehs
|
||||
int code = listen(hdl, SOMAXCONN);
|
||||
if (code == -1)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to listen with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to listen with error #" + Str_8::FromNum(errno) + ".");
|
||||
|
||||
return;
|
||||
}
|
||||
@ -164,7 +164,7 @@ namespace ehs
|
||||
if (client->hdl == EHS_INVALID_SOCKET)
|
||||
{
|
||||
if (errno != EWOULDBLOCK)
|
||||
EHS_LOG_INT("Error", 0, "Failed to accept client with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to accept client with error #" + Str_8::FromNum(errno) + ".");
|
||||
|
||||
delete client;
|
||||
|
||||
@ -177,7 +177,7 @@ namespace ehs
|
||||
|
||||
if (!inet_ntop(remote.sin6_family, &remote.sin6_addr, tmpAddr, INET6_ADDRSTRLEN))
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert IPv6 address with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to convert IPv6 address with error #" + Str_8::FromNum(errno) + ".");
|
||||
|
||||
delete client;
|
||||
|
||||
@ -193,7 +193,7 @@ namespace ehs
|
||||
|
||||
if (!inet_ntop(((sockaddr_in*)&remote)->sin_family, &((sockaddr_in*)&remote)->sin_addr, tmpAddr, INET_ADDRSTRLEN))
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert IPv4 address with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to convert IPv4 address with error #" + Str_8::FromNum(errno) + ".");
|
||||
|
||||
delete client;
|
||||
|
||||
@ -228,13 +228,13 @@ namespace ehs
|
||||
{
|
||||
if (!IsValid())
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Attempted to send while socket is not initialized.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Attempted to send while socket is not initialized.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((!connection && !connected))
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Attempted to send while socket is not connected or a connection.");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Attempted to send while socket is not connected or a connection.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -245,10 +245,10 @@ namespace ehs
|
||||
if (err == ECONNRESET)
|
||||
{
|
||||
Release();
|
||||
EHS_LOG_INT("Information", 0, "Connection dropped.");
|
||||
EHS_LOG_INT(LogType::INFO, 0, "Connection dropped.");
|
||||
}
|
||||
else
|
||||
EHS_LOG_INT("Error", 1, "Failed to send with error #" + Str_8::FromNum(err) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to send with error #" + Str_8::FromNum(err) + ".");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -260,13 +260,13 @@ namespace ehs
|
||||
{
|
||||
if (!IsValid())
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Attempted to receive while socket is not initialized.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Attempted to receive while socket is not initialized.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((!connection && !connected))
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Attempted to receive while socket is not connected or a connection.");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Attempted to receive while socket is not connected or a connection.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -277,11 +277,11 @@ namespace ehs
|
||||
if (err == ECONNRESET)
|
||||
{
|
||||
Release();
|
||||
EHS_LOG_INT("Information", 0, "Connection dropped.");
|
||||
EHS_LOG_INT(LogType::INFO, 0, "Connection dropped.");
|
||||
}
|
||||
else if (err != EWOULDBLOCK)
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Failed to receive with error #" + Str_8::FromNum(err) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to receive with error #" + Str_8::FromNum(err) + ".");
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -294,14 +294,14 @@ namespace ehs
|
||||
{
|
||||
if (!IsValid())
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Attempted to toggle blocking while socket is not initialized.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Attempted to toggle blocking while socket is not initialized.");
|
||||
return;
|
||||
}
|
||||
|
||||
int flags = fcntl(hdl, F_GETFL, 0);
|
||||
if (flags == -1)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve flags.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to retrieve flags.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -311,7 +311,7 @@ namespace ehs
|
||||
flags |= O_NONBLOCK;
|
||||
|
||||
if (fcntl(hdl, F_SETFL, flags) == -1)
|
||||
EHS_LOG_INT("Error", 1, "Failed to toggle non-blocking mode with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to toggle non-blocking mode with error #" + Str_8::FromNum(errno) + ".");
|
||||
}
|
||||
|
||||
bool TCP::IsBlocking() const
|
||||
@ -319,7 +319,7 @@ namespace ehs
|
||||
int flags = fcntl(hdl, F_GETFL, 0);
|
||||
if (flags == -1)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve flags.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to retrieve flags.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -342,14 +342,14 @@ namespace ehs
|
||||
int code = inet_pton(AF_INET6, address, &result.sin6_addr);
|
||||
if (!code)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "The given address, \"" + address + "\" is not valid.");
|
||||
return;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = errno;
|
||||
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -361,7 +361,7 @@ namespace ehs
|
||||
int code = bind(hdl, (sockaddr*)&result, sizeof(sockaddr_in6));
|
||||
if (code == -1)
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to bind socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
|
||||
return;
|
||||
}
|
||||
@ -378,14 +378,14 @@ namespace ehs
|
||||
int code = inet_pton(AF_INET, address, &result.sin_addr);
|
||||
if (!code)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "The given address, \"" + address + "\" is not valid.");
|
||||
return;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = errno;
|
||||
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -396,7 +396,7 @@ namespace ehs
|
||||
int code = bind(hdl, (sockaddr*)&result, sizeof(sockaddr_in));
|
||||
if (code == -1)
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to bind socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
|
||||
return;
|
||||
}
|
||||
@ -411,14 +411,14 @@ namespace ehs
|
||||
int code = inet_pton(AF_INET6, address, &result.sin6_addr);
|
||||
if (!code)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "The given address, \"" + address + "\" is not valid.");
|
||||
return;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = errno;
|
||||
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -428,11 +428,11 @@ namespace ehs
|
||||
int err = errno;
|
||||
if (err == ETIMEDOUT)
|
||||
{
|
||||
EHS_LOG_INT("Information", 2, "Connection attempt timed-out.");
|
||||
EHS_LOG_INT(LogType::INFO, 2, "Connection attempt timed-out.");
|
||||
}
|
||||
else
|
||||
{
|
||||
EHS_LOG_INT("Error", 3, "Failed to connect with error #" + Str_8::FromNum(err) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 3, "Failed to connect with error #" + Str_8::FromNum(err) + ".");
|
||||
}
|
||||
|
||||
return;
|
||||
@ -448,14 +448,14 @@ namespace ehs
|
||||
int code = inet_pton(AF_INET, address, &result.sin_addr);
|
||||
if (!code)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "The given address, \"" + address + "\" is not valid.");
|
||||
return;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = errno;
|
||||
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -465,11 +465,11 @@ namespace ehs
|
||||
int err = errno;
|
||||
if (err == ETIMEDOUT)
|
||||
{
|
||||
EHS_LOG_INT("Information", 2, "Connection attempt timed-out.");
|
||||
EHS_LOG_INT(LogType::INFO, 2, "Connection attempt timed-out.");
|
||||
}
|
||||
else
|
||||
{
|
||||
EHS_LOG_INT("Error", 3, "Failed to connect with error #" + Str_8::FromNum(err) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 3, "Failed to connect with error #" + Str_8::FromNum(err) + ".");
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -17,15 +17,15 @@ namespace ehs
|
||||
{
|
||||
code = shutdown(hdl, SD_SEND);
|
||||
if (code == SOCKET_ERROR)
|
||||
EHS_LOG_INT("Error", 0, "Failed to shutdown socket with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to shutdown socket with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
}
|
||||
|
||||
code = closesocket(hdl);
|
||||
if (code == SOCKET_ERROR)
|
||||
EHS_LOG_INT("Error", 1, "Failed to close socket with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to close socket with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
if (!connection && WSACleanup() == SOCKET_ERROR)
|
||||
EHS_LOG_INT("Error", 2, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
}
|
||||
|
||||
TCP::TCP()
|
||||
@ -86,7 +86,7 @@ namespace ehs
|
||||
int code = WSAStartup(MAKEWORD(2, 2), &data);
|
||||
if (code)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "WSAStartup failed with the error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "WSAStartup failed with the error #" + Str_8::FromNum(code) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -101,10 +101,10 @@ namespace ehs
|
||||
{
|
||||
UInt_32 code = WSAGetLastError();
|
||||
|
||||
EHS_LOG_INT("Error", 1, "Failed to create socket with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to create socket with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
if (WSACleanup() == SOCKET_ERROR)
|
||||
EHS_LOG_INT("Error", 2, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,17 +119,17 @@ namespace ehs
|
||||
{
|
||||
code = shutdown(hdl, SD_SEND);
|
||||
if (code == SOCKET_ERROR)
|
||||
EHS_LOG_INT("Error", 0, "Failed to shutdown socket with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to shutdown socket with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
}
|
||||
|
||||
code = closesocket(hdl);
|
||||
if (code == SOCKET_ERROR)
|
||||
EHS_LOG_INT("Error", 1, "Failed to close socket with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to close socket with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
hdl = EHS_INVALID_SOCKET;
|
||||
|
||||
if (!connection && WSACleanup() == SOCKET_ERROR)
|
||||
EHS_LOG_INT("Error", 2, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
|
||||
connection = false;
|
||||
bound = false;
|
||||
@ -161,7 +161,7 @@ namespace ehs
|
||||
int code = listen(hdl, SOMAXCONN);
|
||||
if (code == -1)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to listen with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to listen with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
|
||||
return;
|
||||
}
|
||||
@ -189,7 +189,7 @@ namespace ehs
|
||||
Int_32 code = WSAGetLastError();
|
||||
|
||||
if (code != WSAEWOULDBLOCK)
|
||||
EHS_LOG_INT("Error", 0, "Failed to accept client with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to accept client with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
delete client;
|
||||
|
||||
@ -204,7 +204,7 @@ namespace ehs
|
||||
{
|
||||
Int_32 code = WSAGetLastError();
|
||||
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert IPv6 address with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to convert IPv6 address with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
delete client;
|
||||
|
||||
@ -222,7 +222,7 @@ namespace ehs
|
||||
{
|
||||
Int_32 code = WSAGetLastError();
|
||||
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert IPv4 address with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to convert IPv4 address with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
delete client;
|
||||
|
||||
@ -257,13 +257,13 @@ namespace ehs
|
||||
{
|
||||
if (!IsValid())
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Attempted to send while socket is not initialized.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Attempted to send while socket is not initialized.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((!connection && !connected))
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Attempted to send while socket is not connected or a connection.");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Attempted to send while socket is not connected or a connection.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -274,10 +274,10 @@ namespace ehs
|
||||
if (err == WSAECONNRESET)
|
||||
{
|
||||
Release();
|
||||
EHS_LOG_INT("Information", 0, "Connection dropped.");
|
||||
EHS_LOG_INT(LogType::INFO, 0, "Connection dropped.");
|
||||
}
|
||||
else
|
||||
EHS_LOG_INT("Error", 1, "Failed to send with error #" + Str_8::FromNum(err) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to send with error #" + Str_8::FromNum(err) + ".");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -289,13 +289,13 @@ namespace ehs
|
||||
{
|
||||
if (!IsValid())
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Attempted to receive while socket is not initialized.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Attempted to receive while socket is not initialized.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((!connection && !connected))
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Attempted to receive while socket is not connected or a connection.");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Attempted to receive while socket is not connected or a connection.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -306,15 +306,15 @@ namespace ehs
|
||||
if (err == WSAECONNRESET)
|
||||
{
|
||||
Release();
|
||||
EHS_LOG_INT("Information", 0, "Connection dropped.");
|
||||
EHS_LOG_INT(LogType::INFO, 0, "Connection dropped.");
|
||||
}
|
||||
else if (err == WSAECONNABORTED)
|
||||
{
|
||||
EHS_LOG_INT("Information", 1, "Receiving timed-out.");
|
||||
EHS_LOG_INT(LogType::INFO, 1, "Receiving timed-out.");
|
||||
}
|
||||
else if (err != WSAEWOULDBLOCK)
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Failed to receive with error #" + Str_8::FromNum(err) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to receive with error #" + Str_8::FromNum(err) + ".");
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -327,7 +327,7 @@ namespace ehs
|
||||
{
|
||||
if (!IsValid())
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Attempted to toggle blocking while socket is not initialized.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Attempted to toggle blocking while socket is not initialized.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -335,14 +335,14 @@ namespace ehs
|
||||
|
||||
int result = ioctlsocket(hdl, FIONBIO, &r);
|
||||
if (result != NO_ERROR)
|
||||
EHS_LOG_INT("Error", 1, "Failed to toggle non-blocking mode with error #" + Str_8::FromNum(result) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to toggle non-blocking mode with error #" + Str_8::FromNum(result) + ".");
|
||||
}
|
||||
|
||||
bool TCP::IsBlocking() const
|
||||
{
|
||||
u_long r = 0;
|
||||
if (ioctlsocket(hdl, FIONREAD, &r) == SOCKET_ERROR)
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve socket info.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to retrieve socket info.");
|
||||
|
||||
return (bool)r;
|
||||
}
|
||||
@ -363,14 +363,14 @@ namespace ehs
|
||||
int code = inet_pton(AF_INET6, address, &result.sin6_addr);
|
||||
if (!code)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "The given address, \"" + address + "\" is not valid.");
|
||||
return;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = WSAGetLastError();
|
||||
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -382,7 +382,7 @@ namespace ehs
|
||||
int code = bind(hdl, (sockaddr*)&result, sizeof(sockaddr_in6));
|
||||
if (code == -1)
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to bind socket with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
|
||||
return;
|
||||
}
|
||||
@ -399,14 +399,14 @@ namespace ehs
|
||||
int code = inet_pton(AF_INET, address, &result.sin_addr);
|
||||
if (!code)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "The given address, \"" + address + "\" is not valid.");
|
||||
return;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = WSAGetLastError();
|
||||
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -418,7 +418,7 @@ namespace ehs
|
||||
int code = bind(hdl, (sockaddr*)&result, sizeof(sockaddr_in));
|
||||
if (code == -1)
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to bind socket with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
|
||||
return;
|
||||
}
|
||||
@ -433,14 +433,14 @@ namespace ehs
|
||||
int code = inet_pton(AF_INET6, address, &result.sin6_addr);
|
||||
if (!code)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "The given address, \"" + address + "\" is not valid.");
|
||||
return;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = WSAGetLastError();
|
||||
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -450,11 +450,11 @@ namespace ehs
|
||||
int err = WSAGetLastError();
|
||||
if (err == WSAETIMEDOUT)
|
||||
{
|
||||
EHS_LOG_INT("Information", 2, "Connection attempt timed-out.");
|
||||
EHS_LOG_INT(LogType::INFO, 2, "Connection attempt timed-out.");
|
||||
}
|
||||
else
|
||||
{
|
||||
EHS_LOG_INT("Error", 3, "Failed to connect with error #" + Str_8::FromNum(err) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 3, "Failed to connect with error #" + Str_8::FromNum(err) + ".");
|
||||
}
|
||||
|
||||
return;
|
||||
@ -470,14 +470,14 @@ namespace ehs
|
||||
int code = inet_pton(AF_INET, address, &result.sin_addr);
|
||||
if (!code)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "The given address, \"" + address + "\" is not valid.");
|
||||
return;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = WSAGetLastError();
|
||||
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -487,11 +487,11 @@ namespace ehs
|
||||
int err = WSAGetLastError();
|
||||
if (err == WSAETIMEDOUT)
|
||||
{
|
||||
EHS_LOG_INT("Information", 2, "Connection attempt timed-out.");
|
||||
EHS_LOG_INT(LogType::INFO, 2, "Connection attempt timed-out.");
|
||||
}
|
||||
else
|
||||
{
|
||||
EHS_LOG_INT("Error", 3, "Failed to connect with error #" + Str_8::FromNum(err) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 3, "Failed to connect with error #" + Str_8::FromNum(err) + ".");
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -17,7 +17,7 @@ namespace ehs
|
||||
|
||||
Int_32 code = close(hdl);
|
||||
if (code == -1)
|
||||
EHS_LOG_INT("Error", 0, "Failed to close socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to close socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
}
|
||||
|
||||
UDP::UDP()
|
||||
@ -39,7 +39,7 @@ namespace ehs
|
||||
{
|
||||
UInt_32 code = errno;
|
||||
|
||||
EHS_LOG_INT("Error", 1, "Failed to create socket with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to create socket with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
return;
|
||||
}
|
||||
@ -87,9 +87,9 @@ namespace ehs
|
||||
if (!IsValid())
|
||||
return;
|
||||
|
||||
Int_32 code = close(hdl);
|
||||
const Int_32 code = close(hdl);
|
||||
if (code == -1)
|
||||
EHS_LOG_INT("Error", 0, "Failed to close socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to close socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
|
||||
hdl = EHS_INVALID_SOCKET;
|
||||
|
||||
@ -126,7 +126,7 @@ namespace ehs
|
||||
{
|
||||
if (!IsValid())
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Attempted to receive while socket is not initialized.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Attempted to receive while socket is not initialized.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -142,7 +142,7 @@ namespace ehs
|
||||
{
|
||||
Release();
|
||||
|
||||
EHS_LOG_INT("Error", 1, "Failed to receive with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to receive with error #" + Str_8::FromNum(code) + ".");
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -156,7 +156,7 @@ namespace ehs
|
||||
{
|
||||
Int_32 code = errno;
|
||||
|
||||
EHS_LOG_INT("Error", 2, "Failed to convert IPv6 address with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to convert IPv6 address with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
return received;
|
||||
}
|
||||
@ -173,7 +173,7 @@ namespace ehs
|
||||
{
|
||||
Int_32 code = errno;
|
||||
|
||||
EHS_LOG_INT("Error", 2, "Failed to convert IPv4 address with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to convert IPv4 address with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
return received;
|
||||
}
|
||||
@ -190,12 +190,12 @@ namespace ehs
|
||||
{
|
||||
if (!IsValid())
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Attempted to toggle blocking while socket is not initialized.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Attempted to toggle blocking while socket is not initialized.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (fcntl(hdl, F_SETFL, O_NONBLOCK, blocking) == -1)
|
||||
EHS_LOG_INT("Error", 1, "Failed to toggle non-blocking mode with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to toggle non-blocking mode with error #" + Str_8::FromNum(errno) + ".");
|
||||
}
|
||||
|
||||
bool UDP::IsBlocking() const
|
||||
@ -219,14 +219,14 @@ namespace ehs
|
||||
Int_32 code = inet_pton(AF_INET6, address, &result.sin6_addr);
|
||||
if (!code)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "The given address, \"" + address + "\" is not valid.");
|
||||
return;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = errno;
|
||||
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -238,7 +238,7 @@ namespace ehs
|
||||
int code = bind(hdl, (sockaddr*)&result, sizeof(sockaddr_in6));
|
||||
if (code == -1)
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to bind socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -254,14 +254,14 @@ namespace ehs
|
||||
int code = inet_pton(AF_INET, address, &result.sin_addr);
|
||||
if (!code)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "The given address, \"" + address + "\" is not valid.");
|
||||
return;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = errno;
|
||||
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -273,7 +273,7 @@ namespace ehs
|
||||
int code = bind(hdl, (sockaddr*)&result, sizeof(sockaddr_in));
|
||||
if (code == -1)
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to bind socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -282,7 +282,7 @@ namespace ehs
|
||||
{
|
||||
if (!IsValid())
|
||||
{
|
||||
EHS_LOG_INT("Info", 0, "Attempted to send while socket is not initialized.");
|
||||
EHS_LOG_INT(LogType::INFO, 0, "Attempted to send while socket is not initialized.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -293,14 +293,14 @@ namespace ehs
|
||||
Int_32 code = inet_pton(AF_INET6, address, &result.sin6_addr);
|
||||
if (!code)
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "The given address, \"" + address + "\" is not valid.");
|
||||
return 0;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = errno;
|
||||
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -309,7 +309,7 @@ namespace ehs
|
||||
{
|
||||
Int_32 dCode = errno;
|
||||
|
||||
EHS_LOG_INT("Error", 3, "Failed to send with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 3, "Failed to send with error #" + Str_8::FromNum(dCode) + ".");
|
||||
|
||||
Release();
|
||||
|
||||
@ -323,7 +323,7 @@ namespace ehs
|
||||
{
|
||||
if (!IsValid())
|
||||
{
|
||||
EHS_LOG_INT("Info", 0, "Attempted to send while socket is not initialized.");
|
||||
EHS_LOG_INT(LogType::INFO, 0, "Attempted to send while socket is not initialized.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -334,14 +334,14 @@ namespace ehs
|
||||
int code = inet_pton(AF_INET, address, &result.sin_addr);
|
||||
if (!code)
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "The given address, \"" + address + "\" is not valid.");
|
||||
return 0;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = errno;
|
||||
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -350,7 +350,7 @@ namespace ehs
|
||||
{
|
||||
Int_32 dCode = errno;
|
||||
|
||||
EHS_LOG_INT("Error", 3, "Failed to send with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 3, "Failed to send with error #" + Str_8::FromNum(dCode) + ".");
|
||||
|
||||
Release();
|
||||
|
||||
|
@ -13,10 +13,10 @@ namespace ehs
|
||||
|
||||
Int_32 code = closesocket(hdl);
|
||||
if (code == SOCKET_ERROR)
|
||||
EHS_LOG_INT("Error", 0, "Failed to close socket with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to close socket with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
if (WSACleanup() == SOCKET_ERROR)
|
||||
EHS_LOG_INT("Error", 1, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
}
|
||||
|
||||
UDP::UDP()
|
||||
@ -32,7 +32,7 @@ namespace ehs
|
||||
int code = WSAStartup(MAKEWORD(2, 2), &data);
|
||||
if (code)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "WSAStartup failed with the error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "WSAStartup failed with the error #" + Str_8::FromNum(code) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -47,10 +47,10 @@ namespace ehs
|
||||
{
|
||||
UInt_32 code = WSAGetLastError();
|
||||
|
||||
EHS_LOG_INT("Error", 1, "Failed to create socket with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to create socket with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
if (WSACleanup() == SOCKET_ERROR)
|
||||
EHS_LOG_INT("Error", 2, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
|
||||
return;
|
||||
}
|
||||
@ -100,12 +100,12 @@ namespace ehs
|
||||
|
||||
Int_32 code = closesocket(hdl);
|
||||
if (code == SOCKET_ERROR)
|
||||
EHS_LOG_INT("Error", 0, "Failed to close socket with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to close socket with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
hdl = EHS_INVALID_SOCKET;
|
||||
|
||||
if (WSACleanup() == SOCKET_ERROR)
|
||||
EHS_LOG_INT("Error", 1, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
|
||||
bound = false;
|
||||
}
|
||||
@ -140,7 +140,7 @@ namespace ehs
|
||||
{
|
||||
if (!IsValid())
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Attempted to receive while socket is not initialized.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Attempted to receive while socket is not initialized.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -155,7 +155,7 @@ namespace ehs
|
||||
{
|
||||
Release();
|
||||
|
||||
EHS_LOG_INT("Error", 1, "Failed to receive with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to receive with error #" + Str_8::FromNum(code) + ".");
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -169,7 +169,7 @@ namespace ehs
|
||||
{
|
||||
Int_32 code = WSAGetLastError();
|
||||
|
||||
EHS_LOG_INT("Error", 2, "Failed to convert IPv6 address with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to convert IPv6 address with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
return received;
|
||||
}
|
||||
@ -186,7 +186,7 @@ namespace ehs
|
||||
{
|
||||
Int_32 code = WSAGetLastError();
|
||||
|
||||
EHS_LOG_INT("Error", 2, "Failed to convert IPv4 address with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to convert IPv4 address with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
return received;
|
||||
}
|
||||
@ -203,7 +203,7 @@ namespace ehs
|
||||
{
|
||||
if (!IsValid())
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Attempted to toggle blocking while socket is not initialized.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Attempted to toggle blocking while socket is not initialized.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -211,14 +211,14 @@ namespace ehs
|
||||
|
||||
int result = ioctlsocket(hdl, FIONBIO, &r);
|
||||
if (result != NO_ERROR)
|
||||
EHS_LOG_INT("Error", 1, "Failed to toggle non-blocking mode with error #" + Str_8::FromNum(result) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to toggle non-blocking mode with error #" + Str_8::FromNum(result) + ".");
|
||||
}
|
||||
|
||||
bool UDP::IsBlocking() const
|
||||
{
|
||||
u_long r = 0;
|
||||
if (ioctlsocket(hdl, FIONREAD, &r) == SOCKET_ERROR)
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve socket info.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to retrieve socket info.");
|
||||
|
||||
return (bool)r;
|
||||
}
|
||||
@ -239,14 +239,14 @@ namespace ehs
|
||||
Int_32 code = inet_pton(AF_INET6, address, &result.sin6_addr);
|
||||
if (!code)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "The given address, \"" + address + "\" is not valid.");
|
||||
return;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = WSAGetLastError();
|
||||
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -258,7 +258,7 @@ namespace ehs
|
||||
int code = bind(hdl, (sockaddr*)&result, sizeof(sockaddr_in6));
|
||||
if (code == SOCKET_ERROR)
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to bind socket with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -274,14 +274,14 @@ namespace ehs
|
||||
int code = inet_pton(AF_INET, address, &result.sin_addr);
|
||||
if (!code)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "The given address, \"" + address + "\" is not valid.");
|
||||
return;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = WSAGetLastError();
|
||||
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -293,7 +293,7 @@ namespace ehs
|
||||
int code = bind(hdl, (sockaddr*)&result, sizeof(sockaddr_in));
|
||||
if (code == SOCKET_ERROR)
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to bind socket with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -302,7 +302,7 @@ namespace ehs
|
||||
{
|
||||
if (!IsValid())
|
||||
{
|
||||
EHS_LOG_INT("Info", 0, "Attempted to send while socket is not initialized.");
|
||||
EHS_LOG_INT(LogType::INFO, 0, "Attempted to send while socket is not initialized.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -313,14 +313,14 @@ namespace ehs
|
||||
Int_32 code = inet_pton(AF_INET6, addr, &result.sin6_addr);
|
||||
if (!code)
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "The given address, \"" + address + "\" is not valid.");
|
||||
return 0;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = WSAGetLastError();
|
||||
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -329,7 +329,7 @@ namespace ehs
|
||||
{
|
||||
Int_32 dCode = WSAGetLastError();
|
||||
|
||||
EHS_LOG_INT("Error", 3, "Failed to send with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 3, "Failed to send with error #" + Str_8::FromNum(dCode) + ".");
|
||||
|
||||
Release();
|
||||
|
||||
@ -343,7 +343,7 @@ namespace ehs
|
||||
{
|
||||
if (!IsValid())
|
||||
{
|
||||
EHS_LOG_INT("Info", 0, "Attempted to send while socket is not initialized.");
|
||||
EHS_LOG_INT(LogType::INFO, 0, "Attempted to send while socket is not initialized.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -354,14 +354,14 @@ namespace ehs
|
||||
int code = inet_pton(AF_INET, addr, &result.sin_addr);
|
||||
if (!code)
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "The given address, \"" + address + "\" is not valid.");
|
||||
return 0;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = WSAGetLastError();
|
||||
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -370,7 +370,7 @@ namespace ehs
|
||||
{
|
||||
Int_32 dCode = WSAGetLastError();
|
||||
|
||||
EHS_LOG_INT("Error", 3, "Failed to send with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 3, "Failed to send with error #" + Str_8::FromNum(dCode) + ".");
|
||||
|
||||
Release();
|
||||
|
||||
|
@ -91,19 +91,19 @@ namespace ehs
|
||||
|
||||
if (authRes.GetCode() == 400)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Could not authorize with Spotify because the client id was invalid.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Could not authorize with Spotify because the client id was invalid.");
|
||||
|
||||
return false;
|
||||
}
|
||||
else if (authRes.GetCode() == 403)
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Could not authorize with Spotify because the secret was invalid.");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Could not authorize with Spotify because the secret was invalid.");
|
||||
|
||||
return false;
|
||||
}
|
||||
else if (authRes.GetCode() != 200)
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Could not authorize with Spotify with code " + Str_8::FromNum(authRes.GetCode()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Could not authorize with Spotify with code " + Str_8::FromNum(authRes.GetCode()) + ".");
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -608,7 +608,7 @@ namespace ehs
|
||||
|
||||
if (res.GetCode() != 200)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to reauthorize with Spotify with code #" + Str_8::FromNum(res.GetCode()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to reauthorize with Spotify with code #" + Str_8::FromNum(res.GetCode()) + ".");
|
||||
client.Release();
|
||||
return false;
|
||||
}
|
||||
|
@ -89,21 +89,21 @@ namespace ehs
|
||||
{
|
||||
client.Release();
|
||||
|
||||
EHS_LOG_INT("Error", 0, "Could not authorize with Twitch because the client id was invalid.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Could not authorize with Twitch because the client id was invalid.");
|
||||
|
||||
return false;
|
||||
} else if (authRes.GetCode() == 403)
|
||||
{
|
||||
client.Release();
|
||||
|
||||
EHS_LOG_INT("Error", 1, "Could not authorize with Twitch because the secret was invalid.");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Could not authorize with Twitch because the secret was invalid.");
|
||||
|
||||
return false;
|
||||
} else if (authRes.GetCode() != 200)
|
||||
{
|
||||
client.Release();
|
||||
|
||||
EHS_LOG_INT("Error", 2, "Could not authorize with Twitch.");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Could not authorize with Twitch.");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ namespace ehs
|
||||
{
|
||||
if (!isIndex)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Index has ended, but never started.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Index has ended, but never started.");
|
||||
return levels;
|
||||
}
|
||||
|
||||
@ -219,7 +219,7 @@ namespace ehs
|
||||
levels.Push(Str_8(start, i - start));
|
||||
else
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Index has no value.");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Index has no value.");
|
||||
return levels;
|
||||
}
|
||||
|
||||
@ -228,7 +228,7 @@ namespace ehs
|
||||
}
|
||||
else if (isIndex && (*i < '0' || *i > '9'))
|
||||
{
|
||||
EHS_LOG_INT("Error", 2, "Index has an invalid character, \"" + Str_8(i, 1) + "\". Index must be a whole number.");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Index has an invalid character, \"" + Str_8(i, 1) + "\". Index must be a whole number.");
|
||||
return levels;
|
||||
}
|
||||
else if (*i == '.')
|
||||
@ -240,7 +240,7 @@ namespace ehs
|
||||
}
|
||||
else if (!isIndex && *i != '-' && *i != '_' && (*i < 'A' || *i > 'Z') && (*i < 'a' || *i > 'z'))
|
||||
{
|
||||
EHS_LOG_INT("Error", 3, "Member variable has an invalid character, \"" + Str_8(i, 1) + "\".");
|
||||
EHS_LOG_INT(LogType::ERR, 3, "Member variable has an invalid character, \"" + Str_8(i, 1) + "\".");
|
||||
return levels;
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ namespace ehs
|
||||
{
|
||||
int code = chdir(dir);
|
||||
if (code == -1)
|
||||
EHS_LOG_INT("Error", 0, strerror(errno));
|
||||
EHS_LOG_INT(LogType::ERR, 0, strerror(errno));
|
||||
}
|
||||
|
||||
Str_8 FileSystem::GetWorkingDir()
|
||||
@ -19,7 +19,7 @@ namespace ehs
|
||||
char result[EHS_MAX_PATH];
|
||||
|
||||
if (!getcwd(result, EHS_MAX_PATH))
|
||||
EHS_LOG_INT("Error", 0, strerror(errno));
|
||||
EHS_LOG_INT(LogType::ERR, 0, strerror(errno));
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -27,6 +27,6 @@ namespace ehs
|
||||
void FileSystem::SetOwner(const Str_8& dir, const UInt_32 userId, const UInt_32 groupId)
|
||||
{
|
||||
if (chown(dir, userId, groupId) == -1)
|
||||
EHS_LOG_INT("Error", 0, strerror(errno));
|
||||
EHS_LOG_INT(LogType::ERR, 0, strerror(errno));
|
||||
}
|
||||
}
|
@ -10,7 +10,7 @@ namespace ehs
|
||||
return;
|
||||
|
||||
if (!CloseHandle(hdl))
|
||||
EHS_LOG_INT("Error", 0, "Failed to uninitialize mutex with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to uninitialize mutex with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
}
|
||||
|
||||
Mutex::Mutex()
|
||||
@ -43,7 +43,7 @@ namespace ehs
|
||||
hdl = CreateMutexW(nullptr, FALSE, nullptr);
|
||||
if (!hdl)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to create mutex with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to create mutex with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ namespace ehs
|
||||
return;
|
||||
|
||||
if (!CloseHandle(hdl))
|
||||
EHS_LOG_INT("Error", 0, "Failed to uninitialize mutex with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to uninitialize mutex with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
initialized = false;
|
||||
}
|
||||
@ -68,7 +68,7 @@ namespace ehs
|
||||
|
||||
if (WaitForSingleObject(hdl, EHS_INFINITE) == WAIT_FAILED)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to lock mutex with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to lock mutex with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ namespace ehs
|
||||
return;
|
||||
|
||||
if (!ReleaseMutex(hdl))
|
||||
EHS_LOG_INT("Error", 0, "Failed to unlock mutex with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to unlock mutex with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
locked = false;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ namespace ehs
|
||||
return;
|
||||
|
||||
if (dlclose(hdl))
|
||||
EHS_LOG_INT("Error", 0, "Failed to close.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to close.");
|
||||
}
|
||||
|
||||
Open::Open()
|
||||
@ -77,7 +77,7 @@ namespace ehs
|
||||
hdl = dlopen(filePath, RTLD_LAZY);
|
||||
if (!hdl)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, dlerror());
|
||||
EHS_LOG_INT(LogType::ERR, 0, dlerror());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -88,7 +88,7 @@ namespace ehs
|
||||
return;
|
||||
|
||||
if (dlclose(hdl))
|
||||
EHS_LOG_INT("Error", 0, "Failed to close.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to close.");
|
||||
|
||||
hdl = nullptr;
|
||||
}
|
||||
@ -102,7 +102,7 @@ namespace ehs
|
||||
if (!func)
|
||||
{
|
||||
dlerror();
|
||||
EHS_LOG_INT("Error", 0, "Undefined symbol, \"" + symbol + "\".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Undefined symbol, \"" + symbol + "\".");
|
||||
Release();
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ namespace ehs
|
||||
return;
|
||||
|
||||
if (sem_destroy(&hdl) == -1)
|
||||
EHS_LOG_INT("Error", 0, "Failed to release semaphore with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to release semaphore with error #" + Str_8::FromNum(errno) + ".");
|
||||
|
||||
valid = false;
|
||||
}
|
||||
@ -92,14 +92,14 @@ namespace ehs
|
||||
{
|
||||
sem_t* result = sem_open("/" + GetName(), O_CREAT | O_EXCL, S_IRUSR | S_IWUSR, GetInitial());
|
||||
if (!result)
|
||||
EHS_LOG_INT("Error", 0, "Failed to create semaphore with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to create semaphore with error #" + Str_8::FromNum(errno) + ".");
|
||||
|
||||
hdl = *result;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sem_init(&hdl, 0, GetInitial()) == -1)
|
||||
EHS_LOG_INT("Error", 0, "Failed to create semaphore with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to create semaphore with error #" + Str_8::FromNum(errno) + ".");
|
||||
}
|
||||
|
||||
valid = true;
|
||||
@ -111,7 +111,7 @@ namespace ehs
|
||||
return;
|
||||
|
||||
if (sem_destroy(&hdl) == -1)
|
||||
EHS_LOG_INT("Error", 0, "Failed to release semaphore with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to release semaphore with error #" + Str_8::FromNum(errno) + ".");
|
||||
|
||||
hdl = {};
|
||||
|
||||
@ -124,7 +124,7 @@ namespace ehs
|
||||
return;
|
||||
|
||||
if (sem_post(&hdl) == -1)
|
||||
EHS_LOG_INT("Error", 0, "Failed to signal semaphore with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to signal semaphore with error #" + Str_8::FromNum(errno) + ".");
|
||||
}
|
||||
|
||||
bool Semaphore::Wait(const UInt_32 timeout)
|
||||
@ -148,7 +148,7 @@ namespace ehs
|
||||
{
|
||||
int code = errno;
|
||||
if (code != ETIMEDOUT)
|
||||
EHS_LOG_INT("Error", 0, "Failed to wait for semaphore with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to wait for semaphore with error #" + Str_8::FromNum(errno) + ".");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ namespace ehs
|
||||
if (!CloseHandle(hdl))
|
||||
{
|
||||
DWORD code = GetLastError();
|
||||
EHS_LOG_INT("Error", 0, Str_8("Failed to free semaphore with error #") + code + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, Str_8("Failed to free semaphore with error #") + code + ".");
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ namespace ehs
|
||||
|
||||
hdl = CreateSemaphoreW(nullptr, (LONG)GetInitial(), EHS_SINT_32_MAX, UTF::To_16(GetName()));
|
||||
if (!hdl)
|
||||
EHS_LOG_INT("Error", 0, Str_8("Failed to create semaphore with error #") + GetLastError() + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, Str_8("Failed to create semaphore with error #") + GetLastError() + ".");
|
||||
}
|
||||
|
||||
void Semaphore::Release()
|
||||
@ -93,7 +93,7 @@ namespace ehs
|
||||
if (!CloseHandle(hdl))
|
||||
{
|
||||
DWORD code = GetLastError();
|
||||
EHS_LOG_INT("Error", 0, Str_8("Failed to free semaphore with error #") + code + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, Str_8("Failed to free semaphore with error #") + code + ".");
|
||||
}
|
||||
hdl = nullptr;
|
||||
}
|
||||
@ -104,7 +104,7 @@ namespace ehs
|
||||
return;
|
||||
|
||||
if (!ReleaseSemaphore(hdl, (LONG)inc, nullptr))
|
||||
EHS_LOG_INT("Error", 0, Str_8("Failed to release semaphore with error #") + GetLastError() + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, Str_8("Failed to release semaphore with error #") + GetLastError() + ".");
|
||||
}
|
||||
|
||||
bool Semaphore::Wait(const UInt_32 timeout)
|
||||
@ -115,12 +115,12 @@ namespace ehs
|
||||
DWORD result = WaitForSingleObject(hdl, timeout);
|
||||
if (result == WAIT_ABANDONED)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Wait abandoned.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Wait abandoned.");
|
||||
return false;
|
||||
}
|
||||
else if (result == WAIT_FAILED)
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, Str_8("Wait failed with error #") + GetLastError() + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, Str_8("Wait failed with error #") + GetLastError() + ".");
|
||||
return false;
|
||||
}
|
||||
else if (result == WAIT_TIMEOUT)
|
||||
|
@ -60,7 +60,7 @@ namespace ehs
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
hdl = CreateThread(nullptr, stackSize, (LPTHREAD_START_ROUTINE)cb, args, 0, (DWORD*)&id);
|
||||
if (!hdl)
|
||||
EHS_LOG_INT("Error", 0, "Failed to start thread with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to start thread with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
UInt_64* rArgs = new UInt_64[sizeof(UInt_64) * 2];
|
||||
rArgs[0] = (UInt_64)cb;
|
||||
@ -79,7 +79,7 @@ namespace ehs
|
||||
unsigned int r = WaitForSingleObject(hdl, timeout);
|
||||
if (r == WAIT_ABANDONED)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Abandoned wait because a mutex was not released.");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Abandoned wait because a mutex was not released.");
|
||||
return false;
|
||||
}
|
||||
else if (r == WAIT_TIMEOUT)
|
||||
@ -88,7 +88,7 @@ namespace ehs
|
||||
}
|
||||
else if (r == WAIT_FAILED)
|
||||
{
|
||||
EHS_LOG_INT("Error", 1, "Failed to wait for thread with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to wait for thread with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ namespace ehs
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
int code = pthread_join((pthread_t)hdl, nullptr);
|
||||
if (code != 0)
|
||||
EHS_LOG_INT("Error", 1, "Failed to wait for thread with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to wait for thread with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
hdl = EHS_INVALID_THREAD;
|
||||
#endif
|
||||
@ -112,7 +112,7 @@ namespace ehs
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (!CloseHandle(hdl))
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, "Failed to detach thread with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to detach thread with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
return;
|
||||
}
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
@ -155,7 +155,7 @@ namespace ehs
|
||||
|
||||
taskHdl = AvSetMmThreadCharacteristicsW(UTF::To_16(task), (LPDWORD)&taskIndex);
|
||||
if (!taskHdl)
|
||||
EHS_LOG_INT("Error", 0, "Failed to set the thread's characteristics with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to set the thread's characteristics with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
}
|
||||
|
||||
void Thread::SetTaskType_16(const Str_16& task)
|
||||
@ -165,7 +165,7 @@ namespace ehs
|
||||
|
||||
taskHdl = AvSetMmThreadCharacteristicsW(task, (LPDWORD)&taskIndex);
|
||||
if (!taskHdl)
|
||||
EHS_LOG_INT("Error", 0, "Failed to set the thread's characteristics with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to set the thread's characteristics with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
}
|
||||
|
||||
void Thread::SetTaskType_8(const Str_8& task)
|
||||
@ -175,7 +175,7 @@ namespace ehs
|
||||
|
||||
taskHdl = AvSetMmThreadCharacteristicsW(UTF::To_16(task), (LPDWORD)&taskIndex);
|
||||
if (!taskHdl)
|
||||
EHS_LOG_INT("Error", 0, "Failed to set the thread's characteristics with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to set the thread's characteristics with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
}
|
||||
|
||||
void Thread::RevertTaskType()
|
||||
@ -184,7 +184,7 @@ namespace ehs
|
||||
return;
|
||||
|
||||
if (!AvRevertMmThreadCharacteristics(taskHdl))
|
||||
EHS_LOG_INT("Error", 0, "Failed to revert the thread's characteristics with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to revert the thread's characteristics with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
taskIndex = 0;
|
||||
}
|
||||
@ -212,7 +212,7 @@ namespace ehs
|
||||
|
||||
mainTaskHdl = AvSetMmThreadCharacteristicsW(UTF::To_16(task), (LPDWORD)&mainTaskIndex);
|
||||
if (!mainTaskHdl)
|
||||
EHS_LOG_INT("Error", 0, "Failed to set the main thread's characteristics with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to set the main thread's characteristics with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
}
|
||||
|
||||
void Thread::SetMainTaskType_16(const Str_16& task)
|
||||
@ -222,7 +222,7 @@ namespace ehs
|
||||
|
||||
mainTaskHdl = AvSetMmThreadCharacteristicsW(task, (LPDWORD)&mainTaskIndex);
|
||||
if (!mainTaskHdl)
|
||||
EHS_LOG_INT("Error", 0, "Failed to set the main thread's characteristics with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to set the main thread's characteristics with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
}
|
||||
|
||||
void Thread::SetMainTaskType_8(const Str_8& task)
|
||||
@ -232,7 +232,7 @@ namespace ehs
|
||||
|
||||
mainTaskHdl = AvSetMmThreadCharacteristicsW(UTF::To_16(task), (LPDWORD)&mainTaskIndex);
|
||||
if (!mainTaskHdl)
|
||||
EHS_LOG_INT("Error", 0, "Failed to set the main thread's characteristics with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to set the main thread's characteristics with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
}
|
||||
|
||||
void Thread::RevertMainTaskType()
|
||||
@ -241,7 +241,7 @@ namespace ehs
|
||||
return;
|
||||
|
||||
if (!AvRevertMmThreadCharacteristics(mainTaskHdl))
|
||||
EHS_LOG_INT("Error", 0, "Failed to revert the main thread's characteristics with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to revert the main thread's characteristics with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
mainTaskIndex = 0;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ namespace ehs
|
||||
void User::GetId(UInt_32* const real, UInt_32* const effective, UInt_32* const saved)
|
||||
{
|
||||
if (getresuid(real, effective, saved) == -1)
|
||||
EHS_LOG_INT("Error", 0, strerror(errno));
|
||||
EHS_LOG_INT(LogType::ERR, 0, strerror(errno));
|
||||
}
|
||||
|
||||
Str_8 User::GetName()
|
||||
@ -18,7 +18,7 @@ namespace ehs
|
||||
SInt_64 max = sysconf(_SC_LOGIN_NAME_MAX);
|
||||
if (max == -1)
|
||||
{
|
||||
EHS_LOG_INT("Error", 0, strerror(errno));
|
||||
EHS_LOG_INT(LogType::ERR, 0, strerror(errno));
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ namespace ehs
|
||||
if (getlogin_r(name, max) == -1)
|
||||
{
|
||||
delete[] name;
|
||||
EHS_LOG_INT("Error", 1, strerror(errno));
|
||||
EHS_LOG_INT(LogType::ERR, 1, strerror(errno));
|
||||
return {};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user