diff --git a/CMakeLists.txt b/CMakeLists.txt index 65cf5fb..ee5828a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,138 +83,138 @@ set(EHS_SOURCES include/ShdPtr.h include/WkPtr.h - src/Database/DVar.cpp include/Database/DVar.h + src/database/DVar.cpp include/database/DVar.h - src/System/CPU.cpp include/System/CPU.h - src/System/Thread.cpp include/System/Thread.h - src/System/BaseMutex.cpp include/System/BaseMutex.h - src/System/BaseSemaphore.cpp include/System/BaseSemaphore.h - src/System/BaseSystem.cpp include/System/BaseSystem.h - src/System/BaseOpen.cpp include/System/BaseOpen.h - include/System/Architecture.h - include/System/Mutex.h - include/System/Open.h - include/System/OS.h - include/System/Semaphore.h - include/System/System.h + src/system/CPU.cpp include/system/CPU.h + src/system/Thread.cpp include/system/Thread.h + src/system/BaseMutex.cpp include/system/BaseMutex.h + src/system/BaseSemaphore.cpp include/system/BaseSemaphore.h + src/system/BaseSystem.cpp include/system/BaseSystem.h + src/system/BaseOpen.cpp include/system/BaseOpen.h + include/system/Architecture.h + include/system/Mutex.h + include/system/Open.h + include/system/OS.h + include/system/Semaphore.h + include/system/System.h - src/Json/Json.cpp include/Json/Json.h - src/Json/JsonBase.cpp include/Json/JsonBase.h - src/Json/JsonNum.cpp include/Json/JsonNum.h - src/Json/JsonBool.cpp include/Json/JsonBool.h - src/Json/JsonStr.cpp include/Json/JsonStr.h - src/Json/JsonObj.cpp include/Json/JsonObj.h - src/Json/JsonArray.cpp include/Json/JsonArray.h - src/Json/JsonVar.cpp include/Json/JsonVar.h + src/json/Json.cpp include/json/Json.h + src/json/JsonBase.cpp include/json/JsonBase.h + src/json/JsonNum.cpp include/json/JsonNum.h + src/json/JsonBool.cpp include/json/JsonBool.h + src/json/JsonStr.cpp include/json/JsonStr.h + src/json/JsonObj.cpp include/json/JsonObj.h + src/json/JsonArray.cpp include/json/JsonArray.h + src/json/JsonVar.cpp include/json/JsonVar.h - src/IO/Console.cpp include/IO/Console.h - src/IO/RIFF_Chunk.cpp include/IO/RIFF_Chunk.h - src/IO/RIFF.cpp include/IO/RIFF.h - src/IO/BaseWindow.cpp include/IO/BaseWindow.h - src/IO/BaseFile.cpp include/IO/BaseFile.h - src/IO/Glyph.cpp include/IO/Glyph.h - src/IO/FontAtlas.cpp include/IO/FontAtlas.h - src/IO/BaseFileMonitor.cpp include/IO/BaseFileMonitor.h - include/IO/COM.h - include/IO/File.h - include/IO/FileMonitor.h - include/IO/Window.h + src/io/Console.cpp include/io/Console.h + src/io/RIFF_Chunk.cpp include/io/RIFF_Chunk.h + src/io/RIFF.cpp include/io/RIFF.h + src/io/BaseWindow.cpp include/io/BaseWindow.h + src/io/BaseFile.cpp include/io/BaseFile.h + src/io/Glyph.cpp include/io/Glyph.h + src/io/FontAtlas.cpp include/io/FontAtlas.h + src/io/BaseFileMonitor.cpp include/io/BaseFileMonitor.h + include/io/COM.h + include/io/File.h + include/io/FileMonitor.h + include/io/Window.h - src/IO/Socket/Request.cpp include/IO/Socket/Request.h - src/IO/Socket/Response.cpp include/IO/Socket/Response.h - src/IO/Socket/DNS.cpp include/IO/Socket/DNS.h - src/IO/Socket/BaseUDP.cpp include/IO/Socket/BaseUDP.h - src/IO/Socket/BaseTCP.cpp include/IO/Socket/BaseTCP.h - src/IO/Socket/Comms.cpp include/IO/Socket/Comms.h - src/IO/Socket/CommsSystem.cpp include/IO/Socket/CommsSystem.h - src/IO/Socket/Operation.cpp include/IO/Socket/Operation.h - src/IO/Socket/Fragments.cpp include/IO/Socket/Fragments.h - src/IO/Socket/Endpoint.cpp include/IO/Socket/Endpoint.h - src/IO/Socket/SSL.cpp include/IO/Socket/SSL.h + src/io/socket/Request.cpp include/io/socket/Request.h + src/io/socket/Response.cpp include/io/socket/Response.h + src/io/socket/DNS.cpp include/io/socket/DNS.h + src/io/socket/BaseUDP.cpp include/io/socket/BaseUDP.h + src/io/socket/BaseTCP.cpp include/io/socket/BaseTCP.h + src/io/socket/Comms.cpp include/io/socket/Comms.h + src/io/socket/CommsSystem.cpp include/io/socket/CommsSystem.h + src/io/socket/Operation.cpp include/io/socket/Operation.h + src/io/socket/Fragments.cpp include/io/socket/Fragments.h + src/io/socket/Endpoint.cpp include/io/socket/Endpoint.h + src/io/socket/SSL.cpp include/io/socket/SSL.h - src/IO/Socket/RestAPIs/Twitch.cpp include/IO/Socket/RestAPIs/Twitch.h - src/IO/Socket/RestAPIs/TwitchChat.cpp include/IO/Socket/RestAPIs/TwitchChat.h - src/IO/Socket/RestAPIs/Spotify.cpp include/IO/Socket/RestAPIs/Spotify.h - include/IO/Socket/Socket.h - include/IO/Socket/TCP.h - include/IO/Socket/UDP.h - include/IO/Socket/Utils.h + src/io/socket/rest/Twitch.cpp include/io/socket/rest/Twitch.h + src/io/socket/rest/TwitchChat.cpp include/io/socket/rest/TwitchChat.h + src/io/socket/rest/Spotify.cpp include/io/socket/rest/Spotify.h + include/io/socket/Socket.h + include/io/socket/TCP.h + include/io/socket/UDP.h + include/io/socket/Utils.h - src/IO/Audio/Audio.cpp include/IO/Audio/Audio.h - src/IO/Audio/BaseAudioDevice.cpp include/IO/Audio/BaseAudioDevice.h - src/IO/Audio/AudioCodec.cpp include/IO/Audio/AudioCodec.h - include/IO/Audio/AudioDevice.h + src/io/audio/Audio.cpp include/io/audio/Audio.h + src/io/audio/BaseAudioDevice.cpp include/io/audio/BaseAudioDevice.h + src/io/audio/AudioCodec.cpp include/io/audio/AudioCodec.h + include/io/audio/AudioDevice.h - src/IO/Img/PNG.cpp include/IO/Img/PNG.h - src/IO/Img/Img.cpp include/IO/Img/Img.h - src/IO/Img/PNG_Chunk.cpp include/IO/Img/PNG_Chunk.h - src/IO/Img/ImgCodec.cpp include/IO/Img/ImgCodec.h + src/io/img/PNG.cpp include/io/img/PNG.h + src/io/img/Img.cpp include/io/img/Img.h + src/io/img/PNG_Chunk.cpp include/io/img/PNG_Chunk.h + src/io/img/ImgCodec.cpp include/io/img/ImgCodec.h - include/IO/Model/Vertex.h - src/IO/Model/Mesh.cpp include/IO/Model/Mesh.h - src/IO/Model/Bone.cpp include/IO/Model/Bone.h - src/IO/Model/Model.cpp include/IO/Model/Model.h - src/IO/Model/Animation.cpp include/IO/Model/Animation.h - src/IO/Model/AnimBone.cpp include/IO/Model/AnimBone.h - src/IO/Model/KeyFrame.cpp include/IO/Model/KeyFrame.h - src/IO/Model/PropertyChange.cpp include/IO/Model/PropertyChange.h + include/io/model/Vertex.h + src/io/model/Mesh.cpp include/io/model/Mesh.h + src/io/model/Bone.cpp include/io/model/Bone.h + src/io/model/Model.cpp include/io/model/Model.h + src/io/model/Animation.cpp include/io/model/Animation.h + src/io/model/AnimBone.cpp include/io/model/AnimBone.h + src/io/model/KeyFrame.cpp include/io/model/KeyFrame.h + src/io/model/PropertyChange.cpp include/io/model/PropertyChange.h - src/IO/HID/ButtonState.cpp include/IO/HID/ButtonState.h - src/IO/HID/Button.cpp include/IO/HID/Button.h - src/IO/HID/Mouse.cpp include/IO/HID/Mouse.h - src/IO/HID/Keyboard.cpp include/IO/HID/Keyboard.h - src/IO/HID/HID.cpp include/IO/HID/HID.h - src/IO/HID/InputHandler.cpp include/IO/HID/InputHandler.h - src/IO/HID/Input.cpp include/IO/HID/Input.h + src/io/hid/ButtonState.cpp include/io/hid/ButtonState.h + src/io/hid/Button.cpp include/io/hid/Button.h + src/io/hid/Mouse.cpp include/io/hid/Mouse.h + src/io/hid/Keyboard.cpp include/io/hid/Keyboard.h + src/io/hid/HID.cpp include/io/hid/HID.h + src/io/hid/InputHandler.cpp include/io/hid/InputHandler.h + src/io/hid/Input.cpp include/io/hid/Input.h ) if (IS_OS_WINDOWS) list(APPEND EHS_SOURCES - src/IO/Socket/UDP_W32.cpp include/IO/Socket/UDP_W32.h - src/IO/Socket/TCP_W32.cpp include/IO/Socket/TCP_W32.h - src/System/Semaphore_W32.cpp include/System/Semaphore_W32.h - src/System/System_W32.cpp include/System/System_W32.h - src/System/Mutex_W32.cpp include/System/Mutex_W32.h - src/System/Open_W32.cpp include/System/Open_W32.h - src/IO/Audio/AudioDevice_W32.cpp include/IO/Audio/AudioDevice_W32.h - src/IO/MsgBox.cpp include/IO/MsgBox.h - src/IO/File_W32.cpp include/IO/File_W32.h - src/IO/FileMonitor_W32.cpp include/IO/FileMonitor_W32.h - src/IO/Window_W32.cpp include/IO/Window_W32.h - src/IO/COM.cpp include/IO/COM.h - src/System/CPU_MSVC_AMD64.asm src/HRNG_MSVC.asm src/Math_MSVC_AMD64.asm + src/io/socket/UDP_W32.cpp include/io/socket/UDP_W32.h + src/io/socket/TCP_W32.cpp include/io/socket/TCP_W32.h + src/system/Semaphore_W32.cpp include/system/Semaphore_W32.h + src/system/System_W32.cpp include/system/System_W32.h + src/system/Mutex_W32.cpp include/system/Mutex_W32.h + src/system/Open_W32.cpp include/system/Open_W32.h + src/io/audio/audioDevice_W32.cpp include/io/audio/audioDevice_W32.h + src/io/MsgBox.cpp include/io/MsgBox.h + src/io/File_W32.cpp include/io/File_W32.h + src/io/FileMonitor_W32.cpp include/io/FileMonitor_W32.h + src/io/Window_W32.cpp include/io/Window_W32.h + src/io/COM.cpp include/io/COM.h + src/system/CPU_MSVC_AMD64.asm src/HRNG_MSVC.asm src/Math_MSVC_AMD64.asm ) elseif (IS_OS_LINUX) list(APPEND EHS_SOURCES - src/IO/Socket/UDP_BSD.cpp include/IO/Socket/UDP_BSD.h - src/IO/Socket/TCP_BSD.cpp include/IO/Socket/TCP_BSD.h - src/System/Semaphore_P.cpp include/System/Semaphore_P.h - src/System/System_LNX.cpp include/System/System_LNX.h - src/System/Open_UNX.cpp include/System/Open_UNX.h - src/IO/File_UNX.cpp include/IO/File_UNX.h - src/IO/FileMonitor_UNX.cpp include/IO/FileMonitor_UNX.h - src/System/Mutex_PT.cpp include/System/Mutex_PT.h - src/IO/Audio/AudioDevice_ALSA.cpp include/IO/Audio/AudioDevice_ALSA.h - src/System/FileSystem.cpp include/System/FileSystem.h - src/System/User.cpp include/System/User.h + src/io/socket/UDP_BSD.cpp include/io/socket/UDP_BSD.h + src/io/socket/TCP_BSD.cpp include/io/socket/TCP_BSD.h + src/system/Semaphore_P.cpp include/system/Semaphore_P.h + src/system/System_LNX.cpp include/system/System_LNX.h + src/system/Open_UNX.cpp include/system/Open_UNX.h + src/io/File_UNX.cpp include/io/File_UNX.h + src/io/FileMonitor_UNX.cpp include/io/FileMonitor_UNX.h + src/system/Mutex_PT.cpp include/system/Mutex_PT.h + src/io/audio/AudioDevice_ALSA.cpp include/io/audio/AudioDevice_ALSA.h + src/system/FileSystem.cpp include/system/FileSystem.h + src/system/User.cpp include/system/User.h ) set(LINUX_WINDOW_SYSTEM "Wayland" CACHE STRING "Linux Window System") if (LINUX_WINDOW_SYSTEM STREQUAL "Wayland") - add_compile_definitions(LWE_WS_WAYLAND) - list(APPEND EHS_SOURCES src/IO/xdg-shell-protocol.c include/IO/xdg-shell-client-protocol.h src/IO/Window_Way.cpp include/IO/Window_Way.h) + add_compile_definitions(EHS_WS_WAYLAND) + list(APPEND EHS_SOURCES src/io/xdg-shell-protocol.c include/io/xdg-shell-client-protocol.h src/io/Window_Way.cpp include/io/Window_Way.h) message("Building for Wayland.") elseif (LINUX_WINDOW_SYSTEM STREQUAL "XCB") - add_compile_definitions(LWE_WS_XCB) - list(APPEND EHS_SOURCES src/IO/Window_XCB.cpp include/IO/Window_XCB.h) + add_compile_definitions(EHS_WS_XCB) + list(APPEND EHS_SOURCES src/io/Window_XCB.cpp include/io/Window_XCB.h) message("Building for XCB.") endif () if (IS_ARCH_AMD64) - list(APPEND EHS_SOURCES src/System/CPU_GCC_AMD64.asm src/HRNG_GCC.asm src/Math_GCC_AMD64.asm) + list(APPEND EHS_SOURCES src/system/CPU_GCC_AMD64.asm src/HRNG_GCC.asm src/Math_GCC_AMD64.asm) elseif (IS_ARCH_ARM64) - list(APPEND EHS_SOURCES src/System/CPU_ARM64.cpp src/HRNG_ARM64.cpp src/Math_GCC_ARM64.s) + list(APPEND EHS_SOURCES src/system/CPU_ARM64.cpp src/HRNG_ARM64.cpp src/Math_GCC_ARM64.s) endif () endif() @@ -259,7 +259,7 @@ if (IS_ARCH_AMD64) if (IS_OS_WINDOWS) target_link_libraries(StrToHash ws2_32 avrt LWE) elseif (IS_OS_LINUX) - #add_compile_definitions(LWE_WOOTING) + #add_compile_definitions(EHS_WOOTING) target_link_libraries(StrToHash z xcb xcb-cursor xcb-xfixes xcb-xinput wayland-client z asound EHS) endif () diff --git a/include/Anchor.h b/include/Anchor.h index 458a258..7eda0ce 100644 --- a/include/Anchor.h +++ b/include/Anchor.h @@ -2,7 +2,7 @@ #include "EHS.h" -namespace lwe +namespace ehs { enum class Anchor : UInt_8 { diff --git a/include/Array.h b/include/Array.h index d05a65e..3af0e90 100644 --- a/include/Array.h +++ b/include/Array.h @@ -5,7 +5,7 @@ #include #include -namespace lwe +namespace ehs { /// A helper class for C-style arrays. /// @tparam T Array data type to use. diff --git a/include/Base64.h b/include/Base64.h index dc3e006..bbdb778 100644 --- a/include/Base64.h +++ b/include/Base64.h @@ -3,7 +3,7 @@ #include "EHS.h" #include "Str.h" -namespace lwe +namespace ehs { class Base64 { diff --git a/include/BaseObj.h b/include/BaseObj.h index da2b4ce..4dd1a14 100644 --- a/include/BaseObj.h +++ b/include/BaseObj.h @@ -5,7 +5,7 @@ #include "Array.h" #include "Log.h" -namespace lwe +namespace ehs { class BaseObj { diff --git a/include/Color3.h b/include/Color3.h index 616c973..60d8e9f 100644 --- a/include/Color3.h +++ b/include/Color3.h @@ -2,7 +2,7 @@ #include "Types.h" -namespace lwe +namespace ehs { class Color3 { diff --git a/include/Color4.h b/include/Color4.h index 9233cc4..2ee80e9 100644 --- a/include/Color4.h +++ b/include/Color4.h @@ -3,7 +3,7 @@ #include "Types.h" #include "Color3.h" -namespace lwe +namespace ehs { class Color4 { diff --git a/include/Data.h b/include/Data.h index dacb070..1fe4392 100644 --- a/include/Data.h +++ b/include/Data.h @@ -3,7 +3,7 @@ #include "EHS.h" #include "Serializer.h" -namespace lwe +namespace ehs { class Data { diff --git a/include/DataType.h b/include/DataType.h index cbdf85a..111d45c 100644 --- a/include/DataType.h +++ b/include/DataType.h @@ -2,7 +2,7 @@ #include "EHS.h" -namespace lwe +namespace ehs { enum class DataType : UInt_8 { diff --git a/include/EHS.h b/include/EHS.h index 3c3a543..0fdff8b 100644 --- a/include/EHS.h +++ b/include/EHS.h @@ -1,17 +1,17 @@ #pragma once #if defined(NDEBUG) - #define LWE_RELEASE + #define EHS_RELEASE #else - #define LWE_DEBUG + #define EHS_DEBUG #endif #include "Types.h" -#include "System/OS.h" +#include "system/OS.h" #include "Version.h" #include "Str.h" -namespace lwe +namespace ehs { enum class MemoryPattern { diff --git a/include/Encryption.h b/include/Encryption.h index cafb8ca..49b11de 100644 --- a/include/Encryption.h +++ b/include/Encryption.h @@ -6,7 +6,7 @@ #include "Serializer.h" #include "Str.h" -namespace lwe +namespace ehs { class Encryption { diff --git a/include/GarbageCollector.h b/include/GarbageCollector.h index f781482..1aeafe5 100644 --- a/include/GarbageCollector.h +++ b/include/GarbageCollector.h @@ -3,10 +3,10 @@ #include "EHS.h" #include "Vector.h" #include "BaseObj.h" -#include "System/Mutex.h" -#include "System/Thread.h" +#include "system/Mutex.h" +#include "system/Thread.h" -namespace lwe +namespace ehs { class GarbageCollector { diff --git a/include/HRNG.h b/include/HRNG.h index f6d1873..f95e38a 100644 --- a/include/HRNG.h +++ b/include/HRNG.h @@ -3,7 +3,7 @@ #include "EHS.h" #include "Types.h" -namespace lwe +namespace ehs { class HRNG { diff --git a/include/HashMap.h b/include/HashMap.h index 5998000..d694186 100644 --- a/include/HashMap.h +++ b/include/HashMap.h @@ -5,7 +5,7 @@ #include -namespace lwe +namespace ehs { template class HashNode diff --git a/include/IO/Socket/Socket.h b/include/IO/Socket/Socket.h deleted file mode 100644 index 30a1241..0000000 --- a/include/IO/Socket/Socket.h +++ /dev/null @@ -1,51 +0,0 @@ -#pragma once - -#ifndef LWE_IPV4_HEADER - #define LWE_IPV4_HEADER 60 -#endif - -#ifndef LWE_IPV6_HEADER - #define LWE_IPV6_HEADER 40 -#endif - -#ifndef LWE_UDP_HEADER - #define LWE_UDP_HEADER 8 -#endif - -#ifndef LWE_IPV4_UDP_PAYLOAD - #define LWE_IPV4_UDP_PAYLOAD (LWE_UINT_16_MAX - LWE_IPV4_HEADER - LWE_UDP_HEADER) -#endif - -#ifndef LWE_IPV6_UDP_PAYLOAD - #define LWE_IPV6_UDP_PAYLOAD (LWE_UINT_16_MAX - LWE_IPV6_HEADER - LWE_UDP_HEADER) -#endif - -namespace lwe -{ - enum class AddrType - { - IPV6, - IPV4 - }; - - enum class ContentType - { - APP_MULTIPART_FORMDATA, - APP_FORMURLENCODED, - APP_JAVASCRIPT, - APP_JSON, - APP_XML, - TEXT_PLAIN, - TEXT_HTML, - TEXT_XML, - NONE - }; - -#if defined(LWE_OS_WINDOWS) - typedef UInt_64 Socket; - #define LWE_INVALID_SOCKET LWE_UINT_64_MAX -#elif defined(LWE_OS_LINUX) - typedef SInt_32 Socket; - #define LWE_INVALID_SOCKET (SInt_32)0xffffffff -#endif -} \ No newline at end of file diff --git a/include/Link.h b/include/Link.h index 39d1081..4910d40 100644 --- a/include/Link.h +++ b/include/Link.h @@ -1,6 +1,6 @@ #pragma once -namespace lwe +namespace ehs { /// Test template diff --git a/include/LinkedList.h b/include/LinkedList.h index 1ab2216..ae20b73 100644 --- a/include/LinkedList.h +++ b/include/LinkedList.h @@ -4,7 +4,7 @@ #include "Log.h" #include "Link.h" -namespace lwe +namespace ehs { template class LinkedList diff --git a/include/Log.h b/include/Log.h index 3817c0c..c4f670c 100644 --- a/include/Log.h +++ b/include/Log.h @@ -7,7 +7,7 @@ #include "UTF.h" #include "Str.h" -namespace lwe +namespace ehs { /// A helper class for holding error information and handling them. /// @tparam T The character data type to use. @@ -99,18 +99,18 @@ namespace lwe }; } -#ifndef LWE_LOG_INT - #ifdef LWE_DEBUG - #define LWE_LOG_INT(type, code, msg) Log::Raise({{type, GetAcronym_8(), LWE_FILE, LWE_FUNC, Str_8::FromNum((UInt_32)LWE_LINE)}, code, msg}) +#ifndef EHS_LOG_INT + #ifdef EHS_DEBUG + #define EHS_LOG_INT(type, code, msg) Log::Raise({{type, GetAcronym_8(), EHS_FILE, EHS_FUNC, Str_8::FromNum((UInt_32)EHS_LINE)}, code, msg}) #else - #define LWE_LOG_INT(type, code, msg) Log::Raise({{type, GetAcronym_8(), LWE_FUNC}, code, msg}) + #define EHS_LOG_INT(type, code, msg) Log::Raise({{type, GetAcronym_8(), EHS_FUNC}, code, msg}) #endif #endif -#ifndef LWE_LOG - #ifdef LWE_DEBUG - #define LWE_LOG(type, code, msg) lwe::Log::Raise({{type, lwe::GetAppName_8(), LWE_FILE, LWE_FUNC, lwe::Str_8::FromNum((lwe::UInt_32)LWE_LINE)}, code, msg}) +#ifndef EHS_LOG + #ifdef EHS_DEBUG + #define EHS_LOG(type, code, msg) lwe::Log::Raise({{type, lwe::GetAppName_8(), EHS_FILE, EHS_FUNC, lwe::Str_8::FromNum((lwe::UInt_32)EHS_LINE)}, code, msg}) #else - #define LWE_LOG(type, code, msg) lwe::Log::Raise({{type, lwe::GetAppName_8(), LWE_FUNC}, code, msg}) + #define EHS_LOG(type, code, msg) lwe::Log::Raise({{type, lwe::GetAppName_8(), EHS_FUNC}, code, msg}) #endif #endif \ No newline at end of file diff --git a/include/Mat2.h b/include/Mat2.h index 4552200..f98ce40 100644 --- a/include/Mat2.h +++ b/include/Mat2.h @@ -3,7 +3,7 @@ #include "EHS.h" #include "Vec2.h" -namespace lwe +namespace ehs { template class Mat2 diff --git a/include/Mat3.h b/include/Mat3.h index 74f700d..74d637b 100644 --- a/include/Mat3.h +++ b/include/Mat3.h @@ -4,7 +4,7 @@ #include "Vec3.h" #include "Mat2.h" -namespace lwe +namespace ehs { template class Mat3 diff --git a/include/Mat4.h b/include/Mat4.h index 2444971..e935215 100644 --- a/include/Mat4.h +++ b/include/Mat4.h @@ -6,7 +6,7 @@ #include "Vec4.h" #include "Vec3.h" -namespace lwe +namespace ehs { template class Mat4 diff --git a/include/Math.h b/include/Math.h index ecc261f..ce323e2 100644 --- a/include/Math.h +++ b/include/Math.h @@ -1,10 +1,10 @@ #pragma once -#include "System/CPU.h" +#include "system/CPU.h" -#define LWE_LOW_WORD(x) *((int*)&x) + 1 +#define EHS_LOW_WORD(x) *((int*)&x) + 1 -namespace lwe +namespace ehs { class Math { diff --git a/include/PRNG.h b/include/PRNG.h index 952b470..55282a0 100644 --- a/include/PRNG.h +++ b/include/PRNG.h @@ -2,7 +2,7 @@ #include "EHS.h" -namespace lwe +namespace ehs { template class PRNG diff --git a/include/PtrData.h b/include/PtrData.h index e26cc2f..d692fe4 100644 --- a/include/PtrData.h +++ b/include/PtrData.h @@ -2,7 +2,7 @@ #include "DataType.h" -namespace lwe +namespace ehs { struct PtrData { diff --git a/include/Quat.h b/include/Quat.h index 1747073..085a504 100644 --- a/include/Quat.h +++ b/include/Quat.h @@ -5,7 +5,7 @@ #include "Mat4.h" #include "Vec3.h" -namespace lwe +namespace ehs { template class Quat diff --git a/include/Range.h b/include/Range.h index 7db4373..bfea28a 100644 --- a/include/Range.h +++ b/include/Range.h @@ -1,6 +1,6 @@ #pragma once -namespace lwe +namespace ehs { template class Range diff --git a/include/Rect.h b/include/Rect.h index 7827d9d..d652741 100644 --- a/include/Rect.h +++ b/include/Rect.h @@ -5,7 +5,7 @@ #include "Vec3.h" #include "Vec4.h" -namespace lwe +namespace ehs { template class Rect @@ -130,7 +130,7 @@ namespace lwe case 3: return h; default: - LWE_LOG_INT("Error", 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Rectangle."); + EHS_LOG_INT("Error", 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Rectangle."); return x; } } @@ -148,7 +148,7 @@ namespace lwe case 3: return h; default: - LWE_LOG_INT("Error", 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Rectangle."); + EHS_LOG_INT("Error", 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Rectangle."); return x; } } diff --git a/include/SArray.h b/include/SArray.h index a7c0bf3..23519f6 100644 --- a/include/SArray.h +++ b/include/SArray.h @@ -3,7 +3,7 @@ #include "EHS.h" #include "Log.h" -namespace lwe +namespace ehs { /// This container is useful for sorting arrays efficiently. template @@ -87,7 +87,7 @@ namespace lwe { if (index >= size) { - LWE_LOG_INT("Warning", 0, "Cannot insert value at " + Str_8::FromNum(index) + " because it is outside of array range of " + size + "."); + EHS_LOG_INT("Warning", 0, "Cannot insert value at " + Str_8::FromNum(index) + " because it is outside of array range of " + size + "."); return; } diff --git a/include/Serializer.h b/include/Serializer.h index 0de8498..cf94d54 100644 --- a/include/Serializer.h +++ b/include/Serializer.h @@ -17,7 +17,7 @@ #include "Mat3.h" #include "Mat4.h" -namespace lwe +namespace ehs { template class Serializer diff --git a/include/ShdPtr.h b/include/ShdPtr.h index 201e9ff..a2e55bb 100644 --- a/include/ShdPtr.h +++ b/include/ShdPtr.h @@ -2,7 +2,7 @@ #include "PtrData.h" -namespace lwe +namespace ehs { template class ShdPtr diff --git a/include/Str.h b/include/Str.h index 3f4285c..f3fb27b 100644 --- a/include/Str.h +++ b/include/Str.h @@ -6,7 +6,7 @@ #include -namespace lwe +namespace ehs { enum class SearchPattern { @@ -250,7 +250,7 @@ namespace lwe return operator+=(FromNum(num)); } - #ifdef LWE_OS_WINDOWS + #ifdef EHS_OS_WINDOWS /// Concatenates with the given number. /// @param [in] num The given number to concatenate. /// @returns The result. @@ -390,7 +390,7 @@ namespace lwe return operator+(FromNum(num)); } - #ifdef LWE_OS_WINDOWS + #ifdef EHS_OS_WINDOWS /// Concatenates with the given number. /// @param [in] str The given number to Concatenate. /// @returns The result. @@ -1543,7 +1543,7 @@ namespace lwe return r.GetReverse(); } - #ifdef LWE_OS_WINDOWS + #ifdef EHS_OS_WINDOWS /// Converts the given number into a string. /// @returns The result. static Str FromNum(const DWORD num) diff --git a/include/Task.h b/include/Task.h index 84bbbbf..d18e23f 100644 --- a/include/Task.h +++ b/include/Task.h @@ -2,10 +2,10 @@ #include "EHS.h" #include "BaseObj.h" -#include "System/Thread.h" -#include "System/Semaphore.h" +#include "system/Thread.h" +#include "system/Semaphore.h" -namespace lwe +namespace ehs { typedef void (*TaskCb)(Serializer*); diff --git a/include/Type.h b/include/Type.h index 29e5da3..a5286a3 100644 --- a/include/Type.h +++ b/include/Type.h @@ -3,7 +3,7 @@ #include "EHS.h" #include "Str.h" -namespace lwe +namespace ehs { class Type { diff --git a/include/Types.h b/include/Types.h index 72babbc..a67bda1 100644 --- a/include/Types.h +++ b/include/Types.h @@ -1,33 +1,33 @@ #pragma once -#include "System/OS.h" +#include "system/OS.h" -#define LWE_MAX_PATH 0x104 -#define LWE_UINT_8_MAX 0xFF -#define LWE_SINT_8_MAX 0x7F -#define LWE_SINT_8_MIN 0x80 -#define LWE_UINT_16_MAX 0xFFFF -#define LWE_SINT_16_MAX 0x7FFF -#define LWE_SINT_16_MIN 0x8000 -#define LWE_UINT_24_MAX 0xFFFFFF -#define LWE_SINT_24_MAX 0x7FFFFF -#define LWE_SINT_24_MIN 0x800000 -#define LWE_UINT_32_MAX 0xFFFFFFFF -#define LWE_SINT_32_MAX 0x7FFFFFFF -#define LWE_SINT_32_MIN 0x80000000 -#define LWE_UINT_64_MAX 0xFFFFFFFFFFFFFFFF -#define LWE_SINT_64_MAX 0x7FFFFFFFFFFFFFFF -#define LWE_SINT_64_MIN 0x8000000000000000 -#define LWE_FLOAT_MAX 3.40282e+038f -#define LWE_FLOAT_MIN 1.17549e-038f -#define LWE_DOUBLE_MAX 1.79769e+308 -#define LWE_DOUBLE_MIN 2.22507e-308 -#define LWE_LDOUBLE_MAX 1.79769e+308 -#define LWE_LDOUBLE_MIN 2.22507e-308 +#define EHS_MAX_PATH 0x104 +#define EHS_UINT_8_MAX 0xFF +#define EHS_SINT_8_MAX 0x7F +#define EHS_SINT_8_MIN 0x80 +#define EHS_UINT_16_MAX 0xFFFF +#define EHS_SINT_16_MAX 0x7FFF +#define EHS_SINT_16_MIN 0x8000 +#define EHS_UINT_24_MAX 0xFFFFFF +#define EHS_SINT_24_MAX 0x7FFFFF +#define EHS_SINT_24_MIN 0x800000 +#define EHS_UINT_32_MAX 0xFFFFFFFF +#define EHS_SINT_32_MAX 0x7FFFFFFF +#define EHS_SINT_32_MIN 0x80000000 +#define EHS_UINT_64_MAX 0xFFFFFFFFFFFFFFFF +#define EHS_SINT_64_MAX 0x7FFFFFFFFFFFFFFF +#define EHS_SINT_64_MIN 0x8000000000000000 +#define EHS_FLOAT_MAX 3.40282e+038f +#define EHS_FLOAT_MIN 1.17549e-038f +#define EHS_DOUBLE_MAX 1.79769e+308 +#define EHS_DOUBLE_MIN 2.22507e-308 +#define EHS_LDOUBLE_MAX 1.79769e+308 +#define EHS_LDOUBLE_MIN 2.22507e-308 -#define LWE_INFINITE LWE_UINT_32_MAX +#define EHS_INFINITE EHS_UINT_32_MAX -namespace lwe +namespace ehs { typedef unsigned char Byte; typedef char Char_8; @@ -43,11 +43,11 @@ namespace lwe typedef signed int SInt_32; typedef int Int_32; - #if defined(LWE_OS_WINDOWS) + #if defined(EHS_OS_WINDOWS) typedef unsigned long long UInt_64; typedef signed long long SInt_64; typedef long long Int_64; - #elif defined(LWE_OS_LINUX) + #elif defined(EHS_OS_LINUX) typedef unsigned long UInt_64; typedef signed long SInt_64; typedef long Int_64; diff --git a/include/URI.h b/include/URI.h index db80656..1dd683e 100644 --- a/include/URI.h +++ b/include/URI.h @@ -3,7 +3,7 @@ #include "EHS.h" #include "Str.h" -namespace lwe +namespace ehs { class URI { diff --git a/include/UTF.h b/include/UTF.h index b7f070b..6646d6f 100644 --- a/include/UTF.h +++ b/include/UTF.h @@ -3,7 +3,7 @@ #include "EHS.h" #include "Str.h" -namespace lwe +namespace ehs { enum class CharEncoding { diff --git a/include/UniPtr.h b/include/UniPtr.h index 04584ec..bbc56a3 100644 --- a/include/UniPtr.h +++ b/include/UniPtr.h @@ -1,6 +1,6 @@ #pragma once -namespace lwe +namespace ehs { template class UniPtr diff --git a/include/Util.h b/include/Util.h index 2b61831..a87a975 100644 --- a/include/Util.h +++ b/include/Util.h @@ -2,7 +2,7 @@ #include "Types.h" -namespace lwe +namespace ehs { class Util { diff --git a/include/Vec2.h b/include/Vec2.h index 4681c35..464047e 100644 --- a/include/Vec2.h +++ b/include/Vec2.h @@ -6,7 +6,7 @@ #include "Math.h" #include "Log.h" -namespace lwe +namespace ehs { template class Vec2 @@ -229,7 +229,7 @@ namespace lwe case 1: return y; default: - LWE_LOG_INT("Error", 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 3."); + EHS_LOG_INT("Error", 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 3."); return x; } } @@ -243,7 +243,7 @@ namespace lwe case 1: return y; default: - LWE_LOG_INT("Error", 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 3."); + EHS_LOG_INT("Error", 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 3."); return x; } } diff --git a/include/Vec3.h b/include/Vec3.h index 3d1df2a..1f3e520 100644 --- a/include/Vec3.h +++ b/include/Vec3.h @@ -7,7 +7,7 @@ #include "Vec2.h" #include "Log.h" -namespace lwe +namespace ehs { template class Vec3 @@ -266,7 +266,7 @@ namespace lwe case 2: return z; default: - LWE_LOG_INT("Error", 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 3."); + EHS_LOG_INT("Error", 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 3."); return x; } } @@ -282,7 +282,7 @@ namespace lwe case 2: return z; default: - LWE_LOG_INT("Error", 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 3."); + EHS_LOG_INT("Error", 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 3."); return x; } } diff --git a/include/Vec4.h b/include/Vec4.h index 9c27031..8a02e7b 100644 --- a/include/Vec4.h +++ b/include/Vec4.h @@ -8,7 +8,7 @@ #include "Vec3.h" #include "Log.h" -namespace lwe +namespace ehs { template class Vec4 @@ -279,7 +279,7 @@ namespace lwe case 3: return w; default: - LWE_LOG_INT("Error", 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 4."); + EHS_LOG_INT("Error", 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 4."); return x; } } @@ -297,7 +297,7 @@ namespace lwe case 3: return w; default: - LWE_LOG_INT("Error", 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 4."); + EHS_LOG_INT("Error", 0, "Index of, \"" + Str_8::FromNum(index) + "\" is out of range for a Vector 4."); return x; } } diff --git a/include/Vector.h b/include/Vector.h index 2070168..3546ecd 100644 --- a/include/Vector.h +++ b/include/Vector.h @@ -7,7 +7,7 @@ #include "Util.h" -namespace lwe +namespace ehs { /// An array with extra memory pre-allocated for fast pushes. /// @tparam T Array data type to use. diff --git a/include/Version.h b/include/Version.h index 0d085e4..3c8f2b6 100644 --- a/include/Version.h +++ b/include/Version.h @@ -2,7 +2,7 @@ #include "Types.h" -namespace lwe +namespace ehs { /// A helper class for storing version major, minor and patch. class Version diff --git a/include/WkPtr.h b/include/WkPtr.h index 45e0c1c..9b48e96 100644 --- a/include/WkPtr.h +++ b/include/WkPtr.h @@ -2,7 +2,7 @@ #include "ShdPtr.h" -namespace lwe +namespace ehs { template class WkPtr diff --git a/include/Database/DVar.h b/include/database/DVar.h similarity index 93% rename from include/Database/DVar.h rename to include/database/DVar.h index da6ba6e..8d0b30d 100644 --- a/include/Database/DVar.h +++ b/include/database/DVar.h @@ -4,7 +4,7 @@ #include "BaseObj.h" #include "Str.h" -namespace lwe +namespace ehs { enum class DType : UInt_8 { diff --git a/include/IO/BaseFile.h b/include/io/BaseFile.h similarity index 99% rename from include/IO/BaseFile.h rename to include/io/BaseFile.h index c532e9b..36a59a5 100644 --- a/include/IO/BaseFile.h +++ b/include/io/BaseFile.h @@ -6,7 +6,7 @@ #include "Array.h" #include "Serializer.h" -namespace lwe +namespace ehs { enum class Mode { diff --git a/include/IO/BaseFileMonitor.h b/include/io/BaseFileMonitor.h similarity index 81% rename from include/IO/BaseFileMonitor.h rename to include/io/BaseFileMonitor.h index d8f0e01..fd1ddce 100644 --- a/include/IO/BaseFileMonitor.h +++ b/include/io/BaseFileMonitor.h @@ -3,13 +3,13 @@ #include "EHS.h" #include "Str.h" -#define LWE_FE_NONE 0x00 -#define LWE_FE_MODIFIED 0x01 -#define LWE_FE_DELETED 0x02 -#define LWE_FE_MOVED 0x04 -#define LWE_FE_OPENED 0x08 +#define EHS_FE_NONE 0x00 +#define EHS_FE_MODIFIED 0x01 +#define EHS_FE_DELETED 0x02 +#define EHS_FE_MOVED 0x04 +#define EHS_FE_OPENED 0x08 -namespace lwe +namespace ehs { class BaseFileMonitor { diff --git a/include/IO/BaseWindow.h b/include/io/BaseWindow.h similarity index 98% rename from include/IO/BaseWindow.h rename to include/io/BaseWindow.h index 5429438..f7f713e 100644 --- a/include/IO/BaseWindow.h +++ b/include/io/BaseWindow.h @@ -4,9 +4,9 @@ #include "Str.h" #include "Vec2.h" #include "Rect.h" -#include "HID/Input.h" +#include "hid/Input.h" -namespace lwe +namespace ehs { enum class WindowState : UInt_8 { diff --git a/include/IO/COM.h b/include/io/COM.h similarity index 98% rename from include/IO/COM.h rename to include/io/COM.h index 680fe53..f9bd01e 100644 --- a/include/IO/COM.h +++ b/include/io/COM.h @@ -2,7 +2,7 @@ #include "EHS.h" -namespace lwe +namespace ehs { enum class Parity : UInt_8 { diff --git a/include/IO/Console.h b/include/io/Console.h similarity index 97% rename from include/IO/Console.h rename to include/io/Console.h index 041bed6..941df17 100644 --- a/include/IO/Console.h +++ b/include/io/Console.h @@ -4,11 +4,11 @@ #include "UTF.h" #include "Array.h" -namespace lwe +namespace ehs { - #if defined(LWE_OS_WINDOWS) + #if defined(EHS_OS_WINDOWS) typedef void* ConsoleHdl; - #elif defined(LWE_OS_LINUX) + #elif defined(EHS_OS_LINUX) typedef int ConsoleHdl; #endif @@ -18,7 +18,7 @@ namespace lwe static ConsoleHdl hdlOut; static ConsoleHdl hdlIn; - #if defined(LWE_OS_WINDOWS) + #if defined(EHS_OS_WINDOWS) static bool isConsole; #endif diff --git a/include/IO/File.h b/include/io/File.h similarity index 59% rename from include/IO/File.h rename to include/io/File.h index edb15b9..27a4930 100644 --- a/include/IO/File.h +++ b/include/io/File.h @@ -2,8 +2,8 @@ #include "EHS.h" -#if defined(LWE_OS_WINDOWS) +#if defined(EHS_OS_WINDOWS) #include "File_W32.h" -#elif defined(LWE_OS_LINUX) +#elif defined(EHS_OS_LINUX) #include "File_UNX.h" #endif \ No newline at end of file diff --git a/include/IO/FileMonitor.h b/include/io/FileMonitor.h similarity index 58% rename from include/IO/FileMonitor.h rename to include/io/FileMonitor.h index f483176..54da73a 100644 --- a/include/IO/FileMonitor.h +++ b/include/io/FileMonitor.h @@ -1,7 +1,7 @@ #pragma once -#if defined(LWE_OS_WINDOWS) +#if defined(EHS_OS_WINDOWS) #include "FileMonitor_W32.h" -#elif defined(LWE_OS_LINUX) +#elif defined(EHS_OS_LINUX) #include "FileMonitor_UNX.h" #endif \ No newline at end of file diff --git a/include/IO/FileMonitor_UNX.h b/include/io/FileMonitor_UNX.h similarity index 97% rename from include/IO/FileMonitor_UNX.h rename to include/io/FileMonitor_UNX.h index 2fe48a7..9ef4f47 100644 --- a/include/IO/FileMonitor_UNX.h +++ b/include/io/FileMonitor_UNX.h @@ -3,7 +3,7 @@ #include "EHS.h" #include "BaseFileMonitor.h" -namespace lwe +namespace ehs { class FileMonitor : public BaseFileMonitor { diff --git a/include/IO/FileMonitor_W32.h b/include/io/FileMonitor_W32.h similarity index 97% rename from include/IO/FileMonitor_W32.h rename to include/io/FileMonitor_W32.h index c84afe3..1613c62 100644 --- a/include/IO/FileMonitor_W32.h +++ b/include/io/FileMonitor_W32.h @@ -3,7 +3,7 @@ #include "EHS.h" #include "BaseFileMonitor.h" -namespace lwe +namespace ehs { class FileMonitor final : public BaseFileMonitor { diff --git a/include/IO/File_UNX.h b/include/io/File_UNX.h similarity index 98% rename from include/IO/File_UNX.h rename to include/io/File_UNX.h index 06a6fe6..60bc495 100644 --- a/include/IO/File_UNX.h +++ b/include/io/File_UNX.h @@ -8,7 +8,7 @@ #include "Serializer.h" #include "BaseFile.h" -namespace lwe +namespace ehs { class File : public BaseFile { diff --git a/include/IO/File_W32.h b/include/io/File_W32.h similarity index 98% rename from include/IO/File_W32.h rename to include/io/File_W32.h index 91ea2df..47bea6c 100644 --- a/include/IO/File_W32.h +++ b/include/io/File_W32.h @@ -8,7 +8,7 @@ #include "Serializer.h" #include "BaseFile.h" -namespace lwe +namespace ehs { class File : public BaseFile { diff --git a/include/IO/FontAtlas.h b/include/io/FontAtlas.h similarity index 93% rename from include/IO/FontAtlas.h rename to include/io/FontAtlas.h index 32db8f9..26f7fee 100644 --- a/include/IO/FontAtlas.h +++ b/include/io/FontAtlas.h @@ -5,10 +5,10 @@ #include "Glyph.h" #include "Anchor.h" -#include "Img/Img.h" -#include "Model/Mesh.h" +#include "img/Img.h" +#include "model/Mesh.h" -namespace lwe +namespace ehs { class FontAtlas : public Img { diff --git a/include/IO/Glyph.h b/include/io/Glyph.h similarity index 98% rename from include/IO/Glyph.h rename to include/io/Glyph.h index 7863771..ea3a230 100644 --- a/include/IO/Glyph.h +++ b/include/io/Glyph.h @@ -5,7 +5,7 @@ #include "Rect.h" #include "Serializer.h" -namespace lwe +namespace ehs { class Glyph { diff --git a/include/IO/RIFF.h b/include/io/RIFF.h similarity index 97% rename from include/IO/RIFF.h rename to include/io/RIFF.h index 066ee25..95e4d4c 100644 --- a/include/IO/RIFF.h +++ b/include/io/RIFF.h @@ -6,7 +6,7 @@ #include "Serializer.h" #include "RIFF_Chunk.h" -namespace lwe +namespace ehs { class RIFF { diff --git a/include/IO/RIFF_Chunk.h b/include/io/RIFF_Chunk.h similarity index 96% rename from include/IO/RIFF_Chunk.h rename to include/io/RIFF_Chunk.h index 9d3ef73..468e99f 100644 --- a/include/IO/RIFF_Chunk.h +++ b/include/io/RIFF_Chunk.h @@ -4,7 +4,7 @@ #include "Str.h" #include "Serializer.h" -namespace lwe +namespace ehs { class RIFF_Chunk { diff --git a/include/IO/Window.h b/include/io/Window.h similarity index 54% rename from include/IO/Window.h rename to include/io/Window.h index e9b3819..b8631e0 100644 --- a/include/IO/Window.h +++ b/include/io/Window.h @@ -2,12 +2,12 @@ #include "EHS.h" -#if defined(LWE_OS_WINDOWS) +#if defined(EHS_OS_WINDOWS) #include "Window_W32.h" -#elif defined(LWE_OS_LINUX) - #if defined(LWE_WS_XCB) +#elif defined(EHS_OS_LINUX) + #if defined(EHS_WS_XCB) #include "Window_XCB.h" - #elif defined(LWE_WS_WAYLAND) + #elif defined(EHS_WS_WAYLAND) #include "Window_Way.h" #endif #endif \ No newline at end of file diff --git a/include/IO/Window_W32.h b/include/io/Window_W32.h similarity index 99% rename from include/IO/Window_W32.h rename to include/io/Window_W32.h index 8a80b25..e28ec77 100644 --- a/include/IO/Window_W32.h +++ b/include/io/Window_W32.h @@ -12,7 +12,7 @@ #define WM_HIDE_CURSOR (WM_APP + 3) #define WM_SHOW_CURSOR (WM_APP + 4) -namespace lwe +namespace ehs { class Window : public BaseWindow { diff --git a/include/IO/Window_Way.h b/include/io/Window_Way.h similarity index 99% rename from include/IO/Window_Way.h rename to include/io/Window_Way.h index 1715d2a..83a96b1 100644 --- a/include/IO/Window_Way.h +++ b/include/io/Window_Way.h @@ -5,7 +5,7 @@ #include #include "xdg-shell-client-protocol.h" -namespace lwe +namespace ehs { class Window : public BaseWindow { diff --git a/include/IO/Window_XCB.h b/include/io/Window_XCB.h similarity index 99% rename from include/IO/Window_XCB.h rename to include/io/Window_XCB.h index c847d60..9676abc 100644 --- a/include/IO/Window_XCB.h +++ b/include/io/Window_XCB.h @@ -6,7 +6,7 @@ #include #include -namespace lwe +namespace ehs { class Window : public BaseWindow { diff --git a/include/IO/Audio/Audio.h b/include/io/audio/Audio.h similarity index 99% rename from include/IO/Audio/Audio.h rename to include/io/audio/Audio.h index 297108a..a379d5a 100644 --- a/include/IO/Audio/Audio.h +++ b/include/io/audio/Audio.h @@ -8,7 +8,7 @@ #include "Array.h" #include "AudioCodec.h" -namespace lwe +namespace ehs { class Audio : public Resource { diff --git a/include/IO/Audio/AudioCodec.h b/include/io/audio/AudioCodec.h similarity index 96% rename from include/IO/Audio/AudioCodec.h rename to include/io/audio/AudioCodec.h index fda3edc..464dfb9 100644 --- a/include/IO/Audio/AudioCodec.h +++ b/include/io/audio/AudioCodec.h @@ -2,9 +2,9 @@ #include "EHS.h" #include "Str.h" -#include "IO/File.h" +#include "io/File.h" -namespace lwe +namespace ehs { class Audio; diff --git a/include/IO/Audio/AudioDevice.h b/include/io/audio/AudioDevice.h similarity index 63% rename from include/IO/Audio/AudioDevice.h rename to include/io/audio/AudioDevice.h index 26a2a04..6827168 100644 --- a/include/IO/Audio/AudioDevice.h +++ b/include/io/audio/AudioDevice.h @@ -2,8 +2,8 @@ #include "EHS.h" -#if defined(LWE_OS_WINDOWS) +#if defined(EHS_OS_WINDOWS) #include "AudioDevice_W32.h" -#elif defined(LWE_OS_LINUX) +#elif defined(EHS_OS_LINUX) #include "AudioDevice_ALSA.h" #endif \ No newline at end of file diff --git a/include/IO/Audio/AudioDevice_ALSA.h b/include/io/audio/AudioDevice_ALSA.h similarity index 98% rename from include/IO/Audio/AudioDevice_ALSA.h rename to include/io/audio/AudioDevice_ALSA.h index 604604a..edc2a0d 100644 --- a/include/IO/Audio/AudioDevice_ALSA.h +++ b/include/io/audio/AudioDevice_ALSA.h @@ -5,7 +5,7 @@ #include -namespace lwe +namespace ehs { class AudioDevice : public BaseAudioDevice { diff --git a/include/IO/Audio/AudioDevice_W32.h b/include/io/audio/AudioDevice_W32.h similarity index 98% rename from include/IO/Audio/AudioDevice_W32.h rename to include/io/audio/AudioDevice_W32.h index 9f0fdb7..cbc924f 100644 --- a/include/IO/Audio/AudioDevice_W32.h +++ b/include/io/audio/AudioDevice_W32.h @@ -10,7 +10,7 @@ struct IMMDevice; -namespace lwe +namespace ehs { class AudioDevice : public BaseAudioDevice { diff --git a/include/IO/Audio/BaseAudioDevice.h b/include/io/audio/BaseAudioDevice.h similarity index 99% rename from include/IO/Audio/BaseAudioDevice.h rename to include/io/audio/BaseAudioDevice.h index ab29a3d..4e8f283 100644 --- a/include/IO/Audio/BaseAudioDevice.h +++ b/include/io/audio/BaseAudioDevice.h @@ -6,7 +6,7 @@ #include "Array.h" #include "DataType.h" -namespace lwe +namespace ehs { enum class AudioDeviceType { diff --git a/include/IO/HID/Button.h b/include/io/hid/Button.h similarity index 96% rename from include/IO/HID/Button.h rename to include/io/hid/Button.h index bb60211..13af7b4 100644 --- a/include/IO/HID/Button.h +++ b/include/io/hid/Button.h @@ -3,7 +3,7 @@ #include "EHS.h" #include "Str.h" -namespace lwe +namespace ehs { class Button { diff --git a/include/IO/HID/ButtonState.h b/include/io/hid/ButtonState.h similarity index 98% rename from include/IO/HID/ButtonState.h rename to include/io/hid/ButtonState.h index 4ef2af9..0b3826c 100644 --- a/include/IO/HID/ButtonState.h +++ b/include/io/hid/ButtonState.h @@ -3,7 +3,7 @@ #include "EHS.h" #include "Button.h" -namespace lwe +namespace ehs { enum class State { diff --git a/include/IO/HID/HID.h b/include/io/hid/HID.h similarity index 97% rename from include/IO/HID/HID.h rename to include/io/hid/HID.h index 9223b5e..64d79e5 100644 --- a/include/IO/HID/HID.h +++ b/include/io/hid/HID.h @@ -3,9 +3,9 @@ #include "Array.h" #include "ButtonState.h" -#define LWE_HID_UNKNOWN 0 +#define EHS_HID_UNKNOWN 0 -namespace lwe +namespace ehs { class HID { diff --git a/include/IO/HID/Input.h b/include/io/hid/Input.h similarity index 98% rename from include/IO/HID/Input.h rename to include/io/hid/Input.h index a7b32d0..cf25670 100644 --- a/include/IO/HID/Input.h +++ b/include/io/hid/Input.h @@ -4,7 +4,7 @@ #include "Serializer.h" #include "InputHandler.h" -namespace lwe +namespace ehs { class Input { diff --git a/include/IO/HID/InputHandler.h b/include/io/hid/InputHandler.h similarity index 98% rename from include/IO/HID/InputHandler.h rename to include/io/hid/InputHandler.h index 0a4acab..6fabc82 100644 --- a/include/IO/HID/InputHandler.h +++ b/include/io/hid/InputHandler.h @@ -3,7 +3,7 @@ #include "Array.h" #include "HID.h" -namespace lwe +namespace ehs { class InputHandler { diff --git a/include/IO/HID/Keyboard.h b/include/io/hid/Keyboard.h similarity index 98% rename from include/IO/HID/Keyboard.h rename to include/io/hid/Keyboard.h index bc5becb..d4d469e 100644 --- a/include/IO/HID/Keyboard.h +++ b/include/io/hid/Keyboard.h @@ -4,9 +4,9 @@ #include "Button.h" #include "HID.h" -#define LWE_HID_KEYBOARD 0x02 +#define EHS_HID_KEYBOARD 0x02 -namespace lwe +namespace ehs { class Keyboard : public HID { diff --git a/include/IO/HID/Mouse.h b/include/io/hid/Mouse.h similarity index 95% rename from include/IO/HID/Mouse.h rename to include/io/hid/Mouse.h index 2dd7e2d..0681b7a 100644 --- a/include/IO/HID/Mouse.h +++ b/include/io/hid/Mouse.h @@ -5,9 +5,9 @@ #include "Button.h" #include "HID.h" -#define LWE_HID_MOUSE 0x01 +#define EHS_HID_MOUSE 0x01 -namespace lwe +namespace ehs { class Mouse : public HID { diff --git a/include/IO/Img/Img.h b/include/io/img/Img.h similarity index 99% rename from include/IO/Img/Img.h rename to include/io/img/Img.h index 18d3573..e63a5dd 100644 --- a/include/IO/Img/Img.h +++ b/include/io/img/Img.h @@ -4,7 +4,7 @@ #include "Str.h" #include "ImgCodec.h" -namespace lwe +namespace ehs { enum class Resampling : UInt_8 { diff --git a/include/IO/Img/ImgCodec.h b/include/io/img/ImgCodec.h similarity index 96% rename from include/IO/Img/ImgCodec.h rename to include/io/img/ImgCodec.h index 9279e71..09fdb66 100644 --- a/include/IO/Img/ImgCodec.h +++ b/include/io/img/ImgCodec.h @@ -2,9 +2,9 @@ #include "EHS.h" #include "Str.h" -#include "IO/File.h" +#include "io/File.h" -namespace lwe +namespace ehs { class Img; diff --git a/include/IO/Img/PNG.h b/include/io/img/PNG.h similarity index 98% rename from include/IO/Img/PNG.h rename to include/io/img/PNG.h index 636dee6..3b4d776 100644 --- a/include/IO/Img/PNG.h +++ b/include/io/img/PNG.h @@ -5,7 +5,7 @@ #include "PNG_Chunk.h" #include "Img.h" -namespace lwe +namespace ehs { class PNG { diff --git a/include/IO/Img/PNG_Chunk.h b/include/io/img/PNG_Chunk.h similarity index 97% rename from include/IO/Img/PNG_Chunk.h rename to include/io/img/PNG_Chunk.h index 0a19ac8..a50ed82 100644 --- a/include/IO/Img/PNG_Chunk.h +++ b/include/io/img/PNG_Chunk.h @@ -4,7 +4,7 @@ #include "Str.h" #include "Serializer.h" -namespace lwe +namespace ehs { class PNG_Chunk { diff --git a/include/IO/Model/AnimBone.h b/include/io/model/AnimBone.h similarity index 98% rename from include/IO/Model/AnimBone.h rename to include/io/model/AnimBone.h index 78ce863..9f0f775 100644 --- a/include/IO/Model/AnimBone.h +++ b/include/io/model/AnimBone.h @@ -4,7 +4,7 @@ #include "Array.h" #include "KeyFrame.h" -namespace lwe +namespace ehs { class AnimBone { diff --git a/include/IO/Model/Animation.h b/include/io/model/Animation.h similarity index 98% rename from include/IO/Model/Animation.h rename to include/io/model/Animation.h index 2b87edb..2df05fd 100644 --- a/include/IO/Model/Animation.h +++ b/include/io/model/Animation.h @@ -5,7 +5,7 @@ #include "Array.h" #include "AnimBone.h" -namespace lwe +namespace ehs { class Animation { diff --git a/include/IO/Model/Bone.h b/include/io/model/Bone.h similarity index 98% rename from include/IO/Model/Bone.h rename to include/io/model/Bone.h index 8a10cd2..91cb039 100644 --- a/include/IO/Model/Bone.h +++ b/include/io/model/Bone.h @@ -4,7 +4,7 @@ #include "Quat.h" #include "Mat4.h" -namespace lwe +namespace ehs { class Bone { diff --git a/include/IO/Model/KeyFrame.h b/include/io/model/KeyFrame.h similarity index 98% rename from include/IO/Model/KeyFrame.h rename to include/io/model/KeyFrame.h index 908bcd9..ac25287 100644 --- a/include/IO/Model/KeyFrame.h +++ b/include/io/model/KeyFrame.h @@ -7,7 +7,7 @@ #include "Mat4.h" #include "PropertyChange.h" -namespace lwe +namespace ehs { class KeyFrame { diff --git a/include/IO/Model/Mesh.h b/include/io/model/Mesh.h similarity index 99% rename from include/IO/Model/Mesh.h rename to include/io/model/Mesh.h index a270555..90b5938 100644 --- a/include/IO/Model/Mesh.h +++ b/include/io/model/Mesh.h @@ -4,7 +4,7 @@ #include "Array.h" #include "Vertex.h" -namespace lwe +namespace ehs { const Array portraitGuiVerts({ {{0.0f, 0.0f, 1.0f}, {0.0f, 0.0f, -1.0f}, {0.0f, 0.0f}}, diff --git a/include/IO/Model/Model.h b/include/io/model/Model.h similarity index 97% rename from include/IO/Model/Model.h rename to include/io/model/Model.h index fe9e7ae..af0cbe2 100644 --- a/include/IO/Model/Model.h +++ b/include/io/model/Model.h @@ -2,12 +2,12 @@ #include "EHS.h" #include "Array.h" -#include "IO/File.h" +#include "io/File.h" #include "Mesh.h" #include "Bone.h" #include "Animation.h" -namespace lwe +namespace ehs { enum class ModelEncoding : UInt_8 { diff --git a/include/IO/Model/PropertyChange.h b/include/io/model/PropertyChange.h similarity index 96% rename from include/IO/Model/PropertyChange.h rename to include/io/model/PropertyChange.h index d31f820..b4af2ef 100644 --- a/include/IO/Model/PropertyChange.h +++ b/include/io/model/PropertyChange.h @@ -2,7 +2,7 @@ #include "EHS.h" -namespace lwe +namespace ehs { enum class ChangeType : UInt_8 { diff --git a/include/IO/Model/Vertex.h b/include/io/model/Vertex.h similarity index 98% rename from include/IO/Model/Vertex.h rename to include/io/model/Vertex.h index 738ccf0..6081a69 100644 --- a/include/IO/Model/Vertex.h +++ b/include/io/model/Vertex.h @@ -5,7 +5,7 @@ #include "Vec2.h" #include "Color4.h" -namespace lwe +namespace ehs { template class Vertex diff --git a/include/IO/Socket/BaseTCP.h b/include/io/socket/BaseTCP.h similarity index 99% rename from include/IO/Socket/BaseTCP.h rename to include/io/socket/BaseTCP.h index c0e1ea7..324a2d6 100644 --- a/include/IO/Socket/BaseTCP.h +++ b/include/io/socket/BaseTCP.h @@ -7,7 +7,7 @@ #include "Socket.h" -namespace lwe +namespace ehs { class BaseTCP { diff --git a/include/IO/Socket/BaseUDP.h b/include/io/socket/BaseUDP.h similarity index 98% rename from include/IO/Socket/BaseUDP.h rename to include/io/socket/BaseUDP.h index e878ff7..a0348d7 100644 --- a/include/IO/Socket/BaseUDP.h +++ b/include/io/socket/BaseUDP.h @@ -4,7 +4,7 @@ #include "Str.h" #include "Socket.h" -namespace lwe +namespace ehs { class BaseUDP { diff --git a/include/IO/Socket/Comms.h b/include/io/socket/Comms.h similarity index 99% rename from include/IO/Socket/Comms.h rename to include/io/socket/Comms.h index 8bc76eb..3f1d316 100644 --- a/include/IO/Socket/Comms.h +++ b/include/io/socket/Comms.h @@ -11,7 +11,7 @@ #include "Utils.h" -namespace lwe +namespace ehs { class CommsSystem; class Endpoint; diff --git a/include/IO/Socket/CommsSystem.h b/include/io/socket/CommsSystem.h similarity index 97% rename from include/IO/Socket/CommsSystem.h rename to include/io/socket/CommsSystem.h index 51da76e..f140d25 100644 --- a/include/IO/Socket/CommsSystem.h +++ b/include/io/socket/CommsSystem.h @@ -5,7 +5,7 @@ #include "Array.h" #include "Serializer.h" -namespace lwe +namespace ehs { class Endpoint; class Operation; diff --git a/include/IO/Socket/DNS.h b/include/io/socket/DNS.h similarity index 93% rename from include/IO/Socket/DNS.h rename to include/io/socket/DNS.h index d9c0929..cbd1713 100644 --- a/include/IO/Socket/DNS.h +++ b/include/io/socket/DNS.h @@ -4,7 +4,7 @@ #include "Str.h" #include "Socket.h" -namespace lwe +namespace ehs { class DNS { diff --git a/include/IO/Socket/Endpoint.h b/include/io/socket/Endpoint.h similarity index 98% rename from include/IO/Socket/Endpoint.h rename to include/io/socket/Endpoint.h index f0e8643..63c9f81 100644 --- a/include/IO/Socket/Endpoint.h +++ b/include/io/socket/Endpoint.h @@ -5,12 +5,12 @@ #include "BaseObj.h" #include "Vector.h" #include "Serializer.h" -#include "IO/Socket/Socket.h" +#include "io/socket/Socket.h" #include "Utils.h" #include "Fragments.h" -namespace lwe +namespace ehs { class Comms; diff --git a/include/IO/Socket/Fragments.h b/include/io/socket/Fragments.h similarity index 97% rename from include/IO/Socket/Fragments.h rename to include/io/socket/Fragments.h index 17e2204..0b793df 100644 --- a/include/IO/Socket/Fragments.h +++ b/include/io/socket/Fragments.h @@ -5,7 +5,7 @@ #include "Utils.h" -namespace lwe +namespace ehs { class Fragments { diff --git a/include/IO/Socket/Operation.h b/include/io/socket/Operation.h similarity index 97% rename from include/IO/Socket/Operation.h rename to include/io/socket/Operation.h index a9b32d6..7f128c5 100644 --- a/include/IO/Socket/Operation.h +++ b/include/io/socket/Operation.h @@ -4,7 +4,7 @@ #include "Str.h" #include "Serializer.h" -namespace lwe +namespace ehs { class CommsSystem; class Comms; diff --git a/include/IO/Socket/Request.h b/include/io/socket/Request.h similarity index 99% rename from include/IO/Socket/Request.h rename to include/io/socket/Request.h index 890f03d..a894609 100644 --- a/include/IO/Socket/Request.h +++ b/include/io/socket/Request.h @@ -3,10 +3,10 @@ #include "EHS.h" #include "Vector.h" #include "Str.h" -#include "Json/Json.h" +#include "json/Json.h" #include "Socket.h" -namespace lwe +namespace ehs { enum class Verb { diff --git a/include/IO/Socket/Response.h b/include/io/socket/Response.h similarity index 99% rename from include/IO/Socket/Response.h rename to include/io/socket/Response.h index d5e156b..00db4fa 100644 --- a/include/IO/Socket/Response.h +++ b/include/io/socket/Response.h @@ -3,10 +3,10 @@ #include "EHS.h" #include "Vector.h" #include "Str.h" -#include "Json/Json.h" +#include "json/Json.h" #include "Socket.h" -namespace lwe +namespace ehs { class Response { diff --git a/include/IO/Socket/SSL.h b/include/io/socket/SSL.h similarity index 98% rename from include/IO/Socket/SSL.h rename to include/io/socket/SSL.h index aebe2e7..3bcd3e5 100644 --- a/include/IO/Socket/SSL.h +++ b/include/io/socket/SSL.h @@ -9,7 +9,7 @@ typedef struct ssl_ctx_st SSL_CTX; typedef struct ssl_st SSL; -namespace lwe +namespace ehs { /// A class for handling the HTTP(S) TCP socket layer. class SSL : public TCP diff --git a/include/io/socket/Socket.h b/include/io/socket/Socket.h new file mode 100644 index 0000000..f825875 --- /dev/null +++ b/include/io/socket/Socket.h @@ -0,0 +1,51 @@ +#pragma once + +#ifndef EHS_IPV4_HEADER + #define EHS_IPV4_HEADER 60 +#endif + +#ifndef EHS_IPV6_HEADER + #define EHS_IPV6_HEADER 40 +#endif + +#ifndef EHS_UDP_HEADER + #define EHS_UDP_HEADER 8 +#endif + +#ifndef EHS_IPV4_UDP_PAYLOAD + #define EHS_IPV4_UDP_PAYLOAD (EHS_UINT_16_MAX - EHS_IPV4_HEADER - EHS_UDP_HEADER) +#endif + +#ifndef EHS_IPV6_UDP_PAYLOAD + #define EHS_IPV6_UDP_PAYLOAD (EHS_UINT_16_MAX - EHS_IPV6_HEADER - EHS_UDP_HEADER) +#endif + +namespace ehs +{ + enum class AddrType + { + IPV6, + IPV4 + }; + + enum class ContentType + { + APP_MULTIPART_FORMDATA, + APP_FORMURLENCODED, + APP_JAVASCRIPT, + APP_JSON, + APP_XML, + TEXT_PLAIN, + TEXT_HTML, + TEXT_XML, + NONE + }; + +#if defined(EHS_OS_WINDOWS) + typedef UInt_64 Socket; + #define EHS_INVALID_SOCKET EHS_UINT_64_MAX +#elif defined(EHS_OS_LINUX) + typedef SInt_32 Socket; + #define EHS_INVALID_SOCKET (SInt_32)0xffffffff +#endif +} \ No newline at end of file diff --git a/include/IO/Socket/TCP.h b/include/io/socket/TCP.h similarity index 75% rename from include/IO/Socket/TCP.h rename to include/io/socket/TCP.h index dd7c4ed..012198d 100644 --- a/include/IO/Socket/TCP.h +++ b/include/io/socket/TCP.h @@ -1,6 +1,6 @@ #pragma once -#ifdef LWE_OS_WINDOWS +#ifdef EHS_OS_WINDOWS #include "TCP_W32.h" #else #include "TCP_BSD.h" diff --git a/include/IO/Socket/TCP_BSD.h b/include/io/socket/TCP_BSD.h similarity index 99% rename from include/IO/Socket/TCP_BSD.h rename to include/io/socket/TCP_BSD.h index a9f307d..161205d 100644 --- a/include/IO/Socket/TCP_BSD.h +++ b/include/io/socket/TCP_BSD.h @@ -7,7 +7,7 @@ #include "Socket.h" #include "BaseTCP.h" -namespace lwe +namespace ehs { /// A wrapper class for the transmission control protocol socket. class TCP : public BaseTCP diff --git a/include/IO/Socket/TCP_W32.h b/include/io/socket/TCP_W32.h similarity index 99% rename from include/IO/Socket/TCP_W32.h rename to include/io/socket/TCP_W32.h index a9f307d..161205d 100644 --- a/include/IO/Socket/TCP_W32.h +++ b/include/io/socket/TCP_W32.h @@ -7,7 +7,7 @@ #include "Socket.h" #include "BaseTCP.h" -namespace lwe +namespace ehs { /// A wrapper class for the transmission control protocol socket. class TCP : public BaseTCP diff --git a/include/IO/Socket/UDP.h b/include/io/socket/UDP.h similarity index 75% rename from include/IO/Socket/UDP.h rename to include/io/socket/UDP.h index 0d50bf6..e439f17 100644 --- a/include/IO/Socket/UDP.h +++ b/include/io/socket/UDP.h @@ -1,6 +1,6 @@ #pragma once -#ifdef LWE_OS_WINDOWS +#ifdef EHS_OS_WINDOWS #include "UDP_W32.h" #else #include "UDP_BSD.h" diff --git a/include/IO/Socket/UDP_BSD.h b/include/io/socket/UDP_BSD.h similarity index 99% rename from include/IO/Socket/UDP_BSD.h rename to include/io/socket/UDP_BSD.h index 7aaeb97..69fecf9 100644 --- a/include/IO/Socket/UDP_BSD.h +++ b/include/io/socket/UDP_BSD.h @@ -4,7 +4,7 @@ #include "Str.h" #include "BaseUDP.h" -namespace lwe +namespace ehs { /// A wrapper class for the user datagram protocol socket. class UDP : public BaseUDP diff --git a/include/IO/Socket/UDP_W32.h b/include/io/socket/UDP_W32.h similarity index 99% rename from include/IO/Socket/UDP_W32.h rename to include/io/socket/UDP_W32.h index 7aaeb97..69fecf9 100644 --- a/include/IO/Socket/UDP_W32.h +++ b/include/io/socket/UDP_W32.h @@ -4,7 +4,7 @@ #include "Str.h" #include "BaseUDP.h" -namespace lwe +namespace ehs { /// A wrapper class for the user datagram protocol socket. class UDP : public BaseUDP diff --git a/include/IO/Socket/Utils.h b/include/io/socket/Utils.h similarity index 83% rename from include/IO/Socket/Utils.h rename to include/io/socket/Utils.h index 7c6b3d8..9c99c9a 100644 --- a/include/IO/Socket/Utils.h +++ b/include/io/socket/Utils.h @@ -3,7 +3,7 @@ #include "EHS.h" #include "Serializer.h" -namespace lwe +namespace ehs { enum class EndDisp : UInt_8 { @@ -48,9 +48,9 @@ namespace lwe } #ifndef COMMS_IPV4_PAYLOAD - #define COMMS_IPV4_PAYLOAD (LWE_IPV4_UDP_PAYLOAD - (UInt_16)sizeof(Header)) + #define COMMS_IPV4_PAYLOAD (EHS_IPV4_UDP_PAYLOAD - (UInt_16)sizeof(Header)) #endif #ifndef COMMS_IPV6_PAYLOAD - #define COMMS_IPV6_PAYLOAD (LWE_IPV6_UDP_PAYLOAD - (UInt_16)sizeof(Header)) + #define COMMS_IPV6_PAYLOAD (EHS_IPV6_UDP_PAYLOAD - (UInt_16)sizeof(Header)) #endif \ No newline at end of file diff --git a/include/IO/Socket/RestAPIs/Spotify.h b/include/io/socket/rest/Spotify.h similarity index 98% rename from include/IO/Socket/RestAPIs/Spotify.h rename to include/io/socket/rest/Spotify.h index fbbb76a..a019929 100644 --- a/include/IO/Socket/RestAPIs/Spotify.h +++ b/include/io/socket/rest/Spotify.h @@ -3,9 +3,9 @@ #include "EHS.h" #include "Str.h" #include "Array.h" -#include "IO/Socket/SSL.h" +#include "io/socket/SSL.h" -namespace lwe +namespace ehs { enum class SpotifyState { diff --git a/include/IO/Socket/RestAPIs/Twitch.h b/include/io/socket/rest/Twitch.h similarity index 93% rename from include/IO/Socket/RestAPIs/Twitch.h rename to include/io/socket/rest/Twitch.h index 8ec1f0e..70fa290 100644 --- a/include/IO/Socket/RestAPIs/Twitch.h +++ b/include/io/socket/rest/Twitch.h @@ -2,9 +2,9 @@ #include "EHS.h" #include "Str.h" -#include "IO/Socket/SSL.h" +#include "io/socket/SSL.h" -namespace lwe +namespace ehs { class Twitch { diff --git a/include/IO/Socket/RestAPIs/TwitchChat.h b/include/io/socket/rest/TwitchChat.h similarity index 94% rename from include/IO/Socket/RestAPIs/TwitchChat.h rename to include/io/socket/rest/TwitchChat.h index afcb316..bc3bfcb 100644 --- a/include/IO/Socket/RestAPIs/TwitchChat.h +++ b/include/io/socket/rest/TwitchChat.h @@ -2,9 +2,9 @@ #include "EHS.h" #include "Str.h" -#include "IO/Socket/TCP.h" +#include "io/socket/TCP.h" -namespace lwe +namespace ehs { class TwitchChat { diff --git a/include/IO/xdg-shell-client-protocol.h b/include/io/xdg-shell-client-protocol.h similarity index 100% rename from include/IO/xdg-shell-client-protocol.h rename to include/io/xdg-shell-client-protocol.h diff --git a/include/Json/Json.h b/include/json/Json.h similarity index 99% rename from include/Json/Json.h rename to include/json/Json.h index 6a1863f..3497b68 100644 --- a/include/Json/Json.h +++ b/include/json/Json.h @@ -10,7 +10,7 @@ #include "JsonStr.h" #include "JsonVar.h" -namespace lwe +namespace ehs { class Json { diff --git a/include/Json/JsonArray.h b/include/json/JsonArray.h similarity index 98% rename from include/Json/JsonArray.h rename to include/json/JsonArray.h index 819c0b5..4618832 100644 --- a/include/Json/JsonArray.h +++ b/include/json/JsonArray.h @@ -4,7 +4,7 @@ #include "Str.h" #include "JsonBase.h" -namespace lwe +namespace ehs { class JsonObj; class JsonBool; diff --git a/include/Json/JsonBase.h b/include/json/JsonBase.h similarity index 96% rename from include/Json/JsonBase.h rename to include/json/JsonBase.h index 84cf16f..f24fd77 100644 --- a/include/Json/JsonBase.h +++ b/include/json/JsonBase.h @@ -3,7 +3,7 @@ #include "EHS.h" #include "Str.h" -namespace lwe +namespace ehs { enum class JsonType { diff --git a/include/Json/JsonBool.h b/include/json/JsonBool.h similarity index 96% rename from include/Json/JsonBool.h rename to include/json/JsonBool.h index fd5f75c..9fec982 100644 --- a/include/Json/JsonBool.h +++ b/include/json/JsonBool.h @@ -5,7 +5,7 @@ #include "JsonBase.h" -namespace lwe +namespace ehs { class JsonBool : public JsonBase { diff --git a/include/Json/JsonNum.h b/include/json/JsonNum.h similarity index 97% rename from include/Json/JsonNum.h rename to include/json/JsonNum.h index 2c6c480..da7f29f 100644 --- a/include/Json/JsonNum.h +++ b/include/json/JsonNum.h @@ -5,7 +5,7 @@ #include "JsonBase.h" -namespace lwe +namespace ehs { class JsonNum : public JsonBase { diff --git a/include/Json/JsonObj.h b/include/json/JsonObj.h similarity index 98% rename from include/Json/JsonObj.h rename to include/json/JsonObj.h index 6fc8253..4aa54d0 100644 --- a/include/Json/JsonObj.h +++ b/include/json/JsonObj.h @@ -5,7 +5,7 @@ #include "JsonBase.h" -namespace lwe +namespace ehs { class JsonVar; diff --git a/include/Json/JsonStr.h b/include/json/JsonStr.h similarity index 97% rename from include/Json/JsonStr.h rename to include/json/JsonStr.h index a4b61b2..83ebc53 100644 --- a/include/Json/JsonStr.h +++ b/include/json/JsonStr.h @@ -5,7 +5,7 @@ #include "JsonBase.h" -namespace lwe +namespace ehs { class JsonStr : public JsonBase { diff --git a/include/Json/JsonVar.h b/include/json/JsonVar.h similarity index 99% rename from include/Json/JsonVar.h rename to include/json/JsonVar.h index a4b8716..1c368d0 100644 --- a/include/Json/JsonVar.h +++ b/include/json/JsonVar.h @@ -3,7 +3,7 @@ #include "EHS.h" #include "Str.h" -namespace lwe +namespace ehs { class JsonBase; class JsonObj; diff --git a/include/System/Architecture.h b/include/system/Architecture.h similarity index 63% rename from include/System/Architecture.h rename to include/system/Architecture.h index 2194b2e..f854eb1 100644 --- a/include/System/Architecture.h +++ b/include/system/Architecture.h @@ -1,11 +1,11 @@ #pragma once #if defined(_M_AMD64) || defined(_M_X64) || defined(__x86_64__) - #define LWE_LITTLE_ENDIAN - #define LWE_ARCH_X64 + #define EHS_LITTLE_ENDIAN + #define EHS_ARCH_X64 #elif defined(_M_ARM64) || defined(__aarch64__) -#define LWE_LITTLE_ENDIAN - #define LWE_ARCH_ARM64 +#define EHS_LITTLE_ENDIAN + #define EHS_ARCH_ARM64 #else #error Unsupported architecture. #endif \ No newline at end of file diff --git a/include/System/BaseMutex.h b/include/system/BaseMutex.h similarity index 96% rename from include/System/BaseMutex.h rename to include/system/BaseMutex.h index 1c19340..73e84c3 100644 --- a/include/System/BaseMutex.h +++ b/include/system/BaseMutex.h @@ -2,7 +2,7 @@ #include "EHS.h" -namespace lwe +namespace ehs { class BaseMutex { diff --git a/include/System/BaseOpen.h b/include/system/BaseOpen.h similarity index 97% rename from include/System/BaseOpen.h rename to include/system/BaseOpen.h index 0a696e7..95606ff 100644 --- a/include/System/BaseOpen.h +++ b/include/system/BaseOpen.h @@ -2,7 +2,7 @@ #include "Str.h" -namespace lwe +namespace ehs { class BaseOpen { diff --git a/include/System/BaseSemaphore.h b/include/system/BaseSemaphore.h similarity index 98% rename from include/System/BaseSemaphore.h rename to include/system/BaseSemaphore.h index 8033f4e..865d4c2 100644 --- a/include/System/BaseSemaphore.h +++ b/include/system/BaseSemaphore.h @@ -3,7 +3,7 @@ #include "EHS.h" #include "Str.h" -namespace lwe +namespace ehs { class BaseSemaphore { diff --git a/include/System/BaseSystem.h b/include/system/BaseSystem.h similarity index 90% rename from include/System/BaseSystem.h rename to include/system/BaseSystem.h index a74ef0f..f20e298 100644 --- a/include/System/BaseSystem.h +++ b/include/system/BaseSystem.h @@ -3,7 +3,7 @@ #include "EHS.h" #include "Str.h" -namespace lwe +namespace ehs { class BaseSystem { diff --git a/include/System/CPU.h b/include/system/CPU.h similarity index 98% rename from include/System/CPU.h rename to include/system/CPU.h index b088f99..ac0b7e1 100644 --- a/include/System/CPU.h +++ b/include/system/CPU.h @@ -6,7 +6,7 @@ #include "Str.h" #include "Array.h" -namespace lwe +namespace ehs { enum class Architecture : UInt_8 { @@ -33,7 +33,7 @@ namespace lwe class CPU { private: - #ifdef LWE_OS_LINUX + #ifdef EHS_OS_LINUX static UInt_64 TSC_Freq; #endif diff --git a/include/System/FileSystem.h b/include/system/FileSystem.h similarity index 95% rename from include/System/FileSystem.h rename to include/system/FileSystem.h index d0643b2..671790c 100644 --- a/include/System/FileSystem.h +++ b/include/system/FileSystem.h @@ -3,7 +3,7 @@ #include "EHS.h" #include "Str.h" -namespace lwe +namespace ehs { class FileSystem { diff --git a/include/System/Mutex.h b/include/system/Mutex.h similarity index 60% rename from include/System/Mutex.h rename to include/system/Mutex.h index c6b664f..10d81cc 100644 --- a/include/System/Mutex.h +++ b/include/system/Mutex.h @@ -2,8 +2,8 @@ #include "EHS.h" -#if defined(LWE_OS_WINDOWS) +#if defined(EHS_OS_WINDOWS) #include "Mutex_W32.h" -#elif defined(LWE_OS_LINUX) +#elif defined(EHS_OS_LINUX) #include "Mutex_PT.h" #endif \ No newline at end of file diff --git a/include/System/Mutex_PT.h b/include/system/Mutex_PT.h similarity index 96% rename from include/System/Mutex_PT.h rename to include/system/Mutex_PT.h index 151fe1e..f119c52 100644 --- a/include/System/Mutex_PT.h +++ b/include/system/Mutex_PT.h @@ -5,7 +5,7 @@ #include -namespace lwe +namespace ehs { class Mutex : public BaseMutex { diff --git a/include/System/Mutex_W32.h b/include/system/Mutex_W32.h similarity index 96% rename from include/System/Mutex_W32.h rename to include/system/Mutex_W32.h index 5f67b1c..5de2db9 100644 --- a/include/System/Mutex_W32.h +++ b/include/system/Mutex_W32.h @@ -3,7 +3,7 @@ #include "EHS.h" #include "BaseMutex.h" -namespace lwe +namespace ehs { class Mutex : public BaseMutex { diff --git a/include/System/OS.h b/include/system/OS.h similarity index 56% rename from include/System/OS.h rename to include/system/OS.h index cd5e70f..fe5db29 100644 --- a/include/System/OS.h +++ b/include/system/OS.h @@ -1,10 +1,10 @@ #pragma once #if defined(_WIN32) || defined(_WIN64) -#define LWE_OS_WINDOWS - #define LWE_FILE __FILE__ - #define LWE_FUNC __FUNCTION__ - #define LWE_LINE __LINE__ +#define EHS_OS_WINDOWS + #define EHS_FILE __FILE__ + #define EHS_FUNC __FUNCTION__ + #define EHS_LINE __LINE__ #ifndef NOMINMAX #define NOMINMAX @@ -18,10 +18,10 @@ typedef void* Handle; #elif defined(__linux__) - #define LWE_OS_LINUX - #define LWE_FILE __FILE__ - #define LWE_FUNC __FUNCTION__ - #define LWE_LINE __LINE__ + #define EHS_OS_LINUX + #define EHS_FILE __FILE__ + #define EHS_FUNC __FUNCTION__ + #define EHS_LINE __LINE__ typedef int Handle; #endif \ No newline at end of file diff --git a/include/System/Open.h b/include/system/Open.h similarity index 59% rename from include/System/Open.h rename to include/system/Open.h index 8ef9611..ae63673 100644 --- a/include/System/Open.h +++ b/include/system/Open.h @@ -2,8 +2,8 @@ #include "OS.h" -#if defined(LWE_OS_WINDOWS) +#if defined(EHS_OS_WINDOWS) #include "Open_W32.h" -#elif defined(LWE_OS_LINUX) +#elif defined(EHS_OS_LINUX) #include "Open_UNX.h" #endif \ No newline at end of file diff --git a/include/System/Open_UNX.h b/include/system/Open_UNX.h similarity index 96% rename from include/System/Open_UNX.h rename to include/system/Open_UNX.h index e9ed807..ce895be 100644 --- a/include/System/Open_UNX.h +++ b/include/system/Open_UNX.h @@ -2,7 +2,7 @@ #include "BaseOpen.h" -namespace lwe +namespace ehs { class Open : public BaseOpen { diff --git a/include/System/Open_W32.h b/include/system/Open_W32.h similarity index 89% rename from include/System/Open_W32.h rename to include/system/Open_W32.h index 10db2ff..acf00b8 100644 --- a/include/System/Open_W32.h +++ b/include/system/Open_W32.h @@ -5,7 +5,7 @@ #ifndef OPEN_W32_H #define OPEN_W32_H -namespace lwe { +namespace ehs { class Open_W32 { diff --git a/include/System/Semaphore.h b/include/system/Semaphore.h similarity index 78% rename from include/System/Semaphore.h rename to include/system/Semaphore.h index 550bd31..afc6294 100644 --- a/include/System/Semaphore.h +++ b/include/system/Semaphore.h @@ -1,6 +1,6 @@ #pragma once -#ifdef LWE_OS_WINDOWS +#ifdef EHS_OS_WINDOWS #include "Semaphore_W32.h" #else #include "Semaphore_P.h" diff --git a/include/System/Semaphore_P.h b/include/system/Semaphore_P.h similarity index 97% rename from include/System/Semaphore_P.h rename to include/system/Semaphore_P.h index f72f7fe..bcbc889 100644 --- a/include/System/Semaphore_P.h +++ b/include/system/Semaphore_P.h @@ -6,7 +6,7 @@ #include -namespace lwe +namespace ehs { class Semaphore : public BaseSemaphore { diff --git a/include/System/Semaphore_W32.h b/include/system/Semaphore_W32.h similarity index 97% rename from include/System/Semaphore_W32.h rename to include/system/Semaphore_W32.h index eb97b14..acf8826 100644 --- a/include/System/Semaphore_W32.h +++ b/include/system/Semaphore_W32.h @@ -4,7 +4,7 @@ #include "Str.h" #include "BaseSemaphore.h" -namespace lwe +namespace ehs { class Semaphore : public BaseSemaphore { diff --git a/include/System/System.h b/include/system/System.h similarity index 60% rename from include/System/System.h rename to include/system/System.h index bc8ec49..e8163a2 100644 --- a/include/System/System.h +++ b/include/system/System.h @@ -2,8 +2,8 @@ #include "EHS.h" -#if defined(LWE_OS_WINDOWS) +#if defined(EHS_OS_WINDOWS) #include "System_W32.h" -#elif defined(LWE_OS_LINUX) +#elif defined(EHS_OS_LINUX) #include "System_LNX.h" #endif \ No newline at end of file diff --git a/include/System/System_LNX.h b/include/system/System_LNX.h similarity index 91% rename from include/System/System_LNX.h rename to include/system/System_LNX.h index 97998a3..25ac2f8 100644 --- a/include/System/System_LNX.h +++ b/include/system/System_LNX.h @@ -3,7 +3,7 @@ #include "EHS.h" #include "BaseSystem.h" -namespace lwe +namespace ehs { class System : public BaseSystem { diff --git a/include/System/System_W32.h b/include/system/System_W32.h similarity index 90% rename from include/System/System_W32.h rename to include/system/System_W32.h index e9b356c..8bf8109 100644 --- a/include/System/System_W32.h +++ b/include/system/System_W32.h @@ -2,7 +2,7 @@ #include "BaseSystem.h" -namespace lwe +namespace ehs { class System : public BaseSystem { diff --git a/include/System/Thread.h b/include/system/Thread.h similarity index 93% rename from include/System/Thread.h rename to include/system/Thread.h index 9ad7675..45df3b4 100644 --- a/include/System/Thread.h +++ b/include/system/Thread.h @@ -6,17 +6,17 @@ #include "Log.h" #include "Str.h" -#ifdef LWE_OS_WINDOWS +#ifdef EHS_OS_WINDOWS #include #endif -namespace lwe +namespace ehs { - #if defined(LWE_OS_WINDOWS) - #define LWE_INVALID_THREAD nullptr + #if defined(EHS_OS_WINDOWS) + #define EHS_INVALID_THREAD nullptr typedef void* THandle; - #elif defined(LWE_OS_LINUX) - #define LWE_INVALID_THREAD 0 + #elif defined(EHS_OS_LINUX) + #define EHS_INVALID_THREAD 0 typedef UInt_64 THandle; #endif @@ -25,7 +25,7 @@ namespace lwe private: static UInt_32 mainId; - #ifdef LWE_OS_WINDOWS + #ifdef EHS_OS_WINDOWS static Handle mainTaskHdl; static UInt_32 mainTaskIndex; #endif @@ -34,7 +34,7 @@ namespace lwe THandle hdl; UInt_32 id; - #ifdef LWE_OS_WINDOWS + #ifdef EHS_OS_WINDOWS Handle taskHdl; UInt_32 taskIndex; #endif @@ -62,8 +62,8 @@ namespace lwe /// Blocks the calling thread until the referenced thread is finished. /// @param timeout The time to wait for before moving on. - /// @note Pass "LWE_INFINITE" to wait until the thread is finished. - bool Join(const unsigned int timeout = LWE_INFINITE); + /// @note Pass "EHS_INFINITE" to wait until the thread is finished. + bool Join(const unsigned int timeout = EHS_INFINITE); /// Detaches the referenced thread, removing ownership. void Detach(); @@ -86,7 +86,7 @@ namespace lwe bool IsValid() const; - #ifdef LWE_OS_WINDOWS + #ifdef EHS_OS_WINDOWS /// Adjusts the thread's performance based on the type of task provided, that's going to be executed. /// @param[in] task A task name from the provided list in the registry. /// @note A list of tasks are in the registry at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks. @@ -112,7 +112,7 @@ namespace lwe /// @returns The id. static UInt_64 GetCurrentId(); - #ifdef LWE_OS_WINDOWS + #ifdef EHS_OS_WINDOWS /// Adjusts the main thread's performance based on the type of task provided, that's going to be executed. /// @param[in] task A task name from the provided list in the registry. /// @note A list of tasks are in the registry at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile\Tasks. diff --git a/include/System/User.h b/include/system/User.h similarity index 94% rename from include/System/User.h rename to include/system/User.h index 3ed533e..3f8072f 100644 --- a/include/System/User.h +++ b/include/system/User.h @@ -3,7 +3,7 @@ #include "EHS.h" #include "Str.h" -namespace lwe +namespace ehs { class User { diff --git a/src/Base64.cpp b/src/Base64.cpp index 16d6c0a..2f977b8 100644 --- a/src/Base64.cpp +++ b/src/Base64.cpp @@ -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) diff --git a/src/BaseObj.cpp b/src/BaseObj.cpp index 8bd9ac4..2030b46 100644 --- a/src/BaseObj.cpp +++ b/src/BaseObj.cpp @@ -1,6 +1,6 @@ #include "BaseObj.h" -namespace lwe +namespace ehs { BaseObj::~BaseObj() { diff --git a/src/Color3.cpp b/src/Color3.cpp index 0fb66fc..5f852d7 100644 --- a/src/Color3.cpp +++ b/src/Color3.cpp @@ -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) diff --git a/src/Color4.cpp b/src/Color4.cpp index 9043157..cce129a 100644 --- a/src/Color4.cpp +++ b/src/Color4.cpp @@ -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) diff --git a/src/Data.cpp b/src/Data.cpp index eefde30..f7f25aa 100644 --- a/src/Data.cpp +++ b/src/Data.cpp @@ -1,5 +1,5 @@ #include "Data.h" -namespace lwe +namespace ehs { } \ No newline at end of file diff --git a/src/DataType.cpp b/src/DataType.cpp index da777c7..0381cfd 100644 --- a/src/DataType.cpp +++ b/src/DataType.cpp @@ -1,6 +1,6 @@ #include "DataType.h" -namespace lwe +namespace ehs { DataType FromAudioBitDepth(const UInt_16 bitDepth) { diff --git a/src/Database/DVar.cpp b/src/Database/DVar.cpp deleted file mode 100644 index e83a79f..0000000 --- a/src/Database/DVar.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "Database/DVar.h" - -namespace lwe -{ -} \ No newline at end of file diff --git a/src/EHS.cpp b/src/EHS.cpp index c02dc19..a782b87 100644 --- a/src/EHS.cpp +++ b/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 -#if defined(LWE_OS_LINUX) +#if defined(EHS_OS_LINUX) #include #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(); 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(); 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(); 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(); 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(); 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(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(); diff --git a/src/Encryption.cpp b/src/Encryption.cpp index 9ccd5da..79f49ac 100644 --- a/src/Encryption.cpp +++ b/src/Encryption.cpp @@ -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) diff --git a/src/GarbageCollector.cpp b/src/GarbageCollector.cpp index 96c5aba..a9a7a46 100644 --- a/src/GarbageCollector.cpp +++ b/src/GarbageCollector.cpp @@ -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)obj) + "\" is already in garbage."); + EHS_LOG_INT("Warning", 1, obj->GetTypeId() + " object with address of, \"" + Str_8::FromNum((USize)obj) + "\" is already in garbage."); return; } */ diff --git a/src/HRNG_ARM64.cpp b/src/HRNG_ARM64.cpp index 29626c4..7d1c0f2 100644 --- a/src/HRNG_ARM64.cpp +++ b/src/HRNG_ARM64.cpp @@ -1,6 +1,6 @@ #include "HRNG.h" -namespace lwe +namespace ehs { UInt_64 HRNG::GenerateSeed_u64() { diff --git a/src/Log.cpp b/src/Log.cpp index 4b0432f..8dfbf2c 100644 --- a/src/Log.cpp +++ b/src/Log.cpp @@ -1,6 +1,6 @@ #include "Log.h" -namespace lwe +namespace ehs { void (*Log::logCb)(const Log&) = nullptr; Log Log::lastLog; diff --git a/src/Math.cpp b/src/Math.cpp index 671ce15..00c505a 100644 --- a/src/Math.cpp +++ b/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 } diff --git a/src/PtrData.cpp b/src/PtrData.cpp index acc624d..695b5a2 100644 --- a/src/PtrData.cpp +++ b/src/PtrData.cpp @@ -1,6 +1,6 @@ #include "PtrData.h" -namespace lwe +namespace ehs { Vector pointers; diff --git a/src/StrToHash.cpp b/src/StrToHash.cpp index 63a07fb..fbdbeb9 100644 --- a/src/StrToHash.cpp +++ b/src/StrToHash.cpp @@ -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) { diff --git a/src/System/Open_W32.cpp b/src/System/Open_W32.cpp deleted file mode 100644 index b8e8b6b..0000000 --- a/src/System/Open_W32.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "System/Open_W32.h" - -namespace lwe -{ -} \ No newline at end of file diff --git a/src/Task.cpp b/src/Task.cpp index 0e0f028..2f643eb 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -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; } diff --git a/src/Type.cpp b/src/Type.cpp index 3998ad7..750dd1f 100644 --- a/src/Type.cpp +++ b/src/Type.cpp @@ -1,6 +1,6 @@ #include "Type.h" -namespace lwe +namespace ehs { Type::Type() : hashId(0) diff --git a/src/URI.cpp b/src/URI.cpp index 03c0968..72e5ad4 100644 --- a/src/URI.cpp +++ b/src/URI.cpp @@ -1,6 +1,6 @@ #include "URI.h" -namespace lwe +namespace ehs { bool IsAN(const Char_8 c) { diff --git a/src/Util.cpp b/src/Util.cpp index a3be584..585598e 100644 --- a/src/Util.cpp +++ b/src/Util.cpp @@ -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) { diff --git a/src/Version.cpp b/src/Version.cpp index ab60304..ec60287 100644 --- a/src/Version.cpp +++ b/src/Version.cpp @@ -1,6 +1,6 @@ #include "Version.h" -namespace lwe +namespace ehs { Version::Version() : major(0), minor(0), patch(0) diff --git a/src/database/DVar.cpp b/src/database/DVar.cpp new file mode 100644 index 0000000..4e03a40 --- /dev/null +++ b/src/database/DVar.cpp @@ -0,0 +1,5 @@ +#include "database/DVar.h" + +namespace ehs +{ +} \ No newline at end of file diff --git a/src/IO/BaseFile.cpp b/src/io/BaseFile.cpp similarity index 94% rename from src/IO/BaseFile.cpp rename to src/io/BaseFile.cpp index 0ab703e..59156b2 100644 --- a/src/IO/BaseFile.cpp +++ b/src/io/BaseFile.cpp @@ -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; } diff --git a/src/IO/BaseFileMonitor.cpp b/src/io/BaseFileMonitor.cpp similarity index 94% rename from src/IO/BaseFileMonitor.cpp rename to src/io/BaseFileMonitor.cpp index d4781bf..622d105 100644 --- a/src/IO/BaseFileMonitor.cpp +++ b/src/io/BaseFileMonitor.cpp @@ -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) diff --git a/src/IO/BaseWindow.cpp b/src/io/BaseWindow.cpp similarity index 96% rename from src/IO/BaseWindow.cpp rename to src/io/BaseWindow.cpp index 53e7961..42f6a4d 100644 --- a/src/IO/BaseWindow.cpp +++ b/src/io/BaseWindow.cpp @@ -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), diff --git a/src/IO/COM.cpp b/src/io/COM.cpp similarity index 85% rename from src/IO/COM.cpp rename to src/io/COM.cpp index b23f604..6831211 100644 --- a/src/IO/COM.cpp +++ b/src/io/COM.cpp @@ -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(); } } diff --git a/src/IO/Console.cpp b/src/io/Console.cpp similarity index 83% rename from src/IO/Console.cpp rename to src/io/Console.cpp index ef44083..c4b118d 100644 --- a/src/IO/Console.cpp +++ b/src/io/Console.cpp @@ -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 #include #include #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 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 data = cmdFile.ReadArray(bufferSize); cmdFile.Release(); @@ -724,9 +724,9 @@ namespace lwe Vector 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 data = cmdFile.ReadArray(bufferSize); cmdFile.Release(); @@ -754,9 +754,9 @@ namespace lwe Vector 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 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 diff --git a/src/IO/FileMonitor_UNX.cpp b/src/io/FileMonitor_UNX.cpp similarity index 82% rename from src/IO/FileMonitor_UNX.cpp rename to src/io/FileMonitor_UNX.cpp index a12a1a5..7501790 100644 --- a/src/IO/FileMonitor_UNX.cpp +++ b/src/io/FileMonitor_UNX.cpp @@ -1,4 +1,4 @@ -#include "IO/FileMonitor_UNX.h" +#include "io/FileMonitor_UNX.h" #include "Log.h" #include @@ -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; diff --git a/src/IO/FileMonitor_W32.cpp b/src/io/FileMonitor_W32.cpp similarity index 88% rename from src/IO/FileMonitor_W32.cpp rename to src/io/FileMonitor_W32.cpp index ff5e8d9..a65d59d 100644 --- a/src/IO/FileMonitor_W32.cpp +++ b/src/io/FileMonitor_W32.cpp @@ -1,10 +1,10 @@ -#include "IO/FileMonitor_W32.h" +#include "io/FileMonitor_W32.h" #include "Log.h" #include "UTF.h" #include -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; } diff --git a/src/IO/File_UNX.cpp b/src/io/File_UNX.cpp similarity index 82% rename from src/IO/File_UNX.cpp rename to src/io/File_UNX.cpp index e9e10bb..51d5967 100644 --- a/src/IO/File_UNX.cpp +++ b/src/io/File_UNX.cpp @@ -1,4 +1,4 @@ -#include "IO/File_UNX.h" +#include "io/File_UNX.h" #include #include @@ -8,15 +8,15 @@ #include #include -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) + "."); } } diff --git a/src/IO/File_W32.cpp b/src/io/File_W32.cpp similarity index 82% rename from src/IO/File_W32.cpp rename to src/io/File_W32.cpp index 6cec8af..275293d 100644 --- a/src/IO/File_W32.cpp +++ b/src/io/File_W32.cpp @@ -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) diff --git a/src/IO/FontAtlas.cpp b/src/io/FontAtlas.cpp similarity index 97% rename from src/IO/FontAtlas.cpp rename to src/io/FontAtlas.cpp index 21ddd44..4a2d179 100644 --- a/src/IO/FontAtlas.cpp +++ b/src/io/FontAtlas.cpp @@ -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; diff --git a/src/IO/Glyph.cpp b/src/io/Glyph.cpp similarity index 98% rename from src/IO/Glyph.cpp rename to src/io/Glyph.cpp index 5034d78..c97a945 100644 --- a/src/IO/Glyph.cpp +++ b/src/io/Glyph.cpp @@ -1,6 +1,6 @@ -#include "IO/Glyph.h" +#include "io/Glyph.h" -namespace lwe +namespace ehs { Glyph::Glyph() : code(0) diff --git a/src/IO/RIFF.cpp b/src/io/RIFF.cpp similarity index 91% rename from src/IO/RIFF.cpp rename to src/io/RIFF.cpp index 2468eeb..387c53a 100644 --- a/src/IO/RIFF.cpp +++ b/src/io/RIFF.cpp @@ -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(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(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; } diff --git a/src/IO/RIFF_Chunk.cpp b/src/io/RIFF_Chunk.cpp similarity index 94% rename from src/IO/RIFF_Chunk.cpp rename to src/io/RIFF_Chunk.cpp index 7d3475b..b5a6977 100644 --- a/src/IO/RIFF_Chunk.cpp +++ b/src/io/RIFF_Chunk.cpp @@ -1,6 +1,6 @@ -#include "IO/RIFF_Chunk.h" +#include "io/RIFF_Chunk.h" -namespace lwe +namespace ehs { RIFF_Chunk::RIFF_Chunk() : hashId(0) diff --git a/src/IO/Window_W32.cpp b/src/io/Window_W32.cpp similarity index 89% rename from src/IO/Window_W32.cpp rename to src/io/Window_W32.cpp index 172662c..e4838fb 100644 --- a/src/IO/Window_W32.cpp +++ b/src/io/Window_W32.cpp @@ -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 -namespace lwe +namespace ehs { Array 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; } } diff --git a/src/IO/Window_Way.cpp b/src/io/Window_Way.cpp similarity index 95% rename from src/IO/Window_Way.cpp rename to src/io/Window_Way.cpp index f390bac..b07d3e5 100644 --- a/src/IO/Window_Way.cpp +++ b/src/io/Window_Way.cpp @@ -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; } diff --git a/src/IO/Window_XCB.cpp b/src/io/Window_XCB.cpp similarity index 95% rename from src/IO/Window_XCB.cpp rename to src/io/Window_XCB.cpp index 5fe8625..5cd8323 100644 --- a/src/IO/Window_XCB.cpp +++ b/src/io/Window_XCB.cpp @@ -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 #include #include -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; } diff --git a/src/IO/Audio/Audio.cpp b/src/io/audio/Audio.cpp similarity index 91% rename from src/IO/Audio/Audio.cpp rename to src/io/audio/Audio.cpp index d30c016..fa62147 100644 --- a/src/IO/Audio/Audio.cpp +++ b/src/io/audio/Audio.cpp @@ -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 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); } } \ No newline at end of file diff --git a/src/IO/Audio/AudioCodec.cpp b/src/io/audio/AudioCodec.cpp similarity index 92% rename from src/IO/Audio/AudioCodec.cpp rename to src/io/audio/AudioCodec.cpp index eb79a49..79e6c08 100644 --- a/src/IO/Audio/AudioCodec.cpp +++ b/src/io/audio/AudioCodec.cpp @@ -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; } diff --git a/src/IO/Audio/AudioDevice_ALSA.cpp b/src/io/audio/AudioDevice_ALSA.cpp similarity index 78% rename from src/IO/Audio/AudioDevice_ALSA.cpp rename to src/io/audio/AudioDevice_ALSA.cpp index e1d9cbf..b9eb19d 100644 --- a/src/IO/Audio/AudioDevice_ALSA.cpp +++ b/src/io/audio/AudioDevice_ALSA.cpp @@ -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 {}; } diff --git a/src/IO/Audio/AudioDevice_W32.cpp b/src/io/audio/AudioDevice_W32.cpp similarity index 80% rename from src/IO/Audio/AudioDevice_W32.cpp rename to src/io/audio/AudioDevice_W32.cpp index df68c5b..87962e1 100644 --- a/src/IO/Audio/AudioDevice_W32.cpp +++ b/src/io/audio/AudioDevice_W32.cpp @@ -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; } diff --git a/src/IO/Audio/BaseAudioDevice.cpp b/src/io/audio/BaseAudioDevice.cpp similarity index 98% rename from src/IO/Audio/BaseAudioDevice.cpp rename to src/io/audio/BaseAudioDevice.cpp index e691e64..578dd0c 100644 --- a/src/IO/Audio/BaseAudioDevice.cpp +++ b/src/io/audio/BaseAudioDevice.cpp @@ -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), diff --git a/src/IO/HID/Button.cpp b/src/io/hid/Button.cpp similarity index 93% rename from src/IO/HID/Button.cpp rename to src/io/hid/Button.cpp index d7c2ad0..d11b524 100644 --- a/src/IO/HID/Button.cpp +++ b/src/io/hid/Button.cpp @@ -1,6 +1,6 @@ -#include "IO/HID/Button.h" +#include "io/hid/Button.h" -namespace lwe +namespace ehs { Button::Button() : hash(0) diff --git a/src/IO/HID/ButtonState.cpp b/src/io/hid/ButtonState.cpp similarity index 96% rename from src/IO/HID/ButtonState.cpp rename to src/io/hid/ButtonState.cpp index b391ae8..4720ffc 100644 --- a/src/IO/HID/ButtonState.cpp +++ b/src/io/hid/ButtonState.cpp @@ -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) diff --git a/src/IO/HID/HID.cpp b/src/io/hid/HID.cpp similarity index 97% rename from src/IO/HID/HID.cpp rename to src/io/hid/HID.cpp index e18a5ae..312479d 100644 --- a/src/IO/HID/HID.cpp +++ b/src/io/hid/HID.cpp @@ -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&&)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&&)hid.states; - hid.type = LWE_HID_UNKNOWN; + hid.type = EHS_HID_UNKNOWN; hid.id = 0; return *this; diff --git a/src/IO/HID/Input.cpp b/src/io/hid/Input.cpp similarity index 98% rename from src/IO/HID/Input.cpp rename to src/io/hid/Input.cpp index d780ae1..1d2f4a4 100644 --- a/src/IO/HID/Input.cpp +++ b/src/io/hid/Input.cpp @@ -1,6 +1,6 @@ -#include "IO/HID/Input.h" +#include "io/hid/Input.h" -namespace lwe +namespace ehs { Input::~Input() { diff --git a/src/IO/HID/InputHandler.cpp b/src/io/hid/InputHandler.cpp similarity index 98% rename from src/IO/HID/InputHandler.cpp rename to src/io/hid/InputHandler.cpp index ab00470..bc92029 100644 --- a/src/IO/HID/InputHandler.cpp +++ b/src/io/hid/InputHandler.cpp @@ -1,6 +1,6 @@ -#include "IO/HID/InputHandler.h" +#include "io/hid/InputHandler.h" -namespace lwe +namespace ehs { InputHandler::~InputHandler() { diff --git a/src/IO/HID/Keyboard.cpp b/src/io/hid/Keyboard.cpp similarity index 99% rename from src/IO/HID/Keyboard.cpp rename to src/io/hid/Keyboard.cpp index 70990fc..f034553 100644 --- a/src/IO/HID/Keyboard.cpp +++ b/src/io/hid/Keyboard.cpp @@ -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) { } diff --git a/src/IO/HID/Mouse.cpp b/src/io/hid/Mouse.cpp similarity index 94% rename from src/IO/HID/Mouse.cpp rename to src/io/hid/Mouse.cpp index a1be144..ea114b1 100644 --- a/src/IO/HID/Mouse.cpp +++ b/src/io/hid/Mouse.cpp @@ -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) { } diff --git a/src/IO/Img/Img.cpp b/src/io/img/Img.cpp similarity index 93% rename from src/IO/Img/Img.cpp rename to src/io/img/Img.cpp index 79976a4..ed2f782 100644 --- a/src/IO/Img/Img.cpp +++ b/src/io/img/Img.cpp @@ -1,6 +1,6 @@ -#include "IO/Img/Img.h" +#include "io/img/Img.h" -namespace lwe +namespace ehs { Array 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); } } \ No newline at end of file diff --git a/src/IO/Img/ImgCodec.cpp b/src/io/img/ImgCodec.cpp similarity index 92% rename from src/IO/Img/ImgCodec.cpp rename to src/io/img/ImgCodec.cpp index 2e4f47a..7f61d5c 100644 --- a/src/IO/Img/ImgCodec.cpp +++ b/src/io/img/ImgCodec.cpp @@ -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; } diff --git a/src/IO/Img/PNG.cpp b/src/io/img/PNG.cpp similarity index 98% rename from src/IO/Img/PNG.cpp rename to src/io/img/PNG.cpp index b423814..832cb80 100644 --- a/src/IO/Img/PNG.cpp +++ b/src/io/img/PNG.cpp @@ -1,6 +1,6 @@ -#include "IO/Img/PNG.h" +#include "io/img/PNG.h" -namespace lwe +namespace ehs { Array pngSeq = {0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A}; @@ -23,7 +23,7 @@ namespace lwe Array seq = data.ReadArray(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; } diff --git a/src/IO/Img/PNG_Chunk.cpp b/src/io/img/PNG_Chunk.cpp similarity index 95% rename from src/IO/Img/PNG_Chunk.cpp rename to src/io/img/PNG_Chunk.cpp index fa21af2..b85144b 100644 --- a/src/IO/Img/PNG_Chunk.cpp +++ b/src/io/img/PNG_Chunk.cpp @@ -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} diff --git a/src/IO/Model/AnimBone.cpp b/src/io/model/AnimBone.cpp similarity index 97% rename from src/IO/Model/AnimBone.cpp rename to src/io/model/AnimBone.cpp index 7d583e1..f20d4d8 100644 --- a/src/IO/Model/AnimBone.cpp +++ b/src/io/model/AnimBone.cpp @@ -1,8 +1,8 @@ -#include "IO/Model/AnimBone.h" +#include "io/model/AnimBone.h" #include -namespace lwe +namespace ehs { AnimBone::AnimBone() : boneId(0xFF) diff --git a/src/IO/Model/Animation.cpp b/src/io/model/Animation.cpp similarity index 98% rename from src/IO/Model/Animation.cpp rename to src/io/model/Animation.cpp index 52e23e1..689bb92 100644 --- a/src/IO/Model/Animation.cpp +++ b/src/io/model/Animation.cpp @@ -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) diff --git a/src/IO/Model/Bone.cpp b/src/io/model/Bone.cpp similarity index 99% rename from src/IO/Model/Bone.cpp rename to src/io/model/Bone.cpp index 9fa6223..bfe855d 100644 --- a/src/IO/Model/Bone.cpp +++ b/src/io/model/Bone.cpp @@ -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()) diff --git a/src/IO/Model/KeyFrame.cpp b/src/io/model/KeyFrame.cpp similarity index 97% rename from src/IO/Model/KeyFrame.cpp rename to src/io/model/KeyFrame.cpp index caa9bd8..30cc542 100644 --- a/src/IO/Model/KeyFrame.cpp +++ b/src/io/model/KeyFrame.cpp @@ -1,8 +1,8 @@ -#include "IO/Model/KeyFrame.h" +#include "io/model/KeyFrame.h" #include -namespace lwe +namespace ehs { KeyFrame::KeyFrame() : num(0.0f), timeStamp(0.0f), scale(1.0f), trans(Mat4_f::Identity()) diff --git a/src/IO/Model/Mesh.cpp b/src/io/model/Mesh.cpp similarity index 99% rename from src/IO/Model/Mesh.cpp rename to src/io/model/Mesh.cpp index f9732a9..15e0d10 100644 --- a/src/IO/Model/Mesh.cpp +++ b/src/io/model/Mesh.cpp @@ -1,6 +1,6 @@ -#include "IO/Model/Mesh.h" +#include "io/model/Mesh.h" -namespace lwe +namespace ehs { Mesh::Mesh() { diff --git a/src/IO/Model/Model.cpp b/src/io/model/Model.cpp similarity index 97% rename from src/IO/Model/Model.cpp rename to src/io/model/Model.cpp index ce985b3..b5953aa 100644 --- a/src/IO/Model/Model.cpp +++ b/src/io/model/Model.cpp @@ -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; } diff --git a/src/IO/Model/PropertyChange.cpp b/src/io/model/PropertyChange.cpp similarity index 79% rename from src/IO/Model/PropertyChange.cpp rename to src/io/model/PropertyChange.cpp index 988c47e..92c1f1a 100644 --- a/src/IO/Model/PropertyChange.cpp +++ b/src/io/model/PropertyChange.cpp @@ -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) diff --git a/src/IO/Socket/BaseTCP.cpp b/src/io/socket/BaseTCP.cpp similarity index 95% rename from src/IO/Socket/BaseTCP.cpp rename to src/io/socket/BaseTCP.cpp index d1c0358..5195aef 100644 --- a/src/IO/Socket/BaseTCP.cpp +++ b/src/io/socket/BaseTCP.cpp @@ -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 {}; } diff --git a/src/IO/Socket/BaseUDP.cpp b/src/io/socket/BaseUDP.cpp similarity index 96% rename from src/IO/Socket/BaseUDP.cpp rename to src/io/socket/BaseUDP.cpp index ee34e7c..5fb074e 100644 --- a/src/IO/Socket/BaseUDP.cpp +++ b/src/io/socket/BaseUDP.cpp @@ -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) diff --git a/src/IO/Socket/Comms.cpp b/src/io/socket/Comms.cpp similarity index 87% rename from src/IO/Socket/Comms.cpp rename to src/io/socket/Comms.cpp index 81bf346..98eca75 100644 --- a/src/IO/Socket/Comms.cpp +++ b/src/io/socket/Comms.cpp @@ -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 #include -#elif defined(LWE_OS_LINUX) +#elif defined(EHS_OS_LINUX) #include #include #include @@ -17,7 +17,7 @@ #include #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(); 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; } diff --git a/src/IO/Socket/CommsSystem.cpp b/src/io/socket/CommsSystem.cpp similarity index 86% rename from src/IO/Socket/CommsSystem.cpp rename to src/io/socket/CommsSystem.cpp index fff1ea1..860913d 100644 --- a/src/IO/Socket/CommsSystem.cpp +++ b/src/io/socket/CommsSystem.cpp @@ -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."); } } \ No newline at end of file diff --git a/src/IO/Socket/DNS.cpp b/src/io/socket/DNS.cpp similarity index 80% rename from src/IO/Socket/DNS.cpp rename to src/io/socket/DNS.cpp index 8ae6bdb..64160cc 100644 --- a/src/IO/Socket/DNS.cpp +++ b/src/io/socket/DNS.cpp @@ -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 #include -#elif defined(LWE_OS_LINUX) +#elif defined(EHS_OS_LINUX) #include #include #include #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 diff --git a/src/IO/Socket/Endpoint.cpp b/src/io/socket/Endpoint.cpp similarity index 87% rename from src/IO/Socket/Endpoint.cpp rename to src/io/socket/Endpoint.cpp index 3eede38..c3d0135 100644 --- a/src/IO/Socket/Endpoint.cpp +++ b/src/io/socket/Endpoint.cpp @@ -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 #include -#elif defined(LWE_OS_LINUX) +#elif defined(EHS_OS_LINUX) #include #include #include @@ -17,10 +17,10 @@ #include #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(); } diff --git a/src/IO/Socket/Fragments.cpp b/src/io/socket/Fragments.cpp similarity index 97% rename from src/IO/Socket/Fragments.cpp rename to src/io/socket/Fragments.cpp index 77aa16b..71d3f49 100644 --- a/src/IO/Socket/Fragments.cpp +++ b/src/io/socket/Fragments.cpp @@ -1,6 +1,6 @@ -#include "IO/Socket/Fragments.h" +#include "io/socket/Fragments.h" -namespace lwe +namespace ehs { Fragments::~Fragments() { diff --git a/src/IO/Socket/Operation.cpp b/src/io/socket/Operation.cpp similarity index 80% rename from src/IO/Socket/Operation.cpp rename to src/io/socket/Operation.cpp index bc112ca..675786c 100644 --- a/src/IO/Socket/Operation.cpp +++ b/src/io/socket/Operation.cpp @@ -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) diff --git a/src/IO/Socket/Request.cpp b/src/io/socket/Request.cpp similarity index 99% rename from src/IO/Socket/Request.cpp rename to src/io/socket/Request.cpp index efa5bad..7cef3fe 100644 --- a/src/IO/Socket/Request.cpp +++ b/src/io/socket/Request.cpp @@ -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) diff --git a/src/IO/Socket/Response.cpp b/src/io/socket/Response.cpp similarity index 99% rename from src/IO/Socket/Response.cpp rename to src/io/socket/Response.cpp index f41523d..1f40cc1 100644 --- a/src/IO/Socket/Response.cpp +++ b/src/io/socket/Response.cpp @@ -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) diff --git a/src/IO/Socket/SSL.cpp b/src/io/socket/SSL.cpp similarity index 88% rename from src/IO/Socket/SSL.cpp rename to src/io/socket/SSL.cpp index 4ea0af9..276097b 100644 --- a/src/IO/Socket/SSL.cpp +++ b/src/io/socket/SSL.cpp @@ -1,11 +1,11 @@ -#include "IO/Socket/SSL.h" +#include "io/socket/SSL.h" #include #include #include #include -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; } diff --git a/src/IO/Socket/Socket.cpp b/src/io/socket/Socket.cpp similarity index 87% rename from src/IO/Socket/Socket.cpp rename to src/io/socket/Socket.cpp index 30e2585..1bc795b 100644 --- a/src/IO/Socket/Socket.cpp +++ b/src/io/socket/Socket.cpp @@ -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 #include -#elif defined(LWE_OS_LINUX) +#elif defined(EHS_OS_LINUX) #include #include #include @@ -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(); 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; } diff --git a/src/IO/Socket/TCP_BSD.cpp b/src/io/socket/TCP_BSD.cpp similarity index 74% rename from src/IO/Socket/TCP_BSD.cpp rename to src/io/socket/TCP_BSD.cpp index 458e5d9..cbeb021 100644 --- a/src/IO/Socket/TCP_BSD.cpp +++ b/src/io/socket/TCP_BSD.cpp @@ -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 #include @@ -8,30 +8,30 @@ #include #include -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; diff --git a/src/IO/Socket/TCP_W32.cpp b/src/io/socket/TCP_W32.cpp similarity index 73% rename from src/IO/Socket/TCP_W32.cpp rename to src/io/socket/TCP_W32.cpp index 70b23f1..3c09e88 100644 --- a/src/IO/Socket/TCP_W32.cpp +++ b/src/io/socket/TCP_W32.cpp @@ -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 #include -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; diff --git a/src/IO/Socket/UDP_BSD.cpp b/src/io/socket/UDP_BSD.cpp similarity index 76% rename from src/IO/Socket/UDP_BSD.cpp rename to src/io/socket/UDP_BSD.cpp index 4d7189a..978fe68 100644 --- a/src/IO/Socket/UDP_BSD.cpp +++ b/src/io/socket/UDP_BSD.cpp @@ -1,4 +1,4 @@ -#include "IO/Socket/UDP_BSD.h" +#include "io/socket/UDP_BSD.h" #include "Log.h" #include @@ -10,25 +10,25 @@ #include #include -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(); diff --git a/src/IO/Socket/UDP_W32.cpp b/src/io/socket/UDP_W32.cpp similarity index 75% rename from src/IO/Socket/UDP_W32.cpp rename to src/io/socket/UDP_W32.cpp index ff42307..fdca270 100644 --- a/src/IO/Socket/UDP_W32.cpp +++ b/src/io/socket/UDP_W32.cpp @@ -1,38 +1,38 @@ -#include "IO/Socket/UDP_W32.h" +#include "io/socket/UDP_W32.h" #include "Log.h" #include #include -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(); diff --git a/src/IO/Socket/RestAPIs/Spotify.cpp b/src/io/socket/rest/Spotify.cpp similarity index 97% rename from src/IO/Socket/RestAPIs/Spotify.cpp rename to src/io/socket/rest/Spotify.cpp index be685ce..1b75c73 100644 --- a/src/IO/Socket/RestAPIs/Spotify.cpp +++ b/src/io/socket/rest/Spotify.cpp @@ -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; } diff --git a/src/IO/Socket/RestAPIs/Twitch.cpp b/src/io/socket/rest/Twitch.cpp similarity index 91% rename from src/IO/Socket/RestAPIs/Twitch.cpp rename to src/io/socket/rest/Twitch.cpp index 2e60d22..6ffbee4 100644 --- a/src/IO/Socket/RestAPIs/Twitch.cpp +++ b/src/io/socket/rest/Twitch.cpp @@ -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; } diff --git a/src/IO/Socket/RestAPIs/TwitchChat.cpp b/src/io/socket/rest/TwitchChat.cpp similarity index 96% rename from src/IO/Socket/RestAPIs/TwitchChat.cpp rename to src/io/socket/rest/TwitchChat.cpp index cbe9a43..5099d5e 100644 --- a/src/IO/Socket/RestAPIs/TwitchChat.cpp +++ b/src/io/socket/rest/TwitchChat.cpp @@ -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() { diff --git a/src/IO/xdg-shell-protocol.c b/src/io/xdg-shell-protocol.c similarity index 100% rename from src/IO/xdg-shell-protocol.c rename to src/io/xdg-shell-protocol.c diff --git a/src/Json/Json.cpp b/src/json/Json.cpp similarity index 97% rename from src/Json/Json.cpp rename to src/json/Json.cpp index 410bccc..d86b81e 100644 --- a/src/Json/Json.cpp +++ b/src/json/Json.cpp @@ -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; } } diff --git a/src/Json/JsonArray.cpp b/src/json/JsonArray.cpp similarity index 98% rename from src/Json/JsonArray.cpp rename to src/json/JsonArray.cpp index 1cfe56f..43c6106 100644 --- a/src/Json/JsonArray.cpp +++ b/src/json/JsonArray.cpp @@ -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() { diff --git a/src/Json/JsonBase.cpp b/src/json/JsonBase.cpp similarity index 86% rename from src/Json/JsonBase.cpp rename to src/json/JsonBase.cpp index c2bc1dd..7be9874 100644 --- a/src/Json/JsonBase.cpp +++ b/src/json/JsonBase.cpp @@ -1,6 +1,6 @@ -#include "Json/JsonBase.h" +#include "json/JsonBase.h" -namespace lwe +namespace ehs { JsonBase::JsonBase() : type(JsonType::NULLOBJ) diff --git a/src/Json/JsonBool.cpp b/src/json/JsonBool.cpp similarity index 92% rename from src/Json/JsonBool.cpp rename to src/json/JsonBool.cpp index 59ae2f2..0b30d33 100644 --- a/src/Json/JsonBool.cpp +++ b/src/json/JsonBool.cpp @@ -1,6 +1,6 @@ -#include "Json/JsonBool.h" +#include "json/JsonBool.h" -namespace lwe +namespace ehs { JsonBool::JsonBool() : JsonBase(JsonType::BOOL), value(false) diff --git a/src/Json/JsonNum.cpp b/src/json/JsonNum.cpp similarity index 97% rename from src/Json/JsonNum.cpp rename to src/json/JsonNum.cpp index 3fe2e70..23f5997 100644 --- a/src/Json/JsonNum.cpp +++ b/src/json/JsonNum.cpp @@ -1,6 +1,6 @@ -#include "Json/JsonNum.h" +#include "json/JsonNum.h" -namespace lwe +namespace ehs { JsonNum::JsonNum() : JsonBase(JsonType::NUM), value(0.0f) diff --git a/src/Json/JsonObj.cpp b/src/json/JsonObj.cpp similarity index 98% rename from src/Json/JsonObj.cpp rename to src/json/JsonObj.cpp index 97bf69e..f532ebb 100644 --- a/src/Json/JsonObj.cpp +++ b/src/json/JsonObj.cpp @@ -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() { diff --git a/src/Json/JsonStr.cpp b/src/json/JsonStr.cpp similarity index 95% rename from src/Json/JsonStr.cpp rename to src/json/JsonStr.cpp index 1bae390..5eaadcb 100644 --- a/src/Json/JsonStr.cpp +++ b/src/json/JsonStr.cpp @@ -1,6 +1,6 @@ -#include "Json/JsonStr.h" +#include "json/JsonStr.h" -namespace lwe +namespace ehs { JsonStr::JsonStr() : JsonBase(JsonType::STR) diff --git a/src/Json/JsonVar.cpp b/src/json/JsonVar.cpp similarity index 97% rename from src/Json/JsonVar.cpp rename to src/json/JsonVar.cpp index e8e8554..9a92939 100644 --- a/src/Json/JsonVar.cpp +++ b/src/json/JsonVar.cpp @@ -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() { diff --git a/src/System/BaseMutex.cpp b/src/system/BaseMutex.cpp similarity index 93% rename from src/System/BaseMutex.cpp rename to src/system/BaseMutex.cpp index a4d7d57..dba691d 100644 --- a/src/System/BaseMutex.cpp +++ b/src/system/BaseMutex.cpp @@ -1,6 +1,6 @@ -#include "System/BaseMutex.h" +#include "system/BaseMutex.h" -namespace lwe +namespace ehs { BaseMutex::~BaseMutex() { diff --git a/src/System/BaseOpen.cpp b/src/system/BaseOpen.cpp similarity index 93% rename from src/System/BaseOpen.cpp rename to src/system/BaseOpen.cpp index bf9020b..dc9524b 100644 --- a/src/System/BaseOpen.cpp +++ b/src/system/BaseOpen.cpp @@ -1,6 +1,6 @@ -#include "System/BaseOpen.h" +#include "system/BaseOpen.h" -namespace lwe +namespace ehs { BaseOpen::BaseOpen() { diff --git a/src/System/BaseSemaphore.cpp b/src/system/BaseSemaphore.cpp similarity index 95% rename from src/System/BaseSemaphore.cpp rename to src/system/BaseSemaphore.cpp index d2b9890..2bf0756 100644 --- a/src/System/BaseSemaphore.cpp +++ b/src/system/BaseSemaphore.cpp @@ -1,6 +1,6 @@ -#include "System/BaseSemaphore.h" +#include "system/BaseSemaphore.h" -namespace lwe +namespace ehs { BaseSemaphore::BaseSemaphore() : initial(0) diff --git a/src/System/BaseSystem.cpp b/src/system/BaseSystem.cpp similarity index 54% rename from src/System/BaseSystem.cpp rename to src/system/BaseSystem.cpp index 2dd30fc..f7f0d83 100644 --- a/src/System/BaseSystem.cpp +++ b/src/system/BaseSystem.cpp @@ -1,6 +1,6 @@ -#include "System/BaseSystem.h" +#include "system/BaseSystem.h" -namespace lwe +namespace ehs { void BaseSystem::OpenURI(const Str_8& uri) { diff --git a/src/System/CPU.cpp b/src/system/CPU.cpp similarity index 95% rename from src/System/CPU.cpp rename to src/system/CPU.cpp index ec07761..c14280e 100644 --- a/src/System/CPU.cpp +++ b/src/system/CPU.cpp @@ -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 diff --git a/src/System/CPU_ARM64.cpp b/src/system/CPU_ARM64.cpp similarity index 92% rename from src/System/CPU_ARM64.cpp rename to src/system/CPU_ARM64.cpp index c6b11dc..669f598 100644 --- a/src/System/CPU_ARM64.cpp +++ b/src/system/CPU_ARM64.cpp @@ -1,6 +1,6 @@ -#include "System/CPU.h" +#include "system/CPU.h" -namespace lwe +namespace ehs { void CPU::RDTSCP(TSC* tsc) { diff --git a/src/System/CPU_GCC_AMD64.asm b/src/system/CPU_GCC_AMD64.asm similarity index 100% rename from src/System/CPU_GCC_AMD64.asm rename to src/system/CPU_GCC_AMD64.asm diff --git a/src/System/CPU_MSVC_AMD64.asm b/src/system/CPU_MSVC_AMD64.asm similarity index 100% rename from src/System/CPU_MSVC_AMD64.asm rename to src/system/CPU_MSVC_AMD64.asm diff --git a/src/System/FileSystem.cpp b/src/system/FileSystem.cpp similarity index 60% rename from src/System/FileSystem.cpp rename to src/system/FileSystem.cpp index 27acf71..1824eb3 100644 --- a/src/System/FileSystem.cpp +++ b/src/system/FileSystem.cpp @@ -1,25 +1,25 @@ -#include "System/FileSystem.h" +#include "system/FileSystem.h" #include "Log.h" #include #include #include -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)); } } \ No newline at end of file diff --git a/src/System/Mutex_PT.cpp b/src/system/Mutex_PT.cpp similarity index 95% rename from src/System/Mutex_PT.cpp rename to src/system/Mutex_PT.cpp index 19e5eb9..7ff8779 100644 --- a/src/System/Mutex_PT.cpp +++ b/src/system/Mutex_PT.cpp @@ -1,6 +1,6 @@ -#include "System/Mutex_PT.h" +#include "system/Mutex_PT.h" -namespace lwe +namespace ehs { Mutex::~Mutex() { diff --git a/src/System/Mutex_W32.cpp b/src/system/Mutex_W32.cpp similarity index 71% rename from src/System/Mutex_W32.cpp rename to src/system/Mutex_W32.cpp index c5164ab..99cc63a 100644 --- a/src/System/Mutex_W32.cpp +++ b/src/system/Mutex_W32.cpp @@ -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; } diff --git a/src/System/Open_UNX.cpp b/src/system/Open_UNX.cpp similarity index 84% rename from src/System/Open_UNX.cpp rename to src/system/Open_UNX.cpp index e9bd2ae..d8f5f8f 100644 --- a/src/System/Open_UNX.cpp +++ b/src/system/Open_UNX.cpp @@ -1,9 +1,9 @@ -#include "System/Open_UNX.h" +#include "system/Open_UNX.h" #include "Log.h" #include -namespace lwe +namespace ehs { Open::~Open() { @@ -11,7 +11,7 @@ namespace lwe return; if (dlclose(hdl)) - LWE_LOG_INT("Error", 0, "Failed to close."); + EHS_LOG_INT("Error", 0, "Failed to close."); } Open::Open() @@ -77,7 +77,7 @@ namespace lwe hdl = dlopen(filePath, RTLD_LAZY); if (!hdl) { - LWE_LOG_INT("Error", 0, dlerror()); + EHS_LOG_INT("Error", 0, dlerror()); return; } } @@ -88,7 +88,7 @@ namespace lwe return; if (dlclose(hdl)) - LWE_LOG_INT("Error", 0, "Failed to close."); + EHS_LOG_INT("Error", 0, "Failed to close."); hdl = nullptr; } @@ -102,7 +102,7 @@ namespace lwe if (!func) { dlerror(); - LWE_LOG_INT("Error", 0, "Undefined symbol, \"" + symbol + "\"."); + EHS_LOG_INT("Error", 0, "Undefined symbol, \"" + symbol + "\"."); Release(); return nullptr; } diff --git a/src/system/Open_W32.cpp b/src/system/Open_W32.cpp new file mode 100644 index 0000000..b2b579c --- /dev/null +++ b/src/system/Open_W32.cpp @@ -0,0 +1,5 @@ +#include "system/Open_W32.h" + +namespace ehs +{ +} \ No newline at end of file diff --git a/src/System/Semaphore_P.cpp b/src/system/Semaphore_P.cpp similarity index 84% rename from src/System/Semaphore_P.cpp rename to src/system/Semaphore_P.cpp index a3f7a97..f0f0e66 100644 --- a/src/System/Semaphore_P.cpp +++ b/src/system/Semaphore_P.cpp @@ -1,11 +1,11 @@ -#include "System/Semaphore_P.h" +#include "system/Semaphore_P.h" #include "Log.h" #include #include #include -namespace lwe +namespace ehs { Semaphore::~Semaphore() { @@ -13,7 +13,7 @@ namespace lwe return; if (sem_destroy(&hdl) == -1) - LWE_LOG_INT("Error", 0, "Failed to release semaphore with error #" + Str_8::FromNum(errno) + "."); + EHS_LOG_INT("Error", 0, "Failed to release semaphore with error #" + Str_8::FromNum(errno) + "."); valid = false; } @@ -92,14 +92,14 @@ namespace lwe { sem_t* result = sem_open("/" + GetName(), O_CREAT | O_EXCL, S_IRUSR | S_IWUSR, GetInitial()); if (!result) - LWE_LOG_INT("Error", 0, "Failed to create semaphore with error #" + Str_8::FromNum(errno) + "."); + EHS_LOG_INT("Error", 0, "Failed to create semaphore with error #" + Str_8::FromNum(errno) + "."); hdl = *result; } else { if (sem_init(&hdl, 0, GetInitial()) == -1) - LWE_LOG_INT("Error", 0, "Failed to create semaphore with error #" + Str_8::FromNum(errno) + "."); + EHS_LOG_INT("Error", 0, "Failed to create semaphore with error #" + Str_8::FromNum(errno) + "."); } valid = true; @@ -111,7 +111,7 @@ namespace lwe return; if (sem_destroy(&hdl) == -1) - LWE_LOG_INT("Error", 0, "Failed to release semaphore with error #" + Str_8::FromNum(errno) + "."); + EHS_LOG_INT("Error", 0, "Failed to release semaphore with error #" + Str_8::FromNum(errno) + "."); hdl = {}; @@ -124,7 +124,7 @@ namespace lwe return; if (sem_post(&hdl) == -1) - LWE_LOG_INT("Error", 0, "Failed to signal semaphore with error #" + Str_8::FromNum(errno) + "."); + EHS_LOG_INT("Error", 0, "Failed to signal semaphore with error #" + Str_8::FromNum(errno) + "."); } bool Semaphore::Wait(const UInt_32 timeout) @@ -134,7 +134,7 @@ namespace lwe int result; - if (timeout == LWE_INFINITE) + if (timeout == EHS_INFINITE) { result = sem_wait(&hdl); } @@ -148,7 +148,7 @@ namespace lwe { int code = errno; if (code != ETIMEDOUT) - LWE_LOG_INT("Error", 0, "Failed to wait for semaphore with error #" + Str_8::FromNum(errno) + "."); + EHS_LOG_INT("Error", 0, "Failed to wait for semaphore with error #" + Str_8::FromNum(errno) + "."); return false; } diff --git a/src/System/Semaphore_W32.cpp b/src/system/Semaphore_W32.cpp similarity index 81% rename from src/System/Semaphore_W32.cpp rename to src/system/Semaphore_W32.cpp index 7b5e350..4cba541 100644 --- a/src/System/Semaphore_W32.cpp +++ b/src/system/Semaphore_W32.cpp @@ -1,8 +1,8 @@ -#include "System/Semaphore_W32.h" +#include "system/Semaphore_W32.h" #include "UTF.h" #include "Log.h" -namespace lwe +namespace ehs { Semaphore::~Semaphore() { @@ -12,7 +12,7 @@ namespace lwe if (!CloseHandle(hdl)) { DWORD code = GetLastError(); - LWE_LOG_INT("Error", 0, Str_8("Failed to free semaphore with error #") + code + "."); + EHS_LOG_INT("Error", 0, Str_8("Failed to free semaphore with error #") + code + "."); } } @@ -80,9 +80,9 @@ namespace lwe if (IsValid()) return; - hdl = CreateSemaphoreW(nullptr, (LONG)GetInitial(), LWE_SINT_32_MAX, UTF::To_16(GetName())); + hdl = CreateSemaphoreW(nullptr, (LONG)GetInitial(), EHS_SINT_32_MAX, UTF::To_16(GetName())); if (!hdl) - LWE_LOG_INT("Error", 0, Str_8("Failed to create semaphore with error #") + GetLastError() + "."); + EHS_LOG_INT("Error", 0, Str_8("Failed to create semaphore with error #") + GetLastError() + "."); } void Semaphore::Release() @@ -93,7 +93,7 @@ namespace lwe if (!CloseHandle(hdl)) { DWORD code = GetLastError(); - LWE_LOG_INT("Error", 0, Str_8("Failed to free semaphore with error #") + code + "."); + EHS_LOG_INT("Error", 0, Str_8("Failed to free semaphore with error #") + code + "."); } hdl = nullptr; } @@ -104,7 +104,7 @@ namespace lwe return; if (!ReleaseSemaphore(hdl, (LONG)inc, nullptr)) - LWE_LOG_INT("Error", 0, Str_8("Failed to release semaphore with error #") + GetLastError() + "."); + EHS_LOG_INT("Error", 0, Str_8("Failed to release semaphore with error #") + GetLastError() + "."); } bool Semaphore::Wait(const UInt_32 timeout) @@ -115,12 +115,12 @@ namespace lwe DWORD result = WaitForSingleObject(hdl, timeout); if (result == WAIT_ABANDONED) { - LWE_LOG_INT("Error", 0, "Wait abandoned."); + EHS_LOG_INT("Error", 0, "Wait abandoned."); return false; } else if (result == WAIT_FAILED) { - LWE_LOG_INT("Error", 1, Str_8("Wait failed with error #") + GetLastError() + "."); + EHS_LOG_INT("Error", 1, Str_8("Wait failed with error #") + GetLastError() + "."); return false; } else if (result == WAIT_TIMEOUT) diff --git a/src/System/System_LNX.cpp b/src/system/System_LNX.cpp similarity index 78% rename from src/System/System_LNX.cpp rename to src/system/System_LNX.cpp index bc8b58f..9820f7e 100644 --- a/src/System/System_LNX.cpp +++ b/src/system/System_LNX.cpp @@ -1,8 +1,8 @@ -#include "System/System_LNX.h" -#include "System/Thread.h" +#include "system/System_LNX.h" +#include "system/Thread.h" #include "Log.h" -namespace lwe +namespace ehs { UInt_32 XDG_Thread(void* args) { diff --git a/src/System/System_W32.cpp b/src/system/System_W32.cpp similarity index 75% rename from src/System/System_W32.cpp rename to src/system/System_W32.cpp index dac9015..0cb4dd0 100644 --- a/src/System/System_W32.cpp +++ b/src/system/System_W32.cpp @@ -1,8 +1,8 @@ -#include "System/System_W32.h" +#include "system/System_W32.h" #include -namespace lwe +namespace ehs { void System::OpenURI(const Str_8& uri) { diff --git a/src/System/Thread.cpp b/src/system/Thread.cpp similarity index 75% rename from src/System/Thread.cpp rename to src/system/Thread.cpp index e2d6865..43cedf0 100644 --- a/src/System/Thread.cpp +++ b/src/system/Thread.cpp @@ -1,18 +1,18 @@ -#include "System/Thread.h" -#include "System/CPU.h" +#include "system/Thread.h" +#include "system/CPU.h" -#if defined(LWE_OS_WINDOWS) +#if defined(EHS_OS_WINDOWS) #include -#elif defined(LWE_OS_LINUX) +#elif defined(EHS_OS_LINUX) #include #include #endif -namespace lwe +namespace ehs { UInt_32 Thread::mainId = GetCurrentId(); - #ifdef LWE_OS_WINDOWS + #ifdef EHS_OS_WINDOWS Handle Thread::mainTaskHdl = nullptr; UInt_32 Thread::mainTaskIndex = 0; #endif @@ -23,16 +23,16 @@ namespace lwe } Thread::Thread(const UInt_64 stackSize) - : stackSize(stackSize), hdl(LWE_INVALID_THREAD), id(0) - #ifdef LWE_OS_WINDOWS + : stackSize(stackSize), hdl(EHS_INVALID_THREAD), id(0) + #ifdef EHS_OS_WINDOWS ,taskHdl(nullptr), taskIndex(0) #endif { } Thread::Thread(const Thread& thread) - : stackSize(thread.stackSize), hdl(LWE_INVALID_THREAD), id(0) - #ifdef LWE_OS_WINDOWS + : stackSize(thread.stackSize), hdl(EHS_INVALID_THREAD), id(0) + #ifdef EHS_OS_WINDOWS , taskHdl(nullptr), taskIndex(0) #endif { @@ -44,10 +44,10 @@ namespace lwe return *this; stackSize = thread.stackSize; - hdl = LWE_INVALID_THREAD; + hdl = EHS_INVALID_THREAD; id = 0; - #ifdef LWE_OS_WINDOWS + #ifdef EHS_OS_WINDOWS taskHdl = nullptr; taskIndex = 0; #endif @@ -57,11 +57,11 @@ namespace lwe void Thread::Start(UInt_32 (*cb)(void*), void* args) { - #if defined(LWE_OS_WINDOWS) + #if defined(EHS_OS_WINDOWS) hdl = CreateThread(nullptr, stackSize, (LPTHREAD_START_ROUTINE)cb, args, 0, (DWORD*)&id); if (!hdl) - LWE_LOG_INT("Error", 0, "Failed to start thread with error #" + Str_8::FromNum(GetLastError()) + "."); - #elif defined(LWE_OS_LINUX) + EHS_LOG_INT("Error", 0, "Failed to start thread with error #" + Str_8::FromNum(GetLastError()) + "."); + #elif defined(EHS_OS_LINUX) UInt_64* rArgs = new UInt_64[sizeof(UInt_64) * 2]; rArgs[0] = (UInt_64)cb; rArgs[1] = (UInt_64)args; @@ -72,14 +72,14 @@ namespace lwe bool Thread::Join(const unsigned int timeout) { - if (hdl == LWE_INVALID_THREAD) + if (hdl == EHS_INVALID_THREAD) return false; - #if defined(LWE_WINDOWS) + #if defined(EHS_WINDOWS) unsigned int r = WaitForSingleObject(hdl, timeout); if (r == WAIT_ABANDONED) { - LWE_LOG_INT("Error", 0, "Abandoned wait because a mutex was not released."); + EHS_LOG_INT("Error", 0, "Abandoned wait because a mutex was not released."); return false; } else if (r == WAIT_TIMEOUT) @@ -88,17 +88,17 @@ namespace lwe } else if (r == WAIT_FAILED) { - LWE_LOG_INT("Error", 1, "Failed to wait for thread with error #" + Str_8::FromNum(GetLastError()) + "."); + EHS_LOG_INT("Error", 1, "Failed to wait for thread with error #" + Str_8::FromNum(GetLastError()) + "."); return false; } mainTaskIndex = 0; - #elif defined(LWE_OS_LINUX) + #elif defined(EHS_OS_LINUX) int code = pthread_join((pthread_t)hdl, nullptr); if (code != 0) - LWE_LOG_INT("Error", 1, "Failed to wait for thread with error #" + Str_8::FromNum(code) + "."); + EHS_LOG_INT("Error", 1, "Failed to wait for thread with error #" + Str_8::FromNum(code) + "."); - hdl = LWE_INVALID_THREAD; + hdl = EHS_INVALID_THREAD; #endif return true; @@ -109,16 +109,16 @@ namespace lwe if (!hdl) return; - #if defined(LWE_OS_WINDOWS) + #if defined(EHS_OS_WINDOWS) if (!CloseHandle(hdl)) { - LWE_LOG_INT("Error", 0, "Failed to detach thread with error #" + Str_8::FromNum(GetLastError()) + "."); + EHS_LOG_INT("Error", 0, "Failed to detach thread with error #" + Str_8::FromNum(GetLastError()) + "."); return; } - #elif defined(LWE_OS_LINUX) + #elif defined(EHS_OS_LINUX) pthread_detach(hdl); - hdl = LWE_INVALID_THREAD; + hdl = EHS_INVALID_THREAD; #endif } @@ -147,7 +147,7 @@ namespace lwe return hdl; } - #ifdef LWE_OS_WINDOWS + #ifdef EHS_OS_WINDOWS void Thread::SetTaskType_32(const Str_32& task) { if (!IsCurrent()) @@ -155,7 +155,7 @@ namespace lwe taskHdl = AvSetMmThreadCharacteristicsW(UTF::To_16(task), (LPDWORD)&taskIndex); if (!taskHdl) - LWE_LOG_INT("Error", 0, "Failed to set the thread's characteristics with error #" + Str_8::FromNum(GetLastError()) + "."); + EHS_LOG_INT("Error", 0, "Failed to set the thread's characteristics with error #" + Str_8::FromNum(GetLastError()) + "."); } void Thread::SetTaskType_16(const Str_16& task) @@ -165,7 +165,7 @@ namespace lwe taskHdl = AvSetMmThreadCharacteristicsW(task, (LPDWORD)&taskIndex); if (!taskHdl) - LWE_LOG_INT("Error", 0, "Failed to set the thread's characteristics with error #" + Str_8::FromNum(GetLastError()) + "."); + EHS_LOG_INT("Error", 0, "Failed to set the thread's characteristics with error #" + Str_8::FromNum(GetLastError()) + "."); } void Thread::SetTaskType_8(const Str_8& task) @@ -175,7 +175,7 @@ namespace lwe taskHdl = AvSetMmThreadCharacteristicsW(UTF::To_16(task), (LPDWORD)&taskIndex); if (!taskHdl) - LWE_LOG_INT("Error", 0, "Failed to set the thread's characteristics with error #" + Str_8::FromNum(GetLastError()) + "."); + EHS_LOG_INT("Error", 0, "Failed to set the thread's characteristics with error #" + Str_8::FromNum(GetLastError()) + "."); } void Thread::RevertTaskType() @@ -184,7 +184,7 @@ namespace lwe return; if (!AvRevertMmThreadCharacteristics(taskHdl)) - LWE_LOG_INT("Error", 0, "Failed to revert the thread's characteristics with error #" + Str_8::FromNum(GetLastError()) + "."); + EHS_LOG_INT("Error", 0, "Failed to revert the thread's characteristics with error #" + Str_8::FromNum(GetLastError()) + "."); taskIndex = 0; } @@ -197,14 +197,14 @@ namespace lwe UInt_64 Thread::GetCurrentId() { - #if defined(LWE_OS_WINDOWS) + #if defined(EHS_OS_WINDOWS) return GetCurrentThreadId(); - #elif defined(LWE_OS_LINUX) + #elif defined(EHS_OS_LINUX) return pthread_self(); #endif } - #ifdef LWE_OS_WINDOWS + #ifdef EHS_OS_WINDOWS void Thread::SetMainTaskType_32(const Str_32& task) { if (GetCurrentId() != mainId) @@ -212,7 +212,7 @@ namespace lwe mainTaskHdl = AvSetMmThreadCharacteristicsW(UTF::To_16(task), (LPDWORD)&mainTaskIndex); if (!mainTaskHdl) - LWE_LOG_INT("Error", 0, "Failed to set the main thread's characteristics with error #" + Str_8::FromNum(GetLastError()) + "."); + EHS_LOG_INT("Error", 0, "Failed to set the main thread's characteristics with error #" + Str_8::FromNum(GetLastError()) + "."); } void Thread::SetMainTaskType_16(const Str_16& task) @@ -222,7 +222,7 @@ namespace lwe mainTaskHdl = AvSetMmThreadCharacteristicsW(task, (LPDWORD)&mainTaskIndex); if (!mainTaskHdl) - LWE_LOG_INT("Error", 0, "Failed to set the main thread's characteristics with error #" + Str_8::FromNum(GetLastError()) + "."); + EHS_LOG_INT("Error", 0, "Failed to set the main thread's characteristics with error #" + Str_8::FromNum(GetLastError()) + "."); } void Thread::SetMainTaskType_8(const Str_8& task) @@ -232,7 +232,7 @@ namespace lwe mainTaskHdl = AvSetMmThreadCharacteristicsW(UTF::To_16(task), (LPDWORD)&mainTaskIndex); if (!mainTaskHdl) - LWE_LOG_INT("Error", 0, "Failed to set the main thread's characteristics with error #" + Str_8::FromNum(GetLastError()) + "."); + EHS_LOG_INT("Error", 0, "Failed to set the main thread's characteristics with error #" + Str_8::FromNum(GetLastError()) + "."); } void Thread::RevertMainTaskType() @@ -241,7 +241,7 @@ namespace lwe return; if (!AvRevertMmThreadCharacteristics(mainTaskHdl)) - LWE_LOG_INT("Error", 0, "Failed to revert the main thread's characteristics with error #" + Str_8::FromNum(GetLastError()) + "."); + EHS_LOG_INT("Error", 0, "Failed to revert the main thread's characteristics with error #" + Str_8::FromNum(GetLastError()) + "."); mainTaskIndex = 0; } @@ -260,9 +260,9 @@ namespace lwe void Thread::SleepFor(const UInt_32 miliseconds) { - #if defined(LWE_OS_WINDOWS) + #if defined(EHS_OS_WINDOWS) Sleep(miliseconds); - #elif defined(LWE_OS_LINUX) + #elif defined(EHS_OS_LINUX) timespec req = {miliseconds / 1000, miliseconds % 1000 * 1000000}; nanosleep(&req, nullptr); #endif diff --git a/src/System/User.cpp b/src/system/User.cpp similarity index 75% rename from src/System/User.cpp rename to src/system/User.cpp index c462f91..8a05ce2 100644 --- a/src/System/User.cpp +++ b/src/system/User.cpp @@ -1,16 +1,16 @@ -#include "System/User.h" +#include "system/User.h" #include "Log.h" #include #include #include -namespace lwe +namespace ehs { void User::GetId(UInt_32* const real, UInt_32* const effective, UInt_32* const saved) { if (getresuid(real, effective, saved) == -1) - LWE_LOG_INT("Error", 0, strerror(errno)); + EHS_LOG_INT("Error", 0, strerror(errno)); } Str_8 User::GetName() @@ -18,7 +18,7 @@ namespace lwe SInt_64 max = sysconf(_SC_LOGIN_NAME_MAX); if (max == -1) { - LWE_LOG_INT("Error", 0, strerror(errno)); + EHS_LOG_INT("Error", 0, strerror(errno)); return {}; } @@ -27,7 +27,7 @@ namespace lwe if (getlogin_r(name, max) == -1) { delete[] name; - LWE_LOG_INT("Error", 1, strerror(errno)); + EHS_LOG_INT("Error", 1, strerror(errno)); return {}; }