Reorganized project again.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#include "Base64.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
const char Base64::ascii[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace lwe
|
||||
return i;
|
||||
}
|
||||
|
||||
return LWE_SINT_8_MAX;
|
||||
return EHS_SINT_8_MAX;
|
||||
}
|
||||
|
||||
bool Base64::IsBase64(const char c)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include "BaseObj.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
BaseObj::~BaseObj()
|
||||
{
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#include "Color3.h"
|
||||
#include "Math.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
Color3::Color3()
|
||||
: r(0.0f), g(0.0f), b(0.0f)
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#include "Color4.h"
|
||||
#include "Math.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
Color4::Color4()
|
||||
: r(0.0f), g(0.0f), b(0.0f), a(1.0f)
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#include "Data.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
#include "DataType.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
DataType FromAudioBitDepth(const UInt_16 bitDepth)
|
||||
{
|
||||
|
@@ -1,5 +0,0 @@
|
||||
#include "Database/DVar.h"
|
||||
|
||||
namespace lwe
|
||||
{
|
||||
}
|
58
src/EHS.cpp
58
src/EHS.cpp
@@ -2,18 +2,18 @@
|
||||
#include "Log.h"
|
||||
#include "Version.h"
|
||||
#include "GarbageCollector.h"
|
||||
#include "IO/Audio/Audio.h"
|
||||
#include "IO/Img/Img.h"
|
||||
#include "IO/Img/PNG.h"
|
||||
#include "IO/RIFF.h"
|
||||
#include "io/audio/Audio.h"
|
||||
#include "io/img/Img.h"
|
||||
#include "io/img/PNG.h"
|
||||
#include "io/RIFF.h"
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
#if defined(LWE_OS_LINUX)
|
||||
#if defined(EHS_OS_LINUX)
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
constexpr Char_32 name_32[] = U"Lone Wolf Engine";
|
||||
constexpr Char_16 name_16[] = L"Lone Wolf Engine";
|
||||
@@ -100,14 +100,14 @@ namespace lwe
|
||||
|
||||
if (riff.GetType() != "WAVE")
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Data is not in WAVE format.");
|
||||
EHS_LOG_INT("Error", 0, "Data is not in WAVE format.");
|
||||
return false;
|
||||
}
|
||||
|
||||
RIFF_Chunk fmt = riff.GetChunk("fmt ");
|
||||
if (!fmt.IsValid())
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "Wave does not have a format chunk.");
|
||||
EHS_LOG_INT("Error", 1, "Wave does not have a format chunk.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -116,59 +116,59 @@ namespace lwe
|
||||
RIFF_Chunk dChunk = riff.GetChunk("data");
|
||||
if (!dChunk.IsValid())
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Wave does not have a data chunk.");
|
||||
EHS_LOG_INT("Error", 2, "Wave does not have a data chunk.");
|
||||
return false;
|
||||
}
|
||||
|
||||
UInt_16 compression = fmtSer.Read<UInt_16>();
|
||||
if (compression == 0x2)
|
||||
{
|
||||
LWE_LOG_INT("Error", 3, "Microsoft ADPCM compression unsupported.");
|
||||
EHS_LOG_INT("Error", 3, "Microsoft ADPCM compression unsupported.");
|
||||
return false;
|
||||
}
|
||||
else if (compression == 0x6)
|
||||
{
|
||||
LWE_LOG_INT("Error", 4, "ITU G.711 a-law compression unsupported.");
|
||||
EHS_LOG_INT("Error", 4, "ITU G.711 a-law compression unsupported.");
|
||||
return false;
|
||||
}
|
||||
else if (compression == 0x7)
|
||||
{
|
||||
LWE_LOG_INT("Error", 5, "ITU G.711 µ-law compression unsupported.");
|
||||
EHS_LOG_INT("Error", 5, "ITU G.711 µ-law compression unsupported.");
|
||||
return false;
|
||||
}
|
||||
else if (compression == 0x11)
|
||||
{
|
||||
LWE_LOG_INT("Error", 6, "IMA ADPCM compression unsupported.");
|
||||
EHS_LOG_INT("Error", 6, "IMA ADPCM compression unsupported.");
|
||||
return false;
|
||||
}
|
||||
else if (compression == 0x16)
|
||||
{
|
||||
LWE_LOG_INT("Error", 7, "TU G.723 ADPCM (Yamaha) compression unsupported.");
|
||||
EHS_LOG_INT("Error", 7, "TU G.723 ADPCM (Yamaha) compression unsupported.");
|
||||
return false;
|
||||
}
|
||||
else if (compression == 0x31)
|
||||
{
|
||||
LWE_LOG_INT("Error", 8, "GSM 6.10 compression unsupported.");
|
||||
EHS_LOG_INT("Error", 8, "GSM 6.10 compression unsupported.");
|
||||
return false;
|
||||
}
|
||||
else if (compression == 0x40)
|
||||
{
|
||||
LWE_LOG_INT("Error", 9, "ITU G.721 ADPCM compression unsupported.");
|
||||
EHS_LOG_INT("Error", 9, "ITU G.721 ADPCM compression unsupported.");
|
||||
return false;
|
||||
}
|
||||
else if (compression == 0x50)
|
||||
{
|
||||
LWE_LOG_INT("Error", 10, "MPEG compression unsupported.");
|
||||
EHS_LOG_INT("Error", 10, "MPEG compression unsupported.");
|
||||
return false;
|
||||
}
|
||||
else if (compression == 0xFFFF)
|
||||
{
|
||||
LWE_LOG_INT("Error", 11, "Experimental compression unsupported.");
|
||||
EHS_LOG_INT("Error", 11, "Experimental compression unsupported.");
|
||||
return false;
|
||||
}
|
||||
else if (compression != 0x1 && compression != 0x3)
|
||||
{
|
||||
LWE_LOG_INT("Error", 12, "Wave has unknown compression of " + Str_8::FromNum(compression) + ".");
|
||||
EHS_LOG_INT("Error", 12, "Wave has unknown compression of " + Str_8::FromNum(compression) + ".");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -282,7 +282,7 @@ namespace lwe
|
||||
Version version = in.ReadVersion();
|
||||
if (version != Version(1, 0, 0))
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Incompatible audio file version.");
|
||||
EHS_LOG_INT("Error", 0, "Incompatible audio file version.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -317,7 +317,7 @@ namespace lwe
|
||||
UInt_8 colorType = ihdrData->Read<UInt_8>();
|
||||
if (colorType == 3)
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "Color type of " + Str_8::FromNum(colorType) + " is unsupported.");
|
||||
EHS_LOG_INT("Error", 1, "Color type of " + Str_8::FromNum(colorType) + " is unsupported.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -334,21 +334,21 @@ namespace lwe
|
||||
UInt_8 compression = ihdrData->Read<UInt_8>();
|
||||
if (compression)
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Compression method of " + Str_8::FromNum(compression) + " is unsupported.");
|
||||
EHS_LOG_INT("Error", 2, "Compression method of " + Str_8::FromNum(compression) + " is unsupported.");
|
||||
return false;
|
||||
}
|
||||
|
||||
UInt_8 filter = ihdrData->Read<UInt_8>();
|
||||
if (filter)
|
||||
{
|
||||
LWE_LOG_INT("Error", 3, "Filter method of " + Str_8::FromNum(filter) + " is unsupported.");
|
||||
EHS_LOG_INT("Error", 3, "Filter method of " + Str_8::FromNum(filter) + " is unsupported.");
|
||||
return false;
|
||||
}
|
||||
|
||||
UInt_8 interlaced = ihdrData->Read<UInt_8>();
|
||||
if (interlaced)
|
||||
{
|
||||
LWE_LOG_INT("Error", 4, "Interlacing method of " + Str_8::FromNum(interlaced) + " is unsupported.");
|
||||
EHS_LOG_INT("Error", 4, "Interlacing method of " + Str_8::FromNum(interlaced) + " is unsupported.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -373,7 +373,7 @@ namespace lwe
|
||||
int code = inflateInit(&strm);
|
||||
if (code != Z_OK)
|
||||
{
|
||||
LWE_LOG_INT("Error", 5, "Failed to initialize zlib inflate with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 5, "Failed to initialize zlib inflate with error #" + Str_8::FromNum(code) + ".");
|
||||
delete[] buffer;
|
||||
return false;
|
||||
}
|
||||
@@ -383,7 +383,7 @@ namespace lwe
|
||||
code = inflate(&strm, Z_NO_FLUSH);
|
||||
if (code != Z_STREAM_END && code != Z_OK)
|
||||
{
|
||||
LWE_LOG_INT("Error", 6, "Failed to zlib inflate with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 6, "Failed to zlib inflate with error #" + Str_8::FromNum(code) + ".");
|
||||
delete[] buffer;
|
||||
return false;
|
||||
}
|
||||
@@ -392,7 +392,7 @@ namespace lwe
|
||||
code = inflateEnd(&strm);
|
||||
if (code != Z_OK)
|
||||
{
|
||||
LWE_LOG_INT("Error", 7, "Failed to uninitialize zlib inflate with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 7, "Failed to uninitialize zlib inflate with error #" + Str_8::FromNum(code) + ".");
|
||||
delete[] buffer;
|
||||
return false;
|
||||
}
|
||||
@@ -541,7 +541,7 @@ namespace lwe
|
||||
Str_8 imgType = in.ReadStr<Char_8, UInt_64>(4);
|
||||
if (imgType != "qoif")
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Given data is not in the qoif format.");
|
||||
EHS_LOG_INT("Error", 0, "Given data is not in the qoif format.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -659,7 +659,7 @@ int main()
|
||||
|
||||
const lwe::SInt_32 code = Main(&lwe::appName, &lwe::appVerId, &lwe::appVer);
|
||||
if (code)
|
||||
LWE_LOG("Warning", 0, "Executable exited with code #" + lwe::Str_8::FromNum(code) + ".");
|
||||
EHS_LOG("Warning", 0, "Executable exited with code #" + lwe::Str_8::FromNum(code) + ".");
|
||||
|
||||
lwe::GarbageCollector::Stop();
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#include "Encryption.h"
|
||||
#include "PRNG.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
void Encryption::Encrypt_64(const UInt_64 key, const UInt_64 size, Byte* const data)
|
||||
{
|
||||
@@ -11,22 +11,22 @@ namespace lwe
|
||||
{
|
||||
if (i + sizeof(UInt_64) < size)
|
||||
{
|
||||
*((UInt_64*)&data[i]) ^= rand.Generate(0, (UInt_64)LWE_UINT_64_MAX);
|
||||
*((UInt_64*)&data[i]) ^= rand.Generate(0, (UInt_64)EHS_UINT_64_MAX);
|
||||
i += sizeof(UInt_64);
|
||||
}
|
||||
else if (i + sizeof(UInt_32) < size)
|
||||
{
|
||||
*((UInt_32*)&data[i]) ^= (UInt_32)rand.Generate(0, LWE_UINT_32_MAX);
|
||||
*((UInt_32*)&data[i]) ^= (UInt_32)rand.Generate(0, EHS_UINT_32_MAX);
|
||||
i += sizeof(UInt_32);
|
||||
}
|
||||
else if (i + sizeof(UInt_16) < size)
|
||||
{
|
||||
*((UInt_16*)&data[i]) ^= (UInt_16)rand.Generate(0, LWE_UINT_16_MAX);
|
||||
*((UInt_16*)&data[i]) ^= (UInt_16)rand.Generate(0, EHS_UINT_16_MAX);
|
||||
i += sizeof(UInt_16);
|
||||
}
|
||||
else
|
||||
{
|
||||
data[i] ^= (Byte) rand.Generate(0, LWE_UINT_8_MAX);
|
||||
data[i] ^= (Byte) rand.Generate(0, EHS_UINT_8_MAX);
|
||||
++i;
|
||||
}
|
||||
}
|
||||
@@ -60,17 +60,17 @@ namespace lwe
|
||||
{
|
||||
if (i + sizeof(UInt_32) < size)
|
||||
{
|
||||
*((UInt_32*)&data[i]) ^= rand.Generate(0, LWE_UINT_32_MAX);
|
||||
*((UInt_32*)&data[i]) ^= rand.Generate(0, EHS_UINT_32_MAX);
|
||||
i += sizeof(UInt_32);
|
||||
}
|
||||
else if (i + sizeof(UInt_16) < size)
|
||||
{
|
||||
*((UInt_16*)&data[i]) ^= (UInt_16)rand.Generate(0, LWE_UINT_16_MAX);
|
||||
*((UInt_16*)&data[i]) ^= (UInt_16)rand.Generate(0, EHS_UINT_16_MAX);
|
||||
i += sizeof(UInt_16);
|
||||
}
|
||||
else
|
||||
{
|
||||
data[i] ^= (Byte)rand.Generate(0, LWE_UINT_8_MAX);
|
||||
data[i] ^= (Byte)rand.Generate(0, EHS_UINT_8_MAX);
|
||||
++i;
|
||||
}
|
||||
}
|
||||
@@ -99,12 +99,12 @@ namespace lwe
|
||||
{
|
||||
if (i + sizeof(UInt_16) < size)
|
||||
{
|
||||
*((UInt_16*)&data[i]) ^= (UInt_16)rand.Generate(0, LWE_UINT_16_MAX);
|
||||
*((UInt_16*)&data[i]) ^= (UInt_16)rand.Generate(0, EHS_UINT_16_MAX);
|
||||
i += sizeof(UInt_16);
|
||||
}
|
||||
else
|
||||
{
|
||||
data[i] ^= (Byte)rand.Generate(0, LWE_UINT_8_MAX);
|
||||
data[i] ^= (Byte)rand.Generate(0, EHS_UINT_8_MAX);
|
||||
++i;
|
||||
}
|
||||
}
|
||||
@@ -130,7 +130,7 @@ namespace lwe
|
||||
PRNG_u64 rand(key);
|
||||
|
||||
for (UInt_64 i = 0; i < size; ++i)
|
||||
data[i] ^= (Byte)rand.Generate(0, LWE_UINT_8_MAX);
|
||||
data[i] ^= (Byte)rand.Generate(0, EHS_UINT_8_MAX);
|
||||
}
|
||||
|
||||
void Encryption::Encrypt_8(const UInt_64 size, Byte* const data)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include "GarbageCollector.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
UInt_32 GarbageCollectionThread(void* params)
|
||||
{
|
||||
@@ -60,7 +60,7 @@ namespace lwe
|
||||
/*
|
||||
if (Has(obj))
|
||||
{
|
||||
LWE_LOG_INT("Warning", 1, obj->GetTypeId() + " object with address of, \"" + Str_8::FromNum<USize>((USize)obj) + "\" is already in garbage.");
|
||||
EHS_LOG_INT("Warning", 1, obj->GetTypeId() + " object with address of, \"" + Str_8::FromNum<USize>((USize)obj) + "\" is already in garbage.");
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include "HRNG.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
UInt_64 HRNG::GenerateSeed_u64()
|
||||
{
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include "Log.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
void (*Log::logCb)(const Log&) = nullptr;
|
||||
Log Log::lastLog;
|
||||
|
12
src/Math.cpp
12
src/Math.cpp
@@ -1,7 +1,7 @@
|
||||
#include "Math.h"
|
||||
#include "System/Architecture.h"
|
||||
#include "system/Architecture.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
bool Math::AbsCmp(const float a, const float b)
|
||||
{
|
||||
@@ -35,7 +35,7 @@ namespace lwe
|
||||
|
||||
double Math::Sqrt(const double from)
|
||||
{
|
||||
#if defined(LWE_ARCH_X64)
|
||||
#if defined(EHS_ARCH_X64)
|
||||
if (CPU::HasAVX())
|
||||
return Sqrt_AVX(from);
|
||||
else if (CPU::HasSSE())
|
||||
@@ -51,14 +51,14 @@ namespace lwe
|
||||
}
|
||||
|
||||
return result;
|
||||
#elif defined(LWE_ARCH_ARM64)
|
||||
#elif defined(EHS_ARCH_ARM64)
|
||||
return Sqrt_VFP4(from);
|
||||
#endif
|
||||
}
|
||||
|
||||
float Math::Sqrt(const float from)
|
||||
{
|
||||
#if defined(LWE_ARCH_X64)
|
||||
#if defined(EHS_ARCH_X64)
|
||||
if (CPU::HasAVX())
|
||||
return Sqrt_AVX(from);
|
||||
else if (CPU::HasSSE())
|
||||
@@ -74,7 +74,7 @@ namespace lwe
|
||||
}
|
||||
|
||||
return result;
|
||||
#elif defined(LWE_ARCH_ARM64)
|
||||
#elif defined(EHS_ARCH_ARM64)
|
||||
return Sqrt_VFP4(from);
|
||||
#endif
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include "PtrData.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
Vector<PtrData> pointers;
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include "EHS.h"
|
||||
#include "Str.h"
|
||||
#include "IO/Console.h"
|
||||
#include "io/Console.h"
|
||||
|
||||
lwe::Int_32 Main(lwe::Str_8* appName, lwe::Str_8* appVerId, lwe::Version* appVer)
|
||||
{
|
||||
|
@@ -1,5 +0,0 @@
|
||||
#include "System/Open_W32.h"
|
||||
|
||||
namespace lwe
|
||||
{
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
#include "Task.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
UInt_32 TaskThread(void* args)
|
||||
{
|
||||
@@ -15,7 +15,7 @@ namespace lwe
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (!available->Wait(LWE_INFINITE))
|
||||
if (!available->Wait(EHS_INFINITE))
|
||||
{
|
||||
done->Signal(1);
|
||||
return 1;
|
||||
@@ -189,7 +189,7 @@ namespace lwe
|
||||
{
|
||||
if (working)
|
||||
{
|
||||
LWE_LOG_INT("Warning", 0, "Attempted to give work while task is still working.");
|
||||
EHS_LOG_INT("Warning", 0, "Attempted to give work while task is still working.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ namespace lwe
|
||||
if (!working)
|
||||
return;
|
||||
|
||||
done->Wait(LWE_INFINITE);
|
||||
done->Wait(EHS_INFINITE);
|
||||
working = false;
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include "Type.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
Type::Type()
|
||||
: hashId(0)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include "URI.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
bool IsAN(const Char_8 c)
|
||||
{
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include "Util.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
bool Util::IsEqual(const void* const a, const void* const b, const UInt_64 size)
|
||||
{
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include "Version.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
Version::Version()
|
||||
: major(0), minor(0), patch(0)
|
||||
|
5
src/database/DVar.cpp
Normal file
5
src/database/DVar.cpp
Normal file
@@ -0,0 +1,5 @@
|
||||
#include "database/DVar.h"
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
#include "IO/BaseFile.h"
|
||||
#include "io/BaseFile.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
BaseFile::BaseFile()
|
||||
: mode(Mode::READ_WRITE), disposition(Disposition::OPEN_PERSISTENT)
|
||||
@@ -52,7 +52,7 @@ namespace lwe
|
||||
UInt_64 written = Write(&((Byte*)str)[total], size - total);
|
||||
if (!written)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
EHS_LOG_INT("Error", 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
Str_8::FromNum(size) + ").");
|
||||
break;
|
||||
}
|
||||
@@ -74,7 +74,7 @@ namespace lwe
|
||||
UInt_64 written = Write(&str.ToBytes()[total], str.Size(true) - total);
|
||||
if (!written)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
EHS_LOG_INT("Error", 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
Str_8::FromNum(str.Size()) + ").");
|
||||
break;
|
||||
}
|
||||
@@ -96,7 +96,7 @@ namespace lwe
|
||||
UInt_64 written = Write(&((Byte*)str)[total], size - total);
|
||||
if (!written)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
EHS_LOG_INT("Error", 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
Str_8::FromNum(size) + ").");
|
||||
break;
|
||||
}
|
||||
@@ -118,7 +118,7 @@ namespace lwe
|
||||
UInt_64 written = Write(&str.ToBytes()[total], str.Size(true) - total);
|
||||
if (!written)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
EHS_LOG_INT("Error", 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
Str_8::FromNum(str.Size()) + ").");
|
||||
break;
|
||||
}
|
||||
@@ -140,7 +140,7 @@ namespace lwe
|
||||
UInt_64 written = Write(&((Byte*)str)[total], size - total);
|
||||
if (!written)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
EHS_LOG_INT("Error", 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
Str_8::FromNum(size) + ").");
|
||||
break;
|
||||
}
|
||||
@@ -162,7 +162,7 @@ namespace lwe
|
||||
UInt_64 written = Write(&str.ToBytes()[total], str.Size(true) - total);
|
||||
if (!written)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
EHS_LOG_INT("Error", 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
Str_8::FromNum(str.Size()) + ").");
|
||||
break;
|
||||
}
|
||||
@@ -184,7 +184,7 @@ namespace lwe
|
||||
UInt_64 written = Write(&vec[total], vec.Size() - total);
|
||||
if (!written)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
EHS_LOG_INT("Error", 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
Str_8::FromNum(vec.Size()) + ").");
|
||||
break;
|
||||
}
|
||||
@@ -206,7 +206,7 @@ namespace lwe
|
||||
UInt_64 written = Write(&arr[total], arr.Size() - total);
|
||||
if (!written)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
EHS_LOG_INT("Error", 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
Str_8::FromNum(arr.Size()) + ").");
|
||||
break;
|
||||
}
|
||||
@@ -228,7 +228,7 @@ namespace lwe
|
||||
UInt_64 written = Write(&ser[total], ser.Size() - total);
|
||||
if (!written)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
EHS_LOG_INT("Error", 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
Str_8::FromNum(ser.Size()) + ").");
|
||||
break;
|
||||
}
|
||||
@@ -250,7 +250,7 @@ namespace lwe
|
||||
UInt_64 written = Write(&ser[total], ser.Size() - total);
|
||||
if (!written)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
EHS_LOG_INT("Error", 0, "Failed to write all data (" + Str_8::FromNum(total) + "/" +
|
||||
Str_8::FromNum(ser.Size()) + ").");
|
||||
break;
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
#include "IO/BaseFileMonitor.h"
|
||||
#include "io/BaseFileMonitor.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
BaseFileMonitor::BaseFileMonitor(Str_8 filePath)
|
||||
: filePath((Str_8&&)filePath)
|
@@ -1,6 +1,6 @@
|
||||
#include "IO/BaseWindow.h"
|
||||
#include "io/BaseWindow.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
BaseWindow::BaseWindow()
|
||||
: created(false), focused(false), cursorVisible(true), cursorConstrained(false),
|
@@ -1,8 +1,8 @@
|
||||
#include "IO/COM.h"
|
||||
#include "io/COM.h"
|
||||
#include "Str.h"
|
||||
#include "Log.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
COM::COM()
|
||||
: port(0), baudRate(9600), byteSize(8), parity(Parity::NONE), stopBits(StopBits::ONE), hdl(nullptr), initialized(false)
|
||||
@@ -24,7 +24,7 @@ namespace lwe
|
||||
nullptr);
|
||||
if (hdl == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to create handle at COM" + Str_8::FromNum(port) + " with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to create handle at COM" + Str_8::FromNum(port) + " with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace lwe
|
||||
|
||||
if (!GetCommState(hdl, &dcb))
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "Failed to retrieve COM" + Str_8::FromNum(port) + " state with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to retrieve COM" + Str_8::FromNum(port) + " state with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
UnInitialize();
|
||||
return;
|
||||
}
|
||||
@@ -46,7 +46,7 @@ namespace lwe
|
||||
|
||||
if (!SetCommState(hdl, &dcb))
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Failed to set COM" + Str_8::FromNum(port) + " state with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to set COM" + Str_8::FromNum(port) + " state with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
UnInitialize();
|
||||
return;
|
||||
}
|
||||
@@ -63,7 +63,7 @@ namespace lwe
|
||||
if (hdl)
|
||||
{
|
||||
if (!CloseHandle(hdl))
|
||||
LWE_LOG_INT("Error", 0, "Failed to close COM" + Str_8::FromNum(port) + " handle with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to close COM" + Str_8::FromNum(port) + " handle with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
hdl = nullptr;
|
||||
}
|
||||
@@ -77,7 +77,7 @@ namespace lwe
|
||||
|
||||
if (!WaitCommEvent(hdl, (DWORD*)&event, nullptr))
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to wait for COM" + Str_8::FromNum(port) + " event with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to wait for COM" + Str_8::FromNum(port) + " event with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
UnInitialize();
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace lwe
|
||||
|
||||
if (!TransmitCommChar(hdl, data))
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to transmit character to COM" + Str_8::FromNum(port) + " with error #" +
|
||||
EHS_LOG_INT("Error", 0, "Failed to transmit character to COM" + Str_8::FromNum(port) + " with error #" +
|
||||
Str_8::FromNum(GetLastError()) + ".");
|
||||
UnInitialize();
|
||||
}
|
||||
@@ -103,7 +103,7 @@ namespace lwe
|
||||
|
||||
if (!WriteFile(hdl, (void*)data, (DWORD)size, (DWORD*)&sent, nullptr))
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to receive data from COM" + Str_8::FromNum(port) + " with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to receive data from COM" + Str_8::FromNum(port) + " with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
UnInitialize();
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace lwe
|
||||
|
||||
if (!ReadFile(hdl, (void*)data, (DWORD)size, (DWORD*)&received, nullptr))
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to receive data from COM" + Str_8::FromNum(port) + " with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to receive data from COM" + Str_8::FromNum(port) + " with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
UnInitialize();
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace lwe
|
||||
{
|
||||
if (!FlushFileBuffers(hdl))
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to flush data for COM" + Str_8::FromNum(port) + " with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to flush data for COM" + Str_8::FromNum(port) + " with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
UnInitialize();
|
||||
}
|
||||
}
|
@@ -1,25 +1,25 @@
|
||||
#include "IO/Console.h"
|
||||
#include "io/Console.h"
|
||||
#include "Log.h"
|
||||
#include "IO/File.h"
|
||||
#include "io/File.h"
|
||||
|
||||
#if defined(LWE_OS_LINUX)
|
||||
#if defined(EHS_OS_LINUX)
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <cerrno>
|
||||
#endif
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
ConsoleHdl Console::hdlOut = 0;
|
||||
ConsoleHdl Console::hdlIn = 0;
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
bool Console::isConsole = true;
|
||||
#endif
|
||||
|
||||
void Console::Attach()
|
||||
{
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (!AttachConsole(ATTACH_PARENT_PROCESS))
|
||||
{
|
||||
DWORD code = GetLastError();
|
||||
@@ -41,11 +41,11 @@ namespace lwe
|
||||
{
|
||||
//DWORD code = WaitForSingleObject(hdlIn, 15000);
|
||||
//if (code == WAIT_FAILED || code == WAIT_TIMEOUT || code == WAIT_ABANDONED)
|
||||
// LWE_LOG_INT("Error", 0, "Failed to wait for console input.");
|
||||
// EHS_LOG_INT("Error", 0, "Failed to wait for console input.");
|
||||
|
||||
isConsole = true;
|
||||
}
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
hdlOut = open("/dev/stdout", O_WRONLY | O_SYNC);
|
||||
hdlIn = open("/dev/stdin", O_RDONLY);
|
||||
#else
|
||||
@@ -55,18 +55,18 @@ namespace lwe
|
||||
|
||||
bool Console::Create()
|
||||
{
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (!AllocConsole())
|
||||
return false;
|
||||
|
||||
hdlIn = GetStdHandle(STD_INPUT_HANDLE);
|
||||
hdlOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
||||
if (WaitForSingleObject(hdlIn, LWE_INFINITE) == WAIT_FAILED)
|
||||
LWE_LOG_INT("Error", 2, "Failed to wait for console input.");
|
||||
if (WaitForSingleObject(hdlIn, EHS_INFINITE) == WAIT_FAILED)
|
||||
EHS_LOG_INT("Error", 2, "Failed to wait for console input.");
|
||||
|
||||
//if (!SetConsoleActiveScreenBuffer(hdlOut))
|
||||
// LWE_LOG_INT("Error", 3, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
// EHS_LOG_INT("Error", 3, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
isConsole = true;
|
||||
#endif
|
||||
@@ -76,17 +76,17 @@ namespace lwe
|
||||
|
||||
void Console::Free()
|
||||
{
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (!FreeConsole())
|
||||
LWE_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
EHS_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
int code = close(hdlOut);
|
||||
if (code == -1)
|
||||
LWE_LOG_INT("Error", 0, "Failed to free the console output with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to free the console output with error #" + Str_8::FromNum(errno) + ".");
|
||||
|
||||
code = close(hdlIn);
|
||||
if (code == -1)
|
||||
LWE_LOG_INT("Error", 0, "Failed to free the console input with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to free the console input with error #" + Str_8::FromNum(errno) + ".");
|
||||
#endif
|
||||
|
||||
hdlOut = 0;
|
||||
@@ -105,7 +105,7 @@ namespace lwe
|
||||
|
||||
void Console::Write_32(const Str_32& str, const bool newLine)
|
||||
{
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (isConsole)
|
||||
{
|
||||
Str_16 r = UTF::To_16(str);
|
||||
@@ -118,7 +118,7 @@ namespace lwe
|
||||
{
|
||||
DWORD written = 0;
|
||||
if (!WriteConsoleW(hdlOut, &r[offset], (DWORD)r.Size() - offset, &written, nullptr))
|
||||
LWE_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
offset += written;
|
||||
}
|
||||
@@ -136,13 +136,13 @@ namespace lwe
|
||||
{
|
||||
DWORD written = 0;
|
||||
if (!WriteFile(hdlOut, &((Char_8*)r)[offset], (DWORD)r.Size(true) - offset, &written, nullptr))
|
||||
LWE_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
offset += written;
|
||||
}
|
||||
while (offset < r.Size(true));
|
||||
}
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
Str_32 result = str;
|
||||
if (newLine)
|
||||
result += U"\n";
|
||||
@@ -152,7 +152,7 @@ namespace lwe
|
||||
ssize_t written = write(hdlOut, result, result.Size(true));
|
||||
if (written == -1)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to write to console with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to write to console with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
offset += written;
|
||||
@@ -165,7 +165,7 @@ namespace lwe
|
||||
|
||||
void Console::Write_16(const Str_16& str, const bool newLine)
|
||||
{
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (isConsole)
|
||||
{
|
||||
Str_16 r = str;
|
||||
@@ -178,7 +178,7 @@ namespace lwe
|
||||
{
|
||||
DWORD written = 0;
|
||||
if (!WriteConsoleW(hdlOut, &r[offset], (DWORD)r.Size() - offset, &written, nullptr))
|
||||
LWE_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
offset += written;
|
||||
}
|
||||
@@ -196,13 +196,13 @@ namespace lwe
|
||||
{
|
||||
DWORD written = 0;
|
||||
if (!WriteFile(hdlOut, &((Char_8*)r)[offset], (DWORD)r.Size(true) - offset, &written, nullptr))
|
||||
LWE_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
offset += written;
|
||||
}
|
||||
while (offset < r.Size(true));
|
||||
}
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
Str_16 result = str;
|
||||
if (newLine)
|
||||
result += L"\n";
|
||||
@@ -212,7 +212,7 @@ namespace lwe
|
||||
ssize_t written = write(hdlOut, result, result.Size(true));
|
||||
if (written == -1)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to write to console with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to write to console with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
offset += written;
|
||||
@@ -223,7 +223,7 @@ namespace lwe
|
||||
|
||||
void Console::Write_8(const Str_8& str, const bool newLine)
|
||||
{
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (isConsole)
|
||||
{
|
||||
Str_16 r = UTF::To_16(str);
|
||||
@@ -236,7 +236,7 @@ namespace lwe
|
||||
{
|
||||
DWORD written = 0;
|
||||
if (!WriteConsoleW(hdlOut, &r[offset], (DWORD)r.Size() - offset, &written, nullptr))
|
||||
LWE_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
offset += written;
|
||||
}
|
||||
@@ -254,13 +254,13 @@ namespace lwe
|
||||
{
|
||||
DWORD written = 0;
|
||||
if (!WriteFile(hdlOut, &r[offset], (DWORD)r.Size() - offset, &written, nullptr))
|
||||
LWE_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
offset += written;
|
||||
}
|
||||
while (offset < r.Size());
|
||||
}
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
Str_8 result = str;
|
||||
if (newLine)
|
||||
result += "\n";
|
||||
@@ -270,7 +270,7 @@ namespace lwe
|
||||
ssize_t written = write(hdlOut, result, result.Size());
|
||||
if (written == -1)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to write to console with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to write to console with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
offset += written;
|
||||
@@ -284,7 +284,7 @@ namespace lwe
|
||||
if (!hdlIn)
|
||||
return U"";
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (isConsole)
|
||||
{
|
||||
Str_16 result;
|
||||
@@ -299,7 +299,7 @@ namespace lwe
|
||||
|
||||
if (!ReadConsoleW(hdlIn, &result[offset], (DWORD)bufferSize, &read, nullptr))
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
return U"";
|
||||
}
|
||||
@@ -329,7 +329,7 @@ namespace lwe
|
||||
|
||||
if (!ReadFile(hdlIn, &result[offset], (DWORD)bufferSize, &read, nullptr))
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
return U"";
|
||||
}
|
||||
@@ -345,7 +345,7 @@ namespace lwe
|
||||
|
||||
return UTF::To_32(result);
|
||||
}
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
Str_32 result;
|
||||
Str_32 input(bufferSize);
|
||||
ssize_t read = 0;
|
||||
@@ -355,7 +355,7 @@ namespace lwe
|
||||
read = ::read(hdlIn, input, bufferSize);
|
||||
if (read == -1)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to read from console with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to read from console with error #" + Str_8::FromNum(errno) + ".");
|
||||
return result;
|
||||
}
|
||||
result.Push(input, read);
|
||||
@@ -373,7 +373,7 @@ namespace lwe
|
||||
if (!hdlIn)
|
||||
return L"";
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (isConsole)
|
||||
{
|
||||
Str_16 result;
|
||||
@@ -388,7 +388,7 @@ namespace lwe
|
||||
|
||||
if (!ReadConsoleW(hdlIn, &result[offset], (DWORD)bufferSize, &read, nullptr))
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
return L"";
|
||||
}
|
||||
@@ -418,7 +418,7 @@ namespace lwe
|
||||
|
||||
if (!ReadFile(hdlIn, &result[offset], (DWORD)bufferSize, &read, nullptr))
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
return L"";
|
||||
}
|
||||
@@ -434,7 +434,7 @@ namespace lwe
|
||||
|
||||
return UTF::To_16(result);
|
||||
}
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
Str_16 result;
|
||||
Str_16 input(bufferSize);
|
||||
ssize_t read = 0;
|
||||
@@ -444,7 +444,7 @@ namespace lwe
|
||||
read = ::read(hdlIn, input, bufferSize);
|
||||
if (read == -1)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to read from console with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to read from console with error #" + Str_8::FromNum(errno) + ".");
|
||||
return result;
|
||||
}
|
||||
result.Push(input, read);
|
||||
@@ -462,7 +462,7 @@ namespace lwe
|
||||
if (!hdlIn)
|
||||
return "";
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (isConsole)
|
||||
{
|
||||
Str_16 result;
|
||||
@@ -477,7 +477,7 @@ namespace lwe
|
||||
|
||||
if (!ReadConsoleW(hdlIn, &result[offset], (DWORD)bufferSize, &read, nullptr))
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
return "";
|
||||
}
|
||||
@@ -507,7 +507,7 @@ namespace lwe
|
||||
|
||||
if (!ReadFile(hdlIn, &result[offset], (DWORD)bufferSize, &read, nullptr))
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
return "";
|
||||
}
|
||||
@@ -523,7 +523,7 @@ namespace lwe
|
||||
|
||||
return result;
|
||||
}
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
Str_8 result;
|
||||
Str_8 input(bufferSize);
|
||||
ssize_t read = 0;
|
||||
@@ -533,7 +533,7 @@ namespace lwe
|
||||
read = ::read(hdlIn, input, bufferSize);
|
||||
if (read == -1)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to read from console with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to read from console with error #" + Str_8::FromNum(errno) + ".");
|
||||
return result;
|
||||
}
|
||||
result.Push(input, read);
|
||||
@@ -548,7 +548,7 @@ namespace lwe
|
||||
|
||||
void Console::Clear()
|
||||
{
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
CONSOLE_SCREEN_BUFFER_INFO info = {};
|
||||
if (!GetConsoleScreenBufferInfo(hdlOut, &info))
|
||||
return;
|
||||
@@ -566,14 +566,14 @@ namespace lwe
|
||||
return;
|
||||
|
||||
SetConsoleCursorPosition(hdlOut, {0, 0});
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
const Char_8 code[] = "\033[2J\033[1;1H";
|
||||
UInt_64 offset = 0;
|
||||
do {
|
||||
ssize_t written = write(hdlOut, code, sizeof(code));
|
||||
if (written == -1)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to clear console with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to clear console with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
offset += written;
|
||||
@@ -584,17 +584,17 @@ namespace lwe
|
||||
|
||||
void Console::SetTitle_32(const Str_32& title)
|
||||
{
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (!SetConsoleTitleW(UTF::To_16(title)))
|
||||
LWE_LOG_INT("Error", 0, "Failed to set console title with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
EHS_LOG_INT("Error", 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;
|
||||
do {
|
||||
ssize_t written = write(hdlOut, code, code.Size(true));
|
||||
if (written == -1)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to set console title with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to set console title with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
offset += written;
|
||||
@@ -605,17 +605,17 @@ namespace lwe
|
||||
|
||||
void Console::SetTitle_16(const Str_16& title)
|
||||
{
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (!SetConsoleTitleW(title))
|
||||
LWE_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
EHS_LOG_INT("Error", 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;
|
||||
do {
|
||||
ssize_t written = write(hdlOut, code, code.Size(true));
|
||||
if (written == -1)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to set console title with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to set console title with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
offset += written;
|
||||
@@ -626,17 +626,17 @@ namespace lwe
|
||||
|
||||
void Console::SetTitle_8(const Str_8& title)
|
||||
{
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (!SetConsoleTitleW(UTF::To_16(title)))
|
||||
LWE_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
EHS_LOG_INT("Error", 0, "Failed with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
Str_8 code = "\033]0;" + title + "\007";
|
||||
UInt_64 offset = 0;
|
||||
do {
|
||||
ssize_t written = write(hdlOut, code, code.Size());
|
||||
if (written == -1)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to set console title with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to set console title with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
offset += written;
|
||||
@@ -647,10 +647,10 @@ namespace lwe
|
||||
|
||||
Str_32 Console::GetTitle_32()
|
||||
{
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
Str_16 title(LWE_MAX_PATH);
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
Str_16 title(EHS_MAX_PATH);
|
||||
|
||||
DWORD size = GetConsoleTitleW(&title[0], LWE_MAX_PATH);
|
||||
DWORD size = GetConsoleTitleW(&title[0], EHS_MAX_PATH);
|
||||
|
||||
title.Resize(size);
|
||||
|
||||
@@ -662,10 +662,10 @@ namespace lwe
|
||||
|
||||
Str_16 Console::GetTitle_16()
|
||||
{
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
Str_16 title(LWE_MAX_PATH);
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
Str_16 title(EHS_MAX_PATH);
|
||||
|
||||
DWORD size = GetConsoleTitleW(&title[0], LWE_MAX_PATH);
|
||||
DWORD size = GetConsoleTitleW(&title[0], EHS_MAX_PATH);
|
||||
|
||||
title.Resize(size);
|
||||
|
||||
@@ -677,10 +677,10 @@ namespace lwe
|
||||
|
||||
Str_8 Console::GetTitle_8()
|
||||
{
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
Str_16 title(LWE_MAX_PATH);
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
Str_16 title(EHS_MAX_PATH);
|
||||
|
||||
DWORD size = GetConsoleTitleW(&title[0], LWE_MAX_PATH);
|
||||
DWORD size = GetConsoleTitleW(&title[0], EHS_MAX_PATH);
|
||||
|
||||
title.Resize(size);
|
||||
|
||||
@@ -692,9 +692,9 @@ namespace lwe
|
||||
|
||||
Vector<Str_32> Console::GetArgs_32(const UInt_64 bufferSize)
|
||||
{
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
return UTF::To_32(GetCommandLineW()).Split(U" ");
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
File cmdFile("/proc/self/cmdline", Mode::READ, Disposition::OPEN);
|
||||
Array<Byte> data = cmdFile.ReadArray(bufferSize);
|
||||
cmdFile.Release();
|
||||
@@ -724,9 +724,9 @@ namespace lwe
|
||||
|
||||
Vector<Str_16> Console::GetArgs_16(const UInt_64 bufferSize)
|
||||
{
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
return Str_16(GetCommandLineW()).Split(L" ");
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
File cmdFile("/proc/self/cmdline", Mode::READ, Disposition::OPEN);
|
||||
Array<Byte> data = cmdFile.ReadArray(bufferSize);
|
||||
cmdFile.Release();
|
||||
@@ -754,9 +754,9 @@ namespace lwe
|
||||
|
||||
Vector<Str_8> Console::GetArgs_8(const UInt_64 bufferSize)
|
||||
{
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
return UTF::To_8(GetCommandLineW()).Split(" ");
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
File cmdFile("/proc/self/cmdline", Mode::READ, Disposition::OPEN);
|
||||
Array<Byte> data = cmdFile.ReadArray(bufferSize);
|
||||
cmdFile.Release();
|
||||
@@ -785,10 +785,10 @@ namespace lwe
|
||||
/*
|
||||
void* Console::GetHandle()
|
||||
{
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
void* hdl = FindWindowW(nullptr, GetTitle_16());
|
||||
if (hdl == nullptr)
|
||||
LWE_LOG_INT("Error", 0, "Failed to retrieve native handle with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve native handle with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
return hdl;
|
||||
#else
|
@@ -1,4 +1,4 @@
|
||||
#include "IO/FileMonitor_UNX.h"
|
||||
#include "io/FileMonitor_UNX.h"
|
||||
#include "Log.h"
|
||||
|
||||
#include <sys/inotify.h>
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#define BUF_LEN (1024 * (sizeof(inotify_event) + 16))
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
FileMonitor::~FileMonitor()
|
||||
{
|
||||
@@ -83,14 +83,14 @@ namespace lwe
|
||||
hdl = inotify_init();
|
||||
if (hdl < 0)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to initialize inotify.");
|
||||
EHS_LOG_INT("Error", 0, "Failed to initialize inotify.");
|
||||
return;
|
||||
}
|
||||
|
||||
int flags = fcntl(hdl, F_GETFL, 0);
|
||||
if (flags == -1)
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "Failed to retrieve flags with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to retrieve flags with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -98,14 +98,14 @@ namespace lwe
|
||||
|
||||
if (fcntl(hdl, F_SETFL, flags) == -1)
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Failed to set flags with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 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)
|
||||
{
|
||||
LWE_LOG_INT("Error", 3, "Failed to add watch.");
|
||||
EHS_LOG_INT("Error", 3, "Failed to add watch.");
|
||||
close(hdl);
|
||||
hdl = -1;
|
||||
return;
|
||||
@@ -126,7 +126,7 @@ namespace lwe
|
||||
|
||||
UInt_8 FileMonitor::Poll()
|
||||
{
|
||||
UInt_8 mask = LWE_FE_NONE;
|
||||
UInt_8 mask = EHS_FE_NONE;
|
||||
|
||||
if (!IsValid() || !IsInitialized())
|
||||
return mask;
|
||||
@@ -137,7 +137,7 @@ namespace lwe
|
||||
{
|
||||
UInt_8 code = errno;
|
||||
if (code != EWOULDBLOCK)
|
||||
LWE_LOG_INT("Error", 0, "Failed to read with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to read with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
return mask;
|
||||
}
|
||||
@@ -147,21 +147,21 @@ namespace lwe
|
||||
{
|
||||
inotify_event *event = (inotify_event*)&buffer[i];
|
||||
if (event->mask & IN_MODIFY)
|
||||
mask |= LWE_FE_MODIFIED;
|
||||
mask |= EHS_FE_MODIFIED;
|
||||
|
||||
if (event->mask & IN_DELETE_SELF)
|
||||
mask |= LWE_FE_DELETED;
|
||||
mask |= EHS_FE_DELETED;
|
||||
|
||||
if (event->mask & IN_MOVE_SELF)
|
||||
mask |= LWE_FE_MOVED;
|
||||
mask |= EHS_FE_MOVED;
|
||||
|
||||
if (event->mask & IN_ACCESS)
|
||||
mask |= LWE_FE_OPENED;
|
||||
mask |= EHS_FE_OPENED;
|
||||
|
||||
i += sizeof(inotify_event) + event->len;
|
||||
}
|
||||
|
||||
if (mask & LWE_FE_DELETED || mask & LWE_FE_MOVED)
|
||||
if (mask & EHS_FE_DELETED || mask & EHS_FE_MOVED)
|
||||
Release();
|
||||
|
||||
return mask;
|
@@ -1,10 +1,10 @@
|
||||
#include "IO/FileMonitor_W32.h"
|
||||
#include "io/FileMonitor_W32.h"
|
||||
#include "Log.h"
|
||||
#include "UTF.h"
|
||||
|
||||
#include <chrono>
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
FileMonitor::~FileMonitor()
|
||||
{
|
||||
@@ -12,7 +12,7 @@ namespace lwe
|
||||
return;
|
||||
|
||||
if (!CloseHandle(hdl))
|
||||
LWE_LOG_INT("Error", 0, "Failed to close file at file path, \"" + filePath + "\", with error #" + GetLastError() + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to close file at file path, \"" + filePath + "\", with error #" + GetLastError() + ".");
|
||||
}
|
||||
|
||||
FileMonitor::FileMonitor()
|
||||
@@ -82,7 +82,7 @@ namespace lwe
|
||||
hdl = CreateFileW(UTF::To_16(filePath), GENERIC_READ, FILE_SHARE_READ,
|
||||
nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
if (hdl == INVALID_HANDLE_VALUE)
|
||||
LWE_LOG_INT("Error", 0, "Failed to open file at file path, \"" + filePath + "\", with error #" + GetLastError() + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to open file at file path, \"" + filePath + "\", with error #" + GetLastError() + ".");
|
||||
}
|
||||
|
||||
void FileMonitor::Release()
|
||||
@@ -91,14 +91,14 @@ namespace lwe
|
||||
return;
|
||||
|
||||
if (!CloseHandle(hdl))
|
||||
LWE_LOG_INT("Error", 0, "Failed to close file at file path, \"" + filePath + "\", with error #" + GetLastError() + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to close file at file path, \"" + filePath + "\", with error #" + GetLastError() + ".");
|
||||
|
||||
hdl = nullptr;
|
||||
}
|
||||
|
||||
UInt_8 FileMonitor::Poll()
|
||||
{
|
||||
UInt_8 mask = LWE_FE_NONE;
|
||||
UInt_8 mask = EHS_FE_NONE;
|
||||
|
||||
FILETIME lastWriteTime = {};
|
||||
if (!GetFileTime(hdl, nullptr, nullptr, &lastWriteTime))
|
||||
@@ -111,7 +111,7 @@ namespace lwe
|
||||
return mask;
|
||||
|
||||
time = lastWriteTime;
|
||||
mask = LWE_FE_MODIFIED;
|
||||
mask = EHS_FE_MODIFIED;
|
||||
|
||||
return mask;
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
#include "IO/File_UNX.h"
|
||||
#include "io/File_UNX.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <sys/stat.h>
|
||||
@@ -8,15 +8,15 @@
|
||||
#include <cerrno>
|
||||
#include <cstdio>
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
File::~File()
|
||||
{
|
||||
if (map != MAP_FAILED && munmap(map, mapSize) == -1)
|
||||
LWE_LOG_INT("Error", 0, "Failed to unmap with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to unmap with error #" + Str_8::FromNum(errno) + ".");
|
||||
|
||||
if (hdl >= 0 && close(hdl) == -1)
|
||||
LWE_LOG_INT("Error", 0, "Failed to close file handle with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to close file handle with error #" + Str_8::FromNum(errno) + ".");
|
||||
}
|
||||
|
||||
File::File()
|
||||
@@ -69,14 +69,14 @@ namespace lwe
|
||||
{
|
||||
hdl = open64(path, linuxMode, S_IRUSR | S_IWUSR);
|
||||
if (hdl == -1)
|
||||
LWE_LOG_INT("Error", 0, strerror(errno));
|
||||
EHS_LOG_INT("Error", 0, strerror(errno));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (code == ENOENT)
|
||||
LWE_LOG_INT("Error", 0, "File at filepath, \"" + filePath + "\" not found.");
|
||||
EHS_LOG_INT("Error", 0, "File at filepath, \"" + filePath + "\" not found.");
|
||||
else
|
||||
LWE_LOG_INT("Error", 0, strerror(code));
|
||||
EHS_LOG_INT("Error", 0, strerror(code));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -137,12 +137,12 @@ namespace lwe
|
||||
void File::Release()
|
||||
{
|
||||
if (IsMapped() && munmap(map, mapSize) == -1)
|
||||
LWE_LOG_INT("Error", 0, "Failed to unmap with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to unmap with error #" + Str_8::FromNum(errno) + ".");
|
||||
map = MAP_FAILED;
|
||||
mapSize = 0;
|
||||
|
||||
if (IsValid() && close(hdl) == -1)
|
||||
LWE_LOG_INT("Error", 0, "Failed to close file handle with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to close file handle with error #" + Str_8::FromNum(errno) + ".");
|
||||
hdl = -1;
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ namespace lwe
|
||||
map = mmap64(nullptr, size, linuxMode, MAP_SHARED, hdl, (off64_t)offset);
|
||||
if (map == MAP_FAILED)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to map with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to map with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ namespace lwe
|
||||
return;
|
||||
|
||||
if (munmap(map, mapSize) == -1)
|
||||
LWE_LOG_INT("Error", 0, "Failed to unmap with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to unmap with error #" + Str_8::FromNum(errno) + ".");
|
||||
|
||||
map = MAP_FAILED;
|
||||
mapSize = 0;
|
||||
@@ -203,7 +203,7 @@ namespace lwe
|
||||
return;
|
||||
|
||||
if (msync((void*)map, mapSize, MS_SYNC) == -1)
|
||||
LWE_LOG_INT("Error", 0, "Failed to flush view with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 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 +214,7 @@ namespace lwe
|
||||
SInt_64 written = 0;
|
||||
written = write(hdl, data, size);
|
||||
if (written == -1)
|
||||
LWE_LOG_INT("Error", 0, "Failed to write to file, \"" + path + "\", with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to write to file, \"" + path + "\", with error #" + Str_8::FromNum(errno) + ".");
|
||||
|
||||
return (UInt_64)written;
|
||||
}
|
||||
@@ -227,7 +227,7 @@ namespace lwe
|
||||
SInt_64 read = 0;
|
||||
read = ::read(hdl, data, (size_t)size);
|
||||
if (read == -1)
|
||||
LWE_LOG_INT("Error", 0, "Failed to read from file, \"" + path + "\", with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to read from file, \"" + path + "\", with error #" + Str_8::FromNum(errno) + ".");
|
||||
|
||||
return (UInt_64)read;
|
||||
}
|
||||
@@ -238,7 +238,7 @@ namespace lwe
|
||||
return;
|
||||
|
||||
if (lseek64(hdl, (off64_t)index, SEEK_SET) == -1)
|
||||
LWE_LOG_INT("Error", 0, "Failed to seek with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to seek with error #" + Str_8::FromNum(errno) + ".");
|
||||
}
|
||||
|
||||
void File::SeekBeginning()
|
||||
@@ -247,7 +247,7 @@ namespace lwe
|
||||
return;
|
||||
|
||||
if (lseek64(hdl, 0, SEEK_SET) == -1)
|
||||
LWE_LOG_INT("Error", 0, "Failed to seek with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to seek with error #" + Str_8::FromNum(errno) + ".");
|
||||
}
|
||||
|
||||
void File::SeekEnd()
|
||||
@@ -256,7 +256,7 @@ namespace lwe
|
||||
return;
|
||||
|
||||
if (lseek64(hdl, 0, SEEK_END) == -1)
|
||||
LWE_LOG_INT("Error", 0, "Failed to seek with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to seek with error #" + Str_8::FromNum(errno) + ".");
|
||||
}
|
||||
|
||||
void File::Truncate(const UInt_64 size)
|
||||
@@ -265,7 +265,7 @@ namespace lwe
|
||||
return;
|
||||
|
||||
if (ftruncate64(hdl, (off64_t)size) == -1)
|
||||
LWE_LOG_INT("Error", 0, "Failed to truncate with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to truncate with error #" + Str_8::FromNum(errno) + ".");
|
||||
}
|
||||
|
||||
UInt_64 File::Size() const
|
||||
@@ -273,7 +273,7 @@ namespace lwe
|
||||
struct stat64 info = {};
|
||||
|
||||
if (fstat64(hdl, &info) == -1)
|
||||
LWE_LOG_INT("Error", 0, "Failed to retrieve file size with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve file size with error #" + Str_8::FromNum(errno) + ".");
|
||||
|
||||
return info.st_size;
|
||||
}
|
||||
@@ -302,6 +302,6 @@ namespace lwe
|
||||
path = filePath.Sub(0, index);
|
||||
|
||||
if (rename(filePath, path + newName) == -1)
|
||||
LWE_LOG_INT("Error", 0, "Failed to rename file with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to rename file with error #" + Str_8::FromNum(errno) + ".");
|
||||
}
|
||||
}
|
@@ -1,17 +1,17 @@
|
||||
#include "IO/File_W32.h"
|
||||
#include "io/File_W32.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
File::~File()
|
||||
{
|
||||
if (view && !UnmapViewOfFile(view))
|
||||
LWE_LOG_INT("Error", 0, "Failed to unmap view with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to unmap view with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
if (map != INVALID_HANDLE_VALUE && !CloseHandle(map))
|
||||
LWE_LOG_INT("Error", 0, "Failed to unmap with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to unmap with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
if (hdl != INVALID_HANDLE_VALUE && !CloseHandle(hdl))
|
||||
LWE_LOG_INT("Error", 0, "Failed to close file handle with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to close file handle with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
}
|
||||
|
||||
File::File()
|
||||
@@ -62,9 +62,9 @@ namespace lwe
|
||||
{
|
||||
DWORD code = GetLastError();
|
||||
if (code == ERROR_FILE_NOT_FOUND)
|
||||
LWE_LOG_INT("Error", 1, "File not found at path, \"" + path + "\".");
|
||||
EHS_LOG_INT("Error", 1, "File not found at path, \"" + path + "\".");
|
||||
else if (code != ERROR_SUCCESS)
|
||||
LWE_LOG_INT("Error", 2, "Failed to create handle for file, \"" + path + "\", with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to create handle for file, \"" + path + "\", with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -132,16 +132,16 @@ namespace lwe
|
||||
void File::Release()
|
||||
{
|
||||
if (view && !UnmapViewOfFile(view))
|
||||
LWE_LOG_INT("Error", 0, "Failed to unmap view with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to unmap view with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
view = nullptr;
|
||||
viewSize = 0;
|
||||
|
||||
if (IsMapped() && !CloseHandle(map))
|
||||
LWE_LOG_INT("Error", 0, "Failed to unmap with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to unmap with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
map = INVALID_HANDLE_VALUE;
|
||||
|
||||
if (IsValid() && !CloseHandle(hdl))
|
||||
LWE_LOG_INT("Error", 0, "Failed to close file handle with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to close file handle with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
hdl = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ namespace lwe
|
||||
map = CreateFileMappingW(hdl, nullptr, winMode, 0, 0, nullptr);
|
||||
if (!map)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to create map handle with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to create map handle with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -197,10 +197,10 @@ namespace lwe
|
||||
view = (Byte*)MapViewOfFile(map, winMode, ((DWORD*)&offset)[1], (DWORD)offset, size);
|
||||
if (!view)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to map view with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to map view with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
if (!CloseHandle(map))
|
||||
LWE_LOG_INT("Error", 0, "Failed to unmap with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to unmap with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
map = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
@@ -213,12 +213,12 @@ namespace lwe
|
||||
return;
|
||||
|
||||
if (!UnmapViewOfFile(view))
|
||||
LWE_LOG_INT("Error", 0, "Failed to unmap view with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to unmap view with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
view = nullptr;
|
||||
viewSize = 0;
|
||||
|
||||
if (!CloseHandle(map))
|
||||
LWE_LOG_INT("Error", 0, "Failed to unmap with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to unmap with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
map = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ namespace lwe
|
||||
return;
|
||||
|
||||
if (!FlushViewOfFile(view, viewSize))
|
||||
LWE_LOG_INT("Error", 0, "Failed to flush view with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 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 +239,7 @@ namespace lwe
|
||||
SInt_64 written = 0;
|
||||
|
||||
if (!WriteFile(hdl, data, (DWORD)size, (DWORD*)&written, nullptr))
|
||||
LWE_LOG_INT("Error", 0, "Failed to write to file, \"" + path + "\", with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to write to file, \"" + path + "\", with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
return (UInt_64)written;
|
||||
}
|
||||
@@ -252,7 +252,7 @@ namespace lwe
|
||||
SInt_64 read = 0;
|
||||
|
||||
if (!ReadFile(hdl, data, (DWORD)size, (DWORD*)&read, nullptr))
|
||||
LWE_LOG_INT("Error", 0, "Failed to read from file, \"" + path + "\", with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to read from file, \"" + path + "\", with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
return (UInt_64)read;
|
||||
}
|
||||
@@ -263,7 +263,7 @@ namespace lwe
|
||||
return;
|
||||
|
||||
if (SetFilePointer(hdl, (LONG)index, (PLONG)&((UInt_32*)&index)[1], FILE_BEGIN) == INVALID_SET_FILE_POINTER)
|
||||
LWE_LOG_INT("Error", 0, "Failed to seek with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to seek with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
}
|
||||
|
||||
void File::SeekBeginning()
|
||||
@@ -272,7 +272,7 @@ namespace lwe
|
||||
return;
|
||||
|
||||
if (SetFilePointer(hdl, 0, nullptr, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
|
||||
LWE_LOG_INT("Error", 0, "Failed to seek with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to seek with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
}
|
||||
|
||||
void File::SeekEnd()
|
||||
@@ -281,7 +281,7 @@ namespace lwe
|
||||
return;
|
||||
|
||||
if (SetFilePointer(hdl, 0, nullptr, FILE_END) == INVALID_SET_FILE_POINTER)
|
||||
LWE_LOG_INT("Error", 0, "Failed to seek with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to seek with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
}
|
||||
|
||||
void File::Truncate(const UInt_64 size)
|
||||
@@ -292,7 +292,7 @@ namespace lwe
|
||||
Seek(size);
|
||||
|
||||
if (!::SetEndOfFile(hdl))
|
||||
LWE_LOG_INT("Error", 0, "Failed to set end of file with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to set end of file with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
SeekBeginning();
|
||||
}
|
||||
@@ -305,7 +305,7 @@ namespace lwe
|
||||
LARGE_INTEGER size = {};
|
||||
|
||||
if (!GetFileSizeEx(hdl, &size))
|
||||
LWE_LOG_INT("Error", 0, "Failed to retrieve file size with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve file size with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
return (UInt_64)size.QuadPart;
|
||||
}
|
||||
@@ -329,7 +329,7 @@ namespace lwe
|
||||
path = filePath.Sub(0, index);
|
||||
|
||||
if (!MoveFileW(filePath, path + newName))
|
||||
LWE_LOG_INT("Error", 0, "Failed to rename file with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to rename file with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
}
|
||||
|
||||
void File::Rename_8(const Str_8& filePath, const Str_8& newName)
|
@@ -1,8 +1,8 @@
|
||||
#include "IO/FontAtlas.h"
|
||||
#include "IO/File.h"
|
||||
#include "io/FontAtlas.h"
|
||||
#include "io/File.h"
|
||||
#include "Serializer.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
FontAtlas::FontAtlas()
|
||||
: glyphScale(0)
|
||||
@@ -26,7 +26,7 @@ namespace lwe
|
||||
Version ver = fData.ReadVersion();
|
||||
if (ver != Version(1, 0, 0))
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "The Event Horizon Font file, \"" + filePath + "\", must be version 1.0.0, but was version " +
|
||||
EHS_LOG_INT("Error", 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;
|
@@ -1,6 +1,6 @@
|
||||
#include "IO/Glyph.h"
|
||||
#include "io/Glyph.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
Glyph::Glyph()
|
||||
: code(0)
|
@@ -1,7 +1,7 @@
|
||||
#include "IO/RIFF.h"
|
||||
#include "IO/File.h"
|
||||
#include "io/RIFF.h"
|
||||
#include "io/File.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
RIFF::RIFF(const Str_8& filePath)
|
||||
{
|
||||
@@ -12,7 +12,7 @@ namespace lwe
|
||||
Str_8 riffId = data.ReadStr<Char_8, UInt_64>(4);
|
||||
if (riffId != "RIFF")
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "File at file path, \"" + filePath + "\", is not a valid RIFF file.");
|
||||
EHS_LOG_INT("Error", 0, "File at file path, \"" + filePath + "\", is not a valid RIFF file.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace lwe
|
||||
Str_8 riffId = data.ReadStr<Char_8, UInt_64>(4);
|
||||
if (riffId != "RIFF")
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Data is not in RIFF format.");
|
||||
EHS_LOG_INT("Error", 0, "Data is not in RIFF format.");
|
||||
return;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include "IO/RIFF_Chunk.h"
|
||||
#include "io/RIFF_Chunk.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
RIFF_Chunk::RIFF_Chunk()
|
||||
: hashId(0)
|
@@ -1,11 +1,11 @@
|
||||
#include "IO/Window_W32.h"
|
||||
#include "IO/HID/Keyboard.h"
|
||||
#include "IO/HID/Mouse.h"
|
||||
#include "System/Thread.h"
|
||||
#include "io/Window_W32.h"
|
||||
#include "io/hid/Keyboard.h"
|
||||
#include "io/hid/Mouse.h"
|
||||
#include "system/Thread.h"
|
||||
|
||||
#include <hidusage.h>
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
Array<Window*> Window::windows;
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace lwe
|
||||
|
||||
if (GetRawInputData((HRAWINPUT)lParam, RID_INPUT, data, &dwSize, sizeof(RAWINPUTHEADER)) != dwSize)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Getting raw input returned incorrect size.");
|
||||
EHS_LOG_INT("Error", 0, "Getting raw input returned incorrect size.");
|
||||
delete[] data;
|
||||
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
@@ -113,7 +113,7 @@ namespace lwe
|
||||
|
||||
if (GetRawInputDeviceInfo(hDevice, RIDI_DEVICENAME, deviceName, &bufferSize) < 0)
|
||||
{
|
||||
LWE_LOG_INT("Error, 0, "Failed to retrieve device name.");
|
||||
EHS_LOG_INT("Error, 0, "Failed to retrieve device name.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace lwe
|
||||
|
||||
if (GetRawInputDeviceInfo(hDevice, RIDI_DEVICENAME, deviceName, &bufferSize) < 0)
|
||||
{
|
||||
LWE_LOG_INT("Error, 1, "Failed to retrieve device name.");
|
||||
EHS_LOG_INT("Error, 1, "Failed to retrieve device name.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ namespace lwe
|
||||
if (win->cursorConstrained)
|
||||
{
|
||||
if (!ClipCursor(nullptr))
|
||||
LWE_LOG_INT("Error", 0, "Failed to free cursor after losing focus with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to free cursor after losing focus with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
}
|
||||
|
||||
win->ih.ResetAllStates();
|
||||
@@ -210,7 +210,7 @@ namespace lwe
|
||||
|
||||
if (!GetClientRect(win->GetHdl(), &client))
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to retrieve client scale with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve client scale with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ namespace lwe
|
||||
|
||||
if (!ClientToScreen(win->GetHdl(), &pos))
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "Failed to retrieve client's absolute position with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to retrieve client's absolute position with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ namespace lwe
|
||||
|
||||
if (!ClientToScreen(win->GetHdl(), &scale))
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Failed to retrieve client's absolute scale with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to retrieve client's absolute scale with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ namespace lwe
|
||||
|
||||
if (!ClipCursor(&client))
|
||||
{
|
||||
LWE_LOG_INT("Error", 3, "Failed to confine cursor with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 3, "Failed to confine cursor with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
return DefWindowProcW(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
}
|
||||
@@ -337,7 +337,7 @@ namespace lwe
|
||||
wcex.lpszClassName = title;
|
||||
|
||||
if (!RegisterClassExW(&wcex))
|
||||
LWE_LOG_INT("Error", 0, "Failed to register window.");
|
||||
EHS_LOG_INT("Error", 0, "Failed to register window.");
|
||||
|
||||
hdl = CreateWindowExW(
|
||||
0,
|
||||
@@ -352,7 +352,7 @@ namespace lwe
|
||||
|
||||
if (!hdl)
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "Failed to create window.");
|
||||
EHS_LOG_INT("Error", 1, "Failed to create window.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -381,7 +381,7 @@ namespace lwe
|
||||
|
||||
if (RegisterRawInputDevices(rid, 2, sizeof(rid[0])) == false)
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Failed to register raw input devices.");
|
||||
EHS_LOG_INT("Error", 2, "Failed to register raw input devices.");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -424,7 +424,7 @@ namespace lwe
|
||||
void Window::SetTitle_32(const Str_32& title)
|
||||
{
|
||||
if (!SetWindowTextW(hdl, UTF::To_16(title)))
|
||||
LWE_LOG_INT("Error", 0, "Failed to set window title with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to set window title with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
}
|
||||
|
||||
Str_32 Window::GetTitle_32()
|
||||
@@ -435,7 +435,7 @@ namespace lwe
|
||||
DWORD err = GetLastError();
|
||||
if (err)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to retrieve the window's title length with error #" + Str_8::FromNum(err) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve the window's title length with error #" + Str_8::FromNum(err) + ".");
|
||||
|
||||
return {};
|
||||
}
|
||||
@@ -449,7 +449,7 @@ namespace lwe
|
||||
DWORD err = GetLastError();
|
||||
if (err)
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "Failed to retrieve the window's title length with error #" + Str_8::FromNum(err) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to retrieve the window's title length with error #" + Str_8::FromNum(err) + ".");
|
||||
|
||||
return {};
|
||||
}
|
||||
@@ -461,7 +461,7 @@ namespace lwe
|
||||
void Window::SetTitle_16(const Str_16& title)
|
||||
{
|
||||
if (!SetWindowTextW(hdl, title))
|
||||
LWE_LOG_INT("Error", 0, "Failed to set window title with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to set window title with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
}
|
||||
|
||||
Str_16 Window::GetTitle_16()
|
||||
@@ -472,7 +472,7 @@ namespace lwe
|
||||
DWORD err = GetLastError();
|
||||
if (err)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to retrieve the window's title length with error #" + Str_8::FromNum(err) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve the window's title length with error #" + Str_8::FromNum(err) + ".");
|
||||
|
||||
return {};
|
||||
}
|
||||
@@ -486,7 +486,7 @@ namespace lwe
|
||||
DWORD err = GetLastError();
|
||||
if (err)
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "Failed to retrieve the window's title length with error #" + Str_8::FromNum(err) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to retrieve the window's title length with error #" + Str_8::FromNum(err) + ".");
|
||||
|
||||
return {};
|
||||
}
|
||||
@@ -498,7 +498,7 @@ namespace lwe
|
||||
void Window::SetTitle_8(const Str_8& title)
|
||||
{
|
||||
if (!SetWindowTextW(hdl, UTF::To_16(title)))
|
||||
LWE_LOG_INT("Error", 0, "Failed to set window title with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to set window title with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
}
|
||||
|
||||
Str_8 Window::GetTitle_8()
|
||||
@@ -509,7 +509,7 @@ namespace lwe
|
||||
DWORD err = GetLastError();
|
||||
if (err)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to retrieve the window's title length with error #" + Str_8::FromNum(err) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve the window's title length with error #" + Str_8::FromNum(err) + ".");
|
||||
|
||||
return {};
|
||||
}
|
||||
@@ -523,7 +523,7 @@ namespace lwe
|
||||
DWORD err = GetLastError();
|
||||
if (err)
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "Failed to retrieve the window's title length with error #" + Str_8::FromNum(err) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to retrieve the window's title length with error #" + Str_8::FromNum(err) + ".");
|
||||
|
||||
return {};
|
||||
}
|
||||
@@ -537,7 +537,7 @@ namespace lwe
|
||||
Handle icon = LoadImageW(nullptr, UTF::To_16(filePath), IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE);
|
||||
if (!icon)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to load icon at file path, \"" + filePath + "\" with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to load icon at file path, \"" + filePath + "\" with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -624,7 +624,7 @@ namespace lwe
|
||||
RECT rect = {};
|
||||
|
||||
if (!GetClientRect(hdl, &rect))
|
||||
LWE_LOG_INT("Error", 0, "Failed to retrieve client size with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve client size with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
return {(UInt_32)rect.right, (UInt_32)rect.bottom};
|
||||
}
|
||||
@@ -667,7 +667,7 @@ namespace lwe
|
||||
|
||||
if (!GetClientRect(GetHdl(), &client))
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to retrieve client scale with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve client scale with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -675,7 +675,7 @@ namespace lwe
|
||||
|
||||
if (!ClientToScreen(GetHdl(), &pos))
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "Failed to retrieve client's absolute position with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to retrieve client's absolute position with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -686,7 +686,7 @@ namespace lwe
|
||||
|
||||
if (!ClientToScreen(GetHdl(), &scale))
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Failed to retrieve client's absolute scale with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to retrieve client's absolute scale with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -695,7 +695,7 @@ namespace lwe
|
||||
|
||||
if (!ClipCursor(&client))
|
||||
{
|
||||
LWE_LOG_INT("Error", 3, "Failed to confine cursor with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 3, "Failed to confine cursor with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
#include "IO/Window_Way.h"
|
||||
#include "io/Window_Way.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
void Window::SurfaceConfigure(void* data, xdg_surface* xdg_surface, UInt_32 serial)
|
||||
{
|
||||
@@ -66,7 +66,7 @@ namespace lwe
|
||||
display = wl_display_connect(nullptr);
|
||||
if (!display)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to connect to display server.");
|
||||
EHS_LOG_INT("Error", 0, "Failed to connect to display server.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace lwe
|
||||
|
||||
if (!compositor || !xdgShell)
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "Can't find required interfaces.");
|
||||
EHS_LOG_INT("Error", 1, "Can't find required interfaces.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace lwe
|
||||
surface = wl_compositor_create_surface(compositor);
|
||||
if (!surface)
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Can't create surface.");
|
||||
EHS_LOG_INT("Error", 2, "Can't create surface.");
|
||||
return;
|
||||
}
|
||||
|
@@ -1,14 +1,14 @@
|
||||
#include "IO/Window_XCB.h"
|
||||
#include "io/Window_XCB.h"
|
||||
#include "UTF.h"
|
||||
#include "IO/HID/Keyboard.h"
|
||||
#include "IO/HID/Mouse.h"
|
||||
#include "IO/Console.h"
|
||||
#include "io/hid/Keyboard.h"
|
||||
#include "io/hid/Mouse.h"
|
||||
#include "io/Console.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <xcb/xfixes.h>
|
||||
#include <xcb/xcb_cursor.h>
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
Window::Window()
|
||||
: server(nullptr), screen(nullptr), hdl(0), events{XCB_ATOM_NONE, XCB_ATOM_NONE}, extOpCode(0)
|
||||
@@ -33,7 +33,7 @@ namespace lwe
|
||||
server = xcb_connect(nullptr, nullptr);
|
||||
if (xcb_connection_has_error(server))
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to connect to display server.");
|
||||
EHS_LOG_INT("Error", 0, "Failed to connect to display server.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace lwe
|
||||
{
|
||||
xcb_disconnect(server);
|
||||
|
||||
LWE_LOG_INT("Warning", 1, "Failed to query for XCB XInput extension.");
|
||||
EHS_LOG_INT("Warning", 1, "Failed to query for XCB XInput extension.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace lwe
|
||||
{
|
||||
xcb_disconnect(server);
|
||||
|
||||
LWE_LOG_INT("Warning", 2, "XCB XInput extension is not available.");
|
||||
EHS_LOG_INT("Warning", 2, "XCB XInput extension is not available.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -380,7 +380,7 @@ namespace lwe
|
||||
if (!reply || reply->status != XCB_GRAB_STATUS_SUCCESS)
|
||||
{
|
||||
free(reply);
|
||||
LWE_LOG_INT("Error", 0, "Failed to constrain cursor.");
|
||||
EHS_LOG_INT("Error", 0, "Failed to constrain cursor.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -443,7 +443,7 @@ namespace lwe
|
||||
xcb_get_geometry_reply_t *geom = xcb_get_geometry_reply(server, geom_cookie, nullptr);
|
||||
if (!geom)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to retrieve window position.");
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve window position.");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -469,7 +469,7 @@ namespace lwe
|
||||
xcb_get_geometry_reply_t *geom = xcb_get_geometry_reply(server, geom_cookie, nullptr);
|
||||
if (!geom)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to retrieve window scale.");
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve window scale.");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -490,7 +490,7 @@ namespace lwe
|
||||
|
||||
if (clipboard_atom == XCB_ATOM_NONE || utf8_string_atom == XCB_ATOM_NONE || property_atom == XCB_ATOM_NONE)
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "Failed to retrieve atoms.");
|
||||
EHS_LOG_INT("Error", 1, "Failed to retrieve atoms.");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -525,7 +525,7 @@ namespace lwe
|
||||
const xcb_atom_t clipboard_atom = RetrieveAtom(false, "CLIPBOARD");
|
||||
if (clipboard_atom == XCB_ATOM_NONE)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to retrieve atom.");
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve atom.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -604,7 +604,7 @@ namespace lwe
|
||||
|
||||
if (!device_reply)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to query primary devices.");
|
||||
EHS_LOG_INT("Error", 0, "Failed to query primary devices.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -636,7 +636,7 @@ namespace lwe
|
||||
|
||||
if (!device_reply)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to query device name from the id, \"" + Str_8::FromNum(id) + "\".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to query device name from the id, \"" + Str_8::FromNum(id) + "\".");
|
||||
return result;
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#include "IO/Audio/Audio.h"
|
||||
#include "IO/File.h"
|
||||
#include "IO/RIFF.h"
|
||||
#include "io/audio/Audio.h"
|
||||
#include "io/File.h"
|
||||
#include "io/RIFF.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
Array<AudioCodec> Audio::codecs;
|
||||
|
||||
@@ -264,7 +264,7 @@ namespace lwe
|
||||
}
|
||||
else
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Conversion from " + Str_8::FromNum(channels) + " channels, to 2 channels is unsupported.");
|
||||
EHS_LOG_INT("Error", 0, "Conversion from " + Str_8::FromNum(channels) + " channels, to 2 channels is unsupported.");
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -295,7 +295,7 @@ namespace lwe
|
||||
}
|
||||
else
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Conversion from " + Str_8::FromNum(channels) + " channels, to 6 channels is unsupported.");
|
||||
EHS_LOG_INT("Error", 0, "Conversion from " + Str_8::FromNum(channels) + " channels, to 6 channels is unsupported.");
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -326,7 +326,7 @@ namespace lwe
|
||||
}
|
||||
else
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Conversion from " + Str_8::FromNum(channels) + " channels, to 8 channels is unsupported.");
|
||||
EHS_LOG_INT("Error", 0, "Conversion from " + Str_8::FromNum(channels) + " channels, to 8 channels is unsupported.");
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -339,13 +339,13 @@ namespace lwe
|
||||
case DataType::SINT_8:
|
||||
return ((SInt_8*)data)[sampleIndex];
|
||||
case DataType::SINT_16:
|
||||
return (SInt_8)((float)((SInt_16*)data)[sampleIndex] / (float)LWE_SINT_16_MAX * (float)LWE_SINT_8_MAX);
|
||||
return (SInt_8)((float)((SInt_16*)data)[sampleIndex] / (float)EHS_SINT_16_MAX * (float)EHS_SINT_8_MAX);
|
||||
case DataType::FLOAT:
|
||||
return (SInt_8)(((float*)data)[sampleIndex] * (float)LWE_SINT_8_MAX);
|
||||
return (SInt_8)(((float*)data)[sampleIndex] * (float)EHS_SINT_8_MAX);
|
||||
case DataType::SINT_32:
|
||||
return (SInt_8)((float)((SInt_32*)data)[sampleIndex] / (float)LWE_SINT_32_MAX * (float)LWE_SINT_8_MAX);
|
||||
return (SInt_8)((float)((SInt_32*)data)[sampleIndex] / (float)EHS_SINT_32_MAX * (float)EHS_SINT_8_MAX);
|
||||
case DataType::SINT_64:
|
||||
return (SInt_8)((float)((SInt_64*)data)[sampleIndex] / (float)LWE_SINT_64_MAX * (float)LWE_SINT_8_MAX);
|
||||
return (SInt_8)((float)((SInt_64*)data)[sampleIndex] / (float)EHS_SINT_64_MAX * (float)EHS_SINT_8_MAX);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -356,15 +356,15 @@ namespace lwe
|
||||
switch (dataType)
|
||||
{
|
||||
case DataType::SINT_8:
|
||||
return (SInt_16)((float)((SInt_8*)data)[sampleIndex] / (float)LWE_SINT_8_MAX * (float)LWE_SINT_16_MAX);
|
||||
return (SInt_16)((float)((SInt_8*)data)[sampleIndex] / (float)EHS_SINT_8_MAX * (float)EHS_SINT_16_MAX);
|
||||
case DataType::SINT_16:
|
||||
return ((SInt_16*)data)[sampleIndex];
|
||||
case DataType::FLOAT:
|
||||
return (SInt_16)(((float*)data)[sampleIndex] * (float)LWE_SINT_16_MAX);
|
||||
return (SInt_16)(((float*)data)[sampleIndex] * (float)EHS_SINT_16_MAX);
|
||||
case DataType::SINT_32:
|
||||
return (SInt_16)((float)((SInt_32*)data)[sampleIndex] / (float)LWE_SINT_32_MAX * (float)LWE_SINT_16_MAX);
|
||||
return (SInt_16)((float)((SInt_32*)data)[sampleIndex] / (float)EHS_SINT_32_MAX * (float)EHS_SINT_16_MAX);
|
||||
case DataType::SINT_64:
|
||||
return (SInt_16)((float)((SInt_64*)data)[sampleIndex] / (float)LWE_SINT_64_MAX * (float)LWE_SINT_16_MAX);
|
||||
return (SInt_16)((float)((SInt_64*)data)[sampleIndex] / (float)EHS_SINT_64_MAX * (float)EHS_SINT_16_MAX);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -375,15 +375,15 @@ namespace lwe
|
||||
switch (dataType)
|
||||
{
|
||||
case DataType::SINT_8:
|
||||
return (float)((SInt_8*)data)[sampleIndex] / (float)LWE_SINT_8_MAX;
|
||||
return (float)((SInt_8*)data)[sampleIndex] / (float)EHS_SINT_8_MAX;
|
||||
case DataType::SINT_16:
|
||||
return (float)((SInt_16*)data)[sampleIndex] / (float)LWE_SINT_16_MAX;
|
||||
return (float)((SInt_16*)data)[sampleIndex] / (float)EHS_SINT_16_MAX;
|
||||
case DataType::FLOAT:
|
||||
return ((float*)data)[sampleIndex];
|
||||
case DataType::SINT_32:
|
||||
return (float)((SInt_32*)data)[sampleIndex] / (float)LWE_SINT_32_MAX;
|
||||
return (float)((SInt_32*)data)[sampleIndex] / (float)EHS_SINT_32_MAX;
|
||||
case DataType::SINT_64:
|
||||
return (float)((SInt_64*)data)[sampleIndex] / (float)LWE_SINT_64_MAX;
|
||||
return (float)((SInt_64*)data)[sampleIndex] / (float)EHS_SINT_64_MAX;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -394,15 +394,15 @@ namespace lwe
|
||||
switch (dataType)
|
||||
{
|
||||
case DataType::SINT_8:
|
||||
return (SInt_32)((float)((SInt_8*)data)[sampleIndex] / (float)LWE_SINT_8_MAX * (float)LWE_SINT_32_MAX);
|
||||
return (SInt_32)((float)((SInt_8*)data)[sampleIndex] / (float)EHS_SINT_8_MAX * (float)EHS_SINT_32_MAX);
|
||||
case DataType::SINT_16:
|
||||
return (SInt_32)((float)((SInt_16*)data)[sampleIndex] / (float)LWE_SINT_16_MAX * (float)LWE_SINT_32_MAX);
|
||||
return (SInt_32)((float)((SInt_16*)data)[sampleIndex] / (float)EHS_SINT_16_MAX * (float)EHS_SINT_32_MAX);
|
||||
case DataType::FLOAT:
|
||||
return (SInt_32)(((float*)data)[sampleIndex] * (float)LWE_SINT_32_MAX);
|
||||
return (SInt_32)(((float*)data)[sampleIndex] * (float)EHS_SINT_32_MAX);
|
||||
case DataType::SINT_32:
|
||||
return ((SInt_32*)data)[sampleIndex];
|
||||
case DataType::SINT_64:
|
||||
return (SInt_32)((float)((SInt_64*)data)[sampleIndex] / (float)LWE_SINT_64_MAX * (float)LWE_SINT_32_MAX);
|
||||
return (SInt_32)((float)((SInt_64*)data)[sampleIndex] / (float)EHS_SINT_64_MAX * (float)EHS_SINT_32_MAX);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -413,13 +413,13 @@ namespace lwe
|
||||
switch (dataType)
|
||||
{
|
||||
case DataType::SINT_8:
|
||||
return (SInt_64)((float)((SInt_8*)data)[sampleIndex] / (float)LWE_SINT_8_MAX * (float)LWE_SINT_64_MAX);
|
||||
return (SInt_64)((float)((SInt_8*)data)[sampleIndex] / (float)EHS_SINT_8_MAX * (float)EHS_SINT_64_MAX);
|
||||
case DataType::SINT_16:
|
||||
return (SInt_64)((float)((SInt_16*)data)[sampleIndex] / (float)LWE_SINT_16_MAX * (float)LWE_SINT_64_MAX);
|
||||
return (SInt_64)((float)((SInt_16*)data)[sampleIndex] / (float)EHS_SINT_16_MAX * (float)EHS_SINT_64_MAX);
|
||||
case DataType::FLOAT:
|
||||
return (SInt_64)(((float*)data)[sampleIndex] * (float)LWE_SINT_64_MAX);
|
||||
return (SInt_64)(((float*)data)[sampleIndex] * (float)EHS_SINT_64_MAX);
|
||||
case DataType::SINT_32:
|
||||
return (SInt_64)((float)((SInt_32*)data)[sampleIndex] / (float)LWE_SINT_32_MAX * (float)LWE_SINT_64_MAX);
|
||||
return (SInt_64)((float)((SInt_32*)data)[sampleIndex] / (float)EHS_SINT_32_MAX * (float)EHS_SINT_64_MAX);
|
||||
case DataType::SINT_64:
|
||||
return ((SInt_64*)data)[sampleIndex];
|
||||
default:
|
||||
@@ -434,13 +434,13 @@ namespace lwe
|
||||
case DataType::SINT_8:
|
||||
return *(SInt_8*)peak;
|
||||
case DataType::SINT_16:
|
||||
return (SInt_8)((float)*(SInt_16*)peak / (float)LWE_SINT_16_MAX * (float)LWE_SINT_8_MAX);
|
||||
return (SInt_8)((float)*(SInt_16*)peak / (float)EHS_SINT_16_MAX * (float)EHS_SINT_8_MAX);
|
||||
case DataType::FLOAT:
|
||||
return (SInt_8)(*(float*)peak * (float)LWE_SINT_8_MAX);
|
||||
return (SInt_8)(*(float*)peak * (float)EHS_SINT_8_MAX);
|
||||
case DataType::SINT_32:
|
||||
return (SInt_8)((float)*(SInt_32*)peak / (float)LWE_SINT_32_MAX * (float)LWE_SINT_8_MAX);
|
||||
return (SInt_8)((float)*(SInt_32*)peak / (float)EHS_SINT_32_MAX * (float)EHS_SINT_8_MAX);
|
||||
case DataType::SINT_64:
|
||||
return (SInt_8)((float)*(SInt_64*)peak / (float)LWE_SINT_64_MAX * (float)LWE_SINT_8_MAX);
|
||||
return (SInt_8)((float)*(SInt_64*)peak / (float)EHS_SINT_64_MAX * (float)EHS_SINT_8_MAX);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -451,15 +451,15 @@ namespace lwe
|
||||
switch (dataType)
|
||||
{
|
||||
case DataType::SINT_8:
|
||||
return (SInt_16)((float)*(SInt_8*)peak / (float)LWE_SINT_8_MAX * (float)LWE_SINT_16_MAX);
|
||||
return (SInt_16)((float)*(SInt_8*)peak / (float)EHS_SINT_8_MAX * (float)EHS_SINT_16_MAX);
|
||||
case DataType::SINT_16:
|
||||
return *(SInt_16*)peak;
|
||||
case DataType::FLOAT:
|
||||
return (SInt_16)(*(float*)peak * (float)LWE_SINT_16_MAX);
|
||||
return (SInt_16)(*(float*)peak * (float)EHS_SINT_16_MAX);
|
||||
case DataType::SINT_32:
|
||||
return (SInt_16)((float)*(SInt_32*)peak / (float)LWE_SINT_32_MAX * (float)LWE_SINT_16_MAX);
|
||||
return (SInt_16)((float)*(SInt_32*)peak / (float)EHS_SINT_32_MAX * (float)EHS_SINT_16_MAX);
|
||||
case DataType::SINT_64:
|
||||
return (SInt_16)((float)*(SInt_64*)peak / (float)LWE_SINT_64_MAX * (float)LWE_SINT_16_MAX);
|
||||
return (SInt_16)((float)*(SInt_64*)peak / (float)EHS_SINT_64_MAX * (float)EHS_SINT_16_MAX);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -470,15 +470,15 @@ namespace lwe
|
||||
switch (dataType)
|
||||
{
|
||||
case DataType::SINT_8:
|
||||
return (float)*(SInt_8*)peak / (float)LWE_SINT_8_MAX;
|
||||
return (float)*(SInt_8*)peak / (float)EHS_SINT_8_MAX;
|
||||
case DataType::SINT_16:
|
||||
return (float)*(SInt_16*)peak / (float)LWE_SINT_16_MAX;
|
||||
return (float)*(SInt_16*)peak / (float)EHS_SINT_16_MAX;
|
||||
case DataType::FLOAT:
|
||||
return *(float*)peak;
|
||||
case DataType::SINT_32:
|
||||
return (float)*(SInt_32*)peak / (float)LWE_SINT_32_MAX;
|
||||
return (float)*(SInt_32*)peak / (float)EHS_SINT_32_MAX;
|
||||
case DataType::SINT_64:
|
||||
return (float)*(SInt_64*)peak / (float)LWE_SINT_64_MAX;
|
||||
return (float)*(SInt_64*)peak / (float)EHS_SINT_64_MAX;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -489,15 +489,15 @@ namespace lwe
|
||||
switch (dataType)
|
||||
{
|
||||
case DataType::SINT_8:
|
||||
return (SInt_32)((float)*(SInt_8*)peak / (float)LWE_SINT_8_MAX * (float)LWE_SINT_32_MAX);
|
||||
return (SInt_32)((float)*(SInt_8*)peak / (float)EHS_SINT_8_MAX * (float)EHS_SINT_32_MAX);
|
||||
case DataType::SINT_16:
|
||||
return (SInt_32)((float)*(SInt_16*)peak / (float)LWE_SINT_16_MAX * (float)LWE_SINT_32_MAX);
|
||||
return (SInt_32)((float)*(SInt_16*)peak / (float)EHS_SINT_16_MAX * (float)EHS_SINT_32_MAX);
|
||||
case DataType::FLOAT:
|
||||
return (SInt_32)(*(float*)peak * (float)LWE_SINT_32_MAX);
|
||||
return (SInt_32)(*(float*)peak * (float)EHS_SINT_32_MAX);
|
||||
case DataType::SINT_32:
|
||||
return *(SInt_32*)peak;
|
||||
case DataType::SINT_64:
|
||||
return (SInt_32)((float)*(SInt_64*)peak / (float)LWE_SINT_64_MAX * (float)LWE_SINT_32_MAX);
|
||||
return (SInt_32)((float)*(SInt_64*)peak / (float)EHS_SINT_64_MAX * (float)EHS_SINT_32_MAX);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -508,13 +508,13 @@ namespace lwe
|
||||
switch (dataType)
|
||||
{
|
||||
case DataType::SINT_8:
|
||||
return (SInt_64)((float)*(SInt_8*)peak / (float)LWE_SINT_8_MAX * (float)LWE_SINT_64_MAX);
|
||||
return (SInt_64)((float)*(SInt_8*)peak / (float)EHS_SINT_8_MAX * (float)EHS_SINT_64_MAX);
|
||||
case DataType::SINT_16:
|
||||
return (SInt_64)((float)*(SInt_16*)peak / (float)LWE_SINT_16_MAX * (float)LWE_SINT_64_MAX);
|
||||
return (SInt_64)((float)*(SInt_16*)peak / (float)EHS_SINT_16_MAX * (float)EHS_SINT_64_MAX);
|
||||
case DataType::FLOAT:
|
||||
return (SInt_64)(*(float*)peak * (float)LWE_SINT_64_MAX);
|
||||
return (SInt_64)(*(float*)peak * (float)EHS_SINT_64_MAX);
|
||||
case DataType::SINT_32:
|
||||
return (SInt_64)((float)*(SInt_32*)peak / (float)LWE_SINT_32_MAX * (float)LWE_SINT_64_MAX);
|
||||
return (SInt_64)((float)*(SInt_32*)peak / (float)EHS_SINT_32_MAX * (float)EHS_SINT_64_MAX);
|
||||
case DataType::SINT_64:
|
||||
return *(SInt_64*)peak;
|
||||
default:
|
||||
@@ -711,7 +711,7 @@ namespace lwe
|
||||
}
|
||||
else
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Conversion from " + Str_8::FromNum(channels) + " channels, to " +
|
||||
EHS_LOG_INT("Error", 0, "Conversion from " + Str_8::FromNum(channels) + " channels, to " +
|
||||
Str_8::FromNum(newChannels) + " channels is unsupported.");
|
||||
return;
|
||||
}
|
||||
@@ -810,7 +810,7 @@ namespace lwe
|
||||
}
|
||||
else
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Conversion from " + Str_8::FromNum(channels) + " channels, to " +
|
||||
EHS_LOG_INT("Error", 0, "Conversion from " + Str_8::FromNum(channels) + " channels, to " +
|
||||
Str_8::FromNum(newChannels) + " channels is unsupported.");
|
||||
|
||||
return result;
|
||||
@@ -833,7 +833,7 @@ namespace lwe
|
||||
const AudioCodec* codec = GetCodec(ext);
|
||||
if (!codec)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
EHS_LOG_INT("Error", 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -857,7 +857,7 @@ namespace lwe
|
||||
const AudioCodec* codec = GetCodec(ext);
|
||||
if (!codec)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
EHS_LOG_INT("Error", 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -883,7 +883,7 @@ namespace lwe
|
||||
const AudioCodec* codec = GetCodec(ext);
|
||||
if (!codec)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
EHS_LOG_INT("Error", 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -930,7 +930,7 @@ namespace lwe
|
||||
const AudioCodec* codec = GetCodec(ext);
|
||||
if (!codec)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
EHS_LOG_INT("Error", 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1770,160 +1770,160 @@ namespace lwe
|
||||
void Audio::SInt_16_to_SInt_8(Byte* newData, Byte* newPeak) const
|
||||
{
|
||||
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
||||
newData[a] = (Byte)((float)((SInt_16*)data)[a] / (float)LWE_SINT_16_MAX * (float)LWE_SINT_8_MAX);
|
||||
newData[a] = (Byte)((float)((SInt_16*)data)[a] / (float)EHS_SINT_16_MAX * (float)EHS_SINT_8_MAX);
|
||||
|
||||
*(SInt_8*)newPeak = (SInt_8)((float)*(SInt_16*)peak / (float)LWE_SINT_16_MAX * (float)LWE_SINT_8_MAX);
|
||||
*(SInt_8*)newPeak = (SInt_8)((float)*(SInt_16*)peak / (float)EHS_SINT_16_MAX * (float)EHS_SINT_8_MAX);
|
||||
}
|
||||
|
||||
void Audio::Float_to_SInt_8(Byte* newData, Byte* newPeak) const
|
||||
{
|
||||
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
||||
((SInt_8*)newData)[a] = (SInt_8)(((float*)data)[a] * (float)LWE_SINT_8_MAX);
|
||||
((SInt_8*)newData)[a] = (SInt_8)(((float*)data)[a] * (float)EHS_SINT_8_MAX);
|
||||
|
||||
*(SInt_8*)newPeak = (SInt_8)(*(float*)peak * (float)LWE_SINT_8_MAX);
|
||||
*(SInt_8*)newPeak = (SInt_8)(*(float*)peak * (float)EHS_SINT_8_MAX);
|
||||
}
|
||||
|
||||
void Audio::SInt_32_to_SInt_8(Byte* newData, Byte* newPeak) const
|
||||
{
|
||||
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
||||
newData[a] = (Byte)((float)((SInt_32*)data)[a] / (float)LWE_SINT_32_MAX * (float)LWE_SINT_8_MAX);
|
||||
newData[a] = (Byte)((float)((SInt_32*)data)[a] / (float)EHS_SINT_32_MAX * (float)EHS_SINT_8_MAX);
|
||||
|
||||
*(SInt_8*)newPeak = (SInt_8)((float)*(SInt_32*)peak / (float)LWE_SINT_32_MAX * (float)LWE_SINT_8_MAX);
|
||||
*(SInt_8*)newPeak = (SInt_8)((float)*(SInt_32*)peak / (float)EHS_SINT_32_MAX * (float)EHS_SINT_8_MAX);
|
||||
}
|
||||
|
||||
void Audio::SInt_64_to_SInt_8(Byte* newData, Byte* newPeak) const
|
||||
{
|
||||
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
||||
newData[a] = (Byte)((float)((SInt_64*)data)[a] / (float)LWE_SINT_64_MAX * (float)LWE_SINT_8_MAX);
|
||||
newData[a] = (Byte)((float)((SInt_64*)data)[a] / (float)EHS_SINT_64_MAX * (float)EHS_SINT_8_MAX);
|
||||
|
||||
*(SInt_8*)newPeak = (SInt_8)((float)*(SInt_64*)peak / (float)LWE_SINT_64_MAX * (float)LWE_SINT_8_MAX);
|
||||
*(SInt_8*)newPeak = (SInt_8)((float)*(SInt_64*)peak / (float)EHS_SINT_64_MAX * (float)EHS_SINT_8_MAX);
|
||||
}
|
||||
|
||||
void Audio::SInt_8_to_SInt_16(Byte* newData, Byte* newPeak) const
|
||||
{
|
||||
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
||||
((SInt_16*)newData)[a] = (SInt_16)((float)(SInt_8)data[a] / (float)LWE_SINT_8_MAX * (float)LWE_SINT_16_MAX);
|
||||
((SInt_16*)newData)[a] = (SInt_16)((float)(SInt_8)data[a] / (float)EHS_SINT_8_MAX * (float)EHS_SINT_16_MAX);
|
||||
|
||||
*(SInt_16*)newPeak = (SInt_16)((float)*(SInt_8*)peak / (float)LWE_SINT_8_MAX * (float)LWE_SINT_16_MAX);
|
||||
*(SInt_16*)newPeak = (SInt_16)((float)*(SInt_8*)peak / (float)EHS_SINT_8_MAX * (float)EHS_SINT_16_MAX);
|
||||
}
|
||||
|
||||
void Audio::Float_to_SInt_16(Byte* newData, Byte* newPeak) const
|
||||
{
|
||||
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
||||
((SInt_16*)newData)[a] = (SInt_16)(((float*)data)[a] * (float)LWE_SINT_16_MAX);
|
||||
((SInt_16*)newData)[a] = (SInt_16)(((float*)data)[a] * (float)EHS_SINT_16_MAX);
|
||||
|
||||
*(SInt_16*)newPeak = (SInt_16)(*(float*)peak * (float)LWE_SINT_16_MAX);
|
||||
*(SInt_16*)newPeak = (SInt_16)(*(float*)peak * (float)EHS_SINT_16_MAX);
|
||||
}
|
||||
|
||||
void Audio::SInt_32_to_SInt_16(Byte* newData, Byte* newPeak) const
|
||||
{
|
||||
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
||||
((SInt_16*)newData)[a] = (SInt_16)((float)((SInt_32*)data)[a] / (float)LWE_SINT_32_MAX * (float)LWE_SINT_16_MAX);
|
||||
((SInt_16*)newData)[a] = (SInt_16)((float)((SInt_32*)data)[a] / (float)EHS_SINT_32_MAX * (float)EHS_SINT_16_MAX);
|
||||
|
||||
*(SInt_16*)newPeak = (SInt_16)((float)*(SInt_32*)peak / (float)LWE_SINT_32_MAX * (float)LWE_SINT_16_MAX);
|
||||
*(SInt_16*)newPeak = (SInt_16)((float)*(SInt_32*)peak / (float)EHS_SINT_32_MAX * (float)EHS_SINT_16_MAX);
|
||||
}
|
||||
|
||||
void Audio::SInt_64_to_SInt_16(Byte* newData, Byte* newPeak) const
|
||||
{
|
||||
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
||||
((SInt_16*)newData)[a] = (SInt_16)((float)((SInt_64*)data)[a] / (float)LWE_SINT_64_MAX * (float)LWE_SINT_16_MAX);
|
||||
((SInt_16*)newData)[a] = (SInt_16)((float)((SInt_64*)data)[a] / (float)EHS_SINT_64_MAX * (float)EHS_SINT_16_MAX);
|
||||
|
||||
*(SInt_16*)newPeak = (SInt_16)((float)*(SInt_64*)peak / (float)LWE_SINT_64_MAX * (float)LWE_SINT_16_MAX);
|
||||
*(SInt_16*)newPeak = (SInt_16)((float)*(SInt_64*)peak / (float)EHS_SINT_64_MAX * (float)EHS_SINT_16_MAX);
|
||||
}
|
||||
|
||||
void Audio::SInt_8_to_Float(Byte* newData, Byte* newPeak) const
|
||||
{
|
||||
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
||||
((float*)newData)[a] = (float)(((SInt_8*)data)[a]) / (float)LWE_SINT_8_MAX;
|
||||
((float*)newData)[a] = (float)(((SInt_8*)data)[a]) / (float)EHS_SINT_8_MAX;
|
||||
|
||||
*(float*)newPeak = (float)*(SInt_8*)peak / (float)LWE_SINT_8_MAX;
|
||||
*(float*)newPeak = (float)*(SInt_8*)peak / (float)EHS_SINT_8_MAX;
|
||||
}
|
||||
|
||||
void Audio::SInt_16_to_Float(Byte* newData, Byte* newPeak) const
|
||||
{
|
||||
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
||||
((float*)newData)[a] = (float)(((SInt_16*)data)[a]) / (float)LWE_SINT_16_MAX;
|
||||
((float*)newData)[a] = (float)(((SInt_16*)data)[a]) / (float)EHS_SINT_16_MAX;
|
||||
|
||||
*(float*)newPeak = (float)*(SInt_16*)peak / (float)LWE_SINT_16_MAX;
|
||||
*(float*)newPeak = (float)*(SInt_16*)peak / (float)EHS_SINT_16_MAX;
|
||||
}
|
||||
|
||||
void Audio::SInt_32_to_Float(Byte* newData, Byte* newPeak) const
|
||||
{
|
||||
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
||||
((float*)newData)[a] = (float)(((SInt_32*)data)[a]) / (float)LWE_SINT_32_MAX;
|
||||
((float*)newData)[a] = (float)(((SInt_32*)data)[a]) / (float)EHS_SINT_32_MAX;
|
||||
|
||||
*(float*)newPeak = (float)*(SInt_32*)peak / (float)LWE_SINT_32_MAX;
|
||||
*(float*)newPeak = (float)*(SInt_32*)peak / (float)EHS_SINT_32_MAX;
|
||||
}
|
||||
|
||||
void Audio::SInt_64_to_Float(Byte* newData, Byte* newPeak) const
|
||||
{
|
||||
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
||||
((float*)newData)[a] = (float)(((SInt_64*)data)[a]) / (float)LWE_SINT_64_MAX;
|
||||
((float*)newData)[a] = (float)(((SInt_64*)data)[a]) / (float)EHS_SINT_64_MAX;
|
||||
|
||||
*(float*)newPeak = (float)*(SInt_64*)peak / (float)LWE_SINT_64_MAX;
|
||||
*(float*)newPeak = (float)*(SInt_64*)peak / (float)EHS_SINT_64_MAX;
|
||||
}
|
||||
|
||||
void Audio::SInt_8_to_SInt_32(Byte* newData, Byte* newPeak) const
|
||||
{
|
||||
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
||||
((SInt_32*)newData)[a] = (SInt_32)((float)(SInt_8)data[a] / (float)LWE_SINT_8_MAX * (float)LWE_SINT_32_MAX);
|
||||
((SInt_32*)newData)[a] = (SInt_32)((float)(SInt_8)data[a] / (float)EHS_SINT_8_MAX * (float)EHS_SINT_32_MAX);
|
||||
|
||||
*(SInt_32*)newPeak = (SInt_32)((float)*(SInt_8*)peak / (float)LWE_SINT_8_MAX * (float)LWE_SINT_32_MAX);
|
||||
*(SInt_32*)newPeak = (SInt_32)((float)*(SInt_8*)peak / (float)EHS_SINT_8_MAX * (float)EHS_SINT_32_MAX);
|
||||
}
|
||||
|
||||
void Audio::SInt_16_to_SInt_32(Byte* newData, Byte* newPeak) const
|
||||
{
|
||||
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
||||
((SInt_32*)newData)[a] = (SInt_32)((float)((SInt_16*)data)[a] / (float)LWE_SINT_16_MAX * (float)LWE_SINT_32_MAX);
|
||||
((SInt_32*)newData)[a] = (SInt_32)((float)((SInt_16*)data)[a] / (float)EHS_SINT_16_MAX * (float)EHS_SINT_32_MAX);
|
||||
|
||||
*(SInt_32*)newPeak = (SInt_32)((float)*(SInt_16*)peak / (float)LWE_SINT_16_MAX * (float)LWE_SINT_32_MAX);
|
||||
*(SInt_32*)newPeak = (SInt_32)((float)*(SInt_16*)peak / (float)EHS_SINT_16_MAX * (float)EHS_SINT_32_MAX);
|
||||
}
|
||||
|
||||
void Audio::Float_to_SInt_32(Byte* newData, Byte* newPeak) const
|
||||
{
|
||||
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
||||
((SInt_32*)newData)[a] = (SInt_32)(((float*)data)[a] * (float)LWE_SINT_32_MAX);
|
||||
((SInt_32*)newData)[a] = (SInt_32)(((float*)data)[a] * (float)EHS_SINT_32_MAX);
|
||||
|
||||
*(SInt_32*)newPeak = (SInt_32)(*(float*)peak * (float)LWE_SINT_32_MAX);
|
||||
*(SInt_32*)newPeak = (SInt_32)(*(float*)peak * (float)EHS_SINT_32_MAX);
|
||||
}
|
||||
|
||||
void Audio::SInt_64_to_SInt_32(Byte* newData, Byte* newPeak) const
|
||||
{
|
||||
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
||||
((SInt_32*)newData)[a] = (SInt_32)((float)((SInt_64*)data)[a] / (float)LWE_SINT_64_MAX * (float)LWE_SINT_32_MAX);
|
||||
((SInt_32*)newData)[a] = (SInt_32)((float)((SInt_64*)data)[a] / (float)EHS_SINT_64_MAX * (float)EHS_SINT_32_MAX);
|
||||
|
||||
*(SInt_32*)newPeak = (SInt_32)((float)*(SInt_64*)peak / (float)LWE_SINT_64_MAX * (float)LWE_SINT_32_MAX);
|
||||
*(SInt_32*)newPeak = (SInt_32)((float)*(SInt_64*)peak / (float)EHS_SINT_64_MAX * (float)EHS_SINT_32_MAX);
|
||||
}
|
||||
|
||||
void Audio::SInt_8_to_SInt_64(Byte* newData, Byte* newPeak) const
|
||||
{
|
||||
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
||||
((SInt_64*)newData)[a] = (SInt_64)((float)(SInt_8)data[a] / (float)LWE_SINT_8_MAX * (float)LWE_SINT_64_MAX);
|
||||
((SInt_64*)newData)[a] = (SInt_64)((float)(SInt_8)data[a] / (float)EHS_SINT_8_MAX * (float)EHS_SINT_64_MAX);
|
||||
|
||||
*(SInt_64*)newPeak = (SInt_64)((float)*(SInt_8*)peak / (float)LWE_SINT_8_MAX * (float)LWE_SINT_64_MAX);
|
||||
*(SInt_64*)newPeak = (SInt_64)((float)*(SInt_8*)peak / (float)EHS_SINT_8_MAX * (float)EHS_SINT_64_MAX);
|
||||
}
|
||||
|
||||
void Audio::SInt_16_to_SInt_64(Byte* newData, Byte* newPeak) const
|
||||
{
|
||||
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
||||
((SInt_64*)newData)[a] = (SInt_64)((float)((SInt_16*)data)[a] / (float)LWE_SINT_16_MAX * (float)LWE_SINT_64_MAX);
|
||||
((SInt_64*)newData)[a] = (SInt_64)((float)((SInt_16*)data)[a] / (float)EHS_SINT_16_MAX * (float)EHS_SINT_64_MAX);
|
||||
|
||||
*(SInt_64*)newPeak = (SInt_64)((float)*(SInt_16*)peak / (float)LWE_SINT_16_MAX * (float)LWE_SINT_64_MAX);
|
||||
*(SInt_64*)newPeak = (SInt_64)((float)*(SInt_16*)peak / (float)EHS_SINT_16_MAX * (float)EHS_SINT_64_MAX);
|
||||
}
|
||||
|
||||
void Audio::Float_to_SInt_64(Byte* newData, Byte* newPeak) const
|
||||
{
|
||||
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
||||
((SInt_64*)newData)[a] = (SInt_64)(((float*)data)[a] * (float)LWE_SINT_64_MAX);
|
||||
((SInt_64*)newData)[a] = (SInt_64)(((float*)data)[a] * (float)EHS_SINT_64_MAX);
|
||||
|
||||
*(SInt_64*)newPeak = (SInt_64)(*(float*)peak * (float)LWE_SINT_64_MAX);
|
||||
*(SInt_64*)newPeak = (SInt_64)(*(float*)peak * (float)EHS_SINT_64_MAX);
|
||||
}
|
||||
|
||||
void Audio::SInt_32_to_SInt_64(Byte* newData, Byte* newPeak) const
|
||||
{
|
||||
for (UInt_64 a = 0; a < GetSampleCount(); ++a)
|
||||
((SInt_64*)newData)[a] = (SInt_64)((float)((SInt_32*)data)[a] / (float)LWE_SINT_32_MAX * (float)LWE_SINT_64_MAX);
|
||||
((SInt_64*)newData)[a] = (SInt_64)((float)((SInt_32*)data)[a] / (float)EHS_SINT_32_MAX * (float)EHS_SINT_64_MAX);
|
||||
|
||||
*(SInt_64*)newPeak = (SInt_64)((float)*(SInt_32*)peak / (float)LWE_SINT_32_MAX * (float)LWE_SINT_64_MAX);
|
||||
*(SInt_64*)newPeak = (SInt_64)((float)*(SInt_32*)peak / (float)EHS_SINT_32_MAX * (float)EHS_SINT_64_MAX);
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
#include "IO/Audio/AudioCodec.h"
|
||||
#include "io/audio/AudioCodec.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
AudioCodec::AudioCodec()
|
||||
: hashExt(0), endianness(Endianness::LE), encodeCb(nullptr), decodeCb(nullptr)
|
||||
@@ -89,7 +89,7 @@ namespace lwe
|
||||
{
|
||||
if (!encodeCb)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Encoding is not supported for the " + id + " format.");
|
||||
EHS_LOG_INT("Error", 0, "Encoding is not supported for the " + id + " format.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace lwe
|
||||
{
|
||||
if (!decodeCb)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Decoding is not supported for the " + id + " format.");
|
||||
EHS_LOG_INT("Error", 0, "Decoding is not supported for the " + id + " format.");
|
||||
return false;
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
#include "IO/Audio/AudioDevice_ALSA.h"
|
||||
#include "io/audio/AudioDevice_ALSA.h"
|
||||
#include "EHS.h"
|
||||
#include "Log.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
AudioDevice::~AudioDevice()
|
||||
{
|
||||
@@ -77,7 +77,7 @@ namespace lwe
|
||||
|
||||
if (snd_pcm_hw_params_set_access(hdl, params, SND_PCM_ACCESS_MMAP_INTERLEAVED) < 0)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to set access.");
|
||||
EHS_LOG_INT("Error", 0, "Failed to set access.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace lwe
|
||||
}
|
||||
default:
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Invalid data type.");
|
||||
EHS_LOG_INT("Error", 0, "Invalid data type.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -125,7 +125,7 @@ namespace lwe
|
||||
{
|
||||
if (snd_pcm_hw_params_set_channels_near(hdl, params, &channels) < 0)
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "Failed to set channels.");
|
||||
EHS_LOG_INT("Error", 1, "Failed to set channels.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -134,26 +134,26 @@ namespace lwe
|
||||
{
|
||||
if (snd_pcm_hw_params_set_rate_near(hdl, params, &sampleRate, nullptr) < 0)
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Failed to set sample rate.");
|
||||
EHS_LOG_INT("Error", 2, "Failed to set sample rate.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (snd_pcm_hw_params_set_period_time_near(hdl, params, &period, nullptr) < 0)
|
||||
{
|
||||
LWE_LOG_INT("Error", 3, "Failed to set period.");
|
||||
EHS_LOG_INT("Error", 3, "Failed to set period.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (snd_pcm_hw_params_set_buffer_time_near(hdl, params, &latency, nullptr) < 0)
|
||||
{
|
||||
LWE_LOG_INT("Error", 4, "Failed to set latency.");
|
||||
EHS_LOG_INT("Error", 4, "Failed to set latency.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (snd_pcm_hw_params(hdl, params) < 0)
|
||||
{
|
||||
LWE_LOG_INT("Error", 5, "Failed to apply hardware parameters.");
|
||||
EHS_LOG_INT("Error", 5, "Failed to apply hardware parameters.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ namespace lwe
|
||||
snd_pcm_format_t format;
|
||||
if (snd_pcm_hw_params_get_format(params, &format) < 0)
|
||||
{
|
||||
LWE_LOG_INT("Error", 6, "Failed to retrieve audio device properties.");
|
||||
EHS_LOG_INT("Error", 6, "Failed to retrieve audio device properties.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ namespace lwe
|
||||
}
|
||||
default:
|
||||
{
|
||||
LWE_LOG_INT("Error", 7, "Format unsupported.");
|
||||
EHS_LOG_INT("Error", 7, "Format unsupported.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -210,7 +210,7 @@ namespace lwe
|
||||
{
|
||||
if (snd_pcm_hw_params_get_channels(params, &channels) < 0)
|
||||
{
|
||||
LWE_LOG_INT("Error", 8, "Failed to retrieve channel count.");
|
||||
EHS_LOG_INT("Error", 8, "Failed to retrieve channel count.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -220,14 +220,14 @@ namespace lwe
|
||||
int dir;
|
||||
if (snd_pcm_hw_params_get_rate(params, &sampleRate, &dir) < 0)
|
||||
{
|
||||
LWE_LOG_INT("Error", 9, "Failed to retrieve sample rate.");
|
||||
EHS_LOG_INT("Error", 9, "Failed to retrieve sample rate.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (snd_pcm_hw_params_get_buffer_size(params, &maxFrames) < 0)
|
||||
{
|
||||
LWE_LOG_INT("Error", 10, "Failed to retrieve buffer size.");
|
||||
EHS_LOG_INT("Error", 10, "Failed to retrieve buffer size.");
|
||||
}
|
||||
|
||||
snd_pcm_sw_params_t* swParams = nullptr;
|
||||
@@ -235,31 +235,31 @@ namespace lwe
|
||||
|
||||
if (snd_pcm_sw_params_current(hdl, swParams) < 0)
|
||||
{
|
||||
LWE_LOG_INT("Error", 11, "Failed to retrieve software parameters.");
|
||||
EHS_LOG_INT("Error", 11, "Failed to retrieve software parameters.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (snd_pcm_sw_params_set_silence_threshold(hdl, swParams, maxFrames) < 0)
|
||||
{
|
||||
LWE_LOG_INT("Error", 12, "Failed to set silence threshold.");
|
||||
EHS_LOG_INT("Error", 12, "Failed to set silence threshold.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (snd_pcm_sw_params_set_silence_size(hdl, swParams, maxFrames) < 0)
|
||||
{
|
||||
LWE_LOG_INT("Error", 12, "Failed to set silence size.");
|
||||
EHS_LOG_INT("Error", 12, "Failed to set silence size.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (snd_pcm_sw_params(hdl, swParams) < 0)
|
||||
{
|
||||
LWE_LOG_INT("Error", 13, "Failed to set software parameters.");
|
||||
EHS_LOG_INT("Error", 13, "Failed to set software parameters.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (snd_pcm_prepare(hdl) < 0)
|
||||
{
|
||||
LWE_LOG_INT("Error", 14, "Failed to prepare audio stream.");
|
||||
EHS_LOG_INT("Error", 14, "Failed to prepare audio stream.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -281,10 +281,10 @@ namespace lwe
|
||||
snd_pcm_state_t state = snd_pcm_state(hdl);
|
||||
if (state == SND_PCM_STATE_XRUN)
|
||||
{
|
||||
LWE_LOG_INT("Warning", 0, "Buffer overrun/underrun occurred.");
|
||||
EHS_LOG_INT("Warning", 0, "Buffer overrun/underrun occurred.");
|
||||
if (snd_pcm_recover(hdl, -EPIPE, 0) < 0)
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "Failed to recover from buffer overrun/underrun.");
|
||||
EHS_LOG_INT("Error", 1, "Failed to recover from buffer overrun/underrun.");
|
||||
return 0;
|
||||
}
|
||||
return GetAvailFrames();
|
||||
@@ -293,7 +293,7 @@ namespace lwe
|
||||
{
|
||||
if (snd_pcm_start(hdl) < 0)
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Failed to start audio stream.");
|
||||
EHS_LOG_INT("Error", 2, "Failed to start audio stream.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -305,10 +305,10 @@ namespace lwe
|
||||
{
|
||||
if (frames == -EPIPE)
|
||||
{
|
||||
LWE_LOG_INT("Warning", 3, "Buffer overrun/underrun occurred.");
|
||||
EHS_LOG_INT("Warning", 3, "Buffer overrun/underrun occurred.");
|
||||
if (snd_pcm_recover(hdl, -EPIPE, 1) < 0)
|
||||
{
|
||||
LWE_LOG_INT("Error", 4, "Failed to recover from buffer overrun/underrun.");
|
||||
EHS_LOG_INT("Error", 4, "Failed to recover from buffer overrun/underrun.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -316,7 +316,7 @@ namespace lwe
|
||||
}
|
||||
else
|
||||
{
|
||||
LWE_LOG_INT("Error", 5, "Failed to retrieve available frames with error #" + Str_8::FromNum(frames) + ".");
|
||||
EHS_LOG_INT("Error", 5, "Failed to retrieve available frames with error #" + Str_8::FromNum(frames) + ".");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -329,7 +329,7 @@ namespace lwe
|
||||
const snd_pcm_channel_area_t* areas;
|
||||
if (snd_pcm_mmap_begin(hdl, &areas, offset, frames) < 0)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to map audio buffer.");
|
||||
EHS_LOG_INT("Error", 0, "Failed to map audio buffer.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -341,7 +341,7 @@ namespace lwe
|
||||
snd_pcm_sframes_t committed = snd_pcm_mmap_commit(hdl, offset, frames);
|
||||
if (committed < 0)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to commit mapped audio buffer.");
|
||||
EHS_LOG_INT("Error", 0, "Failed to commit mapped audio buffer.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -366,7 +366,7 @@ namespace lwe
|
||||
}
|
||||
else
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Wrong value for the audio device type.");
|
||||
EHS_LOG_INT("Error", 0, "Wrong value for the audio device type.");
|
||||
return {};
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#include "IO/Audio/AudioDevice_W32.h"
|
||||
#include "io/audio/AudioDevice_W32.h"
|
||||
#include "Log.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
AudioDevice::~AudioDevice()
|
||||
{
|
||||
@@ -87,7 +87,7 @@ namespace lwe
|
||||
HRESULT r = client->Stop();
|
||||
if (FAILED(r))
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to stop audio with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to stop audio with error #" + Str_8::FromNum(r) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace lwe
|
||||
|
||||
HRESULT r = hdl->Activate(__uuidof(IAudioClient), CLSCTX_ALL, nullptr, (void**)&client);
|
||||
if (FAILED(r))
|
||||
LWE_LOG_INT("Error", 0, "Failed to create audio client with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to create audio client with error #" + Str_8::FromNum(r) + ".");
|
||||
|
||||
WAVEFORMATEXTENSIBLE* format;
|
||||
client->GetMixFormat((WAVEFORMATEX**)&format);
|
||||
@@ -146,7 +146,7 @@ namespace lwe
|
||||
{
|
||||
if (r == AUDCLNT_E_UNSUPPORTED_FORMAT)
|
||||
{
|
||||
LWE_LOG_INT("Error", 1,
|
||||
EHS_LOG_INT("Error", 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 lwe
|
||||
);
|
||||
}
|
||||
else
|
||||
LWE_LOG_INT("Error", 2, "Failed to retrieve supported audio format with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to retrieve supported audio format with error #" + Str_8::FromNum(r) + ".");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (match)
|
||||
{
|
||||
LWE_LOG_INT("Error", 3,
|
||||
EHS_LOG_INT("Error", 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 lwe
|
||||
|
||||
if (r == AUDCLNT_E_ALREADY_INITIALIZED)
|
||||
{
|
||||
LWE_LOG_INT("Error", 5, "Audio client is already initialized.");
|
||||
EHS_LOG_INT("Error", 5, "Audio client is already initialized.");
|
||||
return;
|
||||
}
|
||||
else if (r == AUDCLNT_E_WRONG_ENDPOINT_TYPE)
|
||||
{
|
||||
LWE_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("Error", 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)
|
||||
{
|
||||
LWE_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("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.");
|
||||
return;
|
||||
}
|
||||
else if (r == AUDCLNT_E_CPUUSAGE_EXCEEDED)
|
||||
{
|
||||
LWE_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("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.");
|
||||
return;
|
||||
}
|
||||
else if (r == AUDCLNT_E_DEVICE_IN_USE)
|
||||
{
|
||||
LWE_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("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.");
|
||||
return;
|
||||
}
|
||||
else if (r == AUDCLNT_E_ENDPOINT_CREATE_FAILED)
|
||||
{
|
||||
LWE_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("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.");
|
||||
return;
|
||||
}
|
||||
else if (r == AUDCLNT_E_INVALID_DEVICE_PERIOD)
|
||||
{
|
||||
LWE_LOG_INT("Error", 11, "Indicates that the device period requested by an exclusive-mode client is greater than 5000 milliseconds.");
|
||||
EHS_LOG_INT("Error", 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)
|
||||
{
|
||||
LWE_LOG_INT("Error", 12, "The audio engine (shared mode) or audio endpoint device (exclusive mode) does not support the specified format.");
|
||||
EHS_LOG_INT("Error", 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)
|
||||
{
|
||||
LWE_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("Error", 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)
|
||||
{
|
||||
LWE_LOG_INT("Error", 14, "The AUDCLNT_STREAMFLAGS_EVENTCALLBACK flag is set but parameters hnsBufferDuration and hnsPeriodicity are not equal.");
|
||||
EHS_LOG_INT("Error", 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)
|
||||
{
|
||||
LWE_LOG_INT("Error", 15, "The Windows audio service is not running.");
|
||||
EHS_LOG_INT("Error", 15, "The Windows audio service is not running.");
|
||||
return;
|
||||
}
|
||||
else if (r == E_POINTER)
|
||||
{
|
||||
LWE_LOG_INT("Error", 16, "Parameter pFormat is NULL.");
|
||||
EHS_LOG_INT("Error", 16, "Parameter pFormat is NULL.");
|
||||
return;
|
||||
}
|
||||
else if (r == E_INVALIDARG)
|
||||
{
|
||||
LWE_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("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"
|
||||
"A prior call to SetClientProperties was made with an invalid category for audio/render streams.");
|
||||
return;
|
||||
}
|
||||
else if (r == E_OUTOFMEMORY)
|
||||
{
|
||||
LWE_LOG_INT("Error", 18, "Out of memory.");
|
||||
EHS_LOG_INT("Error", 18, "Out of memory.");
|
||||
return;
|
||||
}
|
||||
else if (FAILED(r))
|
||||
{
|
||||
LWE_LOG_INT("Error", 19, "Failed to initialize audio stream with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT("Error", 19, "Failed to initialize audio stream with error #" + Str_8::FromNum(r) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ namespace lwe
|
||||
r = client->GetService(__uuidof(IAudioRenderClient), (void**)&playbackClient);
|
||||
if (FAILED(r))
|
||||
{
|
||||
LWE_LOG_INT("Error", 27, "Failed to retrieve audio render client with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT("Error", 27, "Failed to retrieve audio render client with error #" + Str_8::FromNum(r) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -274,7 +274,7 @@ namespace lwe
|
||||
r = client->GetService(__uuidof(IAudioCaptureClient), (void**)&captureClient);
|
||||
if (FAILED(r))
|
||||
{
|
||||
LWE_LOG_INT("Error", 28, "Failed to retrieve audio capture client with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT("Error", 28, "Failed to retrieve audio capture client with error #" + Str_8::FromNum(r) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -282,14 +282,14 @@ namespace lwe
|
||||
r = client->GetBufferSize((UINT32*)&maxFrames);
|
||||
if (FAILED(r))
|
||||
{
|
||||
LWE_LOG_INT("Error", 29, "Failed to retrieve buffer size with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT("Error", 29, "Failed to retrieve buffer size with error #" + Str_8::FromNum(r) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
r = client->Start();
|
||||
if (FAILED(r))
|
||||
{
|
||||
LWE_LOG_INT("Error", 30, "Failed to start audio with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT("Error", 30, "Failed to start audio with error #" + Str_8::FromNum(r) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -318,7 +318,7 @@ namespace lwe
|
||||
HRESULT r = client->Stop();
|
||||
if (FAILED(r))
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to stop audio with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to stop audio with error #" + Str_8::FromNum(r) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -340,9 +340,9 @@ namespace lwe
|
||||
{
|
||||
HRESULT r = client->GetCurrentPadding(&sampleSize);
|
||||
if (r == AUDCLNT_E_DEVICE_INVALIDATED)
|
||||
LWE_LOG_INT("Error", 0, "The audio device has been invalidated.");
|
||||
EHS_LOG_INT("Error", 0, "The audio device has been invalidated.");
|
||||
else if (FAILED(r))
|
||||
LWE_LOG_INT("Error", 1, "Failed to retrieve samples padding with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to retrieve samples padding with error #" + Str_8::FromNum(r) + ".");
|
||||
|
||||
sampleSize = maxFrames - sampleSize;
|
||||
}
|
||||
@@ -350,9 +350,9 @@ namespace lwe
|
||||
{
|
||||
HRESULT r = captureClient->GetNextPacketSize(&sampleSize);
|
||||
if (r == AUDCLNT_E_DEVICE_INVALIDATED)
|
||||
LWE_LOG_INT("Error", 0, "The audio device has been invalidated.");
|
||||
EHS_LOG_INT("Error", 0, "The audio device has been invalidated.");
|
||||
else if (FAILED(r))
|
||||
LWE_LOG_INT("Error", 1, "Failed to retrieve samples size with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to retrieve samples size with error #" + Str_8::FromNum(r) + ".");
|
||||
}
|
||||
|
||||
return sampleSize;
|
||||
@@ -367,19 +367,19 @@ namespace lwe
|
||||
|
||||
HRESULT r = client->GetCurrentPadding((UINT32*)&offset);
|
||||
if (r == AUDCLNT_E_DEVICE_INVALIDATED)
|
||||
LWE_LOG_INT("Error", 0, "The audio device has been invalidated.");
|
||||
EHS_LOG_INT("Error", 0, "The audio device has been invalidated.");
|
||||
else if (FAILED(r))
|
||||
LWE_LOG_INT("Error", 1, "Failed to retrieve samples padding with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT("Error", 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)
|
||||
LWE_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("Error", 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)
|
||||
LWE_LOG_INT("Error", 1, "The audio device has been invalidated.");
|
||||
EHS_LOG_INT("Error", 1, "The audio device has been invalidated.");
|
||||
else if (FAILED(r))
|
||||
LWE_LOG_INT("Error", 2, "Failed to retrieve buffer with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to retrieve buffer with error #" + Str_8::FromNum(r) + ".");
|
||||
}
|
||||
else if (captureClient)
|
||||
{
|
||||
@@ -387,9 +387,9 @@ namespace lwe
|
||||
|
||||
r = captureClient->GetBuffer(&buffer, (UINT32*)frames, (DWORD*)&flags, nullptr, nullptr);
|
||||
if (r == AUDCLNT_E_DEVICE_INVALIDATED)
|
||||
LWE_LOG_INT("Error", 1, "The audio device has been invalidated.");
|
||||
EHS_LOG_INT("Error", 1, "The audio device has been invalidated.");
|
||||
else if (FAILED(r))
|
||||
LWE_LOG_INT("Error", 2, "Failed to retrieve buffer with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to retrieve buffer with error #" + Str_8::FromNum(r) + ".");
|
||||
}
|
||||
|
||||
return buffer;
|
||||
@@ -404,17 +404,17 @@ namespace lwe
|
||||
{
|
||||
HRESULT r = playbackClient->ReleaseBuffer(frames, 0);
|
||||
if (r == AUDCLNT_E_DEVICE_INVALIDATED)
|
||||
LWE_LOG_INT("Error", 0, "The audio device has been invalidated.");
|
||||
EHS_LOG_INT("Error", 0, "The audio device has been invalidated.");
|
||||
else if (FAILED(r))
|
||||
LWE_LOG_INT("Error", 1, "Failed to release buffer with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT("Error", 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)
|
||||
LWE_LOG_INT("Error", 0, "The audio device has been invalidated.");
|
||||
EHS_LOG_INT("Error", 0, "The audio device has been invalidated.");
|
||||
else if (FAILED(r))
|
||||
LWE_LOG_INT("Error", 1, "Failed to release buffer with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to release buffer with error #" + Str_8::FromNum(r) + ".");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -429,7 +429,7 @@ namespace lwe
|
||||
HRESULT r = hdl->OpenPropertyStore(STGM_READ, &pProps);
|
||||
if (FAILED(r))
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to retrieve interface name with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve interface name with error #" + Str_8::FromNum(r) + ".");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -462,7 +462,7 @@ namespace lwe
|
||||
HRESULT r = hdl->OpenPropertyStore(STGM_READ, &pProps);
|
||||
if (FAILED(r))
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to retrieve name with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve name with error #" + Str_8::FromNum(r) + ".");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -496,7 +496,7 @@ namespace lwe
|
||||
HRESULT r = CoInitialize(nullptr);
|
||||
if (FAILED(r))
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to initialize COM with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to initialize COM with error #" + Str_8::FromNum(r) + ".");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -504,7 +504,7 @@ namespace lwe
|
||||
r = CoCreateInstance(__uuidof(MMDeviceEnumerator), nullptr, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void**)&enumerator);
|
||||
if (FAILED(r))
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "Failed to initialize WASAPI with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to initialize WASAPI with error #" + Str_8::FromNum(r) + ".");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -512,7 +512,7 @@ namespace lwe
|
||||
r = enumerator->GetDefaultAudioEndpoint((EDataFlow)type, eConsole, &deviceHdl);
|
||||
if (FAILED(r))
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Failed to retrieve default audio output device with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to retrieve default audio output device with error #" + Str_8::FromNum(r) + ".");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -531,7 +531,7 @@ namespace lwe
|
||||
HRESULT r = CoInitialize(nullptr);
|
||||
if (FAILED(r))
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to initialize COM with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to initialize COM with error #" + Str_8::FromNum(r) + ".");
|
||||
return devices;
|
||||
}
|
||||
|
||||
@@ -539,7 +539,7 @@ namespace lwe
|
||||
r = CoCreateInstance(__uuidof(MMDeviceEnumerator), nullptr, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void**)&enumerator);
|
||||
if (FAILED(r))
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "Failed to initialize WASAPI with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to initialize WASAPI with error #" + Str_8::FromNum(r) + ".");
|
||||
return devices;
|
||||
}
|
||||
|
||||
@@ -547,7 +547,7 @@ namespace lwe
|
||||
r = enumerator->EnumAudioEndpoints((EDataFlow)type, (DWORD)state, &collection);
|
||||
if (FAILED(r))
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Failed to retrieve audio device collection with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to retrieve audio device collection with error #" + Str_8::FromNum(r) + ".");
|
||||
return devices;
|
||||
}
|
||||
|
||||
@@ -555,7 +555,7 @@ namespace lwe
|
||||
r = collection->GetCount((UINT*)&count);
|
||||
if (FAILED(r))
|
||||
{
|
||||
LWE_LOG_INT("Error", 3, "Failed to retrieve audio device count with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT("Error", 3, "Failed to retrieve audio device count with error #" + Str_8::FromNum(r) + ".");
|
||||
return devices;
|
||||
}
|
||||
|
||||
@@ -566,7 +566,7 @@ namespace lwe
|
||||
r = collection->Item(i, &deviceHdl);
|
||||
if (FAILED(r))
|
||||
{
|
||||
LWE_LOG_INT("Error", 4, "Failed to retrieve audio device with error #" + Str_8::FromNum(r) + ".");
|
||||
EHS_LOG_INT("Error", 4, "Failed to retrieve audio device with error #" + Str_8::FromNum(r) + ".");
|
||||
return devices;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include "IO/Audio/BaseAudioDevice.h"
|
||||
#include "io/audio/BaseAudioDevice.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
BaseAudioDevice::BaseAudioDevice()
|
||||
: type(AudioDeviceType::ALL), dataType(DataType::SINT_8), bitDepth(0), sampleRate(0), channels(0),
|
@@ -1,6 +1,6 @@
|
||||
#include "IO/HID/Button.h"
|
||||
#include "io/hid/Button.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
Button::Button()
|
||||
: hash(0)
|
@@ -1,6 +1,6 @@
|
||||
#include "IO/HID/ButtonState.h"
|
||||
#include "io/hid/ButtonState.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
ButtonState::ButtonState()
|
||||
: state(State::RELEASED), pressed(false), threshold(1.0f)
|
@@ -1,9 +1,9 @@
|
||||
#include "IO/HID/HID.h"
|
||||
#include "io/hid/HID.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
HID::HID()
|
||||
: type(LWE_HID_UNKNOWN), id(0)
|
||||
: type(EHS_HID_UNKNOWN), id(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace lwe
|
||||
HID::HID(HID&& hid) noexcept
|
||||
: type(hid.type), name((Str_8&&)hid.name), id(hid.id), states((Array<ButtonState>&&)hid.states)
|
||||
{
|
||||
hid.type = LWE_HID_UNKNOWN;
|
||||
hid.type = EHS_HID_UNKNOWN;
|
||||
hid.id = 0;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace lwe
|
||||
id = hid.id;
|
||||
states = (Array<ButtonState>&&)hid.states;
|
||||
|
||||
hid.type = LWE_HID_UNKNOWN;
|
||||
hid.type = EHS_HID_UNKNOWN;
|
||||
hid.id = 0;
|
||||
|
||||
return *this;
|
@@ -1,6 +1,6 @@
|
||||
#include "IO/HID/Input.h"
|
||||
#include "io/hid/Input.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
Input::~Input()
|
||||
{
|
@@ -1,6 +1,6 @@
|
||||
#include "IO/HID/InputHandler.h"
|
||||
#include "io/hid/InputHandler.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
InputHandler::~InputHandler()
|
||||
{
|
@@ -1,13 +1,13 @@
|
||||
#include "IO/HID/Keyboard.h"
|
||||
#include "io/hid/Keyboard.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
Keyboard::Keyboard()
|
||||
{
|
||||
}
|
||||
|
||||
Keyboard::Keyboard(Str_8 name, const UInt_64 id)
|
||||
: HID(LWE_HID_KEYBOARD, (Str_8&&)name, id)
|
||||
: HID(EHS_HID_KEYBOARD, (Str_8&&)name, id)
|
||||
{
|
||||
}
|
||||
|
@@ -1,13 +1,13 @@
|
||||
#include "IO/HID/Mouse.h"
|
||||
#include "io/hid/Mouse.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
Mouse::Mouse()
|
||||
{
|
||||
}
|
||||
|
||||
Mouse::Mouse(Str_8 name, const UInt_64 id)
|
||||
: HID(LWE_HID_MOUSE, (Str_8&&)name, id)
|
||||
: HID(EHS_HID_MOUSE, (Str_8&&)name, id)
|
||||
{
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include "IO/Img/Img.h"
|
||||
#include "io/img/Img.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
Array<ImgCodec> Img::codecs;
|
||||
|
||||
@@ -829,7 +829,7 @@ namespace lwe
|
||||
const ImgCodec* codec = GetCodec(ext);
|
||||
if (!codec)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
EHS_LOG_INT("Error", 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -853,7 +853,7 @@ namespace lwe
|
||||
const ImgCodec* codec = GetCodec(ext);
|
||||
if (!codec)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
EHS_LOG_INT("Error", 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -877,7 +877,7 @@ namespace lwe
|
||||
const ImgCodec* codec = GetCodec(ext);
|
||||
if (!codec)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
EHS_LOG_INT("Error", 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -903,7 +903,7 @@ namespace lwe
|
||||
const ImgCodec* codec = GetCodec(ext);
|
||||
if (!codec)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
EHS_LOG_INT("Error", 0, "Codec not found for file extension, \"" + ext + "\".");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -978,17 +978,17 @@ namespace lwe
|
||||
buffer[i + b] = data[n + b];
|
||||
|
||||
if (bytes == 1)
|
||||
buffer[i + bytes * 3] = LWE_UINT_8_MAX;
|
||||
buffer[i + bytes * 3] = EHS_UINT_8_MAX;
|
||||
else if (bytes == 2)
|
||||
*(UInt_16*)&buffer[i + bytes * 3] = LWE_UINT_16_MAX;
|
||||
*(UInt_16*)&buffer[i + bytes * 3] = EHS_UINT_16_MAX;
|
||||
else if (bytes == 3)
|
||||
{
|
||||
UInt_32 value = LWE_UINT_24_MAX;
|
||||
UInt_32 value = EHS_UINT_24_MAX;
|
||||
for (UInt_64 b = 0; b < bytes; ++b)
|
||||
buffer[i + bytes * 3 + b] = ((Byte*)&value)[b];
|
||||
}
|
||||
else if (bytes == 4)
|
||||
*(UInt_32*)&buffer[i + bytes * 3] = LWE_UINT_32_MAX;
|
||||
*(UInt_32*)&buffer[i + bytes * 3] = EHS_UINT_32_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1025,17 +1025,17 @@ namespace lwe
|
||||
buffer[i + b] = data[n + b % bytes];
|
||||
|
||||
if (bytes == 1)
|
||||
buffer[i + bytes * 3] = LWE_UINT_8_MAX;
|
||||
buffer[i + bytes * 3] = EHS_UINT_8_MAX;
|
||||
else if (bytes == 2)
|
||||
*(UInt_16*)&buffer[i + bytes * 3] = LWE_UINT_16_MAX;
|
||||
*(UInt_16*)&buffer[i + bytes * 3] = EHS_UINT_16_MAX;
|
||||
else if (bytes == 3)
|
||||
{
|
||||
UInt_32 value = LWE_UINT_24_MAX;
|
||||
UInt_32 value = EHS_UINT_24_MAX;
|
||||
for (UInt_64 b = 0; b < bytes; ++b)
|
||||
buffer[i + bytes * 3 + b] = ((Byte*)&value)[b];
|
||||
}
|
||||
else if (bytes == 4)
|
||||
*(UInt_32*) &buffer[i + bytes * 3] = LWE_UINT_32_MAX;
|
||||
*(UInt_32*) &buffer[i + bytes * 3] = EHS_UINT_32_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1143,7 +1143,7 @@ namespace lwe
|
||||
average += data[n + b];
|
||||
|
||||
buffer[i] = average / 4;
|
||||
buffer[i + bytes] = LWE_UINT_8_MAX;
|
||||
buffer[i + bytes] = EHS_UINT_8_MAX;
|
||||
}
|
||||
else if (bytes == 2)
|
||||
{
|
||||
@@ -1153,7 +1153,7 @@ namespace lwe
|
||||
average += *(UInt_16*)&data[n + b];
|
||||
|
||||
*(UInt_16*)&buffer[i] = average / 4;
|
||||
*(UInt_16*)&buffer[i + bytes] = LWE_UINT_16_MAX;
|
||||
*(UInt_16*)&buffer[i + bytes] = EHS_UINT_16_MAX;
|
||||
}
|
||||
else if (bytes == 3)
|
||||
{
|
||||
@@ -1175,7 +1175,7 @@ namespace lwe
|
||||
buffer[i + 1] = ((Byte*)&average)[1];
|
||||
buffer[i + 2] = ((Byte*)&average)[2];
|
||||
|
||||
UInt_32 tmp = LWE_UINT_24_MAX;
|
||||
UInt_32 tmp = EHS_UINT_24_MAX;
|
||||
|
||||
buffer[i + bytes] = ((Byte*)&tmp)[0];
|
||||
buffer[i + bytes + 1] = ((Byte*)&tmp)[1];
|
||||
@@ -1189,7 +1189,7 @@ namespace lwe
|
||||
average += *(UInt_32*)&data[n + b];
|
||||
|
||||
*(UInt_32*)&buffer[i] = average / 4;
|
||||
*(UInt_32*)&buffer[i + bytes] = LWE_UINT_32_MAX;
|
||||
*(UInt_32*)&buffer[i + bytes] = EHS_UINT_32_MAX;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1203,12 +1203,12 @@ namespace lwe
|
||||
if (bytes == 1)
|
||||
{
|
||||
buffer[i] = data[n];
|
||||
buffer[i + bytes] = LWE_UINT_8_MAX;
|
||||
buffer[i + bytes] = EHS_UINT_8_MAX;
|
||||
}
|
||||
else if (bytes == 2)
|
||||
{
|
||||
*(UInt_16*)&buffer[i] = *(UInt_16*)&data[n];
|
||||
*(UInt_16*)&buffer[i + bytes] = LWE_UINT_16_MAX;
|
||||
*(UInt_16*)&buffer[i + bytes] = EHS_UINT_16_MAX;
|
||||
}
|
||||
else if (bytes == 3)
|
||||
{
|
||||
@@ -1216,7 +1216,7 @@ namespace lwe
|
||||
buffer[i + 1] = data[n + 1];
|
||||
buffer[i + 2] = data[n + 2];
|
||||
|
||||
UInt_32 tmp = LWE_UINT_24_MAX;
|
||||
UInt_32 tmp = EHS_UINT_24_MAX;
|
||||
|
||||
buffer[i + bytes] = ((Byte*)&tmp)[0];
|
||||
buffer[i + bytes + 1] = ((Byte*)&tmp)[1];
|
||||
@@ -1225,7 +1225,7 @@ namespace lwe
|
||||
else if (bytes == 4)
|
||||
{
|
||||
*(UInt_32*)&buffer[i] = *(UInt_32*)&data[n];
|
||||
*(UInt_32*)&buffer[i + bytes] = LWE_UINT_32_MAX;
|
||||
*(UInt_32*)&buffer[i + bytes] = EHS_UINT_32_MAX;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1378,27 +1378,27 @@ namespace lwe
|
||||
((Byte*)&inValue)[1] = data[n + 1];
|
||||
((Byte*)&inValue)[2] = data[n + 2];
|
||||
|
||||
*(UInt_32*)&buffer[i] = (UInt_32)((float)inValue / (float)LWE_UINT_24_MAX * (float)LWE_UINT_32_MAX);
|
||||
*(UInt_32*)&buffer[i] = (UInt_32)((float)inValue / (float)EHS_UINT_24_MAX * (float)EHS_UINT_32_MAX);
|
||||
}
|
||||
}
|
||||
|
||||
void Img::BD16_to_BD32(const UInt_64 newSize, Byte* buffer) const
|
||||
{
|
||||
for (UInt_64 i = 0, n = 0; i < newSize; i += 4, n += 2)
|
||||
*(UInt_32*)&buffer[i] = (UInt_32)((float)*(UInt_16*)&data[n] / (float)LWE_UINT_16_MAX * (float)LWE_UINT_32_MAX);
|
||||
*(UInt_32*)&buffer[i] = (UInt_32)((float)*(UInt_16*)&data[n] / (float)EHS_UINT_16_MAX * (float)EHS_UINT_32_MAX);
|
||||
}
|
||||
|
||||
void Img::BD8_to_BD32(const UInt_64 newSize, Byte* buffer) const
|
||||
{
|
||||
for (UInt_64 i = 0, n = 0; i < newSize; i += 4, ++n)
|
||||
*(UInt_32*)&buffer[i] = (UInt_32)((float)data[n] / (float)LWE_UINT_8_MAX * (float)LWE_UINT_32_MAX);
|
||||
*(UInt_32*)&buffer[i] = (UInt_32)((float)data[n] / (float)EHS_UINT_8_MAX * (float)EHS_UINT_32_MAX);
|
||||
}
|
||||
|
||||
void Img::BD32_to_BD24(const UInt_64 newSize, Byte* buffer) const
|
||||
{
|
||||
for (UInt_64 i = 0, n = 0; i < newSize; i += 3, n += 4)
|
||||
{
|
||||
UInt_32 rValue = (UInt_32)((float)*(UInt_32*)&data[n] / (float)LWE_UINT_32_MAX * (float)LWE_UINT_24_MAX);
|
||||
UInt_32 rValue = (UInt_32)((float)*(UInt_32*)&data[n] / (float)EHS_UINT_32_MAX * (float)EHS_UINT_24_MAX);
|
||||
|
||||
buffer[i] = ((Byte*)&rValue)[0];
|
||||
buffer[i + 1] = ((Byte*)&rValue)[1];
|
||||
@@ -1410,7 +1410,7 @@ namespace lwe
|
||||
{
|
||||
for (UInt_64 i = 0, n = 0; i < newSize; i += 3, n += 2)
|
||||
{
|
||||
UInt_32 rValue = (UInt_32)((float)*(UInt_16*)&data[n] / (float)LWE_UINT_16_MAX * (float)LWE_UINT_24_MAX);
|
||||
UInt_32 rValue = (UInt_32)((float)*(UInt_16*)&data[n] / (float)EHS_UINT_16_MAX * (float)EHS_UINT_24_MAX);
|
||||
|
||||
buffer[i] = ((Byte*)&rValue)[0];
|
||||
buffer[i + 1] = ((Byte*)&rValue)[1];
|
||||
@@ -1422,7 +1422,7 @@ namespace lwe
|
||||
{
|
||||
for (UInt_64 i = 0, n = 0; i < newSize; i += 3, ++n)
|
||||
{
|
||||
UInt_32 rValue = (UInt_32)((float)data[n] / (float)LWE_UINT_8_MAX * (float)LWE_UINT_24_MAX);
|
||||
UInt_32 rValue = (UInt_32)((float)data[n] / (float)EHS_UINT_8_MAX * (float)EHS_UINT_24_MAX);
|
||||
|
||||
buffer[i] = ((Byte*)&rValue)[0];
|
||||
buffer[i + 1] = ((Byte*)&rValue)[1];
|
||||
@@ -1433,7 +1433,7 @@ namespace lwe
|
||||
void Img::BD32_to_BD16(const UInt_64 newSize, Byte* buffer) const
|
||||
{
|
||||
for (UInt_64 i = 0, n = 0; i < newSize; i += 2, n += 4)
|
||||
*(UInt_16*)&buffer[i] = (UInt_16)((float)*(UInt_32*)&data[n] / (float)LWE_UINT_32_MAX * (float)LWE_UINT_16_MAX);
|
||||
*(UInt_16*)&buffer[i] = (UInt_16)((float)*(UInt_32*)&data[n] / (float)EHS_UINT_32_MAX * (float)EHS_UINT_16_MAX);
|
||||
}
|
||||
|
||||
void Img::BD24_to_BD16(const UInt_64 newSize, Byte* buffer) const
|
||||
@@ -1445,20 +1445,20 @@ namespace lwe
|
||||
((Byte*)&inValue)[1] = data[n + 1];
|
||||
((Byte*)&inValue)[2] = data[n + 2];
|
||||
|
||||
*(UInt_16*)&buffer[i] = (UInt_16)((float)inValue / (float)LWE_UINT_24_MAX * (float)LWE_UINT_16_MAX);
|
||||
*(UInt_16*)&buffer[i] = (UInt_16)((float)inValue / (float)EHS_UINT_24_MAX * (float)EHS_UINT_16_MAX);
|
||||
}
|
||||
}
|
||||
|
||||
void Img::BD8_to_BD16(const UInt_64 newSize, Byte* buffer) const
|
||||
{
|
||||
for (UInt_64 i = 0, n = 0; i < newSize; i += 2, ++n)
|
||||
*(UInt_16*)&buffer[i] = (UInt_16)((float)data[n] / (float)LWE_UINT_8_MAX * (float)LWE_UINT_16_MAX);
|
||||
*(UInt_16*)&buffer[i] = (UInt_16)((float)data[n] / (float)EHS_UINT_8_MAX * (float)EHS_UINT_16_MAX);
|
||||
}
|
||||
|
||||
void Img::BD32_to_BD8(const UInt_64 newSize, Byte* buffer) const
|
||||
{
|
||||
for (UInt_64 i = 0, n = 0; i < newSize; ++i, n += 4)
|
||||
buffer[i] = (Byte)((float)*(UInt_32*)&data[n] / (float)LWE_UINT_32_MAX * (float)LWE_UINT_8_MAX);
|
||||
buffer[i] = (Byte)((float)*(UInt_32*)&data[n] / (float)EHS_UINT_32_MAX * (float)EHS_UINT_8_MAX);
|
||||
}
|
||||
|
||||
void Img::BD24_to_BD8(const UInt_64 newSize, Byte* buffer) const
|
||||
@@ -1470,13 +1470,13 @@ namespace lwe
|
||||
((Byte*)&inValue)[1] = data[n + 1];
|
||||
((Byte*)&inValue)[2] = data[n + 2];
|
||||
|
||||
buffer[i] = (Byte)((float)inValue / (float)LWE_UINT_24_MAX * (float)LWE_UINT_8_MAX);
|
||||
buffer[i] = (Byte)((float)inValue / (float)EHS_UINT_24_MAX * (float)EHS_UINT_8_MAX);
|
||||
}
|
||||
}
|
||||
|
||||
void Img::BD16_to_BD8(const UInt_64 newSize, Byte* buffer) const
|
||||
{
|
||||
for (UInt_64 i = 0, n = 0; i < newSize; ++i, n += 2)
|
||||
buffer[i] = (Byte)((float)*(UInt_16*)&data[n] / (float)LWE_UINT_16_MAX * (float)LWE_UINT_8_MAX);
|
||||
buffer[i] = (Byte)((float)*(UInt_16*)&data[n] / (float)EHS_UINT_16_MAX * (float)EHS_UINT_8_MAX);
|
||||
}
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
#include "IO/Img/ImgCodec.h"
|
||||
#include "IO/Img/Img.h"
|
||||
#include "io/img/ImgCodec.h"
|
||||
#include "io/img/Img.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
ImgCodec::ImgCodec()
|
||||
: hashExt(0), endianness(Endianness::LE), encodeCb(nullptr), decodeCb(nullptr)
|
||||
@@ -90,7 +90,7 @@ namespace lwe
|
||||
{
|
||||
if (!encodeCb)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Encoding is not supported for the " + id + " format.");
|
||||
EHS_LOG_INT("Error", 0, "Encoding is not supported for the " + id + " format.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace lwe
|
||||
{
|
||||
if (!decodeCb)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Decoding is not supported for the " + id + " format.");
|
||||
EHS_LOG_INT("Error", 0, "Decoding is not supported for the " + id + " format.");
|
||||
return false;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include "IO/Img/PNG.h"
|
||||
#include "io/img/PNG.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
Array<Byte, UInt_64> pngSeq = {0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A};
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace lwe
|
||||
Array<Byte, UInt_64> seq = data.ReadArray<Byte, UInt_64>(8);
|
||||
if (seq != pngSeq)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "File at file path, \"" + filePath + "\", is not a valid PNG file.");
|
||||
EHS_LOG_INT("Error", 0, "File at file path, \"" + filePath + "\", is not a valid PNG file.");
|
||||
return;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include "IO/Img/PNG_Chunk.h"
|
||||
#include "io/img/PNG_Chunk.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
PNG_Chunk::PNG_Chunk()
|
||||
: hashId(0), crc{0x0, 0x0, 0x0, 0x0}
|
@@ -1,8 +1,8 @@
|
||||
#include "IO/Model/AnimBone.h"
|
||||
#include "io/model/AnimBone.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
AnimBone::AnimBone()
|
||||
: boneId(0xFF)
|
@@ -1,6 +1,6 @@
|
||||
#include "IO/Model/Animation.h"
|
||||
#include "io/model/Animation.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
Animation::Animation()
|
||||
: hashId(0), duration(0.0f)
|
@@ -1,6 +1,6 @@
|
||||
#include "IO/Model/Bone.h"
|
||||
#include "io/model/Bone.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
Bone::Bone()
|
||||
: hashName(0), id(0), animTrans(Mat4_f::Identity())
|
@@ -1,8 +1,8 @@
|
||||
#include "IO/Model/KeyFrame.h"
|
||||
#include "io/model/KeyFrame.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
KeyFrame::KeyFrame()
|
||||
: num(0.0f), timeStamp(0.0f), scale(1.0f), trans(Mat4_f::Identity())
|
@@ -1,6 +1,6 @@
|
||||
#include "IO/Model/Mesh.h"
|
||||
#include "io/model/Mesh.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
Mesh::Mesh()
|
||||
{
|
@@ -1,6 +1,6 @@
|
||||
#include "IO/Model/Model.h"
|
||||
#include "io/model/Model.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
Model::Model()
|
||||
{
|
||||
@@ -214,7 +214,7 @@ namespace lwe
|
||||
Version ver = data.ReadVersion();
|
||||
if (ver != Version(1, 0, 0))
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Cannot decode EHM file version " + Str_8::FromNum(ver.major) + "." +
|
||||
EHS_LOG_INT("Error", 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;
|
||||
@@ -256,7 +256,7 @@ namespace lwe
|
||||
Bone* parent = skeleton.GetBone(parentId);
|
||||
if (!parent)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Invalid bone order.");
|
||||
EHS_LOG_INT("Error", 0, "Invalid bone order.");
|
||||
return;
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include "IO/Model/PropertyChange.h"
|
||||
#include "io/model/PropertyChange.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
PropertyChange::PropertyChange()
|
||||
: type(ChangeType::INVALID), value(0.0f)
|
@@ -1,7 +1,7 @@
|
||||
#include "IO/Socket/BaseTCP.h"
|
||||
#include "io/socket/BaseTCP.h"
|
||||
#include "Log.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
BaseTCP::BaseTCP()
|
||||
: addrType(AddrType::IPV6), localPort(0), remotePort(0), connection(false), bound(false), listening(false),
|
||||
@@ -87,7 +87,7 @@ namespace lwe
|
||||
UInt_64 sent = Send((Byte*)&str[offset], size - offset);
|
||||
if (!sent)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to send data.");
|
||||
EHS_LOG_INT("Error", 0, "Failed to send data.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ namespace lwe
|
||||
UInt_64 received = Receive((Byte*)&buffer[offset], contentLength - offset);
|
||||
if (!received)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to receive data.");
|
||||
EHS_LOG_INT("Error", 0, "Failed to receive data.");
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -292,7 +292,7 @@ namespace lwe
|
||||
UInt_64 received = Receive((Byte*)&hexSize[offset], 1);
|
||||
if (!received)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to receive data.");
|
||||
EHS_LOG_INT("Error", 0, "Failed to receive data.");
|
||||
return 0;
|
||||
}
|
||||
else if (hexSize[offset] == '\r')
|
||||
@@ -322,7 +322,7 @@ namespace lwe
|
||||
UInt_64 received = Receive((Byte*)&buffer[offset], chunkSize + 2 - offset);
|
||||
if (!received)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to receive data.");
|
||||
EHS_LOG_INT("Error", 0, "Failed to receive data.");
|
||||
return {};
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include "IO/Socket/BaseUDP.h"
|
||||
#include "io/socket/BaseUDP.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
BaseUDP::BaseUDP()
|
||||
: addrType(AddrType::IPV6), port(0), bound(false)
|
@@ -1,12 +1,12 @@
|
||||
#include "IO/Socket/Comms.h"
|
||||
#include "IO/Socket/CommsSystem.h"
|
||||
#include "IO/Socket/Endpoint.h"
|
||||
#include "io/socket/Comms.h"
|
||||
#include "io/socket/CommsSystem.h"
|
||||
#include "io/socket/Endpoint.h"
|
||||
#include "Encryption.h"
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
#include <WinSock2.h>
|
||||
#include <WS2tcpip.h>
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
@@ -17,7 +17,7 @@
|
||||
#include <cerrno>
|
||||
#endif
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
const Version Comms::ver(1, 0, 0);
|
||||
const UInt_64 Comms::internalSys = Str_8::Hash_64("Internal");
|
||||
@@ -38,7 +38,7 @@ namespace lwe
|
||||
}
|
||||
|
||||
Comms::Comms()
|
||||
: hdl(LWE_INVALID_SOCKET), type(AddrType::IPV4), port(0), bound(false), appVer(0, 0, 0),
|
||||
: hdl(EHS_INVALID_SOCKET), type(AddrType::IPV4), port(0), bound(false), appVer(0, 0, 0),
|
||||
disposition(EndDisp::UNKNOWN), dropPackets(false), hashId(0), buffer(nullptr), bufferSize(0),
|
||||
maxEndpoints(0), lastTSC(0), delta(0.0f), maxTimeout(5.0f), resendRate(0.5f), connectedCb(nullptr),
|
||||
activeCb(nullptr), disconnectedCb(nullptr)
|
||||
@@ -47,7 +47,7 @@ namespace lwe
|
||||
}
|
||||
|
||||
Comms::Comms(const Version& ver, const EndDisp disposition, const Str_8& id, const UInt_64 maxEndpoints)
|
||||
: hdl(LWE_INVALID_SOCKET), type(AddrType::IPV4), port(0), bound(false), appVer(ver), disposition(disposition),
|
||||
: hdl(EHS_INVALID_SOCKET), type(AddrType::IPV4), port(0), bound(false), appVer(ver), disposition(disposition),
|
||||
dropPackets(false), id(id), hashId(id.Hash_32()), buffer(nullptr), bufferSize(0),
|
||||
maxEndpoints(maxEndpoints), lastTSC(CPU::GetTSC()), delta(0.0f), maxTimeout(5.0f), resendRate(0.5f),
|
||||
connectedCb(nullptr), activeCb(nullptr), disconnectedCb(nullptr)
|
||||
@@ -55,7 +55,7 @@ namespace lwe
|
||||
}
|
||||
|
||||
Comms::Comms(const Comms& sock)
|
||||
: BaseObj(sock), hdl(LWE_INVALID_SOCKET), type(sock.type), address(sock.address), port(sock.port), bound(false),
|
||||
: BaseObj(sock), hdl(EHS_INVALID_SOCKET), type(sock.type), address(sock.address), port(sock.port), bound(false),
|
||||
appVer(sock.appVer), disposition(sock.disposition), dropPackets(sock.dropPackets),
|
||||
id(sock.id), hashId(sock.hashId), buffer(nullptr), bufferSize(0), maxEndpoints(sock.maxEndpoints),
|
||||
lastTSC(CPU::GetTSC()), delta(0.0f), maxTimeout(sock.maxTimeout), resendRate(sock.resendRate),
|
||||
@@ -71,7 +71,7 @@ namespace lwe
|
||||
|
||||
BaseObj::operator=(sock);
|
||||
|
||||
hdl = LWE_INVALID_SOCKET;
|
||||
hdl = EHS_INVALID_SOCKET;
|
||||
type = sock.type;
|
||||
address = sock.address;
|
||||
port = sock.port;
|
||||
@@ -99,16 +99,16 @@ namespace lwe
|
||||
|
||||
void Comms::Initialize()
|
||||
{
|
||||
if (hdl != LWE_INVALID_SOCKET)
|
||||
if (hdl != EHS_INVALID_SOCKET)
|
||||
return;
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
WSADATA data = {};
|
||||
|
||||
int wsaCode = WSAStartup(MAKEWORD(2, 2), &data);
|
||||
if (wsaCode)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "WSAStartup failed with the error #" + Str_8::FromNum(wsaCode) + ".");
|
||||
EHS_LOG_INT("Error", 0, "WSAStartup failed with the error #" + Str_8::FromNum(wsaCode) + ".");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -120,21 +120,21 @@ namespace lwe
|
||||
else
|
||||
return;
|
||||
|
||||
if (hdl == LWE_INVALID_SOCKET)
|
||||
if (hdl == EHS_INVALID_SOCKET)
|
||||
{
|
||||
UInt_32 code = 0;
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
code = WSAGetLastError();
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
code = errno;
|
||||
#endif
|
||||
|
||||
LWE_LOG_INT("Error", 1, "Failed to create socket with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to create socket with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (WSACleanup() == SOCKET_ERROR)
|
||||
LWE_LOG_INT("Error", 2, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
#endif
|
||||
|
||||
return;
|
||||
@@ -142,19 +142,19 @@ namespace lwe
|
||||
|
||||
if (type == AddrType::IPV4)
|
||||
{
|
||||
buffer = new Byte[LWE_IPV4_UDP_PAYLOAD];
|
||||
bufferSize = LWE_IPV4_UDP_PAYLOAD;
|
||||
buffer = new Byte[EHS_IPV4_UDP_PAYLOAD];
|
||||
bufferSize = EHS_IPV4_UDP_PAYLOAD;
|
||||
}
|
||||
else if (type == AddrType::IPV6)
|
||||
{
|
||||
buffer = new Byte[LWE_IPV6_UDP_PAYLOAD];
|
||||
bufferSize = LWE_IPV6_UDP_PAYLOAD;
|
||||
buffer = new Byte[EHS_IPV6_UDP_PAYLOAD];
|
||||
bufferSize = EHS_IPV6_UDP_PAYLOAD;
|
||||
}
|
||||
}
|
||||
|
||||
void Comms::UnInitialize()
|
||||
{
|
||||
if (hdl == LWE_INVALID_SOCKET)
|
||||
if (hdl == EHS_INVALID_SOCKET)
|
||||
return;
|
||||
|
||||
delete[] buffer;
|
||||
@@ -179,21 +179,21 @@ namespace lwe
|
||||
|
||||
Int_32 code = 0;
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
code = closesocket(hdl);
|
||||
if (code == SOCKET_ERROR)
|
||||
LWE_LOG_INT("Error", 0, "Failed to close socket with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
EHS_LOG_INT("Error", 0, "Failed to close socket with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
code = close(hdl);
|
||||
if (code == -1)
|
||||
LWE_LOG_INT("Error", 0, "Failed to close socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to close socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
#endif
|
||||
|
||||
hdl = LWE_INVALID_SOCKET;
|
||||
hdl = EHS_INVALID_SOCKET;
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (WSACleanup() == SOCKET_ERROR)
|
||||
LWE_LOG_INT("Error", 1, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
#endif
|
||||
|
||||
bound = false;
|
||||
@@ -201,7 +201,7 @@ namespace lwe
|
||||
|
||||
void Comms::Bind(const Str_8& newAddress, const UInt_16 newPort)
|
||||
{
|
||||
if (hdl == LWE_INVALID_SOCKET || bound)
|
||||
if (hdl == EHS_INVALID_SOCKET || bound)
|
||||
return;
|
||||
|
||||
if (type == AddrType::IPV6)
|
||||
@@ -217,7 +217,7 @@ namespace lwe
|
||||
|
||||
void Comms::Connect(const Str_8& address, const UInt_16 port)
|
||||
{
|
||||
if (hdl == LWE_INVALID_SOCKET)
|
||||
if (hdl == EHS_INVALID_SOCKET)
|
||||
return;
|
||||
|
||||
Serializer payload(Endianness::LE);
|
||||
@@ -235,7 +235,7 @@ namespace lwe
|
||||
|
||||
bool Comms::Disconnect(const EndDisp disposition, const UInt_64 hashId, const Str_8& msg)
|
||||
{
|
||||
if (hdl == LWE_INVALID_SOCKET)
|
||||
if (hdl == EHS_INVALID_SOCKET)
|
||||
return false;
|
||||
|
||||
Endpoint* end = GetEndpoint(disposition, hashId);
|
||||
@@ -246,7 +246,7 @@ namespace lwe
|
||||
if (msg.Size())
|
||||
dcMsg += " Reason: " + msg;
|
||||
|
||||
LWE_LOG_INT("Info", 0, dcMsg);
|
||||
EHS_LOG_INT("Info", 0, dcMsg);
|
||||
|
||||
Serializer<> payload(Endianness::LE);
|
||||
payload.WriteStr(msg);
|
||||
@@ -265,7 +265,7 @@ namespace lwe
|
||||
const bool ensure, const UInt_64 sysHashId, const UInt_64 opHashId,
|
||||
const Serializer<>& payload)
|
||||
{
|
||||
if (hdl == LWE_INVALID_SOCKET)
|
||||
if (hdl == EHS_INVALID_SOCKET)
|
||||
return;
|
||||
|
||||
for (UInt_64 i = 0; i < endpoints.Size(); ++i)
|
||||
@@ -287,7 +287,7 @@ namespace lwe
|
||||
|
||||
void Comms::Poll()
|
||||
{
|
||||
if (hdl == LWE_INVALID_SOCKET)
|
||||
if (hdl == EHS_INVALID_SOCKET)
|
||||
return;
|
||||
|
||||
UInt_64 newTSC = CPU::GetTSC();
|
||||
@@ -389,7 +389,7 @@ namespace lwe
|
||||
sPayload.Write(Status::IN_REMOTE_QUEUE);
|
||||
sPayload.Write(end->GetQueueSlot());
|
||||
|
||||
LWE_LOG_INT("Info", 1, end->GetId() + " connected and is in queue slot " + end->GetQueueSlot() + ".");
|
||||
EHS_LOG_INT("Info", 1, end->GetId() + " connected and is in queue slot " + end->GetQueueSlot() + ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -401,7 +401,7 @@ namespace lwe
|
||||
sPayload.Write(Status::ACTIVE);
|
||||
sPayload.Write(0);
|
||||
|
||||
LWE_LOG_INT("Info", 1, end->GetId() + " connected.");
|
||||
EHS_LOG_INT("Info", 1, end->GetId() + " connected.");
|
||||
}
|
||||
|
||||
end->Send(false, true, false, internalSys, connectedOp, sPayload);
|
||||
@@ -429,7 +429,7 @@ namespace lwe
|
||||
else
|
||||
msg += ".";
|
||||
|
||||
LWE_LOG_INT("Info", 2, msg);
|
||||
EHS_LOG_INT("Info", 2, msg);
|
||||
}
|
||||
else if (!header.ensure && header.endpointId && header.system == internalSys && header.op == rejectedOp)
|
||||
{
|
||||
@@ -438,7 +438,7 @@ namespace lwe
|
||||
|
||||
Str_8 msg = payload.ReadStr<Char_8, UInt_64>();
|
||||
if (msg.Size())
|
||||
LWE_LOG_INT("Info", 3, msg);
|
||||
EHS_LOG_INT("Info", 3, msg);
|
||||
}
|
||||
else if (!header.ensure && header.endpointId && header.system == internalSys && header.op == disconnectOp)
|
||||
{
|
||||
@@ -462,7 +462,7 @@ namespace lwe
|
||||
if (msg.Size())
|
||||
dcMsg += " Reason: " + msg;
|
||||
|
||||
LWE_LOG_INT("Info", 4, dcMsg);
|
||||
EHS_LOG_INT("Info", 4, dcMsg);
|
||||
|
||||
RemoveEndpoint(header.disposition, end->GetHashId());
|
||||
|
||||
@@ -493,11 +493,11 @@ namespace lwe
|
||||
if (activeCb)
|
||||
activeCb(this, end);
|
||||
|
||||
LWE_LOG_INT("Info", 5, "Your connection status to " + end->GetId() + " has now become active.");
|
||||
EHS_LOG_INT("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)
|
||||
{
|
||||
LWE_LOG_INT("Info", 5, "Your queue slot for " + end->GetId() + " is now " + newSlot + ".");
|
||||
EHS_LOG_INT("Info", 5, "Your queue slot for " + end->GetId() + " is now " + newSlot + ".");
|
||||
}
|
||||
|
||||
end->SetStatus(newStatus);
|
||||
@@ -548,7 +548,7 @@ namespace lwe
|
||||
|
||||
if (dropPackets && !header.ensure && header.id < end->GetNextRecvId())
|
||||
{
|
||||
LWE_LOG_INT("Info", 6, "Old packet intentionally dropped.");
|
||||
EHS_LOG_INT("Info", 6, "Old packet intentionally dropped.");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -568,7 +568,7 @@ namespace lwe
|
||||
}
|
||||
else
|
||||
{
|
||||
LWE_LOG_INT("Info", 7, "Corrupted packet.");
|
||||
EHS_LOG_INT("Info", 7, "Corrupted packet.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -577,12 +577,12 @@ namespace lwe
|
||||
|
||||
bool Comms::IsInitialized() const
|
||||
{
|
||||
return hdl != LWE_INVALID_SOCKET;
|
||||
return hdl != EHS_INVALID_SOCKET;
|
||||
}
|
||||
|
||||
void Comms::SetAddressType(const AddrType newType)
|
||||
{
|
||||
if (hdl != LWE_INVALID_SOCKET)
|
||||
if (hdl != EHS_INVALID_SOCKET)
|
||||
return;
|
||||
|
||||
type = newType;
|
||||
@@ -851,33 +851,33 @@ namespace lwe
|
||||
|
||||
void Comms::SetBlocking(const bool blocking)
|
||||
{
|
||||
if (hdl == LWE_INVALID_SOCKET)
|
||||
if (hdl == EHS_INVALID_SOCKET)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Attempted to toggle blocking while socket is not initialized.");
|
||||
EHS_LOG_INT("Error", 0, "Attempted to toggle blocking while socket is not initialized.");
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
u_long r = (u_long)!blocking;
|
||||
|
||||
int result = ioctlsocket(hdl, FIONBIO, &r);
|
||||
if (result != NO_ERROR)
|
||||
LWE_LOG_INT("Error", 1, "Failed to toggle non-blocking mode with error #" + Str_8::FromNum(result) + ".");
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
EHS_LOG_INT("Error", 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)
|
||||
LWE_LOG_INT("Error", 1, "Failed to toggle non-blocking mode with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to toggle non-blocking mode with error #" + Str_8::FromNum(errno) + ".");
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Comms::IsBlocking() const
|
||||
{
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
u_long r = 0;
|
||||
if (ioctlsocket(hdl, FIONREAD, &r) == SOCKET_ERROR)
|
||||
LWE_LOG_INT("Error", 0, "Failed to retrieve socket info.");
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve socket info.");
|
||||
|
||||
return (bool)r;
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
return (bool)fcntl(hdl, F_GETFL, O_NONBLOCK);
|
||||
#else
|
||||
return true;
|
||||
@@ -1043,7 +1043,7 @@ namespace lwe
|
||||
{
|
||||
if (endpoints[i]->GetTimeout() >= maxTimeout)
|
||||
{
|
||||
LWE_LOG_INT("Info", 0, "Failed to connect to, \"" + endpoints[i]->GetAddress() + ":" + Str_8::FromNum(endpoints[i]->GetPort()) + "\".");
|
||||
EHS_LOG_INT("Info", 0, "Failed to connect to, \"" + endpoints[i]->GetAddress() + ":" + Str_8::FromNum(endpoints[i]->GetPort()) + "\".");
|
||||
|
||||
delete endpoints[i];
|
||||
|
||||
@@ -1059,7 +1059,7 @@ namespace lwe
|
||||
{
|
||||
if (endpoints[i]->GetTimeout() >= maxTimeout)
|
||||
{
|
||||
LWE_LOG_INT("Info", 6, endpoints[i]->GetId() + " timed out.");
|
||||
EHS_LOG_INT("Info", 6, endpoints[i]->GetId() + " timed out.");
|
||||
|
||||
if (disconnectedCb)
|
||||
disconnectedCb(this, endpoints[i]);
|
||||
@@ -1120,20 +1120,20 @@ namespace lwe
|
||||
Int_32 code = inet_pton(AF_INET6, address, &result.sin6_addr);
|
||||
if (!code)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
return;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = 0;
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
dCode = WSAGetLastError();
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
dCode = errno;
|
||||
#endif
|
||||
|
||||
LWE_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1144,16 +1144,16 @@ namespace lwe
|
||||
|
||||
code = bind(hdl, (sockaddr*)&result, sizeof(sockaddr_in6));
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (code == SOCKET_ERROR)
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
return;
|
||||
}
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
if (code == -1)
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -1172,20 +1172,20 @@ namespace lwe
|
||||
code = inet_pton(AF_INET, address, &result.sin_addr);
|
||||
if (!code)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
return;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = 0;
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
dCode = WSAGetLastError();
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
dCode = errno;
|
||||
#endif
|
||||
|
||||
LWE_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1196,16 +1196,16 @@ namespace lwe
|
||||
|
||||
code = bind(hdl, (sockaddr*)&result, sizeof(sockaddr_in));
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (code == SOCKET_ERROR)
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
return;
|
||||
}
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
if (code == -1)
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -1213,23 +1213,23 @@ namespace lwe
|
||||
|
||||
UInt_16 Comms::Receive(Str_8* address, UInt_16* port, Byte* const data, const UInt_16 size)
|
||||
{
|
||||
if (hdl == LWE_INVALID_SOCKET)
|
||||
if (hdl == EHS_INVALID_SOCKET)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Attempted to receive while socket is not initialized.");
|
||||
EHS_LOG_INT("Error", 0, "Attempted to receive while socket is not initialized.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (type == AddrType::IPV4 && size > LWE_IPV4_UDP_PAYLOAD)
|
||||
if (type == AddrType::IPV4 && size > EHS_IPV4_UDP_PAYLOAD)
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "Attempted to receive with a buffer size of, \"" + Str_8::FromNum(size)
|
||||
+ "\", that exceeds, \"" + Str_8::FromNum(LWE_IPV4_UDP_PAYLOAD) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Attempted to receive with a buffer size of, \"" + Str_8::FromNum(size)
|
||||
+ "\", that exceeds, \"" + Str_8::FromNum(EHS_IPV4_UDP_PAYLOAD) + ".");
|
||||
}
|
||||
|
||||
sockaddr_in6 remote = {};
|
||||
UInt_32 addrLen = type == AddrType::IPV6 ? sizeof(sockaddr_in6) : sizeof(sockaddr_in);
|
||||
SInt_64 received = 0;
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
received = recvfrom(hdl, (char*)data, (int)size, 0, (sockaddr*)&remote, (int*)&addrLen);
|
||||
if (received == SOCKET_ERROR)
|
||||
{
|
||||
@@ -1238,18 +1238,18 @@ namespace lwe
|
||||
{
|
||||
UnInitialize();
|
||||
|
||||
LWE_LOG_INT("Error", 2, "The buffer size, \"" + Str_8::FromNum(size) + "\" is too small.");
|
||||
EHS_LOG_INT("Error", 2, "The buffer size, \"" + Str_8::FromNum(size) + "\" is too small.");
|
||||
}
|
||||
else if (code != WSAECONNRESET && code != WSAEWOULDBLOCK)
|
||||
{
|
||||
UnInitialize();
|
||||
|
||||
LWE_LOG_INT("Error", 3, "Failed to receive with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 3, "Failed to receive with error #" + Str_8::FromNum(code) + ".");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
received = recvfrom(hdl, data, size, 0, (sockaddr*)&remote, &addrLen);
|
||||
if (received == -1)
|
||||
{
|
||||
@@ -1258,7 +1258,7 @@ namespace lwe
|
||||
{
|
||||
UnInitialize();
|
||||
|
||||
LWE_LOG_INT("Error", 2, "Failed to receive with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to receive with error #" + Str_8::FromNum(code) + ".");
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -1274,13 +1274,13 @@ namespace lwe
|
||||
{
|
||||
Int_32 code = 0;
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
code = WSAGetLastError();
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
code = errno;
|
||||
#endif
|
||||
|
||||
LWE_LOG_INT("Error", 2, "Failed to convert IPv6 address with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to convert IPv6 address with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
return received;
|
||||
}
|
||||
@@ -1296,13 +1296,13 @@ namespace lwe
|
||||
{
|
||||
Int_32 code = 0;
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
code = WSAGetLastError();
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
code = errno;
|
||||
#endif
|
||||
|
||||
LWE_LOG_INT("Error", 2, "Failed to convert IPv4 address with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to convert IPv4 address with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
return (UInt_16)received;
|
||||
}
|
@@ -1,9 +1,9 @@
|
||||
#include "IO/Socket/CommsSystem.h"
|
||||
#include "IO/Socket/Comms.h"
|
||||
#include "IO/Socket/Endpoint.h"
|
||||
#include "IO/Socket/Operation.h"
|
||||
#include "io/socket/CommsSystem.h"
|
||||
#include "io/socket/Comms.h"
|
||||
#include "io/socket/Endpoint.h"
|
||||
#include "io/socket/Operation.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
CommsSystem::~CommsSystem()
|
||||
{
|
||||
@@ -79,6 +79,6 @@ namespace lwe
|
||||
}
|
||||
}
|
||||
|
||||
LWE_LOG_INT("Info", 0, "System not found.");
|
||||
EHS_LOG_INT("Info", 0, "System not found.");
|
||||
}
|
||||
}
|
@@ -1,26 +1,26 @@
|
||||
#include "IO/Socket/DNS.h"
|
||||
#include "io/socket/DNS.h"
|
||||
#include "Log.h"
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
#include <WinSock2.h>
|
||||
#include <WS2tcpip.h>
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
Str_8 DNS::Resolve(const AddrType addrType, const Str_8& hostName)
|
||||
{
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
WSADATA data = {};
|
||||
|
||||
Int_32 wsaCode = WSAStartup(MAKEWORD(2, 2), &data);
|
||||
if (wsaCode)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to start WSA with error #" + Str_8::FromNum(wsaCode) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to start WSA with error #" + Str_8::FromNum(wsaCode) + ".");
|
||||
return {};
|
||||
}
|
||||
#endif
|
||||
@@ -36,14 +36,14 @@ namespace lwe
|
||||
Int_32 code = getaddrinfo(hostName, nullptr, &hints, &result);
|
||||
if (code)
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "Failed to resolve host with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to resolve host with error #" + Str_8::FromNum(code) + ".");
|
||||
return {};
|
||||
}
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (WSACleanup() == SOCKET_ERROR)
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
return {};
|
||||
}
|
||||
#endif
|
@@ -1,12 +1,12 @@
|
||||
#include "IO/Socket/Endpoint.h"
|
||||
#include "IO/Socket/Comms.h"
|
||||
#include "io/socket/Endpoint.h"
|
||||
#include "io/socket/Comms.h"
|
||||
#include "Encryption.h"
|
||||
#include "System/CPU.h"
|
||||
#include "system/CPU.h"
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
#include <WinSock2.h>
|
||||
#include <WS2tcpip.h>
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
@@ -17,10 +17,10 @@
|
||||
#include <cerrno>
|
||||
#endif
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
Endpoint::Endpoint()
|
||||
: hdl(LWE_INVALID_SOCKET), disposition(EndDisp::UNKNOWN), status(Status::PENDING), arch(Architecture::UNKNOWN),
|
||||
: hdl(EHS_INVALID_SOCKET), disposition(EndDisp::UNKNOWN), status(Status::PENDING), arch(Architecture::UNKNOWN),
|
||||
hashId(0), nextSendId(0), nextRecvId(0), port(0), deltaDuration(0.0f), deltaRate(1.0f / 60.0f),
|
||||
timeout(0.0f), lastPing(0.0f), oldLatency(0.0f), latency(0.0f), queueSlot(0)
|
||||
{
|
||||
@@ -45,7 +45,7 @@ namespace lwe
|
||||
}
|
||||
|
||||
Endpoint::Endpoint(const Endpoint& end)
|
||||
: BaseObj(end), hdl(LWE_INVALID_SOCKET), disposition(end.disposition), status(Status::PENDING), arch(end.arch),
|
||||
: BaseObj(end), hdl(EHS_INVALID_SOCKET), disposition(end.disposition), status(Status::PENDING), arch(end.arch),
|
||||
id(end.id), hashId(end.hashId), nextSendId(0), nextRecvId(0), address(end.address), port(end.port),
|
||||
deltaDuration(0.0f), deltaRate(1.0f / 60.0f), timeout(0.0f), lastPing(0.0f),
|
||||
oldLatency(0.0f), latency(0.0f), queueSlot(0)
|
||||
@@ -82,7 +82,7 @@ namespace lwe
|
||||
}
|
||||
else
|
||||
{
|
||||
hdl = LWE_INVALID_SOCKET;
|
||||
hdl = EHS_INVALID_SOCKET;
|
||||
disposition = end.disposition;
|
||||
status = Status::PENDING;
|
||||
arch = end.arch;
|
||||
@@ -111,7 +111,7 @@ namespace lwe
|
||||
Comms* comms = (Comms*)GetParent();
|
||||
if (!comms)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Endpoint must be a child of a Socket object.");
|
||||
EHS_LOG_INT("Error", 0, "Endpoint must be a child of a Socket object.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ namespace lwe
|
||||
Comms* comms = (Comms*)GetParent();
|
||||
if (!comms)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Endpoint must be a child of a Socket object.");
|
||||
EHS_LOG_INT("Error", 0, "Endpoint must be a child of a Socket object.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -383,7 +383,7 @@ namespace lwe
|
||||
Comms* comms = (Comms*)GetParent();
|
||||
if (!comms)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Endpoint must be a child of a Socket object.");
|
||||
EHS_LOG_INT("Error", 0, "Endpoint must be a child of a Socket object.");
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -436,7 +436,7 @@ namespace lwe
|
||||
Comms* comms = (Comms*)GetParent();
|
||||
if (!comms)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Endpoint must be a child of a Socket object.");
|
||||
EHS_LOG_INT("Error", 0, "Endpoint must be a child of a Socket object.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -512,16 +512,16 @@ namespace lwe
|
||||
|
||||
UInt_16 Endpoint::Send_v6(const Serializer<>& payload)
|
||||
{
|
||||
if (hdl == LWE_INVALID_SOCKET)
|
||||
if (hdl == EHS_INVALID_SOCKET)
|
||||
{
|
||||
LWE_LOG_INT("Info", 0, "Attempted to send while socket is not initialized.");
|
||||
EHS_LOG_INT("Info", 0, "Attempted to send while socket is not initialized.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (payload.Size() > LWE_IPV6_UDP_PAYLOAD)
|
||||
if (payload.Size() > EHS_IPV6_UDP_PAYLOAD)
|
||||
{
|
||||
LWE_LOG_INT("Info", 1, "Attempted to send a packet with the size, \"" + Str_8::FromNum(payload.Size())
|
||||
+ "\", that exceeds the max payload of, \"" + Str_8::FromNum(LWE_IPV6_UDP_PAYLOAD) + "\".");
|
||||
EHS_LOG_INT("Info", 1, "Attempted to send a packet with the size, \"" + Str_8::FromNum(payload.Size())
|
||||
+ "\", that exceeds the max payload of, \"" + Str_8::FromNum(EHS_IPV6_UDP_PAYLOAD) + "\".");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -532,39 +532,39 @@ namespace lwe
|
||||
Int_32 code = inet_pton(AF_INET6, address, &result.sin6_addr);
|
||||
if (!code)
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT("Error", 2, "The given address, \"" + address + "\" is not valid.");
|
||||
return 0;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = 0;
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
dCode = WSAGetLastError();
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
dCode = errno;
|
||||
#endif
|
||||
|
||||
LWE_LOG_INT("Error", 3, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT("Error", 3, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Int_32 sent = sendto(hdl, (char*)&payload[0], (int)payload.Size(), 0, (sockaddr*)&result, sizeof(sockaddr_in6));
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (sent == SOCKET_ERROR)
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
if (sent == -1)
|
||||
#endif
|
||||
{
|
||||
Int_32 dCode = 0;
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
code = WSAGetLastError();
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
code = errno;
|
||||
#endif
|
||||
|
||||
LWE_LOG_INT("Error", 4, "Failed to send with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT("Error", 4, "Failed to send with error #" + Str_8::FromNum(dCode) + ".");
|
||||
|
||||
((Comms*)GetParent())->UnInitialize();
|
||||
|
||||
@@ -576,16 +576,16 @@ namespace lwe
|
||||
|
||||
UInt_16 Endpoint::Send_v4(const Serializer<>& payload)
|
||||
{
|
||||
if (hdl == LWE_INVALID_SOCKET)
|
||||
if (hdl == EHS_INVALID_SOCKET)
|
||||
{
|
||||
LWE_LOG_INT("Info", 0, "Attempted to send while socket is not initialized.");
|
||||
EHS_LOG_INT("Info", 0, "Attempted to send while socket is not initialized.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (payload.Size() > LWE_IPV4_UDP_PAYLOAD)
|
||||
if (payload.Size() > EHS_IPV4_UDP_PAYLOAD)
|
||||
{
|
||||
LWE_LOG_INT("Info", 1, "Attempted to send a packet with the size, \"" + Str_8::FromNum(payload.Size())
|
||||
+ "\", that exceeds the max payload of, \"" + Str_8::FromNum(LWE_IPV4_UDP_PAYLOAD) + "\".");
|
||||
EHS_LOG_INT("Info", 1, "Attempted to send a packet with the size, \"" + Str_8::FromNum(payload.Size())
|
||||
+ "\", that exceeds the max payload of, \"" + Str_8::FromNum(EHS_IPV4_UDP_PAYLOAD) + "\".");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -596,45 +596,45 @@ namespace lwe
|
||||
int code = inet_pton(AF_INET, address, &result.sin_addr);
|
||||
if (!code)
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT("Error", 2, "The given address, \"" + address + "\" is not valid.");
|
||||
return 0;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
Int_32 dCode = WSAGetLastError();
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
Int_32 dCode = errno;
|
||||
#else
|
||||
Int_32 dCode = 0;
|
||||
#endif
|
||||
|
||||
LWE_LOG_INT("Error", 2, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return 0;
|
||||
}
|
||||
|
||||
SInt_64 sent = sendto(hdl, (char*)&payload[0], (int)payload.Size(), 0, (sockaddr*)&result, sizeof(sockaddr_in));
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (sent == SOCKET_ERROR)
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
if (sent == -1)
|
||||
#endif
|
||||
{
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
Int_32 dCode = WSAGetLastError();
|
||||
|
||||
if (dCode != WSAEWOULDBLOCK)
|
||||
{
|
||||
LWE_LOG_INT("Error", 3, "Failed to send with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT("Error", 3, "Failed to send with error #" + Str_8::FromNum(dCode) + ".");
|
||||
|
||||
((Comms*)GetParent())->UnInitialize();
|
||||
}
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
Int_32 dCode = errno;
|
||||
|
||||
if (dCode != EWOULDBLOCK)
|
||||
{
|
||||
LWE_LOG_INT("Error", 3, "Failed to send with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT("Error", 3, "Failed to send with error #" + Str_8::FromNum(dCode) + ".");
|
||||
|
||||
((Comms*)GetParent())->UnInitialize();
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
#include "IO/Socket/Fragments.h"
|
||||
#include "io/socket/Fragments.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
Fragments::~Fragments()
|
||||
{
|
@@ -1,9 +1,9 @@
|
||||
#include "IO/Socket/Operation.h"
|
||||
#include "IO/Socket/CommsSystem.h"
|
||||
#include "IO/Socket/Comms.h"
|
||||
#include "IO/Socket/Endpoint.h"
|
||||
#include "io/socket/Operation.h"
|
||||
#include "io/socket/CommsSystem.h"
|
||||
#include "io/socket/Comms.h"
|
||||
#include "io/socket/Endpoint.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
Operation::Operation()
|
||||
: hashId(0)
|
@@ -1,7 +1,7 @@
|
||||
#include "IO/Socket/Request.h"
|
||||
#include "io/socket/Request.h"
|
||||
#include "Base64.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
Request::Request()
|
||||
: verb(Verb::GET), cType(ContentType::NONE)
|
@@ -1,6 +1,6 @@
|
||||
#include "IO/Socket/Response.h"
|
||||
#include "io/socket/Response.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
Response::Response(const UInt_32 code, const Str_8& server)
|
||||
: code(code), server(server), cType(ContentType::NONE)
|
@@ -1,11 +1,11 @@
|
||||
#include "IO/Socket/SSL.h"
|
||||
#include "io/socket/SSL.h"
|
||||
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/bio.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/pem.h>
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
SSL::~SSL()
|
||||
{
|
||||
@@ -130,7 +130,7 @@ namespace lwe
|
||||
int err = SSL_accept(client->sslHdl);
|
||||
if (!err)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed SSL handshake with error #" + Str_8::FromNum(SSL_get_error(client->sslHdl, err)) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed SSL handshake with error #" + Str_8::FromNum(SSL_get_error(client->sslHdl, err)) + ".");
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ namespace lwe
|
||||
{
|
||||
int code = SSL_get_error(sslHdl, written);
|
||||
ERR_print_errors_fp(stderr);
|
||||
LWE_LOG_INT("Error", 0, "Failed to send data with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to send data with error #" + Str_8::FromNum(code) + ".");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ namespace lwe
|
||||
{
|
||||
int code = SSL_get_error(sslHdl, received);
|
||||
ERR_print_errors_fp(stderr);
|
||||
LWE_LOG_INT("Error", 0, "Failed to receive data with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to receive data with error #" + Str_8::FromNum(code) + ".");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -184,13 +184,13 @@ namespace lwe
|
||||
X509 *cert = d2i_X509(nullptr, &data, (long)size);
|
||||
if (!cert)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Invalid certificate.");
|
||||
EHS_LOG_INT("Error", 0, "Invalid certificate.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (SSL_CTX_use_certificate(ctx, cert) != 1)
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "Failed to use certificate.");
|
||||
EHS_LOG_INT("Error", 1, "Failed to use certificate.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -202,13 +202,13 @@ namespace lwe
|
||||
EVP_PKEY *key = d2i_PrivateKey(EVP_PKEY_RSA, nullptr, &data, (long)size);
|
||||
if (!key)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Invalid private key.");
|
||||
EHS_LOG_INT("Error", 0, "Invalid private key.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (SSL_CTX_use_PrivateKey(ctx, key) != 1)
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "Failed to use private key.");
|
||||
EHS_LOG_INT("Error", 1, "Failed to use private key.");
|
||||
return;
|
||||
}
|
||||
|
@@ -1,12 +1,12 @@
|
||||
#include "IO/Socket/Socket.h"
|
||||
#include "IO/Socket/Endpoint.h"
|
||||
#include "System/System.h"
|
||||
#include "io/socket/Socket.h"
|
||||
#include "io/socket/Endpoint.h"
|
||||
#include "system/System.h"
|
||||
#include "Encryption.h"
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
#include <WinSock2.h>
|
||||
#include <WS2tcpip.h>
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
@@ -38,7 +38,7 @@ namespace ehc
|
||||
}
|
||||
|
||||
Socket::Socket()
|
||||
: hdl(LWE_INVALID_SOCKET), type(AddrType::IPV4), port(0), bound(false), appVer(0, 0, 0),
|
||||
: hdl(EHS_INVALID_SOCKET), type(AddrType::IPV4), port(0), bound(false), appVer(0, 0, 0),
|
||||
disposition(Disposition::UNKNOWN), dropPackets(false), hashId(0), buffer(nullptr), bufferSize(0),
|
||||
maxEndpoints(0), lastTSC(0), delta(0.0f), maxTimeout(5.0f), resendRate(0.5f), connectedCb(nullptr),
|
||||
activeCb(nullptr), disconnectedCb(nullptr)
|
||||
@@ -47,7 +47,7 @@ namespace ehc
|
||||
}
|
||||
|
||||
Socket::Socket(const Version& ver, const Disposition disposition, const Str_8& id, const UInt_64 maxEndpoints)
|
||||
: hdl(LWE_INVALID_SOCKET), type(AddrType::IPV4), port(0), bound(false), appVer(ver), disposition(disposition),
|
||||
: hdl(EHS_INVALID_SOCKET), type(AddrType::IPV4), port(0), bound(false), appVer(ver), disposition(disposition),
|
||||
dropPackets(false), id(id), hashId(id.Hash_32()), buffer(nullptr), bufferSize(0),
|
||||
maxEndpoints(maxEndpoints), lastTSC(CPU::GetTSC()), delta(0.0f), maxTimeout(5.0f), resendRate(0.5f),
|
||||
connectedCb(nullptr), activeCb(nullptr), disconnectedCb(nullptr)
|
||||
@@ -55,7 +55,7 @@ namespace ehc
|
||||
}
|
||||
|
||||
Socket::Socket(const Socket& sock)
|
||||
: BaseObj(sock), hdl(LWE_INVALID_SOCKET), type(sock.type), address(sock.address), port(sock.port), bound(false),
|
||||
: BaseObj(sock), hdl(EHS_INVALID_SOCKET), type(sock.type), address(sock.address), port(sock.port), bound(false),
|
||||
appVer(sock.appVer), disposition(sock.disposition), dropPackets(sock.dropPackets),
|
||||
id(sock.id), hashId(sock.hashId), buffer(nullptr), bufferSize(0), maxEndpoints(sock.maxEndpoints),
|
||||
lastTSC(CPU::GetTSC()), delta(0.0f), maxTimeout(sock.maxTimeout), resendRate(sock.resendRate),
|
||||
@@ -71,7 +71,7 @@ namespace ehc
|
||||
|
||||
BaseObj::operator=(sock);
|
||||
|
||||
hdl = LWE_INVALID_SOCKET;
|
||||
hdl = EHS_INVALID_SOCKET;
|
||||
type = sock.type;
|
||||
address = sock.address;
|
||||
port = sock.port;
|
||||
@@ -99,16 +99,16 @@ namespace ehc
|
||||
|
||||
void Socket::Initialize()
|
||||
{
|
||||
if (hdl != LWE_INVALID_SOCKET)
|
||||
if (hdl != EHS_INVALID_SOCKET)
|
||||
return;
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
WSADATA data = {};
|
||||
|
||||
int wsaCode = WSAStartup(MAKEWORD(2, 2), &data);
|
||||
if (wsaCode)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "WSAStartup failed with the error #" + Str_8::FromNum(wsaCode) + ".");
|
||||
EHS_LOG_INT("Error", 0, "WSAStartup failed with the error #" + Str_8::FromNum(wsaCode) + ".");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -120,21 +120,21 @@ namespace ehc
|
||||
else
|
||||
return;
|
||||
|
||||
if (hdl == LWE_INVALID_SOCKET)
|
||||
if (hdl == EHS_INVALID_SOCKET)
|
||||
{
|
||||
UInt_32 code = 0;
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
code = WSAGetLastError();
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
code = errno;
|
||||
#endif
|
||||
|
||||
LWE_LOG_INT("Error", 1, "Failed to create socket with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to create socket with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (WSACleanup() == SOCKET_ERROR)
|
||||
LWE_LOG_INT("Error", 2, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
#endif
|
||||
|
||||
return;
|
||||
@@ -142,19 +142,19 @@ namespace ehc
|
||||
|
||||
if (type == AddrType::IPV4)
|
||||
{
|
||||
buffer = new Byte[LWE_IPV4_UDP_PAYLOAD];
|
||||
bufferSize = LWE_IPV4_UDP_PAYLOAD;
|
||||
buffer = new Byte[EHS_IPV4_UDP_PAYLOAD];
|
||||
bufferSize = EHS_IPV4_UDP_PAYLOAD;
|
||||
}
|
||||
else if (type == AddrType::IPV6)
|
||||
{
|
||||
buffer = new Byte[LWE_IPV6_UDP_PAYLOAD];
|
||||
bufferSize = LWE_IPV6_UDP_PAYLOAD;
|
||||
buffer = new Byte[EHS_IPV6_UDP_PAYLOAD];
|
||||
bufferSize = EHS_IPV6_UDP_PAYLOAD;
|
||||
}
|
||||
}
|
||||
|
||||
void Socket::UnInitialize()
|
||||
{
|
||||
if (hdl == LWE_INVALID_SOCKET)
|
||||
if (hdl == EHS_INVALID_SOCKET)
|
||||
return;
|
||||
|
||||
delete[] buffer;
|
||||
@@ -179,21 +179,21 @@ namespace ehc
|
||||
|
||||
Int_32 code = 0;
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
code = closesocket(hdl);
|
||||
if (code == SOCKET_ERROR)
|
||||
LWE_LOG_INT("Error", 0, "Failed to close socket with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
EHS_LOG_INT("Error", 0, "Failed to close socket with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
code = close(hdl);
|
||||
if (code == -1)
|
||||
LWE_LOG_INT("Error", 0, "Failed to close socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to close socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
#endif
|
||||
|
||||
hdl = LWE_INVALID_SOCKET;
|
||||
hdl = EHS_INVALID_SOCKET;
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (WSACleanup() == SOCKET_ERROR)
|
||||
LWE_LOG_INT("Error", 1, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
#endif
|
||||
|
||||
bound = false;
|
||||
@@ -201,7 +201,7 @@ namespace ehc
|
||||
|
||||
void Socket::Bind(const Str_8& newAddress, const UInt_16 newPort)
|
||||
{
|
||||
if (hdl == LWE_INVALID_SOCKET || bound)
|
||||
if (hdl == EHS_INVALID_SOCKET || bound)
|
||||
return;
|
||||
|
||||
if (type == AddrType::IPV6)
|
||||
@@ -217,7 +217,7 @@ namespace ehc
|
||||
|
||||
void Socket::Connect(const Str_8& address, const UInt_16 port)
|
||||
{
|
||||
if (hdl == LWE_INVALID_SOCKET)
|
||||
if (hdl == EHS_INVALID_SOCKET)
|
||||
return;
|
||||
|
||||
Serializer payload(Endianness::LE);
|
||||
@@ -235,7 +235,7 @@ namespace ehc
|
||||
|
||||
bool Socket::Disconnect(const Disposition disposition, const UInt_64 hashId, const Str_8& msg)
|
||||
{
|
||||
if (hdl == LWE_INVALID_SOCKET)
|
||||
if (hdl == EHS_INVALID_SOCKET)
|
||||
return false;
|
||||
|
||||
Endpoint* end = GetEndpoint(disposition, hashId);
|
||||
@@ -246,7 +246,7 @@ namespace ehc
|
||||
if (msg.Size())
|
||||
dcMsg += " Reason: " + msg;
|
||||
|
||||
LWE_LOG_INT("Info", 0, dcMsg);
|
||||
EHS_LOG_INT("Info", 0, dcMsg);
|
||||
|
||||
Serializer<> payload(Endianness::LE);
|
||||
payload.WriteStr(msg);
|
||||
@@ -265,7 +265,7 @@ namespace ehc
|
||||
const bool ensure, const UInt_64 sysHashId, const UInt_64 opHashId,
|
||||
const Serializer<>& payload)
|
||||
{
|
||||
if (hdl == LWE_INVALID_SOCKET)
|
||||
if (hdl == EHS_INVALID_SOCKET)
|
||||
return;
|
||||
|
||||
for (UInt_64 i = 0; i < endpoints.Size(); ++i)
|
||||
@@ -287,7 +287,7 @@ namespace ehc
|
||||
|
||||
void Socket::Poll()
|
||||
{
|
||||
if (hdl == LWE_INVALID_SOCKET)
|
||||
if (hdl == EHS_INVALID_SOCKET)
|
||||
return;
|
||||
|
||||
UInt_64 newTSC = CPU::GetTSC();
|
||||
@@ -389,7 +389,7 @@ namespace ehc
|
||||
sPayload.Write(Status::IN_REMOTE_QUEUE);
|
||||
sPayload.Write(end->GetQueueSlot());
|
||||
|
||||
LWE_LOG_INT("Info", 1, end->GetId() + " connected and is in queue slot " + end->GetQueueSlot() + ".");
|
||||
EHS_LOG_INT("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);
|
||||
|
||||
LWE_LOG_INT("Info", 1, end->GetId() + " connected.");
|
||||
EHS_LOG_INT("Info", 1, end->GetId() + " connected.");
|
||||
}
|
||||
|
||||
end->Send(false, true, false, internalSys, connectedOp, sPayload);
|
||||
@@ -429,7 +429,7 @@ namespace ehc
|
||||
else
|
||||
msg += ".";
|
||||
|
||||
LWE_LOG_INT("Info", 2, msg);
|
||||
EHS_LOG_INT("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())
|
||||
LWE_LOG_INT("Info", 3, msg);
|
||||
EHS_LOG_INT("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;
|
||||
|
||||
LWE_LOG_INT("Info", 4, dcMsg);
|
||||
EHS_LOG_INT("Info", 4, dcMsg);
|
||||
|
||||
RemoveEndpoint(header.disposition, end->GetHashId());
|
||||
|
||||
@@ -493,11 +493,11 @@ namespace ehc
|
||||
if (activeCb)
|
||||
activeCb(this, end);
|
||||
|
||||
LWE_LOG_INT("Info", 5, "Your connection status to " + end->GetId() + " has now become active.");
|
||||
EHS_LOG_INT("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)
|
||||
{
|
||||
LWE_LOG_INT("Info", 5, "Your queue slot for " + end->GetId() + " is now " + newSlot + ".");
|
||||
EHS_LOG_INT("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())
|
||||
{
|
||||
LWE_LOG_INT("Info", 6, "Old packet intentionally dropped.");
|
||||
EHS_LOG_INT("Info", 6, "Old packet intentionally dropped.");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -568,7 +568,7 @@ namespace ehc
|
||||
}
|
||||
else
|
||||
{
|
||||
LWE_LOG_INT("Info", 7, "Corrupted packet.");
|
||||
EHS_LOG_INT("Info", 7, "Corrupted packet.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -577,12 +577,12 @@ namespace ehc
|
||||
|
||||
bool Socket::IsInitialized() const
|
||||
{
|
||||
return hdl != LWE_INVALID_SOCKET;
|
||||
return hdl != EHS_INVALID_SOCKET;
|
||||
}
|
||||
|
||||
void Socket::SetAddressType(const AddrType newType)
|
||||
{
|
||||
if (hdl != LWE_INVALID_SOCKET)
|
||||
if (hdl != EHS_INVALID_SOCKET)
|
||||
return;
|
||||
|
||||
type = newType;
|
||||
@@ -851,33 +851,33 @@ namespace ehc
|
||||
|
||||
void Socket::SetBlocking(const bool blocking)
|
||||
{
|
||||
if (hdl == LWE_INVALID_SOCKET)
|
||||
if (hdl == EHS_INVALID_SOCKET)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Attempted to toggle blocking while socket is not initialized.");
|
||||
EHS_LOG_INT("Error", 0, "Attempted to toggle blocking while socket is not initialized.");
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
u_long r = (u_long)!blocking;
|
||||
|
||||
int result = ioctlsocket(hdl, FIONBIO, &r);
|
||||
if (result != NO_ERROR)
|
||||
LWE_LOG_INT("Error", 1, "Failed to toggle non-blocking mode with error #" + Str_8::FromNum(result) + ".");
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
EHS_LOG_INT("Error", 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)
|
||||
LWE_LOG_INT("Error", 1, "Failed to toggle non-blocking mode with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to toggle non-blocking mode with error #" + Str_8::FromNum(errno) + ".");
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Socket::IsBlocking() const
|
||||
{
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
u_long r = 0;
|
||||
if (ioctlsocket(hdl, FIONREAD, &r) == SOCKET_ERROR)
|
||||
LWE_LOG_INT("Error", 0, "Failed to retrieve socket info.");
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve socket info.");
|
||||
|
||||
return (bool)r;
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
return (bool)fcntl(hdl, F_GETFL, O_NONBLOCK);
|
||||
#else
|
||||
return true;
|
||||
@@ -1043,7 +1043,7 @@ namespace ehc
|
||||
{
|
||||
if (endpoints[i]->GetTimeout() >= maxTimeout)
|
||||
{
|
||||
LWE_LOG_INT("Info", 0, "Failed to connect to, \"" + endpoints[i]->GetAddress() + ":" + Str_8::FromNum(endpoints[i]->GetPort()) + "\".");
|
||||
EHS_LOG_INT("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)
|
||||
{
|
||||
LWE_LOG_INT("Info", 6, endpoints[i]->GetId() + " timed out.");
|
||||
EHS_LOG_INT("Info", 6, endpoints[i]->GetId() + " timed out.");
|
||||
|
||||
if (disconnectedCb)
|
||||
disconnectedCb(this, endpoints[i]);
|
||||
@@ -1120,20 +1120,20 @@ namespace ehc
|
||||
Int_32 code = inet_pton(AF_INET6, address, &result.sin6_addr);
|
||||
if (!code)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
return;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = 0;
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
dCode = WSAGetLastError();
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
dCode = errno;
|
||||
#endif
|
||||
|
||||
LWE_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1144,16 +1144,16 @@ namespace ehc
|
||||
|
||||
code = bind(hdl, (sockaddr*)&result, sizeof(sockaddr_in6));
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (code == SOCKET_ERROR)
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
return;
|
||||
}
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
if (code == -1)
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -1172,20 +1172,20 @@ namespace ehc
|
||||
code = inet_pton(AF_INET, address, &result.sin_addr);
|
||||
if (!code)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
return;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = 0;
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
dCode = WSAGetLastError();
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
dCode = errno;
|
||||
#endif
|
||||
|
||||
LWE_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1196,16 +1196,16 @@ namespace ehc
|
||||
|
||||
code = bind(hdl, (sockaddr*)&result, sizeof(sockaddr_in));
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (code == SOCKET_ERROR)
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
return;
|
||||
}
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
if (code == -1)
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -1213,23 +1213,23 @@ namespace ehc
|
||||
|
||||
UInt_16 Socket::Receive(Str_8* address, UInt_16* port, Byte* const data, const UInt_16 size)
|
||||
{
|
||||
if (hdl == LWE_INVALID_SOCKET)
|
||||
if (hdl == EHS_INVALID_SOCKET)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Attempted to receive while socket is not initialized.");
|
||||
EHS_LOG_INT("Error", 0, "Attempted to receive while socket is not initialized.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (type == AddrType::IPV4 && size > LWE_IPV4_UDP_PAYLOAD)
|
||||
if (type == AddrType::IPV4 && size > EHS_IPV4_UDP_PAYLOAD)
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "Attempted to receive with a buffer size of, \"" + Str_8::FromNum(size)
|
||||
+ "\", that exceeds, \"" + Str_8::FromNum(LWE_IPV4_UDP_PAYLOAD) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Attempted to receive with a buffer size of, \"" + Str_8::FromNum(size)
|
||||
+ "\", that exceeds, \"" + Str_8::FromNum(EHS_IPV4_UDP_PAYLOAD) + ".");
|
||||
}
|
||||
|
||||
sockaddr_in6 remote = {};
|
||||
UInt_32 addrLen = type == AddrType::IPV6 ? sizeof(sockaddr_in6) : sizeof(sockaddr_in);
|
||||
SInt_64 received = 0;
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
received = recvfrom(hdl, (char*)data, (int)size, 0, (sockaddr*)&remote, (int*)&addrLen);
|
||||
if (received == SOCKET_ERROR)
|
||||
{
|
||||
@@ -1238,18 +1238,18 @@ namespace ehc
|
||||
{
|
||||
UnInitialize();
|
||||
|
||||
LWE_LOG_INT("Error", 2, "The buffer size, \"" + Str_8::FromNum(size) + "\" is too small.");
|
||||
EHS_LOG_INT("Error", 2, "The buffer size, \"" + Str_8::FromNum(size) + "\" is too small.");
|
||||
}
|
||||
else if (code != WSAECONNRESET && code != WSAEWOULDBLOCK)
|
||||
{
|
||||
UnInitialize();
|
||||
|
||||
LWE_LOG_INT("Error", 3, "Failed to receive with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 3, "Failed to receive with error #" + Str_8::FromNum(code) + ".");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
received = recvfrom(hdl, data, size, 0, (sockaddr*)&remote, &addrLen);
|
||||
if (received == -1)
|
||||
{
|
||||
@@ -1258,7 +1258,7 @@ namespace ehc
|
||||
{
|
||||
UnInitialize();
|
||||
|
||||
LWE_LOG_INT("Error", 2, "Failed to receive with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to receive with error #" + Str_8::FromNum(code) + ".");
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -1274,13 +1274,13 @@ namespace ehc
|
||||
{
|
||||
Int_32 code = 0;
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
code = WSAGetLastError();
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
code = errno;
|
||||
#endif
|
||||
|
||||
LWE_LOG_INT("Error", 2, "Failed to convert IPv6 address with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to convert IPv6 address with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
return received;
|
||||
}
|
||||
@@ -1296,13 +1296,13 @@ namespace ehc
|
||||
{
|
||||
Int_32 code = 0;
|
||||
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
code = WSAGetLastError();
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
code = errno;
|
||||
#endif
|
||||
|
||||
LWE_LOG_INT("Error", 2, "Failed to convert IPv4 address with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to convert IPv4 address with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
return (UInt_16)received;
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
#include "IO/Socket/TCP_BSD.h"
|
||||
#include "IO/Socket/DNS.h"
|
||||
#include "io/socket/TCP_BSD.h"
|
||||
#include "io/socket/DNS.h"
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
@@ -8,30 +8,30 @@
|
||||
#include <fcntl.h>
|
||||
#include <cerrno>
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
TCP::~TCP()
|
||||
{
|
||||
if (hdl == LWE_INVALID_SOCKET)
|
||||
if (hdl == EHS_INVALID_SOCKET)
|
||||
return;
|
||||
|
||||
if (connection)
|
||||
{
|
||||
if (shutdown(hdl, SHUT_RDWR) == -1)
|
||||
LWE_LOG_INT("Error", 0, "Failed to shutdown socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to shutdown socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
}
|
||||
|
||||
if (close(hdl) == -1)
|
||||
LWE_LOG_INT("Error", 1, "Failed to close socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to close socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
}
|
||||
|
||||
TCP::TCP()
|
||||
: hdl(LWE_INVALID_SOCKET)
|
||||
: hdl(EHS_INVALID_SOCKET)
|
||||
{
|
||||
}
|
||||
|
||||
TCP::TCP(const AddrType addrType)
|
||||
: BaseTCP(addrType), hdl(LWE_INVALID_SOCKET)
|
||||
: BaseTCP(addrType), hdl(EHS_INVALID_SOCKET)
|
||||
{
|
||||
TCP::Initialize();
|
||||
}
|
||||
@@ -39,11 +39,11 @@ namespace lwe
|
||||
TCP::TCP(TCP&& tcp) noexcept
|
||||
: BaseTCP(std::move(tcp)), hdl(tcp.hdl)
|
||||
{
|
||||
tcp.hdl = LWE_INVALID_SOCKET;
|
||||
tcp.hdl = EHS_INVALID_SOCKET;
|
||||
}
|
||||
|
||||
TCP::TCP(const TCP& tcp)
|
||||
: BaseTCP(tcp), hdl(LWE_INVALID_SOCKET)
|
||||
: BaseTCP(tcp), hdl(EHS_INVALID_SOCKET)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace lwe
|
||||
|
||||
hdl = tcp.hdl;
|
||||
|
||||
tcp.hdl = LWE_INVALID_SOCKET;
|
||||
tcp.hdl = EHS_INVALID_SOCKET;
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -68,7 +68,7 @@ namespace lwe
|
||||
|
||||
BaseTCP::operator=(tcp);
|
||||
|
||||
hdl = LWE_INVALID_SOCKET;
|
||||
hdl = EHS_INVALID_SOCKET;
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -85,11 +85,11 @@ namespace lwe
|
||||
else
|
||||
return;
|
||||
|
||||
if (hdl == LWE_INVALID_SOCKET)
|
||||
if (hdl == EHS_INVALID_SOCKET)
|
||||
{
|
||||
UInt_32 code = errno;
|
||||
|
||||
LWE_LOG_INT("Error", 1, "Failed to create socket with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to create socket with error #" + Str_8::FromNum(code) + ".");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,17 +101,17 @@ namespace lwe
|
||||
if (connection)
|
||||
{
|
||||
if (shutdown(hdl, SHUT_RDWR) == -1)
|
||||
LWE_LOG_INT("Error", 0, "Failed to shutdown socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to shutdown socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
}
|
||||
|
||||
if (close(hdl) == -1)
|
||||
LWE_LOG_INT("Error", 1, "Failed to close socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to close socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
|
||||
connection = false;
|
||||
bound = false;
|
||||
listening = false;
|
||||
connected = false;
|
||||
hdl = LWE_INVALID_SOCKET;
|
||||
hdl = EHS_INVALID_SOCKET;
|
||||
}
|
||||
|
||||
void TCP::Bind(const Str_8& address, unsigned short port)
|
||||
@@ -138,7 +138,7 @@ namespace lwe
|
||||
int code = listen(hdl, SOMAXCONN);
|
||||
if (code == -1)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to listen with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to listen with error #" + Str_8::FromNum(errno) + ".");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -161,10 +161,10 @@ namespace lwe
|
||||
client->connection = true;
|
||||
client->hdl = accept(hdl, (sockaddr*)&remote, &addrLen);
|
||||
|
||||
if (client->hdl == LWE_INVALID_SOCKET)
|
||||
if (client->hdl == EHS_INVALID_SOCKET)
|
||||
{
|
||||
if (errno != EWOULDBLOCK)
|
||||
LWE_LOG_INT("Error", 0, "Failed to accept client with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to accept client with error #" + Str_8::FromNum(errno) + ".");
|
||||
|
||||
delete client;
|
||||
|
||||
@@ -177,7 +177,7 @@ namespace lwe
|
||||
|
||||
if (!inet_ntop(remote.sin6_family, &remote.sin6_addr, tmpAddr, INET6_ADDRSTRLEN))
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "Failed to convert IPv6 address with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert IPv6 address with error #" + Str_8::FromNum(errno) + ".");
|
||||
|
||||
delete client;
|
||||
|
||||
@@ -193,7 +193,7 @@ namespace lwe
|
||||
|
||||
if (!inet_ntop(((sockaddr_in*)&remote)->sin_family, &((sockaddr_in*)&remote)->sin_addr, tmpAddr, INET_ADDRSTRLEN))
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "Failed to convert IPv4 address with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert IPv4 address with error #" + Str_8::FromNum(errno) + ".");
|
||||
|
||||
delete client;
|
||||
|
||||
@@ -228,13 +228,13 @@ namespace lwe
|
||||
{
|
||||
if (!IsValid())
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Attempted to send while socket is not initialized.");
|
||||
EHS_LOG_INT("Error", 0, "Attempted to send while socket is not initialized.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((!connection && !connected))
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "Attempted to send while socket is not connected or a connection.");
|
||||
EHS_LOG_INT("Error", 1, "Attempted to send while socket is not connected or a connection.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -245,10 +245,10 @@ namespace lwe
|
||||
if (err == ECONNRESET)
|
||||
{
|
||||
Release();
|
||||
LWE_LOG_INT("Information", 0, "Connection dropped.");
|
||||
EHS_LOG_INT("Information", 0, "Connection dropped.");
|
||||
}
|
||||
else
|
||||
LWE_LOG_INT("Error", 1, "Failed to send with error #" + Str_8::FromNum(err) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to send with error #" + Str_8::FromNum(err) + ".");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -260,13 +260,13 @@ namespace lwe
|
||||
{
|
||||
if (!IsValid())
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Attempted to receive while socket is not initialized.");
|
||||
EHS_LOG_INT("Error", 0, "Attempted to receive while socket is not initialized.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((!connection && !connected))
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "Attempted to receive while socket is not connected or a connection.");
|
||||
EHS_LOG_INT("Error", 1, "Attempted to receive while socket is not connected or a connection.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -277,11 +277,11 @@ namespace lwe
|
||||
if (err == ECONNRESET)
|
||||
{
|
||||
Release();
|
||||
LWE_LOG_INT("Information", 0, "Connection dropped.");
|
||||
EHS_LOG_INT("Information", 0, "Connection dropped.");
|
||||
}
|
||||
else if (err != EWOULDBLOCK)
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Failed to receive with error #" + Str_8::FromNum(err) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to receive with error #" + Str_8::FromNum(err) + ".");
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -294,14 +294,14 @@ namespace lwe
|
||||
{
|
||||
if (!IsValid())
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Attempted to toggle blocking while socket is not initialized.");
|
||||
EHS_LOG_INT("Error", 0, "Attempted to toggle blocking while socket is not initialized.");
|
||||
return;
|
||||
}
|
||||
|
||||
int flags = fcntl(hdl, F_GETFL, 0);
|
||||
if (flags == -1)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to retrieve flags.");
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve flags.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -311,7 +311,7 @@ namespace lwe
|
||||
flags |= O_NONBLOCK;
|
||||
|
||||
if (fcntl(hdl, F_SETFL, flags) == -1)
|
||||
LWE_LOG_INT("Error", 1, "Failed to toggle non-blocking mode with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to toggle non-blocking mode with error #" + Str_8::FromNum(errno) + ".");
|
||||
}
|
||||
|
||||
bool TCP::IsBlocking() const
|
||||
@@ -319,7 +319,7 @@ namespace lwe
|
||||
int flags = fcntl(hdl, F_GETFL, 0);
|
||||
if (flags == -1)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to retrieve flags.");
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve flags.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -328,7 +328,7 @@ namespace lwe
|
||||
|
||||
bool TCP::IsValid() const
|
||||
{
|
||||
return hdl != LWE_INVALID_SOCKET;
|
||||
return hdl != EHS_INVALID_SOCKET;
|
||||
}
|
||||
|
||||
void TCP::Bind_v6(const Str_8& address, unsigned short port)
|
||||
@@ -342,14 +342,14 @@ namespace lwe
|
||||
int code = inet_pton(AF_INET6, address, &result.sin6_addr);
|
||||
if (!code)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
return;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = errno;
|
||||
|
||||
LWE_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -361,7 +361,7 @@ namespace lwe
|
||||
int code = bind(hdl, (sockaddr*)&result, sizeof(sockaddr_in6));
|
||||
if (code == -1)
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -378,14 +378,14 @@ namespace lwe
|
||||
int code = inet_pton(AF_INET, address, &result.sin_addr);
|
||||
if (!code)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
return;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = errno;
|
||||
|
||||
LWE_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -396,7 +396,7 @@ namespace lwe
|
||||
int code = bind(hdl, (sockaddr*)&result, sizeof(sockaddr_in));
|
||||
if (code == -1)
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -411,14 +411,14 @@ namespace lwe
|
||||
int code = inet_pton(AF_INET6, address, &result.sin6_addr);
|
||||
if (!code)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
return;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = errno;
|
||||
|
||||
LWE_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -428,11 +428,11 @@ namespace lwe
|
||||
int err = errno;
|
||||
if (err == ETIMEDOUT)
|
||||
{
|
||||
LWE_LOG_INT("Information", 2, "Connection attempt timed-out.");
|
||||
EHS_LOG_INT("Information", 2, "Connection attempt timed-out.");
|
||||
}
|
||||
else
|
||||
{
|
||||
LWE_LOG_INT("Error", 3, "Failed to connect with error #" + Str_8::FromNum(err) + ".");
|
||||
EHS_LOG_INT("Error", 3, "Failed to connect with error #" + Str_8::FromNum(err) + ".");
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -448,14 +448,14 @@ namespace lwe
|
||||
int code = inet_pton(AF_INET, address, &result.sin_addr);
|
||||
if (!code)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
return;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = errno;
|
||||
|
||||
LWE_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -465,11 +465,11 @@ namespace lwe
|
||||
int err = errno;
|
||||
if (err == ETIMEDOUT)
|
||||
{
|
||||
LWE_LOG_INT("Information", 2, "Connection attempt timed-out.");
|
||||
EHS_LOG_INT("Information", 2, "Connection attempt timed-out.");
|
||||
}
|
||||
else
|
||||
{
|
||||
LWE_LOG_INT("Error", 3, "Failed to connect with error #" + Str_8::FromNum(err) + ".");
|
||||
EHS_LOG_INT("Error", 3, "Failed to connect with error #" + Str_8::FromNum(err) + ".");
|
||||
}
|
||||
|
||||
return;
|
@@ -1,14 +1,14 @@
|
||||
#include "IO/Socket/TCP_W32.h"
|
||||
#include "IO/Socket/DNS.h"
|
||||
#include "io/socket/TCP_W32.h"
|
||||
#include "io/socket/DNS.h"
|
||||
|
||||
#include <WinSock2.h>
|
||||
#include <WS2tcpip.h>
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
TCP::~TCP()
|
||||
{
|
||||
if (hdl == LWE_INVALID_SOCKET)
|
||||
if (hdl == EHS_INVALID_SOCKET)
|
||||
return;
|
||||
|
||||
Int_32 code;
|
||||
@@ -17,24 +17,24 @@ namespace lwe
|
||||
{
|
||||
code = shutdown(hdl, SD_SEND);
|
||||
if (code == SOCKET_ERROR)
|
||||
LWE_LOG_INT("Error", 0, "Failed to shutdown socket with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to shutdown socket with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
}
|
||||
|
||||
code = closesocket(hdl);
|
||||
if (code == SOCKET_ERROR)
|
||||
LWE_LOG_INT("Error", 1, "Failed to close socket with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to close socket with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
if (!connection && WSACleanup() == SOCKET_ERROR)
|
||||
LWE_LOG_INT("Error", 2, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
}
|
||||
|
||||
TCP::TCP()
|
||||
: hdl(LWE_INVALID_SOCKET)
|
||||
: hdl(EHS_INVALID_SOCKET)
|
||||
{
|
||||
}
|
||||
|
||||
TCP::TCP(const AddrType addrType)
|
||||
: BaseTCP(addrType), hdl(LWE_INVALID_SOCKET)
|
||||
: BaseTCP(addrType), hdl(EHS_INVALID_SOCKET)
|
||||
{
|
||||
TCP::Initialize();
|
||||
}
|
||||
@@ -42,11 +42,11 @@ namespace lwe
|
||||
TCP::TCP(TCP&& tcp) noexcept
|
||||
: BaseTCP(std::move(tcp)), hdl(tcp.hdl)
|
||||
{
|
||||
tcp.hdl = LWE_INVALID_SOCKET;
|
||||
tcp.hdl = EHS_INVALID_SOCKET;
|
||||
}
|
||||
|
||||
TCP::TCP(const TCP& tcp)
|
||||
: BaseTCP(tcp), hdl(LWE_INVALID_SOCKET)
|
||||
: BaseTCP(tcp), hdl(EHS_INVALID_SOCKET)
|
||||
{
|
||||
TCP::Initialize();
|
||||
}
|
||||
@@ -60,7 +60,7 @@ namespace lwe
|
||||
|
||||
hdl = tcp.hdl;
|
||||
|
||||
tcp.hdl = LWE_INVALID_SOCKET;
|
||||
tcp.hdl = EHS_INVALID_SOCKET;
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -72,7 +72,7 @@ namespace lwe
|
||||
|
||||
BaseTCP::operator=(tcp);
|
||||
|
||||
hdl = LWE_INVALID_SOCKET;
|
||||
hdl = EHS_INVALID_SOCKET;
|
||||
|
||||
TCP::Initialize();
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace lwe
|
||||
int code = WSAStartup(MAKEWORD(2, 2), &data);
|
||||
if (code)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "WSAStartup failed with the error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 0, "WSAStartup failed with the error #" + Str_8::FromNum(code) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -97,14 +97,14 @@ namespace lwe
|
||||
else
|
||||
return;
|
||||
|
||||
if (hdl == LWE_INVALID_SOCKET)
|
||||
if (hdl == EHS_INVALID_SOCKET)
|
||||
{
|
||||
UInt_32 code = WSAGetLastError();
|
||||
|
||||
LWE_LOG_INT("Error", 1, "Failed to create socket with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to create socket with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
if (WSACleanup() == SOCKET_ERROR)
|
||||
LWE_LOG_INT("Error", 2, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,17 +119,17 @@ namespace lwe
|
||||
{
|
||||
code = shutdown(hdl, SD_SEND);
|
||||
if (code == SOCKET_ERROR)
|
||||
LWE_LOG_INT("Error", 0, "Failed to shutdown socket with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to shutdown socket with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
}
|
||||
|
||||
code = closesocket(hdl);
|
||||
if (code == SOCKET_ERROR)
|
||||
LWE_LOG_INT("Error", 1, "Failed to close socket with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to close socket with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
hdl = LWE_INVALID_SOCKET;
|
||||
hdl = EHS_INVALID_SOCKET;
|
||||
|
||||
if (!connection && WSACleanup() == SOCKET_ERROR)
|
||||
LWE_LOG_INT("Error", 2, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
|
||||
connection = false;
|
||||
bound = false;
|
||||
@@ -161,7 +161,7 @@ namespace lwe
|
||||
int code = listen(hdl, SOMAXCONN);
|
||||
if (code == -1)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to listen with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to listen with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -184,12 +184,12 @@ namespace lwe
|
||||
client->connection = true;
|
||||
client->hdl = accept(hdl, (sockaddr*)&remote, (int*)&addrLen);
|
||||
|
||||
if (client->hdl == LWE_INVALID_SOCKET)
|
||||
if (client->hdl == EHS_INVALID_SOCKET)
|
||||
{
|
||||
Int_32 code = WSAGetLastError();
|
||||
|
||||
if (code != WSAEWOULDBLOCK)
|
||||
LWE_LOG_INT("Error", 0, "Failed to accept client with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to accept client with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
delete client;
|
||||
|
||||
@@ -204,7 +204,7 @@ namespace lwe
|
||||
{
|
||||
Int_32 code = WSAGetLastError();
|
||||
|
||||
LWE_LOG_INT("Error", 1, "Failed to convert IPv6 address with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert IPv6 address with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
delete client;
|
||||
|
||||
@@ -222,7 +222,7 @@ namespace lwe
|
||||
{
|
||||
Int_32 code = WSAGetLastError();
|
||||
|
||||
LWE_LOG_INT("Error", 1, "Failed to convert IPv4 address with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert IPv4 address with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
delete client;
|
||||
|
||||
@@ -257,13 +257,13 @@ namespace lwe
|
||||
{
|
||||
if (!IsValid())
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Attempted to send while socket is not initialized.");
|
||||
EHS_LOG_INT("Error", 0, "Attempted to send while socket is not initialized.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((!connection && !connected))
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "Attempted to send while socket is not connected or a connection.");
|
||||
EHS_LOG_INT("Error", 1, "Attempted to send while socket is not connected or a connection.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -274,10 +274,10 @@ namespace lwe
|
||||
if (err == WSAECONNRESET)
|
||||
{
|
||||
Release();
|
||||
LWE_LOG_INT("Information", 0, "Connection dropped.");
|
||||
EHS_LOG_INT("Information", 0, "Connection dropped.");
|
||||
}
|
||||
else
|
||||
LWE_LOG_INT("Error", 1, "Failed to send with error #" + Str_8::FromNum(err) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to send with error #" + Str_8::FromNum(err) + ".");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -289,13 +289,13 @@ namespace lwe
|
||||
{
|
||||
if (!IsValid())
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Attempted to receive while socket is not initialized.");
|
||||
EHS_LOG_INT("Error", 0, "Attempted to receive while socket is not initialized.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((!connection && !connected))
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "Attempted to receive while socket is not connected or a connection.");
|
||||
EHS_LOG_INT("Error", 1, "Attempted to receive while socket is not connected or a connection.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -306,15 +306,15 @@ namespace lwe
|
||||
if (err == WSAECONNRESET)
|
||||
{
|
||||
Release();
|
||||
LWE_LOG_INT("Information", 0, "Connection dropped.");
|
||||
EHS_LOG_INT("Information", 0, "Connection dropped.");
|
||||
}
|
||||
else if (err == WSAECONNABORTED)
|
||||
{
|
||||
LWE_LOG_INT("Information", 1, "Receiving timed-out.");
|
||||
EHS_LOG_INT("Information", 1, "Receiving timed-out.");
|
||||
}
|
||||
else if (err != WSAEWOULDBLOCK)
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Failed to receive with error #" + Str_8::FromNum(err) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to receive with error #" + Str_8::FromNum(err) + ".");
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -327,7 +327,7 @@ namespace lwe
|
||||
{
|
||||
if (!IsValid())
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Attempted to toggle blocking while socket is not initialized.");
|
||||
EHS_LOG_INT("Error", 0, "Attempted to toggle blocking while socket is not initialized.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -335,21 +335,21 @@ namespace lwe
|
||||
|
||||
int result = ioctlsocket(hdl, FIONBIO, &r);
|
||||
if (result != NO_ERROR)
|
||||
LWE_LOG_INT("Error", 1, "Failed to toggle non-blocking mode with error #" + Str_8::FromNum(result) + ".");
|
||||
EHS_LOG_INT("Error", 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)
|
||||
LWE_LOG_INT("Error", 0, "Failed to retrieve socket info.");
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve socket info.");
|
||||
|
||||
return (bool)r;
|
||||
}
|
||||
|
||||
bool TCP::IsValid() const
|
||||
{
|
||||
return hdl != LWE_INVALID_SOCKET;
|
||||
return hdl != EHS_INVALID_SOCKET;
|
||||
}
|
||||
|
||||
void TCP::Bind_v6(const Str_8& address, unsigned short port)
|
||||
@@ -363,14 +363,14 @@ namespace lwe
|
||||
int code = inet_pton(AF_INET6, address, &result.sin6_addr);
|
||||
if (!code)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
return;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = WSAGetLastError();
|
||||
|
||||
LWE_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -382,7 +382,7 @@ namespace lwe
|
||||
int code = bind(hdl, (sockaddr*)&result, sizeof(sockaddr_in6));
|
||||
if (code == -1)
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -399,14 +399,14 @@ namespace lwe
|
||||
int code = inet_pton(AF_INET, address, &result.sin_addr);
|
||||
if (!code)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
return;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = WSAGetLastError();
|
||||
|
||||
LWE_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -418,7 +418,7 @@ namespace lwe
|
||||
int code = bind(hdl, (sockaddr*)&result, sizeof(sockaddr_in));
|
||||
if (code == -1)
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -433,14 +433,14 @@ namespace lwe
|
||||
int code = inet_pton(AF_INET6, address, &result.sin6_addr);
|
||||
if (!code)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
return;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = WSAGetLastError();
|
||||
|
||||
LWE_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -450,11 +450,11 @@ namespace lwe
|
||||
int err = WSAGetLastError();
|
||||
if (err == WSAETIMEDOUT)
|
||||
{
|
||||
LWE_LOG_INT("Information", 2, "Connection attempt timed-out.");
|
||||
EHS_LOG_INT("Information", 2, "Connection attempt timed-out.");
|
||||
}
|
||||
else
|
||||
{
|
||||
LWE_LOG_INT("Error", 3, "Failed to connect with error #" + Str_8::FromNum(err) + ".");
|
||||
EHS_LOG_INT("Error", 3, "Failed to connect with error #" + Str_8::FromNum(err) + ".");
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -470,14 +470,14 @@ namespace lwe
|
||||
int code = inet_pton(AF_INET, address, &result.sin_addr);
|
||||
if (!code)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
return;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = WSAGetLastError();
|
||||
|
||||
LWE_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -487,11 +487,11 @@ namespace lwe
|
||||
int err = WSAGetLastError();
|
||||
if (err == WSAETIMEDOUT)
|
||||
{
|
||||
LWE_LOG_INT("Information", 2, "Connection attempt timed-out.");
|
||||
EHS_LOG_INT("Information", 2, "Connection attempt timed-out.");
|
||||
}
|
||||
else
|
||||
{
|
||||
LWE_LOG_INT("Error", 3, "Failed to connect with error #" + Str_8::FromNum(err) + ".");
|
||||
EHS_LOG_INT("Error", 3, "Failed to connect with error #" + Str_8::FromNum(err) + ".");
|
||||
}
|
||||
|
||||
return;
|
@@ -1,4 +1,4 @@
|
||||
#include "IO/Socket/UDP_BSD.h"
|
||||
#include "io/socket/UDP_BSD.h"
|
||||
#include "Log.h"
|
||||
|
||||
#include <sys/socket.h>
|
||||
@@ -10,25 +10,25 @@
|
||||
#include <fcntl.h>
|
||||
#include <cerrno>
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
UDP::~UDP()
|
||||
{
|
||||
if (hdl == LWE_INVALID_SOCKET)
|
||||
if (hdl == EHS_INVALID_SOCKET)
|
||||
return;
|
||||
|
||||
Int_32 code = close(hdl);
|
||||
if (code == -1)
|
||||
LWE_LOG_INT("Error", 0, "Failed to close socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to close socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
}
|
||||
|
||||
UDP::UDP()
|
||||
: hdl(LWE_INVALID_SOCKET)
|
||||
: hdl(EHS_INVALID_SOCKET)
|
||||
{
|
||||
}
|
||||
|
||||
UDP::UDP(const AddrType addrType)
|
||||
: BaseUDP(addrType), hdl(LWE_INVALID_SOCKET)
|
||||
: BaseUDP(addrType), hdl(EHS_INVALID_SOCKET)
|
||||
{
|
||||
if (addrType == AddrType::IPV6)
|
||||
hdl = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
|
||||
@@ -37,11 +37,11 @@ namespace lwe
|
||||
else
|
||||
return;
|
||||
|
||||
if (hdl == LWE_INVALID_SOCKET)
|
||||
if (hdl == EHS_INVALID_SOCKET)
|
||||
{
|
||||
UInt_32 code = errno;
|
||||
|
||||
LWE_LOG_INT("Error", 1, "Failed to create socket with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to create socket with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -50,11 +50,11 @@ namespace lwe
|
||||
UDP::UDP(UDP&& udp) noexcept
|
||||
: BaseUDP(std::move(udp)), hdl(udp.hdl)
|
||||
{
|
||||
udp.hdl = LWE_INVALID_SOCKET;
|
||||
udp.hdl = EHS_INVALID_SOCKET;
|
||||
}
|
||||
|
||||
UDP::UDP(const UDP& udp)
|
||||
: BaseUDP(udp), hdl(LWE_INVALID_SOCKET)
|
||||
: BaseUDP(udp), hdl(EHS_INVALID_SOCKET)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace lwe
|
||||
|
||||
hdl = udp.hdl;
|
||||
|
||||
udp.hdl = LWE_INVALID_SOCKET;
|
||||
udp.hdl = EHS_INVALID_SOCKET;
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -79,7 +79,7 @@ namespace lwe
|
||||
|
||||
BaseUDP::operator=(udp);
|
||||
|
||||
hdl = LWE_INVALID_SOCKET;
|
||||
hdl = EHS_INVALID_SOCKET;
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -91,9 +91,9 @@ namespace lwe
|
||||
|
||||
Int_32 code = close(hdl);
|
||||
if (code == -1)
|
||||
LWE_LOG_INT("Error", 0, "Failed to close socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to close socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
|
||||
hdl = LWE_INVALID_SOCKET;
|
||||
hdl = EHS_INVALID_SOCKET;
|
||||
|
||||
bound = false;
|
||||
}
|
||||
@@ -128,7 +128,7 @@ namespace lwe
|
||||
{
|
||||
if (!IsValid())
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Attempted to receive while socket is not initialized.");
|
||||
EHS_LOG_INT("Error", 0, "Attempted to receive while socket is not initialized.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace lwe
|
||||
{
|
||||
Release();
|
||||
|
||||
LWE_LOG_INT("Error", 1, "Failed to receive with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to receive with error #" + Str_8::FromNum(code) + ".");
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -158,7 +158,7 @@ namespace lwe
|
||||
{
|
||||
Int_32 code = errno;
|
||||
|
||||
LWE_LOG_INT("Error", 2, "Failed to convert IPv6 address with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to convert IPv6 address with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
return received;
|
||||
}
|
||||
@@ -174,7 +174,7 @@ namespace lwe
|
||||
{
|
||||
Int_32 code = errno;
|
||||
|
||||
LWE_LOG_INT("Error", 2, "Failed to convert IPv4 address with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to convert IPv4 address with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
return received;
|
||||
}
|
||||
@@ -190,12 +190,12 @@ namespace lwe
|
||||
{
|
||||
if (!IsValid())
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Attempted to toggle blocking while socket is not initialized.");
|
||||
EHS_LOG_INT("Error", 0, "Attempted to toggle blocking while socket is not initialized.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (fcntl(hdl, F_SETFL, O_NONBLOCK, blocking) == -1)
|
||||
LWE_LOG_INT("Error", 1, "Failed to toggle non-blocking mode with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to toggle non-blocking mode with error #" + Str_8::FromNum(errno) + ".");
|
||||
}
|
||||
|
||||
bool UDP::IsBlocking() const
|
||||
@@ -205,7 +205,7 @@ namespace lwe
|
||||
|
||||
bool UDP::IsValid() const
|
||||
{
|
||||
return hdl != LWE_INVALID_SOCKET;
|
||||
return hdl != EHS_INVALID_SOCKET;
|
||||
}
|
||||
|
||||
void UDP::Bind_v6(const Str_8& address, const UInt_16 port)
|
||||
@@ -219,14 +219,14 @@ namespace lwe
|
||||
Int_32 code = inet_pton(AF_INET6, address, &result.sin6_addr);
|
||||
if (!code)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
return;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = errno;
|
||||
|
||||
LWE_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -238,7 +238,7 @@ namespace lwe
|
||||
int code = bind(hdl, (sockaddr*)&result, sizeof(sockaddr_in6));
|
||||
if (code == -1)
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -254,14 +254,14 @@ namespace lwe
|
||||
int code = inet_pton(AF_INET, address, &result.sin_addr);
|
||||
if (!code)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
return;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = errno;
|
||||
|
||||
LWE_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -273,7 +273,7 @@ namespace lwe
|
||||
int code = bind(hdl, (sockaddr*)&result, sizeof(sockaddr_in));
|
||||
if (code == -1)
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -282,7 +282,7 @@ namespace lwe
|
||||
{
|
||||
if (!IsValid())
|
||||
{
|
||||
LWE_LOG_INT("Info", 0, "Attempted to send while socket is not initialized.");
|
||||
EHS_LOG_INT("Info", 0, "Attempted to send while socket is not initialized.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -293,14 +293,14 @@ namespace lwe
|
||||
Int_32 code = inet_pton(AF_INET6, address, &result.sin6_addr);
|
||||
if (!code)
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT("Error", 1, "The given address, \"" + address + "\" is not valid.");
|
||||
return 0;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = errno;
|
||||
|
||||
LWE_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -309,7 +309,7 @@ namespace lwe
|
||||
{
|
||||
Int_32 dCode = errno;
|
||||
|
||||
LWE_LOG_INT("Error", 3, "Failed to send with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT("Error", 3, "Failed to send with error #" + Str_8::FromNum(dCode) + ".");
|
||||
|
||||
Release();
|
||||
|
||||
@@ -323,7 +323,7 @@ namespace lwe
|
||||
{
|
||||
if (!IsValid())
|
||||
{
|
||||
LWE_LOG_INT("Info", 0, "Attempted to send while socket is not initialized.");
|
||||
EHS_LOG_INT("Info", 0, "Attempted to send while socket is not initialized.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -334,14 +334,14 @@ namespace lwe
|
||||
int code = inet_pton(AF_INET, address, &result.sin_addr);
|
||||
if (!code)
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT("Error", 1, "The given address, \"" + address + "\" is not valid.");
|
||||
return 0;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = errno;
|
||||
|
||||
LWE_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -350,7 +350,7 @@ namespace lwe
|
||||
{
|
||||
Int_32 dCode = errno;
|
||||
|
||||
LWE_LOG_INT("Error", 3, "Failed to send with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT("Error", 3, "Failed to send with error #" + Str_8::FromNum(dCode) + ".");
|
||||
|
||||
Release();
|
||||
|
@@ -1,38 +1,38 @@
|
||||
#include "IO/Socket/UDP_W32.h"
|
||||
#include "io/socket/UDP_W32.h"
|
||||
#include "Log.h"
|
||||
|
||||
#include <WinSock2.h>
|
||||
#include <WS2tcpip.h>
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
UDP::~UDP()
|
||||
{
|
||||
if (hdl == LWE_INVALID_SOCKET)
|
||||
if (hdl == EHS_INVALID_SOCKET)
|
||||
return;
|
||||
|
||||
Int_32 code = closesocket(hdl);
|
||||
if (code == SOCKET_ERROR)
|
||||
LWE_LOG_INT("Error", 0, "Failed to close socket with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to close socket with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
if (WSACleanup() == SOCKET_ERROR)
|
||||
LWE_LOG_INT("Error", 1, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
}
|
||||
|
||||
UDP::UDP()
|
||||
: hdl(LWE_INVALID_SOCKET)
|
||||
: hdl(EHS_INVALID_SOCKET)
|
||||
{
|
||||
}
|
||||
|
||||
UDP::UDP(const AddrType addrType)
|
||||
: BaseUDP(addrType), hdl(LWE_INVALID_SOCKET)
|
||||
: BaseUDP(addrType), hdl(EHS_INVALID_SOCKET)
|
||||
{
|
||||
WSADATA data = {};
|
||||
|
||||
int code = WSAStartup(MAKEWORD(2, 2), &data);
|
||||
if (code)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "WSAStartup failed with the error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 0, "WSAStartup failed with the error #" + Str_8::FromNum(code) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -43,14 +43,14 @@ namespace lwe
|
||||
else
|
||||
return;
|
||||
|
||||
if (hdl == LWE_INVALID_SOCKET)
|
||||
if (hdl == EHS_INVALID_SOCKET)
|
||||
{
|
||||
UInt_32 code = WSAGetLastError();
|
||||
|
||||
LWE_LOG_INT("Error", 1, "Failed to create socket with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to create socket with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
if (WSACleanup() == SOCKET_ERROR)
|
||||
LWE_LOG_INT("Error", 2, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -59,11 +59,11 @@ namespace lwe
|
||||
UDP::UDP(UDP&& udp) noexcept
|
||||
: BaseUDP(std::move(udp)), hdl(udp.hdl)
|
||||
{
|
||||
udp.hdl = LWE_INVALID_SOCKET;
|
||||
udp.hdl = EHS_INVALID_SOCKET;
|
||||
}
|
||||
|
||||
UDP::UDP(const UDP& udp)
|
||||
: BaseUDP(udp), hdl(LWE_INVALID_SOCKET)
|
||||
: BaseUDP(udp), hdl(EHS_INVALID_SOCKET)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace lwe
|
||||
|
||||
hdl = udp.hdl;
|
||||
|
||||
udp.hdl = LWE_INVALID_SOCKET;
|
||||
udp.hdl = EHS_INVALID_SOCKET;
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -88,7 +88,7 @@ namespace lwe
|
||||
|
||||
BaseUDP::operator=(udp);
|
||||
|
||||
hdl = LWE_INVALID_SOCKET;
|
||||
hdl = EHS_INVALID_SOCKET;
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -100,12 +100,12 @@ namespace lwe
|
||||
|
||||
Int_32 code = closesocket(hdl);
|
||||
if (code == SOCKET_ERROR)
|
||||
LWE_LOG_INT("Error", 0, "Failed to close socket with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to close socket with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
hdl = LWE_INVALID_SOCKET;
|
||||
hdl = EHS_INVALID_SOCKET;
|
||||
|
||||
if (WSACleanup() == SOCKET_ERROR)
|
||||
LWE_LOG_INT("Error", 1, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
|
||||
bound = false;
|
||||
}
|
||||
@@ -140,7 +140,7 @@ namespace lwe
|
||||
{
|
||||
if (!IsValid())
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Attempted to receive while socket is not initialized.");
|
||||
EHS_LOG_INT("Error", 0, "Attempted to receive while socket is not initialized.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ namespace lwe
|
||||
{
|
||||
Release();
|
||||
|
||||
LWE_LOG_INT("Error", 1, "Failed to receive with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to receive with error #" + Str_8::FromNum(code) + ".");
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -169,7 +169,7 @@ namespace lwe
|
||||
{
|
||||
Int_32 code = WSAGetLastError();
|
||||
|
||||
LWE_LOG_INT("Error", 2, "Failed to convert IPv6 address with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to convert IPv6 address with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
return received;
|
||||
}
|
||||
@@ -185,7 +185,7 @@ namespace lwe
|
||||
{
|
||||
Int_32 code = WSAGetLastError();
|
||||
|
||||
LWE_LOG_INT("Error", 2, "Failed to convert IPv4 address with error #" + Str_8::FromNum(code) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to convert IPv4 address with error #" + Str_8::FromNum(code) + ".");
|
||||
|
||||
return received;
|
||||
}
|
||||
@@ -201,7 +201,7 @@ namespace lwe
|
||||
{
|
||||
if (!IsValid())
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Attempted to toggle blocking while socket is not initialized.");
|
||||
EHS_LOG_INT("Error", 0, "Attempted to toggle blocking while socket is not initialized.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -209,21 +209,21 @@ namespace lwe
|
||||
|
||||
int result = ioctlsocket(hdl, FIONBIO, &r);
|
||||
if (result != NO_ERROR)
|
||||
LWE_LOG_INT("Error", 1, "Failed to toggle non-blocking mode with error #" + Str_8::FromNum(result) + ".");
|
||||
EHS_LOG_INT("Error", 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)
|
||||
LWE_LOG_INT("Error", 0, "Failed to retrieve socket info.");
|
||||
EHS_LOG_INT("Error", 0, "Failed to retrieve socket info.");
|
||||
|
||||
return (bool)r;
|
||||
}
|
||||
|
||||
bool UDP::IsValid() const
|
||||
{
|
||||
return hdl != LWE_INVALID_SOCKET;
|
||||
return hdl != EHS_INVALID_SOCKET;
|
||||
}
|
||||
|
||||
void UDP::Bind_v6(const Str_8& address, const UInt_16 port)
|
||||
@@ -237,14 +237,14 @@ namespace lwe
|
||||
Int_32 code = inet_pton(AF_INET6, address, &result.sin6_addr);
|
||||
if (!code)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
return;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = WSAGetLastError();
|
||||
|
||||
LWE_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -256,7 +256,7 @@ namespace lwe
|
||||
int code = bind(hdl, (sockaddr*)&result, sizeof(sockaddr_in6));
|
||||
if (code == SOCKET_ERROR)
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -272,14 +272,14 @@ namespace lwe
|
||||
int code = inet_pton(AF_INET, address, &result.sin_addr);
|
||||
if (!code)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT("Error", 0, "The given address, \"" + address + "\" is not valid.");
|
||||
return;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = WSAGetLastError();
|
||||
|
||||
LWE_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -291,7 +291,7 @@ namespace lwe
|
||||
int code = bind(hdl, (sockaddr*)&result, sizeof(sockaddr_in));
|
||||
if (code == SOCKET_ERROR)
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Failed to bind socket with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -300,7 +300,7 @@ namespace lwe
|
||||
{
|
||||
if (!IsValid())
|
||||
{
|
||||
LWE_LOG_INT("Info", 0, "Attempted to send while socket is not initialized.");
|
||||
EHS_LOG_INT("Info", 0, "Attempted to send while socket is not initialized.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -311,14 +311,14 @@ namespace lwe
|
||||
Int_32 code = inet_pton(AF_INET6, addr, &result.sin6_addr);
|
||||
if (!code)
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT("Error", 1, "The given address, \"" + address + "\" is not valid.");
|
||||
return 0;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = WSAGetLastError();
|
||||
|
||||
LWE_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@ namespace lwe
|
||||
{
|
||||
Int_32 dCode = WSAGetLastError();
|
||||
|
||||
LWE_LOG_INT("Error", 3, "Failed to send with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT("Error", 3, "Failed to send with error #" + Str_8::FromNum(dCode) + ".");
|
||||
|
||||
Release();
|
||||
|
||||
@@ -341,7 +341,7 @@ namespace lwe
|
||||
{
|
||||
if (!IsValid())
|
||||
{
|
||||
LWE_LOG_INT("Info", 0, "Attempted to send while socket is not initialized.");
|
||||
EHS_LOG_INT("Info", 0, "Attempted to send while socket is not initialized.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -352,14 +352,14 @@ namespace lwe
|
||||
int code = inet_pton(AF_INET, addr, &result.sin_addr);
|
||||
if (!code)
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "The given address, \"" + address + "\" is not valid.");
|
||||
EHS_LOG_INT("Error", 1, "The given address, \"" + address + "\" is not valid.");
|
||||
return 0;
|
||||
}
|
||||
else if (code == -1)
|
||||
{
|
||||
Int_32 dCode = WSAGetLastError();
|
||||
|
||||
LWE_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT("Error", 1, "Failed to convert address with error #" + Str_8::FromNum(dCode) + ".");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -368,7 +368,7 @@ namespace lwe
|
||||
{
|
||||
Int_32 dCode = WSAGetLastError();
|
||||
|
||||
LWE_LOG_INT("Error", 3, "Failed to send with error #" + Str_8::FromNum(dCode) + ".");
|
||||
EHS_LOG_INT("Error", 3, "Failed to send with error #" + Str_8::FromNum(dCode) + ".");
|
||||
|
||||
Release();
|
||||
|
@@ -1,9 +1,9 @@
|
||||
#include "IO/Socket/RestAPIs/Spotify.h"
|
||||
#include "IO/Socket/DNS.h"
|
||||
#include "System/System.h"
|
||||
#include "io/socket/rest/Spotify.h"
|
||||
#include "io/socket/DNS.h"
|
||||
#include "system/System.h"
|
||||
#include "URI.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
const Str_8 Spotify::trackUriPrefix = "https://open.spotify.com/track/";
|
||||
|
||||
@@ -91,19 +91,19 @@ namespace lwe
|
||||
|
||||
if (authRes.GetCode() == 400)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Could not authorize with Spotify because the client id was invalid.");
|
||||
EHS_LOG_INT("Error", 0, "Could not authorize with Spotify because the client id was invalid.");
|
||||
|
||||
return false;
|
||||
}
|
||||
else if (authRes.GetCode() == 403)
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "Could not authorize with Spotify because the secret was invalid.");
|
||||
EHS_LOG_INT("Error", 1, "Could not authorize with Spotify because the secret was invalid.");
|
||||
|
||||
return false;
|
||||
}
|
||||
else if (authRes.GetCode() != 200)
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Could not authorize with Spotify with code " + Str_8::FromNum(authRes.GetCode()) + ".");
|
||||
EHS_LOG_INT("Error", 2, "Could not authorize with Spotify with code " + Str_8::FromNum(authRes.GetCode()) + ".");
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -608,7 +608,7 @@ namespace lwe
|
||||
|
||||
if (res.GetCode() != 200)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to reauthorize with Spotify with code #" + Str_8::FromNum(res.GetCode()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to reauthorize with Spotify with code #" + Str_8::FromNum(res.GetCode()) + ".");
|
||||
client.Release();
|
||||
return false;
|
||||
}
|
@@ -1,9 +1,9 @@
|
||||
#include "IO/Socket/RestAPIs/Twitch.h"
|
||||
#include "IO/Socket/DNS.h"
|
||||
#include "System/System.h"
|
||||
#include "io/socket/rest/Twitch.h"
|
||||
#include "io/socket/DNS.h"
|
||||
#include "system/System.h"
|
||||
#include "URI.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
Twitch::~Twitch()
|
||||
{
|
||||
@@ -89,21 +89,21 @@ namespace lwe
|
||||
{
|
||||
client.Release();
|
||||
|
||||
LWE_LOG_INT("Error", 0, "Could not authorize with Twitch because the client id was invalid.");
|
||||
EHS_LOG_INT("Error", 0, "Could not authorize with Twitch because the client id was invalid.");
|
||||
|
||||
return false;
|
||||
} else if (authRes.GetCode() == 403)
|
||||
{
|
||||
client.Release();
|
||||
|
||||
LWE_LOG_INT("Error", 1, "Could not authorize with Twitch because the secret was invalid.");
|
||||
EHS_LOG_INT("Error", 1, "Could not authorize with Twitch because the secret was invalid.");
|
||||
|
||||
return false;
|
||||
} else if (authRes.GetCode() != 200)
|
||||
{
|
||||
client.Release();
|
||||
|
||||
LWE_LOG_INT("Error", 2, "Could not authorize with Twitch.");
|
||||
EHS_LOG_INT("Error", 2, "Could not authorize with Twitch.");
|
||||
|
||||
return false;
|
||||
}
|
@@ -1,8 +1,8 @@
|
||||
#include "IO/Socket/RestAPIs/TwitchChat.h"
|
||||
#include "IO/Socket/DNS.h"
|
||||
#include "IO/Console.h"
|
||||
#include "io/socket/rest/TwitchChat.h"
|
||||
#include "io/socket/DNS.h"
|
||||
#include "io/Console.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
TwitchChat::~TwitchChat()
|
||||
{
|
@@ -1,7 +1,7 @@
|
||||
#include "Json/Json.h"
|
||||
#include "json/Json.h"
|
||||
#include "Log.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
Json::~Json()
|
||||
{
|
||||
@@ -211,7 +211,7 @@ namespace lwe
|
||||
{
|
||||
if (!isIndex)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Index has ended, but never started.");
|
||||
EHS_LOG_INT("Error", 0, "Index has ended, but never started.");
|
||||
return levels;
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ namespace lwe
|
||||
levels.Push(Str_8(start, i - start));
|
||||
else
|
||||
{
|
||||
LWE_LOG_INT("Error", 1, "Index has no value.");
|
||||
EHS_LOG_INT("Error", 1, "Index has no value.");
|
||||
return levels;
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ namespace lwe
|
||||
}
|
||||
else if (isIndex && (*i < '0' || *i > '9'))
|
||||
{
|
||||
LWE_LOG_INT("Error", 2, "Index has an invalid character, \"" + Str_8(i, 1) + "\". Index must be a whole number.");
|
||||
EHS_LOG_INT("Error", 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 lwe
|
||||
}
|
||||
else if (!isIndex && *i != '-' && *i != '_' && (*i < 'A' || *i > 'Z') && (*i < 'a' || *i > 'z'))
|
||||
{
|
||||
LWE_LOG_INT("Error", 3, "Member variable has an invalid character, \"" + Str_8(i, 1) + "\".");
|
||||
EHS_LOG_INT("Error", 3, "Member variable has an invalid character, \"" + Str_8(i, 1) + "\".");
|
||||
return levels;
|
||||
}
|
||||
}
|
@@ -1,10 +1,10 @@
|
||||
#include "Json/JsonArray.h"
|
||||
#include "Json/JsonObj.h"
|
||||
#include "Json/JsonBool.h"
|
||||
#include "Json/JsonNum.h"
|
||||
#include "Json/JsonStr.h"
|
||||
#include "json/JsonArray.h"
|
||||
#include "json/JsonObj.h"
|
||||
#include "json/JsonBool.h"
|
||||
#include "json/JsonNum.h"
|
||||
#include "json/JsonStr.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
JsonArray::~JsonArray()
|
||||
{
|
@@ -1,6 +1,6 @@
|
||||
#include "Json/JsonBase.h"
|
||||
#include "json/JsonBase.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
JsonBase::JsonBase()
|
||||
: type(JsonType::NULLOBJ)
|
@@ -1,6 +1,6 @@
|
||||
#include "Json/JsonBool.h"
|
||||
#include "json/JsonBool.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
JsonBool::JsonBool()
|
||||
: JsonBase(JsonType::BOOL), value(false)
|
@@ -1,6 +1,6 @@
|
||||
#include "Json/JsonNum.h"
|
||||
#include "json/JsonNum.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
JsonNum::JsonNum()
|
||||
: JsonBase(JsonType::NUM), value(0.0f)
|
@@ -1,7 +1,7 @@
|
||||
#include "Json/JsonObj.h"
|
||||
#include "Json/JsonVar.h"
|
||||
#include "json/JsonObj.h"
|
||||
#include "json/JsonVar.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
JsonObj::~JsonObj()
|
||||
{
|
@@ -1,6 +1,6 @@
|
||||
#include "Json/JsonStr.h"
|
||||
#include "json/JsonStr.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
JsonStr::JsonStr()
|
||||
: JsonBase(JsonType::STR)
|
@@ -1,12 +1,12 @@
|
||||
#include "Json/JsonVar.h"
|
||||
#include "Json/JsonBase.h"
|
||||
#include "Json/JsonObj.h"
|
||||
#include "Json/JsonArray.h"
|
||||
#include "Json/JsonBool.h"
|
||||
#include "Json/JsonNum.h"
|
||||
#include "Json/JsonStr.h"
|
||||
#include "json/JsonVar.h"
|
||||
#include "json/JsonBase.h"
|
||||
#include "json/JsonObj.h"
|
||||
#include "json/JsonArray.h"
|
||||
#include "json/JsonBool.h"
|
||||
#include "json/JsonNum.h"
|
||||
#include "json/JsonStr.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
JsonVar::~JsonVar()
|
||||
{
|
@@ -1,6 +1,6 @@
|
||||
#include "System/BaseMutex.h"
|
||||
#include "system/BaseMutex.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
BaseMutex::~BaseMutex()
|
||||
{
|
@@ -1,6 +1,6 @@
|
||||
#include "System/BaseOpen.h"
|
||||
#include "system/BaseOpen.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
BaseOpen::BaseOpen()
|
||||
{
|
@@ -1,6 +1,6 @@
|
||||
#include "System/BaseSemaphore.h"
|
||||
#include "system/BaseSemaphore.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
BaseSemaphore::BaseSemaphore()
|
||||
: initial(0)
|
@@ -1,6 +1,6 @@
|
||||
#include "System/BaseSystem.h"
|
||||
#include "system/BaseSystem.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
void BaseSystem::OpenURI(const Str_8& uri)
|
||||
{
|
@@ -1,20 +1,20 @@
|
||||
#include "System/CPU.h"
|
||||
#include "system/CPU.h"
|
||||
#include "Log.h"
|
||||
#include "IO/File.h"
|
||||
#include "Json/Json.h"
|
||||
#include "System/Thread.h"
|
||||
#include "io/File.h"
|
||||
#include "json/Json.h"
|
||||
#include "system/Thread.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
#ifdef LWE_OS_LINUX
|
||||
#ifdef EHS_OS_LINUX
|
||||
UInt_64 CPU::TSC_Freq = 0;
|
||||
#endif
|
||||
|
||||
Architecture CPU::GetArchitecture()
|
||||
{
|
||||
#if defined(LWE_ARCH_X64)
|
||||
#if defined(EHS_ARCH_X64)
|
||||
return Architecture::X64;
|
||||
#elif defined(LWE_ARCH_ARM64)
|
||||
#elif defined(EHS_ARCH_ARM64)
|
||||
return Architecture::ARM64;
|
||||
#else
|
||||
return Architecture::UNKNOWN;
|
||||
@@ -28,9 +28,9 @@ namespace lwe
|
||||
|
||||
Endianness CPU::GetEndianness()
|
||||
{
|
||||
#if defined(LWE_LITTLE_ENDIAN)
|
||||
#if defined(EHS_LITTLE_ENDIAN)
|
||||
return Endianness::LE;
|
||||
#elif defined(LWE_BIG_ENDIAN)
|
||||
#elif defined(EHS_BIG_ENDIAN)
|
||||
return Endianness::BE;
|
||||
#else
|
||||
UInt_16 tmp = 1;
|
||||
@@ -43,12 +43,12 @@ namespace lwe
|
||||
|
||||
UInt_64 CPU::GetTSC_Freq()
|
||||
{
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
LARGE_INTEGER frequency = {};
|
||||
QueryPerformanceFrequency(&frequency);
|
||||
|
||||
return frequency.QuadPart;
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
if (!TSC_Freq)
|
||||
TSC_Freq = RetrieveTSC_Freq();
|
||||
|
||||
@@ -60,28 +60,28 @@ namespace lwe
|
||||
|
||||
UInt_64 CPU::GetTSC()
|
||||
{
|
||||
#if defined(LWE_OS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
LARGE_INTEGER count = {};
|
||||
QueryPerformanceCounter(&count);
|
||||
|
||||
return count.QuadPart;
|
||||
#elif defined(LWE_OS_LINUX)
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
TSC tsc;
|
||||
RDTSCP(&tsc);
|
||||
|
||||
#if defined(LWE_ARCH_X64)
|
||||
#if defined(EHS_ARCH_X64)
|
||||
UInt_64 result = 0;
|
||||
|
||||
#if defined(LWE_LITTLE_ENDIAN)
|
||||
#if defined(EHS_LITTLE_ENDIAN)
|
||||
((UInt_32*)&result)[0] = tsc.lowCount;
|
||||
((UInt_32*)&result)[1] = tsc.highCount;
|
||||
#elif defined(LWE_BIG_ENDIAN)
|
||||
#elif defined(EHS_BIG_ENDIAN)
|
||||
((UInt_32*)&result)[0] = tsc.highCount;
|
||||
((UInt_32*)&result)[1] = tsc.lowCount;
|
||||
#endif
|
||||
|
||||
return result;
|
||||
#elif defined(LWE_ARCH_X86)
|
||||
#elif defined(EHS_ARCH_X86)
|
||||
return tsc.lowPart;
|
||||
#endif
|
||||
#endif
|
@@ -1,6 +1,6 @@
|
||||
#include "System/CPU.h"
|
||||
#include "system/CPU.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
void CPU::RDTSCP(TSC* tsc)
|
||||
{
|
@@ -1,25 +1,25 @@
|
||||
#include "System/FileSystem.h"
|
||||
#include "system/FileSystem.h"
|
||||
#include "Log.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <cstring>
|
||||
#include <cerrno>
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
void FileSystem::SetWorkingDir(const Str_8& dir)
|
||||
{
|
||||
int code = chdir(dir);
|
||||
if (code == -1)
|
||||
LWE_LOG_INT("Error", 0, strerror(errno));
|
||||
EHS_LOG_INT("Error", 0, strerror(errno));
|
||||
}
|
||||
|
||||
Str_8 FileSystem::GetWorkingDir()
|
||||
{
|
||||
char result[LWE_MAX_PATH];
|
||||
char result[EHS_MAX_PATH];
|
||||
|
||||
if (!getcwd(result, LWE_MAX_PATH))
|
||||
LWE_LOG_INT("Error", 0, strerror(errno));
|
||||
if (!getcwd(result, EHS_MAX_PATH))
|
||||
EHS_LOG_INT("Error", 0, strerror(errno));
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -27,6 +27,6 @@ namespace lwe
|
||||
void FileSystem::SetOwner(const Str_8& dir, const UInt_32 userId, const UInt_32 groupId)
|
||||
{
|
||||
if (chown(dir, userId, groupId) == -1)
|
||||
LWE_LOG_INT("Error", 0, strerror(errno));
|
||||
EHS_LOG_INT("Error", 0, strerror(errno));
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
#include "System/Mutex_PT.h"
|
||||
#include "system/Mutex_PT.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
Mutex::~Mutex()
|
||||
{
|
@@ -1,8 +1,8 @@
|
||||
#include "System/Mutex_W32.h"
|
||||
#include "system/Mutex_W32.h"
|
||||
#include "Str.h"
|
||||
#include "Log.h"
|
||||
|
||||
namespace lwe
|
||||
namespace ehs
|
||||
{
|
||||
Mutex::~Mutex()
|
||||
{
|
||||
@@ -10,7 +10,7 @@ namespace lwe
|
||||
return;
|
||||
|
||||
if (!CloseHandle(hdl))
|
||||
LWE_LOG_INT("Error", 0, "Failed to uninitialize mutex with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to uninitialize mutex with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
}
|
||||
|
||||
Mutex::Mutex()
|
||||
@@ -43,7 +43,7 @@ namespace lwe
|
||||
hdl = CreateMutexW(nullptr, FALSE, nullptr);
|
||||
if (!hdl)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to create mutex with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to create mutex with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace lwe
|
||||
return;
|
||||
|
||||
if (!CloseHandle(hdl))
|
||||
LWE_LOG_INT("Error", 0, "Failed to uninitialize mutex with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to uninitialize mutex with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
initialized = false;
|
||||
}
|
||||
@@ -66,9 +66,9 @@ namespace lwe
|
||||
if (locked)
|
||||
return;
|
||||
|
||||
if (WaitForSingleObject(hdl, LWE_INFINITE) == WAIT_FAILED)
|
||||
if (WaitForSingleObject(hdl, EHS_INFINITE) == WAIT_FAILED)
|
||||
{
|
||||
LWE_LOG_INT("Error", 0, "Failed to lock mutex with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to lock mutex with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace lwe
|
||||
return;
|
||||
|
||||
if (!ReleaseMutex(hdl))
|
||||
LWE_LOG_INT("Error", 0, "Failed to unlock mutex with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
EHS_LOG_INT("Error", 0, "Failed to unlock mutex with error #" + Str_8::FromNum(GetLastError()) + ".");
|
||||
|
||||
locked = false;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user