From 0ec35111049dbee4fd0f66089be331ccaf2d28f5 Mon Sep 17 00:00:00 2001 From: d1str4ught Date: Mon, 18 Aug 2025 02:05:07 +0200 Subject: [PATCH] lib files are building --- src/common/utils.h | 2 +- src/db/BlockCountry.cpp | 2 +- src/db/CMakeLists.txt | 3 + src/db/ClientManager.cpp | 2 +- src/db/DBManager.h | 8 +-- src/db/Lock.cpp | 10 +-- src/db/Lock.h | 2 +- src/db/Main.cpp | 8 +-- src/db/stdafx.h | 2 +- src/db/version.cpp | 2 +- src/game/CMakeLists.txt | 3 + src/game/ClientPackageCryptInfo.cpp | 2 +- src/game/HackShield_Impl.cpp | 2 +- src/game/HackShield_Impl.h | 6 +- src/game/MarkConvert.cpp | 8 +-- src/game/XTrapManager.cpp | 8 +-- src/game/XTrapManager.h | 2 +- src/game/auth_brazil.cpp | 6 +- src/game/block_country.cpp | 2 +- src/game/cmd_general.cpp | 4 +- src/game/config.cpp | 12 ++-- src/game/desc_manager.cpp | 2 +- src/game/desc_manager.h | 2 +- src/game/dev_log.cpp | 2 +- src/game/input.cpp | 2 +- src/game/input_auth.cpp | 6 +- src/game/log.cpp | 2 +- src/game/main.cpp | 22 +++--- src/game/questlua.cpp | 2 +- src/game/questlua_dragonsoul.cpp | 2 +- src/game/questlua_dungeon.cpp | 2 +- src/game/questlua_game.cpp | 2 +- src/game/questlua_global.cpp | 2 +- src/game/questlua_guild.cpp | 2 +- src/game/questlua_horse.cpp | 2 +- src/game/questlua_item.cpp | 2 +- src/game/questlua_marriage.cpp | 2 +- src/game/questlua_monarch.cpp | 2 +- src/game/questlua_party.cpp | 2 +- src/game/questlua_pc.cpp | 2 +- src/game/questlua_pet.cpp | 2 +- src/game/questlua_quest.cpp | 2 +- src/game/questmanager.cpp | 2 +- src/game/questmanager.h | 2 +- src/game/utils.h | 2 +- src/game/version.cpp | 2 +- src/libgame/attribute.cpp | 2 +- src/libgame/grid.cpp | 4 +- src/libgame/targa.cpp | 2 +- src/libpoly/Poly.cpp | 2 +- src/libpoly/main.cpp | 4 +- src/libsql/AsyncSQL.cpp | 18 ++--- src/libsql/AsyncSQL.h | 12 ++-- src/libsql/Semaphore.cpp | 2 +- src/libsql/Semaphore.h | 4 +- src/libsql/Tellwait.cpp | 2 +- src/libsql/Tellwait.h | 2 +- src/libsql/stdafx.h | 2 +- src/libthecore/DES_table.h | 1 + src/libthecore/buffer.cpp | 18 ----- src/libthecore/buffer.h | 56 ++++++---------- src/libthecore/crypt.h | 31 ++++----- src/libthecore/des.cpp | 1 - src/libthecore/fdwatch.cpp | 7 +- src/libthecore/fdwatch.h | 100 +++++++++++++--------------- src/libthecore/gost.cpp | 60 +---------------- src/libthecore/hangul.cpp | 97 +++++++++++++-------------- src/libthecore/hangul.h | 24 ++----- src/libthecore/heart.cpp | 61 ++++++++--------- src/libthecore/heart.h | 14 ++-- src/libthecore/kstbl.cpp | 8 --- src/libthecore/kstbl.h | 10 +-- src/libthecore/log.cpp | 23 +++---- src/libthecore/log.h | 50 ++++++-------- src/libthecore/main.cpp | 13 +--- src/libthecore/main.h | 45 +++++-------- src/libthecore/memcpy.cpp | 2 +- src/libthecore/memcpy.h | 19 +----- src/libthecore/signal.cpp | 11 +-- src/libthecore/signal.h | 20 ++---- src/libthecore/socket.cpp | 35 ++++------ src/libthecore/socket.h | 51 +++++--------- src/libthecore/stdafx.h | 31 +++------ src/libthecore/tea.cpp | 28 +------- src/libthecore/typedef.h | 7 +- src/libthecore/utils.cpp | 4 +- src/libthecore/utils.h | 64 +++++++----------- src/libthecore/xdirent.cpp | 13 +--- src/libthecore/xdirent.h | 15 +---- src/libthecore/xgetopt.cpp | 4 +- src/libthecore/xgetopt.h | 5 +- src/libthecore/xmd5.cpp | 6 +- src/libthecore/xmd5.h | 17 +---- 93 files changed, 418 insertions(+), 759 deletions(-) diff --git a/src/common/utils.h b/src/common/utils.h index 5a32c42..c1050cd 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -95,7 +95,7 @@ inline bool str_to_number (double& out, const char *in) return true; } -#ifdef __FreeBSD__ +#ifdef OS_FREEBSD inline bool str_to_number (long double& out, const char *in) { if (0==in || 0==in[0]) return false; diff --git a/src/db/BlockCountry.cpp b/src/db/BlockCountry.cpp index d28cc52..9d5d448 100644 --- a/src/db/BlockCountry.cpp +++ b/src/db/BlockCountry.cpp @@ -106,7 +106,7 @@ bool CBlockCountry::IsBlockedCountryIp(const char *user_ip) BLOCK_IP_VECTOR::iterator iter; struct in_addr st_addr; -#ifndef __WIN32__ +#ifndef OS_WINDOWS if (0 == inet_aton(user_ip, &st_addr)) #else unsigned long in_address; diff --git a/src/db/CMakeLists.txt b/src/db/CMakeLists.txt index 80dcccd..f2c4318 100644 --- a/src/db/CMakeLists.txt +++ b/src/db/CMakeLists.txt @@ -9,6 +9,9 @@ target_link_libraries(db libsql libthecore libredis + + # external + mariadbclient ) if (WIN32) diff --git a/src/db/ClientManager.cpp b/src/db/ClientManager.cpp index ba89ed7..f13117b 100644 --- a/src/db/ClientManager.cpp +++ b/src/db/ClientManager.cpp @@ -3239,7 +3239,7 @@ int CClientManager::Process() } } -#ifdef __WIN32__ +#ifdef OS_WINDOWS if (_kbhit()) { int c = _getch(); switch (c) { diff --git a/src/db/DBManager.h b/src/db/DBManager.h index b7b544d..aab3b2a 100644 --- a/src/db/DBManager.h +++ b/src/db/DBManager.h @@ -1,13 +1,9 @@ -// vim:ts=8 sw=4 #ifndef __INC_METIN2_DB_DBMANAGER_H__ #define __INC_METIN2_DB_DBMANAGER_H__ -// Ŀؼ Ŭ ... ؼ ޾ƿ -// ϵ óѴ. -// ڵ by ķα׷ Ƴ~ = _=)b -#include +#include -#include "../../libsql/AsyncSQL.h" +#include "libsql/AsyncSQL.h" #define SQL_SAFE_LENGTH(size) (size * 2 + 1) #define QUERY_SAFE_LENGTH(size) (1024 + SQL_SAFE_LENGTH(size)) diff --git a/src/db/Lock.cpp b/src/db/Lock.cpp index 876836f..2019a04 100644 --- a/src/db/Lock.cpp +++ b/src/db/Lock.cpp @@ -12,7 +12,7 @@ CLock::~CLock() void CLock::Initialize() { m_bLocked = false; -#ifndef __WIN32__ +#ifndef OS_WINDOWS pthread_mutex_init(&m_lock, NULL); #else ::InitializeCriticalSection(&m_lock); @@ -22,7 +22,7 @@ void CLock::Initialize() void CLock::Destroy() { assert(!m_bLocked && "lock didn't released"); -#ifndef __WIN32__ +#ifndef OS_WINDOWS pthread_mutex_destroy(&m_lock); #else ::DeleteCriticalSection(&m_lock); @@ -31,7 +31,7 @@ void CLock::Destroy() int CLock::Trylock() { -#ifndef __WIN32__ +#ifndef OS_WINDOWS return pthread_mutex_trylock(&m_lock); #else return ::TryEnterCriticalSection(&m_lock); @@ -40,7 +40,7 @@ int CLock::Trylock() void CLock::Lock() { -#ifndef __WIN32__ +#ifndef OS_WINDOWS pthread_mutex_lock(&m_lock); #else ::EnterCriticalSection(&m_lock); @@ -52,7 +52,7 @@ void CLock::Unlock() { assert(m_bLocked && "lock didn't issued"); m_bLocked = false; -#ifndef __WIN32__ +#ifndef OS_WINDOWS pthread_mutex_unlock(&m_lock); #else ::LeaveCriticalSection(&m_lock); diff --git a/src/db/Lock.h b/src/db/Lock.h index d0ae58a..6e82fc8 100644 --- a/src/db/Lock.h +++ b/src/db/Lock.h @@ -2,7 +2,7 @@ #ifndef __INC_LOCK_H__ #define __INC_LOCK_H__ -#ifdef __WIN32__ +#ifdef OS_WINDOWS typedef CRITICAL_SECTION lock_t; #else typedef pthread_mutex_t lock_t; diff --git a/src/db/Main.cpp b/src/db/Main.cpp index 2abc8f0..2442cd8 100644 --- a/src/db/Main.cpp +++ b/src/db/Main.cpp @@ -16,7 +16,7 @@ #include "AuctionManager.h" #endif #include -#undef __FreeBSD__ +#undef OS_FREEBSD void SetPlayerDBName(const char* c_pszPlayerDBName); void SetTablePostfix(const char* c_pszTablePostfix); int Start(); @@ -44,7 +44,7 @@ int g_log = 1; int g_iItemPriceListTableCacheFlushSeconds = 540; // END_OF_MYSHOP_PRICE_LIST -#ifdef __FreeBSD__ +#ifdef OS_FREEBSD extern const char * _malloc_options; #endif @@ -65,7 +65,7 @@ int main() { WriteVersion(); -#ifdef __FreeBSD__ +#ifdef OS_FREEBSD _malloc_options = "A"; #endif @@ -392,7 +392,7 @@ int Start() return false; } -#ifndef __WIN32__ +#ifndef OS_WINDOWS signal(SIGUSR1, emergency_sig); #endif signal(SIGSEGV, emergency_sig); diff --git a/src/db/stdafx.h b/src/db/stdafx.h index c36c862..c3465b2 100644 --- a/src/db/stdafx.h +++ b/src/db/stdafx.h @@ -3,7 +3,7 @@ #include "../../libthecore/include/stdafx.h" -#ifndef __WIN32__ +#ifndef OS_WINDOWS #include #else #define isdigit iswdigit diff --git a/src/db/version.cpp b/src/db/version.cpp index 8142fa6..962e778 100644 --- a/src/db/version.cpp +++ b/src/db/version.cpp @@ -3,7 +3,7 @@ void WriteVersion() { -#ifndef __WIN32__ +#ifndef OS_WINDOWS FILE* fp(fopen("VERSION.txt", "w")); if (NULL != fp) diff --git a/src/game/CMakeLists.txt b/src/game/CMakeLists.txt index 33d45ce..438cc7b 100644 --- a/src/game/CMakeLists.txt +++ b/src/game/CMakeLists.txt @@ -9,6 +9,9 @@ target_link_libraries(game libsql libthecore liblua + + # external + mariadbclient ) if (WIN32) diff --git a/src/game/ClientPackageCryptInfo.cpp b/src/game/ClientPackageCryptInfo.cpp index eb7ea0b..8ac6516 100644 --- a/src/game/ClientPackageCryptInfo.cpp +++ b/src/game/ClientPackageCryptInfo.cpp @@ -2,7 +2,7 @@ #include "ClientPackageCryptInfo.h" #include "../../common/stl.h" -#ifndef __FreeBSD__ +#ifndef OS_FREEBSD #include "../../libthecore/include/xdirent.h" #endif diff --git a/src/game/HackShield_Impl.cpp b/src/game/HackShield_Impl.cpp index 1cdd0f1..becce40 100644 --- a/src/game/HackShield_Impl.cpp +++ b/src/game/HackShield_Impl.cpp @@ -2,7 +2,7 @@ #include "HackShield_Impl.h" -#ifdef __FreeBSD__ +#ifdef OS_FREEBSD #include "char.h" #include "packet.h" diff --git a/src/game/HackShield_Impl.h b/src/game/HackShield_Impl.h index c8e317f..05974b2 100644 --- a/src/game/HackShield_Impl.h +++ b/src/game/HackShield_Impl.h @@ -4,7 +4,7 @@ #include -#ifdef __FreeBSD__ +#ifdef OS_FREEBSD // Live build only #define UNIX #include @@ -16,7 +16,7 @@ typedef struct SPacketGCHSCheck { BYTE bHeader; -#ifdef __FreeBSD__ +#ifdef OS_FREEBSD AHNHS_TRANS_BUFFER Req; #endif } TPacketGCHSCheck; @@ -36,7 +36,7 @@ class CHackShieldImpl bool VerifyAck (LPCHARACTER ch, TPacketGCHSCheck* buf); private: -#ifdef __FreeBSD__ +#ifdef OS_FREEBSD AHNHS_SERVER_HANDLE handle_; typedef std::unordered_map ClientHandleContainer; diff --git a/src/game/MarkConvert.cpp b/src/game/MarkConvert.cpp index 01eff54..684055d 100644 --- a/src/game/MarkConvert.cpp +++ b/src/game/MarkConvert.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #include "MarkManager.h" -#ifdef __WIN32__ +#ifdef OS_WINDOWS #include #endif @@ -31,14 +31,14 @@ static Pixel * LoadOldGuildMarkImageFile() bool GuildMarkConvert(const std::vector & vecGuildID) { // -#ifndef __WIN32__ +#ifndef OS_WINDOWS mkdir("mark", S_IRWXU); #else _mkdir("mark"); #endif // ε ֳ? -#ifndef __WIN32__ +#ifndef OS_WINDOWS if (0 != access(OLD_MARK_INDEX_FILENAME, F_OK)) #else if (0 != _access(OLD_MARK_INDEX_FILENAME, 0)) @@ -120,7 +120,7 @@ bool GuildMarkConvert(const std::vector & vecGuildID) fclose(fp); // Ʈ ѹ ϸǹǷ Űش. -#ifndef __WIN32__ +#ifndef OS_WINDOWS system("mv -f guild_mark.idx guild_mark.idx.removable"); system("mv -f guild_mark.tga guild_mark.tga.removable"); #else diff --git a/src/game/XTrapManager.cpp b/src/game/XTrapManager.cpp index bf4a92c..0354501 100644 --- a/src/game/XTrapManager.cpp +++ b/src/game/XTrapManager.cpp @@ -55,7 +55,7 @@ CXTrapManager::CXTrapManager() CXTrapManager::~CXTrapManager() { -#ifdef __FreeBSD__ +#ifdef OS_FREEBSD if (m_pImpl->hXTrap4Server) { dlclose(m_pImpl->hXTrap4Server); @@ -65,7 +65,7 @@ CXTrapManager::~CXTrapManager() M2_DELETE(m_pImpl); } -#ifdef __FreeBSD__ +#ifdef OS_FREEBSD void CXTrapManager::MapReloadSignalHandler( int signal ) { for(int i=0; i= CSFILE_NUM ) { diff --git a/src/game/XTrapManager.h b/src/game/XTrapManager.h index a2a2e8a..b3e1735 100644 --- a/src/game/XTrapManager.h +++ b/src/game/XTrapManager.h @@ -33,7 +33,7 @@ public: bool Verify_CSStep1( LPCHARACTER lpCharSession, BYTE* pOutBufData ); void Verify_CSStep3( LPCHARACTER lpCharSession, BYTE* pBufData ); -#ifdef __FreeBSD__ +#ifdef OS_FREEBSD static void MapReloadSignalHandler( int signal ); static void NotifyMapFileChanged( const std::string& fileName, eFileUpdatedOptions eUpdateOption ); diff --git a/src/game/auth_brazil.cpp b/src/game/auth_brazil.cpp index dec588f..727898f 100644 --- a/src/game/auth_brazil.cpp +++ b/src/game/auth_brazil.cpp @@ -7,13 +7,13 @@ */ #include "stdafx.h" -#ifndef __WIN32__ +#ifndef OS_WINDOWS #include #include #endif #include #include -#ifdef __FreeBSD__ +#ifdef OS_FREEBSD #include #else #include "../../libthecore/include/xmd5.h" @@ -109,7 +109,7 @@ int auth_brazil(const char *login, const char *pwd) char request[512]; int len = FN_make_request(login, pwd, request, sizeof(request)); -#ifndef __WIN32__ +#ifndef OS_WINDOWS if (write(fd, request, len) < 0) #else if (_write(fd, request, len) < 0) diff --git a/src/game/block_country.cpp b/src/game/block_country.cpp index 5f59fe0..371ae2f 100644 --- a/src/game/block_country.cpp +++ b/src/game/block_country.cpp @@ -110,7 +110,7 @@ bool is_blocked_country_ip(const char *user_ip) DWORD ip_number; struct in_addr st_addr; -#ifndef __WIN32__ +#ifndef OS_WINDOWS if (0 == inet_aton(user_ip, &st_addr)) #else unsigned long in_address; diff --git a/src/game/cmd_general.cpp b/src/game/cmd_general.cpp index afc0c9b..a897811 100644 --- a/src/game/cmd_general.cpp +++ b/src/game/cmd_general.cpp @@ -1,5 +1,5 @@ #include "stdafx.h" -#ifdef __FreeBSD__ +#ifdef OS_FREEBSD #include #else #include "../../libthecore/include/xmd5.h" @@ -2367,7 +2367,7 @@ ACMD(do_in_game_mall) MD5Init(&ctx); MD5Update(&ctx, (const unsigned char *) buf, strlen(buf)); -#ifdef __FreeBSD__ +#ifdef OS_FREEBSD MD5End(&ctx, sas); #else static const char hex[] = "0123456789abcdef"; diff --git a/src/game/config.cpp b/src/game/config.cpp index f29a919..51ca59d 100644 --- a/src/game/config.cpp +++ b/src/game/config.cpp @@ -1,6 +1,6 @@ #include "stdafx.h" #include -#ifndef __WIN32__ +#ifndef OS_WINDOWS #include #endif @@ -233,7 +233,7 @@ static void FN_log_adminpage() bool GetIPInfo() { -#ifndef __WIN32__ +#ifndef OS_WINDOWS struct ifaddrs* ifaddrp = NULL; if (0 != getifaddrs(&ifaddrp)) @@ -273,7 +273,7 @@ bool GetIPInfo() if (!strncmp(netip, "192.168", 7)) // ignore if address is starting with 192 { strlcpy(g_szInternalIP, netip, sizeof(g_szInternalIP)); -#ifndef __WIN32__ +#ifndef OS_WINDOWS fprintf(stderr, "INTERNAL_IP: %s interface %s\n", netip, ifap->ifa_name); #else fprintf(stderr, "INTERNAL_IP: %s\n", netip); @@ -282,7 +282,7 @@ bool GetIPInfo() else if (!strncmp(netip, "10.", 3)) { strlcpy(g_szInternalIP, netip, sizeof(g_szInternalIP)); -#ifndef __WIN32__ +#ifndef OS_WINDOWS fprintf(stderr, "INTERNAL_IP: %s interface %s\n", netip, ifap->ifa_name); #else fprintf(stderr, "INTERNAL_IP: %s\n", netip); @@ -291,7 +291,7 @@ bool GetIPInfo() else if (g_szPublicIP[0] == '0') { strlcpy(g_szPublicIP, netip, sizeof(g_szPublicIP)); -#ifndef __WIN32__ +#ifndef OS_WINDOWS fprintf(stderr, "PUBLIC_IP: %s interface %s\n", netip, ifap->ifa_name); #else fprintf(stderr, "PUBLIC_IP: %s\n", netip); @@ -299,7 +299,7 @@ bool GetIPInfo() } } -#ifndef __WIN32__ +#ifndef OS_WINDOWS freeifaddrs( ifaddrp ); #else WSACleanup(); diff --git a/src/game/desc_manager.cpp b/src/game/desc_manager.cpp index 1cb1c00..e5a3271 100644 --- a/src/game/desc_manager.cpp +++ b/src/game/desc_manager.cpp @@ -516,7 +516,7 @@ bool DESC_MANAGER::LoadClientPackageCryptInfo(const char* pDirName) { return m_pPackageCrypt->LoadPackageCryptInfo(pDirName); } -#ifdef __FreeBSD__ +#ifdef OS_FREEBSD void DESC_MANAGER::NotifyClientPackageFileChanged( const std::string& dirName, eFileUpdatedOptions eUpdateOption ) { Instance().LoadClientPackageCryptInfo(dirName.c_str()); diff --git a/src/game/desc_manager.h b/src/game/desc_manager.h index ef5c834..ef99edb 100644 --- a/src/game/desc_manager.h +++ b/src/game/desc_manager.h @@ -69,7 +69,7 @@ class DESC_MANAGER : public singleton bool LoadClientPackageCryptInfo(const char* pDirName); void SendClientPackageCryptKey( LPDESC desc ); void SendClientPackageSDBToLoadMap( LPDESC desc, const char* pMapName ); -#ifdef __FreeBSD__ +#ifdef OS_FREEBSD static void NotifyClientPackageFileChanged( const std::string& fileName, eFileUpdatedOptions eUpdateOption ); #endif diff --git a/src/game/dev_log.cpp b/src/game/dev_log.cpp index 606af91..a9b3bac 100644 --- a/src/game/dev_log.cpp +++ b/src/game/dev_log.cpp @@ -48,7 +48,7 @@ void dev_log(const char *file, int line, const char *function, int level, const // --------------------------------------- // open file // --------------------------------------- -#ifndef __WIN32__ +#ifndef OS_WINDOWS fd = ::open("DEV_LOG.log", O_WRONLY|O_APPEND|O_CREAT, 0666); #else fd = ::_open("DEV_LOG.log", _O_WRONLY|_O_APPEND|_O_CREAT, 0666); diff --git a/src/game/input.cpp b/src/game/input.cpp index 64bc4a0..813eb4f 100644 --- a/src/game/input.cpp +++ b/src/game/input.cpp @@ -19,7 +19,7 @@ #include "dev_log.h" // #include "HackShield_Impl.h" -#ifndef __WIN32__ +#ifndef OS_WINDOWS #include "limit_time.h" #endif diff --git a/src/game/input_auth.cpp b/src/game/input_auth.cpp index 34f5ef8..4968ead 100644 --- a/src/game/input_auth.cpp +++ b/src/game/input_auth.cpp @@ -11,7 +11,7 @@ #include "auth_brazil.h" #include "db.h" -#ifndef __WIN32__ +#ifndef OS_WINDOWS #include "limit_time.h" #endif @@ -431,7 +431,7 @@ int CInputAuth::auth_OpenID(const char *authKey, const char *ipAddr, char *rID) //"/kyw/gameauth.php", authKey, ipAddr); openid_uri, authKey, ipAddr, openid_host); -//#ifndef __WIN32__ +//#ifndef OS_WINDOWS // if (write(fd, request, len) < 0) //#else if (socket_write(fd, request, len) < 0) @@ -446,7 +446,7 @@ int CInputAuth::auth_OpenID(const char *authKey, const char *ipAddr, char *rID) // read reply char reply[1024] = {0}; int len; -//#ifndef __WIN32__ +//#ifndef OS_WINDOWS // len = read(fd, reply, sizeof(reply)); //#else len = socket_read(fd, reply, sizeof(reply)); diff --git a/src/game/log.cpp b/src/game/log.cpp index 8bc68de..bead477 100644 --- a/src/game/log.cpp +++ b/src/game/log.cpp @@ -318,7 +318,7 @@ void LogManager::DragonSlayLog(DWORD dwGuildID, DWORD dwDragonVnum, DWORD dwStar // { // struct in_addr st_addr; -// #ifndef __WIN32__ +// #ifndef OS_WINDOWS // if (0 == inet_aton(ch->GetDesc()->GetHostName(), &st_addr)) // #else // unsigned long in_address; diff --git a/src/game/main.cpp b/src/game/main.cpp index 42bce73..24d9d9a 100644 --- a/src/game/main.cpp +++ b/src/game/main.cpp @@ -64,13 +64,13 @@ // #include "XTrapManager.h" #include "DragonSoul.h" #include -#ifndef __WIN32__ +#ifndef OS_WINDOWS #include "limit_time.h" #endif //#define __FILEMONITOR__ -#if defined (__FreeBSD__) && defined(__FILEMONITOR__) +#if defined (OS_FREEBSD) && defined(__FILEMONITOR__) #include "FileMonitor_FreeBSD.h" #endif @@ -78,7 +78,7 @@ #include "auction_manager.h" #endif -// #ifndef __WIN32__ +// #ifndef OS_WINDOWS // #include // #endif @@ -94,7 +94,7 @@ extern void WriteVersion(); //extern const char * _malloc_options; -#if defined(__FreeBSD__) && defined(DEBUG_ALLOC) +#if defined(OS_FREEBSD) && defined(DEBUG_ALLOC) extern void (*_malloc_message)(const char* p1, const char* p2, const char* p3, const char* p4); // FreeBSD _malloc_message replacement void WriteMallocMessage(const char* p1, const char* p2, const char* p3, const char* p4) { @@ -317,7 +317,7 @@ void heartbeat(LPHEART ht, int pulse) CHARACTER_MANAGER::instance().ProcessDelayedSave(); //4 -#if defined (__FreeBSD__) && defined(__FILEMONITOR__) +#if defined (OS_FREEBSD) && defined(__FILEMONITOR__) if (!(pulse % (passes_per_sec * 5))) { FileMonitorFreeBSD::Instance().Update(pulse); @@ -448,7 +448,7 @@ int main(int argc, char **argv) DebugAllocator::StaticSetUp(); #endif -// #ifndef __WIN32__ +// #ifndef OS_WINDOWS // // start unit tests if option is set // if ( argc > 1 ) // { @@ -579,7 +579,7 @@ int main(int argc, char **argv) // CleanUpForEarlyExit(); // return 0; // } -// #if defined (__FreeBSD__) && defined(__FILEMONITOR__) +// #if defined (OS_FREEBSD) && defined(__FILEMONITOR__) // // PFN_FileChangeListener pNotifyFunc = boost::bind( &CXTrapManager::NotifyMapFileChanged, CXTrapManager::instance(), _1 ); // PFN_FileChangeListener pNotifyFunc = &(CXTrapManager::NotifyMapFileChanged); @@ -601,7 +601,7 @@ int main(int argc, char **argv) sys_err("Failed to Load ClientPackageCryptInfo File(%s)", strPackageCryptInfoDir.c_str()); } -#if defined (__FreeBSD__) && defined(__FILEMONITOR__) +#if defined (OS_FREEBSD) && defined(__FILEMONITOR__) PFN_FileChangeListener pPackageNotifyFunc = &(DESC_MANAGER::NotifyClientPackageFileChanged); //FileMonitorFreeBSD::Instance().AddWatch( strPackageCryptInfoName, pPackageNotifyFunc ); #endif @@ -705,7 +705,7 @@ int start(int argc, char **argv) char ch; //_malloc_options = "A"; -#if defined(__FreeBSD__) && defined(DEBUG_ALLOC) +#if defined(OS_FREEBSD) && defined(DEBUG_ALLOC) _malloc_message = WriteMallocMessage; #endif #ifdef ENABLE_LIMIT_TIME @@ -788,7 +788,7 @@ int start(int argc, char **argv) config_init(st_localeServiceName); // END_OF_LOCALE_SERVICE -#ifdef __WIN32__ +#ifdef OS_WINDOWS // In Windows dev mode, "verbose" option is [on] by default. bVerbose = true; #endif @@ -983,7 +983,7 @@ int idle() } #endif -#ifdef __WIN32__ +#ifdef OS_WINDOWS if (_kbhit()) { int c = _getch(); switch (c) { diff --git a/src/game/questlua.cpp b/src/game/questlua.cpp index def9dcb..d628f34 100644 --- a/src/game/questlua.cpp +++ b/src/game/questlua.cpp @@ -20,7 +20,7 @@ #include "sectree_manager.h" #undef sys_err -#ifndef __WIN32__ +#ifndef OS_WINDOWS #define sys_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args) #else #define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, __VA_ARGS__) diff --git a/src/game/questlua_dragonsoul.cpp b/src/game/questlua_dragonsoul.cpp index 3073b85..0f9351d 100644 --- a/src/game/questlua_dragonsoul.cpp +++ b/src/game/questlua_dragonsoul.cpp @@ -5,7 +5,7 @@ #include "char.h" #undef sys_err -#ifndef __WIN32__ +#ifndef OS_WINDOWS #define sys_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args) #else #define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, __VA_ARGS__) diff --git a/src/game/questlua_dungeon.cpp b/src/game/questlua_dungeon.cpp index 228e192..7b6ab91 100644 --- a/src/game/questlua_dungeon.cpp +++ b/src/game/questlua_dungeon.cpp @@ -13,7 +13,7 @@ #undef sys_err -#ifndef __WIN32__ +#ifndef OS_WINDOWS #define sys_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args) #else #define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, __VA_ARGS__) diff --git a/src/game/questlua_game.cpp b/src/game/questlua_game.cpp index bb8439b..6a17377 100644 --- a/src/game/questlua_game.cpp +++ b/src/game/questlua_game.cpp @@ -9,7 +9,7 @@ #include "packet.h" #undef sys_err -#ifndef __WIN32__ +#ifndef OS_WINDOWS #define sys_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args) #else #define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, __VA_ARGS__) diff --git a/src/game/questlua_global.cpp b/src/game/questlua_global.cpp index b8b5a69..7ad39a8 100644 --- a/src/game/questlua_global.cpp +++ b/src/game/questlua_global.cpp @@ -25,7 +25,7 @@ #include "sectree_manager.h" #undef sys_err -#ifndef __WIN32__ +#ifndef OS_WINDOWS #define sys_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args) #else #define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, __VA_ARGS__) diff --git a/src/game/questlua_guild.cpp b/src/game/questlua_guild.cpp index c2c5ed3..3d0a94f 100644 --- a/src/game/questlua_guild.cpp +++ b/src/game/questlua_guild.cpp @@ -10,7 +10,7 @@ #include "guild_manager.h" #undef sys_err -#ifndef __WIN32__ +#ifndef OS_WINDOWS #define sys_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args) #else #define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, __VA_ARGS__) diff --git a/src/game/questlua_horse.cpp b/src/game/questlua_horse.cpp index 599207c..91708a8 100644 --- a/src/game/questlua_horse.cpp +++ b/src/game/questlua_horse.cpp @@ -9,7 +9,7 @@ #include "utils.h" #undef sys_err -#ifndef __WIN32__ +#ifndef OS_WINDOWS #define sys_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args) #else #define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, __VA_ARGS__) diff --git a/src/game/questlua_item.cpp b/src/game/questlua_item.cpp index befc676..4945ba6 100644 --- a/src/game/questlua_item.cpp +++ b/src/game/questlua_item.cpp @@ -7,7 +7,7 @@ #include "log.h" #undef sys_err -#ifndef __WIN32__ +#ifndef OS_WINDOWS #define sys_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args) #else #define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, __VA_ARGS__) diff --git a/src/game/questlua_marriage.cpp b/src/game/questlua_marriage.cpp index fb08d54..e2c5fa0 100644 --- a/src/game/questlua_marriage.cpp +++ b/src/game/questlua_marriage.cpp @@ -7,7 +7,7 @@ #include "config.h" #undef sys_err -#ifndef __WIN32__ +#ifndef OS_WINDOWS #define sys_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args) #else #define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, __VA_ARGS__) diff --git a/src/game/questlua_monarch.cpp b/src/game/questlua_monarch.cpp index 3d1374e..a6152b3 100644 --- a/src/game/questlua_monarch.cpp +++ b/src/game/questlua_monarch.cpp @@ -17,7 +17,7 @@ #include "sectree_manager.h" #undef sys_err -#ifndef __WIN32__ +#ifndef OS_WINDOWS #define sys_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args) #else #define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, __VA_ARGS__) diff --git a/src/game/questlua_party.cpp b/src/game/questlua_party.cpp index b934255..4f3eb6f 100644 --- a/src/game/questlua_party.cpp +++ b/src/game/questlua_party.cpp @@ -9,7 +9,7 @@ #include "packet.h" #undef sys_err -#ifndef __WIN32__ +#ifndef OS_WINDOWS #define sys_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args) #else #define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, __VA_ARGS__) diff --git a/src/game/questlua_pc.cpp b/src/game/questlua_pc.cpp index 9db590a..85c44d1 100644 --- a/src/game/questlua_pc.cpp +++ b/src/game/questlua_pc.cpp @@ -25,7 +25,7 @@ #include #undef sys_err -#ifndef __WIN32__ +#ifndef OS_WINDOWS #define sys_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args) #else #define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, __VA_ARGS__) diff --git a/src/game/questlua_pet.cpp b/src/game/questlua_pet.cpp index 87ccefd..09c2e03 100644 --- a/src/game/questlua_pet.cpp +++ b/src/game/questlua_pet.cpp @@ -11,7 +11,7 @@ #include "PetSystem.h" #undef sys_err -#ifndef __WIN32__ +#ifndef OS_WINDOWS #define sys_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args) #else #define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, __VA_ARGS__) diff --git a/src/game/questlua_quest.cpp b/src/game/questlua_quest.cpp index e20fa19..32ae029 100644 --- a/src/game/questlua_quest.cpp +++ b/src/game/questlua_quest.cpp @@ -4,7 +4,7 @@ #include "questmanager.h" #undef sys_err -#ifndef __WIN32__ +#ifndef OS_WINDOWS #define sys_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args) #else #define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, __VA_ARGS__) diff --git a/src/game/questmanager.cpp b/src/game/questmanager.cpp index 0f968fa..fd5a557 100644 --- a/src/game/questmanager.cpp +++ b/src/game/questmanager.cpp @@ -1657,7 +1657,7 @@ namespace quest GetCurrentCharacterPtr()->ChatPacket(CHAT_TYPE_PARTY, "LUA_ERROR: quest %s.%s %s", GetCurrentQuestName().c_str(), state_name, event_index_name.c_str() ); } -#ifndef __WIN32__ +#ifndef OS_WINDOWS void CQuestManager::QuestError(const char* func, int line, const char* fmt, ...) { char szMsg[4096]; diff --git a/src/game/questmanager.h b/src/game/questmanager.h index b946b53..5a91549 100644 --- a/src/game/questmanager.h +++ b/src/game/questmanager.h @@ -167,7 +167,7 @@ namespace quest void ClearError() { m_bError = false; } bool IsError() { return m_bError; } void WriteRunningStateToSyserr(); -#ifndef __WIN32__ +#ifndef OS_WINDOWS void QuestError(const char* func, int line, const char* fmt, ...); #else //void QuestError(const char* fmt, ...); diff --git a/src/game/utils.h b/src/game/utils.h index 707107f..4b1146d 100644 --- a/src/game/utils.h +++ b/src/game/utils.h @@ -40,7 +40,7 @@ inline int DISTANCE_APPROX(int dx, int dy) ( min << 7 ) - ( min << 5 ) + ( min << 3 ) - ( min << 1 )) >> 8 ); } -#ifndef __WIN32__ +#ifndef OS_WINDOWS inline WORD MAKEWORD(BYTE a, BYTE b) { return static_cast(a) | (static_cast(b) << 8); diff --git a/src/game/version.cpp b/src/game/version.cpp index e05f501..fc2d98f 100644 --- a/src/game/version.cpp +++ b/src/game/version.cpp @@ -2,7 +2,7 @@ void WriteVersion() { -#ifndef __WIN32__ +#ifndef OS_WINDOWS FILE* fp = fopen("version.txt", "w"); if (fp) diff --git a/src/libgame/attribute.cpp b/src/libgame/attribute.cpp index c57a954..b98ecae 100644 --- a/src/libgame/attribute.cpp +++ b/src/libgame/attribute.cpp @@ -1,4 +1,4 @@ -#include "../../libthecore/include/stdafx.h" +#include "libthecore/stdafx.h" #include "attribute.h" #define SET_BIT(var,bit) ((var) |= (bit)) diff --git a/src/libgame/grid.cpp b/src/libgame/grid.cpp index e18cda5..834d734 100644 --- a/src/libgame/grid.cpp +++ b/src/libgame/grid.cpp @@ -1,7 +1,7 @@ #include #include -#include "../../libthecore/include/memcpy.h" -#include "../../common/stl.h" +#include "libthecore/memcpy.h" +#include "common/stl.h" #include "grid.h" #include CGrid::CGrid(int w, int h) : m_iWidth(w), m_iHeight(h) diff --git a/src/libgame/targa.cpp b/src/libgame/targa.cpp index 63734fe..5481543 100644 --- a/src/libgame/targa.cpp +++ b/src/libgame/targa.cpp @@ -1,4 +1,4 @@ -#include "../../libthecore/include/stdafx.h" +#include "libthecore/stdafx.h" #include #include #include "targa.h" diff --git a/src/libpoly/Poly.cpp b/src/libpoly/Poly.cpp index 023910d..2f4229b 100644 --- a/src/libpoly/Poly.cpp +++ b/src/libpoly/Poly.cpp @@ -9,7 +9,7 @@ using namespace std; double _random() { -#ifndef __WIN32__ +#ifndef OS_WINDOWS return random() / (2147483648.0); #else return rand() / (2147483648.0); diff --git a/src/libpoly/main.cpp b/src/libpoly/main.cpp index e81dd63..145d12f 100644 --- a/src/libpoly/main.cpp +++ b/src/libpoly/main.cpp @@ -1,4 +1,4 @@ -#ifdef __WIN32__ +#ifdef OS_WINDOWS #include #endif @@ -14,7 +14,7 @@ int main(int argc, char ** argv) { printf( "12345\n" ); -#ifndef __WIN32__ +#ifndef OS_WINDOWS srandom(time(0) + getpid()); #else srand(time(0) + GetCurrentProcessId()); diff --git a/src/libsql/AsyncSQL.cpp b/src/libsql/AsyncSQL.cpp index ed1d5ee..c703991 100644 --- a/src/libsql/AsyncSQL.cpp +++ b/src/libsql/AsyncSQL.cpp @@ -1,4 +1,4 @@ -#ifndef __WIN32__ +#ifndef OS_WINDOWS #include #endif @@ -8,7 +8,7 @@ #include "AsyncSQL.h" // TODO: Consider providing platform-independent mutex class. -#ifndef __WIN32__ +#ifndef OS_WINDOWS #define MUTEX_LOCK(mtx) pthread_mutex_lock(mtx) #define MUTEX_UNLOCK(mtx) pthread_mutex_unlock(mtx) #else @@ -19,7 +19,7 @@ CAsyncSQL::CAsyncSQL() : m_stHost(""), m_stUser(""), m_stPassword(""), m_stDB(""), m_stLocale(""), m_iMsgCount(0), m_bEnd(false), -#ifndef __WIN32__ +#ifndef OS_WINDOWS m_hThread(0), #else m_hThread(INVALID_HANDLE_VALUE), @@ -51,7 +51,7 @@ void CAsyncSQL::Destroy() if (m_mtxQuery) { -#ifndef __WIN32__ +#ifndef OS_WINDOWS pthread_mutex_destroy(m_mtxQuery); #else ::DeleteCriticalSection(m_mtxQuery); @@ -62,7 +62,7 @@ void CAsyncSQL::Destroy() if (m_mtxResult) { -#ifndef __WIN32__ +#ifndef OS_WINDOWS pthread_mutex_destroy(m_mtxResult); #else ::DeleteCriticalSection(m_mtxResult); @@ -72,7 +72,7 @@ void CAsyncSQL::Destroy() } } -#ifndef __WIN32__ +#ifndef OS_WINDOWS void * AsyncSQLThread(void * arg) #else unsigned int __stdcall AsyncSQLThread(void* arg) @@ -190,7 +190,7 @@ bool CAsyncSQL::Setup(const char * c_pszHost, const char * c_pszUser, const char return false; } */ -#ifndef __WIN32__ +#ifndef OS_WINDOWS m_mtxQuery = new pthread_mutex_t; m_mtxResult = new pthread_mutex_t; @@ -232,7 +232,7 @@ void CAsyncSQL::Quit() m_bEnd = true; m_sem.Release(); -#ifndef __WIN32__ +#ifndef OS_WINDOWS if (m_hThread) { pthread_join(m_hThread, NULL); @@ -696,7 +696,7 @@ size_t CAsyncSQL::EscapeString(char* dst, size_t dstSize, const char *src, size_ // \0 Ⱥپ ؼ 256 Ʈ ؼ α׷ char tmp[256]; size_t tmpLen = sizeof(tmp) > srcSize ? srcSize : sizeof(tmp); // ߿ ũ - strlcpy(tmp, src, tmpLen); + std::strncpy(tmp, src, tmpLen); sys_err("FATAL ERROR!! not enough buffer size (dstSize %u srcSize %u src%s: %s)", dstSize, srcSize, tmpLen != srcSize ? "(trimmed to 255 characters)" : "", tmp); diff --git a/src/libsql/AsyncSQL.h b/src/libsql/AsyncSQL.h index 733b467..1bc9e97 100644 --- a/src/libsql/AsyncSQL.h +++ b/src/libsql/AsyncSQL.h @@ -1,16 +1,16 @@ #ifndef __INC_METIN_II_ASYNCSQL_H__ #define __INC_METIN_II_ASYNCSQL_H__ -#include "../libthecore/include/stdafx.h" -#include "../libthecore/include/log.h" +#include "libthecore/stdafx.h" +#include "libthecore/log.h" #include #include #include #include -#include -#include -#include +#include +#include +#include #include "Semaphore.h" @@ -182,7 +182,7 @@ class CAsyncSQL volatile bool m_bEnd; -#ifndef __WIN32__ +#ifndef OS_WINDOWS pthread_t m_hThread; pthread_mutex_t * m_mtxQuery; pthread_mutex_t * m_mtxResult; diff --git a/src/libsql/Semaphore.cpp b/src/libsql/Semaphore.cpp index 8aee340..e1ee6db 100644 --- a/src/libsql/Semaphore.cpp +++ b/src/libsql/Semaphore.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #include "Semaphore.h" -#ifndef __WIN32__ +#ifndef OS_WINDOWS CSemaphore::CSemaphore() : m_hSem(NULL) { diff --git a/src/libsql/Semaphore.h b/src/libsql/Semaphore.h index c0edf97..9b5921f 100644 --- a/src/libsql/Semaphore.h +++ b/src/libsql/Semaphore.h @@ -1,7 +1,7 @@ #ifndef __INC_METIN_II_SEMAPHORE_H__ #define __INC_METIN_II_SEMAPHORE_H__ -#ifndef __WIN32__ +#ifndef OS_WINDOWS #include #else @@ -10,7 +10,7 @@ class CSemaphore { private: -#ifndef __WIN32__ +#ifndef OS_WINDOWS sem_t * m_hSem; #else HANDLE m_hSem; diff --git a/src/libsql/Tellwait.cpp b/src/libsql/Tellwait.cpp index a3b04df..b470e25 100644 --- a/src/libsql/Tellwait.cpp +++ b/src/libsql/Tellwait.cpp @@ -1,4 +1,4 @@ -#ifndef __WIN32__ +#ifndef OS_WINDOWS #include #include diff --git a/src/libsql/Tellwait.h b/src/libsql/Tellwait.h index ef2fb10..e26cbf2 100644 --- a/src/libsql/Tellwait.h +++ b/src/libsql/Tellwait.h @@ -1,7 +1,7 @@ #ifndef __INC_METIN_II_TELLWAIT_H__ #define __INC_METIN_II_TELLWAIT_H__ -#ifndef __WIN32__ +#ifndef OS_WINDOWS extern void TELL_WAIT(); diff --git a/src/libsql/stdafx.h b/src/libsql/stdafx.h index 48ce17c..51e7c25 100644 --- a/src/libsql/stdafx.h +++ b/src/libsql/stdafx.h @@ -1,2 +1,2 @@ -#include "../libthecore/include/stdafx.h" +#include "libthecore/stdafx.h" #include "AsyncSQL.h" diff --git a/src/libthecore/DES_table.h b/src/libthecore/DES_table.h index 7165143..5014d7d 100644 --- a/src/libthecore/DES_table.h +++ b/src/libthecore/DES_table.h @@ -1,3 +1,4 @@ +#pragma once static DWORD SP_boxes[8][64]= { /* 0 */ diff --git a/src/libthecore/buffer.cpp b/src/libthecore/buffer.cpp index 3ea7cae..c5b85fb 100644 --- a/src/libthecore/buffer.cpp +++ b/src/libthecore/buffer.cpp @@ -1,10 +1,3 @@ -/* - * Filename: buffer.c - * Description: Buffer ó - * - * Author: (aka. , Cronan) - */ -#define __LIBTHECORE__ #include "stdafx.h" static LPBUFFER normalized_buffer_pool[32] = { NULL, }; @@ -32,7 +25,6 @@ static int buffer_get_exac_pool_index(int size) { } return -1; // too big... not pooled } -// buffer pool . static void buffer_pool_free () { for (int i = 31; i >= 0; i--) @@ -50,7 +42,6 @@ static void buffer_pool_free () } } } -// n ū buffer pool ϳ . static bool buffer_larger_pool_free (int n) { for (int i = 31; i > n; i--) @@ -102,13 +93,9 @@ LPBUFFER buffer_new(int size) { CREATE(buffer, BUFFER, 1); buffer->mem_size = size; - // buffer_new calloc failed ߻Ͽ(Ű ӽſ ַ ߻), - // calloc ϸ, buffer pool ٽ õѴ. if (!safe_create(&buffer->mem_data, size)) { - // ʿ buffer ū buffer pool ϳ . if (!buffer_larger_pool_free(pool_index)) - // ϸ , pool Ѵ. buffer_pool_free(); CREATE(buffer->mem_data, char, size); sys_err ("buffer pool free success."); @@ -213,10 +200,8 @@ void buffer_read_proceed(LPBUFFER buffer, int length) length = buffer->length; } - // ó ̰ ̺ ۴ٸ, ۸ ܵξ Ѵ. if (length < buffer->length) { - // write_point pos ״ ΰ read_point Ų. if (buffer->read_point + length - buffer->mem_data > buffer->mem_size) { sys_err("buffer_read_proceed: buffer overflow! length %d read_point %d", length, buffer->read_point - buffer->mem_data); @@ -268,8 +253,6 @@ void buffer_realloc(LPBUFFER& buffer, int length) if (buffer->mem_size >= length) return; - // i Ҵ ũ ũ , - // ޸ ũ⸦ Ѵ. i = length - buffer->mem_size; if (i <= 0) @@ -281,7 +264,6 @@ void buffer_realloc(LPBUFFER& buffer, int length) read_point_pos = buffer->read_point - buffer->mem_data; - // write_point read_point Ų. temp->write_point = temp->mem_data + buffer->write_point_pos; temp->write_point_pos = buffer->write_point_pos; temp->read_point = temp->mem_data + read_point_pos; diff --git a/src/libthecore/buffer.h b/src/libthecore/buffer.h index 5a1bc9e..6b6e601 100644 --- a/src/libthecore/buffer.h +++ b/src/libthecore/buffer.h @@ -1,19 +1,12 @@ -/* - * Filename: buffer.h - * Description: Buffer ó - * - * Author: (aka. , Cronan), ۿ (aka. myevan, ڷ) - */ -#ifndef __INC_LIBTHECORE_BUFFER_H__ -#define __INC_LIBTHECORE_BUFFER_H__ +#pragma once #define SAFE_BUFFER_DELETE(buf) { if(buf != NULL) { buffer_delete(buf); buf = NULL; } } - typedef struct buffer BUFFER; - typedef struct buffer * LPBUFFER; +typedef struct buffer BUFFER; +typedef struct buffer * LPBUFFER; - struct buffer - { +struct buffer +{ struct buffer * next; char * write_point; @@ -26,32 +19,25 @@ int mem_size; long flag; - }; +}; - extern LPBUFFER buffer_new(int size); // - extern void buffer_delete(LPBUFFER buffer); // - extern void buffer_reset(LPBUFFER buffer); // ̵ ʱȭ +LPBUFFER buffer_new(int size); +void buffer_delete(LPBUFFER buffer); +void buffer_reset(LPBUFFER buffer); - extern DWORD buffer_size(LPBUFFER buffer); // ۿ - extern int buffer_has_space(LPBUFFER buffer); // ִ ̸ +DWORD buffer_size(LPBUFFER buffer); +int buffer_has_space(LPBUFFER buffer); - extern void buffer_write (LPBUFFER& buffer, const void* src, int length); // ۿ . - extern void buffer_read(LPBUFFER buffer, void * buf, int bytes); // ۿ д´. - extern BYTE buffer_get_byte(LPBUFFER buffer); - extern WORD buffer_get_word(LPBUFFER buffer); - extern DWORD buffer_get_dword(LPBUFFER buffer); +void buffer_write (LPBUFFER& buffer, const void* src, int length); +void buffer_read(LPBUFFER buffer, void * buf, int bytes); +BYTE buffer_get_byte(LPBUFFER buffer); +WORD buffer_get_word(LPBUFFER buffer); +DWORD buffer_get_dword(LPBUFFER buffer); - // buffer_proceed Լ buffer_peek б ͸ ޾Ƽ ʿ䰡 - // ó 󸶳 ó ٰ 뺸ؾ . - // (buffer_read, buffer_get_* ø 쿡 ˾Ƽ ó peek ó - // ׷ Ƿ) - extern const void * buffer_read_peek(LPBUFFER buffer); // д ġ - extern void buffer_read_proceed(LPBUFFER buffer, int length); // lengthŭ ó +const void* buffer_read_peek(LPBUFFER buffer); +void buffer_read_proceed(LPBUFFER buffer, int length); - // write_peek ġ 󸶳 質 뺸 - // buffer_write_proceed Ѵ. - extern void * buffer_write_peek(LPBUFFER buffer); // ġ - extern void buffer_write_proceed(LPBUFFER buffer, int length); // length Ų. +void* buffer_write_peek(LPBUFFER buffer); +void buffer_write_proceed(LPBUFFER buffer, int length); - extern void buffer_adjust_size(LPBUFFER & buffer, int add_size); // add_sizeŭ ߰ ũ⸦ Ȯ -#endif +void buffer_adjust_size(LPBUFFER& buffer, int add_size); diff --git a/src/libthecore/crypt.h b/src/libthecore/crypt.h index e9df66b..e97621d 100644 --- a/src/libthecore/crypt.h +++ b/src/libthecore/crypt.h @@ -1,23 +1,18 @@ -#ifdef __cplusplus -extern "C" { -#endif +#pragma once - /* TEA is a 64-bit symmetric block cipher with a 128-bit key, developed - by David J. Wheeler and Roger M. Needham, and described in their - paper at . +/* TEA is a 64-bit symmetric block cipher with a 128-bit key, developed + by David J. Wheeler and Roger M. Needham, and described in their + paper at . - This implementation is based on their code in - */ + This implementation is based on their code in + +*/ - extern int TEA_Encrypt(DWORD *dest, const DWORD *src, const DWORD *key, int size); - extern int TEA_Decrypt(DWORD *dest, const DWORD *src, const DWORD *key, int size); +int TEA_Encrypt(DWORD *dest, const DWORD *src, const DWORD *key, int size); +int TEA_Decrypt(DWORD *dest, const DWORD *src, const DWORD *key, int size); - extern int GOST_Encrypt(DWORD * DstBuffer, const DWORD * SrcBuffer, const DWORD * KeyAddress, DWORD Length, DWORD *IVector); - extern int GOST_Decrypt(DWORD * DstBuffer, const DWORD * SrcBuffer, const DWORD * KeyAddress, DWORD Length, DWORD *IVector); +int GOST_Encrypt(DWORD * DstBuffer, const DWORD * SrcBuffer, const DWORD * KeyAddress, DWORD Length, DWORD *IVector); +int GOST_Decrypt(DWORD * DstBuffer, const DWORD * SrcBuffer, const DWORD * KeyAddress, DWORD Length, DWORD *IVector); - extern int DES_Encrypt(DWORD *DstBuffer, const DWORD * SrcBuffer, const DWORD *KeyAddress, DWORD Length, DWORD *IVector); - extern int DES_Decrypt(DWORD *DstBuffer, const DWORD * SrcBuffer, const DWORD *KeyAddress, DWORD Length, DWORD *IVector); - -#ifdef __cplusplus -}; -#endif +int DES_Encrypt(DWORD *DstBuffer, const DWORD * SrcBuffer, const DWORD *KeyAddress, DWORD Length, DWORD *IVector); +int DES_Decrypt(DWORD *DstBuffer, const DWORD * SrcBuffer, const DWORD *KeyAddress, DWORD Length, DWORD *IVector); diff --git a/src/libthecore/des.cpp b/src/libthecore/des.cpp index 7a30a4b..61d8545 100644 --- a/src/libthecore/des.cpp +++ b/src/libthecore/des.cpp @@ -278,4 +278,3 @@ int DES_Decrypt(DWORD *DstBuffer, const DWORD * SrcBuffer, const DWORD *KeyAddre return Length; } - diff --git a/src/libthecore/fdwatch.cpp b/src/libthecore/fdwatch.cpp index bbf8774..e220c9b 100644 --- a/src/libthecore/fdwatch.cpp +++ b/src/libthecore/fdwatch.cpp @@ -1,4 +1,3 @@ -#define __LIBTHECORE__ #include "stdafx.h" #ifndef __USE_SELECT__ @@ -233,7 +232,7 @@ void * fdwatch_get_client_data(LPFDWATCH fdw, unsigned int event_idx) } #else // ifndef __USE_SELECT__ -#ifdef __WIN32__ +#ifdef OS_WINDOWS static int win32_init_refcount = 0; static bool win32_init() @@ -265,7 +264,7 @@ LPFDWATCH fdwatch_new(int nfiles) { LPFDWATCH fdw; -#ifdef __WIN32__ +#ifdef OS_WINDOWS if (!win32_init()) return NULL; #endif @@ -295,7 +294,7 @@ void fdwatch_delete(LPFDWATCH fdw) free(fdw->select_rfdidx); free(fdw); -#ifdef __WIN32__ +#ifdef OS_WINDOWS win32_deinit(); #endif } diff --git a/src/libthecore/fdwatch.h b/src/libthecore/fdwatch.h index f97e0a2..186142e 100644 --- a/src/libthecore/fdwatch.h +++ b/src/libthecore/fdwatch.h @@ -1,95 +1,85 @@ -#ifndef __INC_LIBTHECORE_FDWATCH_H__ -#define __INC_LIBTHECORE_FDWATCH_H__ +#pragma once -#ifndef __WIN32__ +#ifndef OS_WINDOWS - typedef struct fdwatch FDWATCH; + typedef struct fdwatch FDWATCH; typedef struct fdwatch * LPFDWATCH; enum EFdwatch { - FDW_NONE = 0, - FDW_READ = 1, - FDW_WRITE = 2, - FDW_WRITE_ONESHOT = 4, - FDW_EOF = 8, + FDW_NONE = 0, + FDW_READ = 1, + FDW_WRITE = 2, + FDW_WRITE_ONESHOT = 4, + FDW_EOF = 8, }; typedef struct kevent KEVENT; typedef struct kevent * LPKEVENT; - typedef int KQUEUE; + typedef int KQUEUE; struct fdwatch { - KQUEUE kq; + KQUEUE kq; - int nfiles; + int nfiles; - LPKEVENT kqevents; - int nkqevents; + LPKEVENT kqevents; + int nkqevents; - LPKEVENT kqrevents; - int * fd_event_idx; + LPKEVENT kqrevents; + int * fd_event_idx; - void ** fd_data; - int * fd_rw; + void ** fd_data; + int * fd_rw; }; #else - typedef struct fdwatch FDWATCH; + typedef struct fdwatch FDWATCH; typedef struct fdwatch * LPFDWATCH; enum EFdwatch { - FDW_NONE = 0, - FDW_READ = 1, - FDW_WRITE = 2, - FDW_WRITE_ONESHOT = 4, - FDW_EOF = 8, + FDW_NONE = 0, + FDW_READ = 1, + FDW_WRITE = 2, + FDW_WRITE_ONESHOT = 4, + FDW_EOF = 8, }; struct fdwatch { - fd_set rfd_set; - fd_set wfd_set; + fd_set rfd_set; + fd_set wfd_set; - socket_t* select_fds; - int* select_rfdidx; + socket_t* select_fds; + int* select_rfdidx; - int nselect_fds; + int nselect_fds; - fd_set working_rfd_set; - fd_set working_wfd_set; + fd_set working_rfd_set; + fd_set working_wfd_set; - int nfiles; + int nfiles; - void** fd_data; - int* fd_rw; + void** fd_data; + int* fd_rw; }; #endif // WIN32 -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - extern LPFDWATCH fdwatch_new(int nfiles); - extern void fdwatch_clear_fd(LPFDWATCH fdw, socket_t fd); - extern void fdwatch_delete(LPFDWATCH fdw); - extern int fdwatch_check_fd(LPFDWATCH fdw, socket_t fd); - extern int fdwatch_check_event(LPFDWATCH fdw, socket_t fd, unsigned int event_idx); - extern void fdwatch_clear_event(LPFDWATCH fdw, socket_t fd, unsigned int event_idx); - extern void fdwatch_add_fd(LPFDWATCH fdw, socket_t fd, void* client_data, int rw, int oneshot); - extern int fdwatch(LPFDWATCH fdw, struct timeval *timeout); - extern void * fdwatch_get_client_data(LPFDWATCH fdw, unsigned int event_idx); - extern void fdwatch_del_fd(LPFDWATCH fdw, socket_t fd); - extern int fdwatch_get_buffer_size(LPFDWATCH fdw, socket_t fd); - extern int fdwatch_get_ident(LPFDWATCH fdw, unsigned int event_idx); +LPFDWATCH fdwatch_new(int nfiles); +void fdwatch_clear_fd(LPFDWATCH fdw, socket_t fd); +void fdwatch_delete(LPFDWATCH fdw); +int fdwatch_check_fd(LPFDWATCH fdw, socket_t fd); +int fdwatch_check_event(LPFDWATCH fdw, socket_t fd, unsigned int event_idx); +void fdwatch_clear_event(LPFDWATCH fdw, socket_t fd, unsigned int event_idx); +void fdwatch_add_fd(LPFDWATCH fdw, socket_t fd, void* client_data, int rw, int oneshot); +int fdwatch(LPFDWATCH fdw, struct timeval *timeout); +void * fdwatch_get_client_data(LPFDWATCH fdw, unsigned int event_idx); +void fdwatch_del_fd(LPFDWATCH fdw, socket_t fd); +int fdwatch_get_buffer_size(LPFDWATCH fdw, socket_t fd); +int fdwatch_get_ident(LPFDWATCH fdw, unsigned int event_idx); -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/libthecore/gost.cpp b/src/libthecore/gost.cpp index 4ca919e..4c0192e 100644 --- a/src/libthecore/gost.cpp +++ b/src/libthecore/gost.cpp @@ -1,14 +1,5 @@ #include "stdafx.h" -/* -static unsigned char const k8[16] = { 14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7 }; -static unsigned char const k7[16] = { 15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10 }; -static unsigned char const k6[16] = { 10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8 }; -static unsigned char const k5[16] = { 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15 }; -static unsigned char const k4[16] = { 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9 }; -static unsigned char const k3[16] = { 12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11 }; -static unsigned char const k2[16] = { 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1 }; -static unsigned char const k1[16] = { 13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7 }; -*/ + static unsigned char const k8[16] = { 15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13 }; static unsigned char const k7[16] = { 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5 }; static unsigned char const k6[16] = { 10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8 }; @@ -42,56 +33,7 @@ INLINE static DWORD f(DWORD x) x = k87[x >> 24 & 255] << 24 | k65[x >> 16 & 255] << 16 | k43[x >> 8 & 255] << 8 | k21[x & 255]; return x << 11 | x >> (32 - 11); } -/* -static void GOST_ECB_Encrypt(DWORD * N1, DWORD * N2, const DWORD * KeyAddress) -{ - DWORD n1, n2; // As named in the GOST - n1 = *N1; - n2 = *N2; - - // Instead of swapping halves, swap names each round - n2 ^= f(n1+KeyAddress[0]); - n1 ^= f(n2+KeyAddress[1]); - n2 ^= f(n1+KeyAddress[2]); - n1 ^= f(n2+KeyAddress[3]); - n2 ^= f(n1+KeyAddress[4]); - n1 ^= f(n2+KeyAddress[5]); - n2 ^= f(n1+KeyAddress[6]); - n1 ^= f(n2+KeyAddress[7]); - - n2 ^= f(n1+KeyAddress[0]); - n1 ^= f(n2+KeyAddress[1]); - n2 ^= f(n1+KeyAddress[2]); - n1 ^= f(n2+KeyAddress[3]); - n2 ^= f(n1+KeyAddress[4]); - n1 ^= f(n2+KeyAddress[5]); - n2 ^= f(n1+KeyAddress[6]); - n1 ^= f(n2+KeyAddress[7]); - - n2 ^= f(n1+KeyAddress[0]); - n1 ^= f(n2+KeyAddress[1]); - n2 ^= f(n1+KeyAddress[2]); - n1 ^= f(n2+KeyAddress[3]); - n2 ^= f(n1+KeyAddress[4]); - n1 ^= f(n2+KeyAddress[5]); - n2 ^= f(n1+KeyAddress[6]); - n1 ^= f(n2+KeyAddress[7]); - - n2 ^= f(n1+KeyAddress[7]); - n1 ^= f(n2+KeyAddress[6]); - n2 ^= f(n1+KeyAddress[5]); - n1 ^= f(n2+KeyAddress[4]); - n2 ^= f(n1+KeyAddress[3]); - n1 ^= f(n2+KeyAddress[2]); - n2 ^= f(n1+KeyAddress[1]); - n1 ^= f(n2+KeyAddress[0]); - - // There is no swap after the last round - *N1 = n2; - *N2 = n1; -} -*/ int GOST_Encrypt(DWORD * DstBuffer, const DWORD * SrcBuffer, const DWORD * KeyAddress, DWORD Length, DWORD *IVector) { DWORD i; diff --git a/src/libthecore/hangul.cpp b/src/libthecore/hangul.cpp index 5d11ccd..3d281a0 100644 --- a/src/libthecore/hangul.cpp +++ b/src/libthecore/hangul.cpp @@ -1,123 +1,116 @@ -/* - * Filename: hangul.c - * Description: ѱ ҽ - * - * Author: aka. Cronan - */ -#define __LIBTHECORE__ -#include "stdafx.h" +#include "stdafx.h" -int is_hangul(const BYTE * str) +int is_hangul(const BYTE* str) { if (str[0] >= 0xb0 && str[0] <= 0xc8 && str[1] >= 0xa1 && str[1] <= 0xfe) - return 1; + return 1; return 0; } -int check_han(const char *str) +int check_han(const char* str) { int i, code; if (!str || !*str) - return 0; + return 0; - for (i = 0; str[i]; i += 2) + for (i = 0; str[i]; i += 2) { - if (isnhspace(str[i])) - return 0; + if (isnhspace(str[i])) + return 0; - if (isalpha(str[i]) || isdigit(str[i])) - continue; + if (isalpha(str[i]) || isdigit(str[i])) + continue; - code = str[i]; - code += 256; + code = str[i]; + code += 256; - if (code < 176 || code > 200) - return 0; + if (code < 176 || code > 200) + return 0; } return 1; } -const char *first_han(const BYTE *str) +const char* first_han(const BYTE* str) { unsigned char high, low; int len, i; - char *p = "׿"; + char* p = "그외"; static const char* wansung[] = { - "", "", "", "", "", - "", "", "", "", "", - "", "", "", "", "", - "ī", "Ÿ", "", "", "" + "가","가","나","다","다", + "라","마","바","바","사", + "사","아","자","자","차", + "카","타","파","하","" }; static const char* johab[] = { - "a", "a", "a", "a", "a", - "a", "a", "a", "a", "a", - "a", "a", "a", "a", "a", - "a", "?", "?", "?", "" + "\x88" "a", "\x8C" "a", "\x90" "a", "\x94" "a", "\x98" "a", + "\x9C" "a", "\xA0" "a", "\xA4" "a", "\xA8" "a", "\xAC" "a", + "\xB0" "a", "\xB4" "a", "\xB8" "a", "\xBC" "a", "\xC0" "a", + "\xC4" "a", "\xC8" "a", "\xCC" "a", "\xD0" "a", "" }; - len = strlen((const char*) str); + len = strlen((const char*)str); if (len < 2) - return p; + return p; high = str[0]; - low = str[1]; + low = str[1]; if (!is_hangul(str)) { - return p; + return p; } high = (KStbl[(high - 0xb0) * 94 + low - 0xa1] >> 8) & 0x7c; - for (i = 0; johab[i][0]; i++) + for (i = 0; johab[i][0]; i++) { - low = (johab[i][0] & 0x7f); + low = (johab[i][0] & 0x7f); - if (low == high) - return (wansung[i]); + if (low == high) + return (wansung[i]); } return (p); } -int under_han(const void * orig) +int under_han(const void* orig) { - const BYTE * str = (const BYTE *) orig; + const BYTE* str = (const BYTE*)orig; BYTE high, low; int len; - len = strlen((const char*) str); + len = strlen((const char*)str); - if (len < 2) - return 0; + if (len < 2) + return 0; if (str[len - 1] == ')') { - while (str[len] != '(') - len--; + while (str[len] != '(') + len--; } high = str[len - 2]; - low = str[len - 1]; + low = str[len - 1]; - if (!is_hangul(&str[len - 2])) - return 0; + if (!is_hangul(&str[len - 2])) + return 0; high = KStbl[(high - 0xb0) * 94 + low - 0xa1] & 0x1f; if (high < 2) - return 0; + return 0; - if (high > 28) - return 0; + if (high > 28) + return 0; return 1; } diff --git a/src/libthecore/hangul.h b/src/libthecore/hangul.h index 4800eb7..ffa84d4 100644 --- a/src/libthecore/hangul.h +++ b/src/libthecore/hangul.h @@ -1,12 +1,6 @@ -#ifndef __INC_LIBTHECORE_HANGUL_H__ -#define __INC_LIBTHECORE_HANGUL_H__ +#pragma once -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -#ifdef __WIN32__ +#ifdef OS_WINDOWS #define isdigit iswdigit #define isspace iswspace #endif @@ -17,15 +11,9 @@ extern "C" #define isnhdigit(ch) (!ishan(ch) && isdigit(ch)) #define isnhspace(ch) (!ishan(ch) && isspace(ch)) - extern const char * first_han(const BYTE * str); // ù° () ̾ ///.. Ѵ. - extern int check_han(const char * str); // ѱ̸ true Ʈ üũ - extern int is_hangul(const BYTE * str); // ѱ̸ true (2Ʈ üũ) - extern int under_han(const void * orig); // ħ true +const char * first_han(const BYTE * str); +int check_han(const char * str); +int is_hangul(const BYTE * str); +int under_han(const void * orig); #define UNDER(str) under_han(str) - -#ifdef __cplusplus -}; -#endif - -#endif diff --git a/src/libthecore/heart.cpp b/src/libthecore/heart.cpp index b6b5a87..32809d9 100644 --- a/src/libthecore/heart.cpp +++ b/src/libthecore/heart.cpp @@ -1,10 +1,3 @@ -/* - * Filename: heart.c - * Description: fps ѹ ȣǴ "" ̴. - * - * Author: aka. Cronan - */ -#define __LIBTHECORE__ #include "stdafx.h" extern volatile int num_events_called; @@ -15,8 +8,8 @@ LPHEART heart_new(int opt_usec, HEARTFUNC func) if (!func) { - sys_err("no function defined"); - return NULL; + sys_err("no function defined"); + return NULL; } CREATE(ht, HEART, 1); @@ -25,8 +18,8 @@ LPHEART heart_new(int opt_usec, HEARTFUNC func) ht->opt_time.tv_sec = 0; ht->opt_time.tv_usec = opt_usec; ht->passes_per_sec = 1000000 / opt_usec; - gettimeofday(&ht->last_time, (struct timezone *) 0); - gettimeofday(&ht->before_sleep, (struct timezone *) 0); + gettimeofday(&ht->last_time, (struct timezone*)0); + gettimeofday(&ht->before_sleep, (struct timezone*)0); return (ht); } @@ -40,7 +33,7 @@ int heart_idle(LPHEART ht) struct timeval now, process_time, timeout, temp_time; int missed_pulse; - gettimeofday(&ht->before_sleep, (struct timezone *) 0); + gettimeofday(&ht->before_sleep, (struct timezone*)0); process_time = *timediff(&ht->before_sleep, &ht->last_time); /* @@ -49,45 +42,43 @@ int heart_idle(LPHEART ht) */ if (process_time.tv_sec == 0 && process_time.tv_usec < ht->opt_time.tv_usec) { - missed_pulse = 0; + missed_pulse = 0; } else { - missed_pulse = process_time.tv_sec * ht->passes_per_sec; - missed_pulse += process_time.tv_usec / ht->opt_time.tv_usec; + missed_pulse = process_time.tv_sec * ht->passes_per_sec; + missed_pulse += process_time.tv_usec / ht->opt_time.tv_usec; } - // ٺ pulse ƴµ ð ... - // ޽ fps Ʋִµ, Ȯ ߴ ߿ ʾ. - if (missed_pulse > 0) - { - gettimeofday(&ht->last_time, (struct timezone *) 0); - } - else - { - /* Calculate the time we should wake up */ - temp_time = *timediff(&ht->opt_time, &process_time); - ht->last_time = *timeadd(&ht->before_sleep, &temp_time); + if (missed_pulse > 0) + { + gettimeofday(&ht->last_time, (struct timezone*)0); + } + else + { + /* Calculate the time we should wake up */ + temp_time = *timediff(&ht->opt_time, &process_time); + ht->last_time = *timeadd(&ht->before_sleep, &temp_time); - /* Now keep sleeping until that time has come */ - gettimeofday(&now, (struct timezone *) 0); - timeout = *timediff(&ht->last_time, &now); + /* Now keep sleeping until that time has come */ + gettimeofday(&now, (struct timezone*)0); + timeout = *timediff(&ht->last_time, &now); - thecore_sleep(&timeout); - } + thecore_sleep(&timeout); + } ++missed_pulse; if (missed_pulse <= 0) { - sys_err("missed_pulse is not positive! (%d)", missed_pulse); - missed_pulse = 1; + sys_err("missed_pulse is not positive! (%d)", missed_pulse); + missed_pulse = 1; } if (missed_pulse > (30 * ht->passes_per_sec)) { - sys_err("losing %d seconds. (lag occured)", missed_pulse / ht->passes_per_sec); - missed_pulse = 30 * ht->passes_per_sec; + sys_err("losing %d seconds. (lag occured)", missed_pulse / ht->passes_per_sec); + missed_pulse = 30 * ht->passes_per_sec; } return missed_pulse; diff --git a/src/libthecore/heart.h b/src/libthecore/heart.h index f98431d..c331d1f 100644 --- a/src/libthecore/heart.h +++ b/src/libthecore/heart.h @@ -1,6 +1,4 @@ -#ifndef __INC_LIBTHECORE_HEART_H__ -#define __INC_LIBTHECORE_HEART_H__ - +#pragma once typedef struct heart HEART; typedef struct heart * LPHEART; @@ -18,9 +16,7 @@ struct heart int pulse; }; -extern LPHEART heart_new(int opt_usec, HEARTFUNC func); -extern void heart_delete(LPHEART ht); -extern int heart_idle(LPHEART ht); // pulse Ѵ. -extern void heart_beat(LPHEART ht, int pulses); - -#endif +LPHEART heart_new(int opt_usec, HEARTFUNC func); +void heart_delete(LPHEART ht); +int heart_idle(LPHEART ht); // pulse Ѵ. +void heart_beat(LPHEART ht, int pulses); diff --git a/src/libthecore/kstbl.cpp b/src/libthecore/kstbl.cpp index c40c0a4..c751ff1 100644 --- a/src/libthecore/kstbl.cpp +++ b/src/libthecore/kstbl.cpp @@ -1,13 +1,5 @@ -/* - * Filename: kstbl.c - * Description: Ʒ δ. - * - * Author: aka. Cronan - */ -#define __LIBTHECORE__ unsigned KStbl[2350] = { - /* KS ϼ 2350 ڵ */ 0x8861,0x8862,0x8865,0x8868,0x8869,0x886a,0x886b,0x8871, 0x8873,0x8874,0x8875,0x8876,0x8877,0x8878,0x8879,0x887b, 0x887c,0x887d,0x8881,0x8882,0x8885,0x8889,0x8891,0x8893, diff --git a/src/libthecore/kstbl.h b/src/libthecore/kstbl.h index 6cf4dbd..b3e7703 100644 --- a/src/libthecore/kstbl.h +++ b/src/libthecore/kstbl.h @@ -1,10 +1,2 @@ -/* - * Filename: kstbl.h - * Description: KS ϼ 2350 ڵ - * - * Author: (server), myevan (Client) - */ -#ifndef __KSTBL_H__ -#define __KSTBL_H__ +#pragma once extern unsigned KStbl[2350]; -#endif diff --git a/src/libthecore/log.cpp b/src/libthecore/log.cpp index 4696898..919bd6d 100644 --- a/src/libthecore/log.cpp +++ b/src/libthecore/log.cpp @@ -1,13 +1,6 @@ -/* - * Filename: log.c - * Description: local log file - * - * Author: aka. Cronan - */ -#define __LIBTHECORE__ #include "stdafx.h" -#ifndef __WIN32__ +#ifndef OS_WINDOWS #define SYSLOG_FILENAME "syslog" #define SYSERR_FILENAME "syserr" #define PTS_FILENAME "PTS" @@ -106,7 +99,7 @@ void log_rotate(void) log_file_rotate(log_file_sys); } -#ifndef __WIN32__ +#ifndef OS_WINDOWS void _sys_err(const char *func, int line, const char *format, ...) { va_list args; @@ -211,7 +204,7 @@ void sys_log(unsigned int bit, const char *format, ...) fflush(log_file_sys->fp); } -#ifndef __WIN32__ +#ifndef OS_WINDOWS // log_level 1 ̻ 쿡 ׽Ʈ 찡 stdout Ѵ. if (log_level_bits > 1) { @@ -224,7 +217,7 @@ void sys_log(unsigned int bit, const char *format, ...) fputc('\n', stdout); fflush(stdout); -#ifndef __WIN32__ +#ifndef OS_WINDOWS } #endif } @@ -321,7 +314,7 @@ void log_file_delete_old(const char *filename) new_tm = *tm_calc(NULL, -log_keep_days); sprintf(buf, "%04d%02d%02d", new_tm.tm_year + 1900, new_tm.tm_mon + 1, new_tm.tm_mday); num1 = atoi(buf); -#ifndef __WIN32__ +#ifndef OS_WINDOWS { struct dirent ** namelist; int n; @@ -404,7 +397,7 @@ void log_file_rotate(LPLOGFILE logfile) struct tm new_tm; new_tm = *tm_calc(&curr_tm, -3); -#ifndef __WIN32__ +#ifndef OS_WINDOWS sprintf(system_cmd, "rm -rf %s/%04d%02d%02d", log_dir, new_tm.tm_year + 1900, new_tm.tm_mon + 1, new_tm.tm_mday); #else sprintf(system_cmd, "del %s\\%04d%02d%02d", log_dir, new_tm.tm_year + 1900, new_tm.tm_mon + 1, new_tm.tm_mday); @@ -423,7 +416,7 @@ void log_file_rotate(LPLOGFILE logfile) if (stat(dir, &stat_buf) != 0 || S_ISDIR(stat_buf.st_mode)) { -#ifdef __WIN32__ +#ifdef OS_WINDOWS CreateDirectory(dir, NULL); #else mkdir(dir, S_IRWXU); @@ -437,7 +430,7 @@ void log_file_rotate(LPLOGFILE logfile) fclose(logfile->fp); // ű. -#ifndef __WIN32__ +#ifndef OS_WINDOWS snprintf(system_cmd, 128, "mv %s %s/%s.%02d", logfile->filename, dir, logfile->filename, logfile->last_hour); #else snprintf(system_cmd, 128, "move %s %s\\%s.%02d", logfile->filename, dir, logfile->filename, logfile->last_hour); diff --git a/src/libthecore/log.h b/src/libthecore/log.h index e759144..da6be21 100644 --- a/src/libthecore/log.h +++ b/src/libthecore/log.h @@ -1,39 +1,27 @@ -#ifndef __INC_LIBTHECORE_LOG_H__ -#define __INC_LIBTHECORE_LOG_H__ +#pragma once -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - extern int log_init(void); - extern void log_destroy(void); - extern void log_rotate(void); +int log_init(void); +void log_destroy(void); +void log_rotate(void); - // α ó ( bitvector óȴ) - extern void log_set_level(unsigned int level); - extern void log_unset_level(unsigned int level); +void log_set_level(unsigned int level); +void log_unset_level(unsigned int level); - // α ŭ ϴ° Լ - extern void log_set_expiration_days(unsigned int days); - extern int log_get_expiration_days(void); +void log_set_expiration_days(unsigned int days); +int log_get_expiration_days(void); -#ifndef __WIN32__ - extern void _sys_err(const char *func, int line, const char *format, ...); +#ifndef OS_WINDOWS +void _sys_err(const char *func, int line, const char *format, ...); #else - extern void _sys_err(const char *func, int line, const char *format, ...); +void _sys_err(const char *func, int line, const char *format, ...); #endif - extern void sys_log_header(const char *header); - extern void sys_log(unsigned int lv, const char *format, ...); - extern void pt_log(const char *format, ...); -#ifndef __WIN32__ -#define sys_err(fmt, args...) _sys_err(__FUNCTION__, __LINE__, fmt, ##args) +void sys_log_header(const char *header); +void sys_log(unsigned int lv, const char *format, ...); +void pt_log(const char *format, ...); + +#ifndef OS_WINDOWS + #define sys_err(fmt, args...) _sys_err(__FUNCTION__, __LINE__, fmt, ##args) #else -#define sys_err(fmt, ...) _sys_err(__FUNCTION__, __LINE__, fmt, __VA_ARGS__) -#endif // __WIN32__ - -#ifdef __cplusplus -} -#endif // __cplusplus - -#endif // __INC_LOG_H__ + #define sys_err(fmt, ...) _sys_err(__FUNCTION__, __LINE__, fmt, __VA_ARGS__) +#endif // OS_WINDOWS diff --git a/src/libthecore/main.cpp b/src/libthecore/main.cpp index 33a2bc6..6dbf007 100644 --- a/src/libthecore/main.cpp +++ b/src/libthecore/main.cpp @@ -1,10 +1,3 @@ -/* - * Filename: main.c - * Description: ̺귯 ʱȭ/ - * - * Author: aka. Cronan - */ -#define __LIBTHECORE__ #include "stdafx.h" #include "memory.h" @@ -18,7 +11,7 @@ unsigned int thecore_profiler[NUM_PF]; static int pid_init(void) { -#ifdef __WIN32__ +#ifdef OS_WINDOWS return true; #else FILE* fp; @@ -40,7 +33,7 @@ static int pid_init(void) static void pid_deinit(void) { -#ifdef __WIN32__ +#ifdef OS_WINDOWS return; #else remove("./pid"); @@ -50,7 +43,7 @@ static void pid_deinit(void) int thecore_init(int fps, HEARTFUNC heartbeat_func) { -#ifdef __WIN32__ +#ifdef OS_WINDOWS srand(time(0)); #else srandom(time(0) + getpid() + getuid()); diff --git a/src/libthecore/main.h b/src/libthecore/main.h index 2ea09ed..2e871dc 100644 --- a/src/libthecore/main.h +++ b/src/libthecore/main.h @@ -1,40 +1,29 @@ -#ifndef __INC_LIBTHECORE_MAIN_H__ -#define __INC_LIBTHECORE_MAIN_H__ +#pragma once -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ +extern volatile int tics; +extern volatile int shutdowned; -#ifdef __LIBTHECORE__ - extern volatile int tics; - extern volatile int shutdowned; -#endif #include "heart.h" - extern LPHEART thecore_heart; +extern LPHEART thecore_heart; - enum ENUM_PROFILER - { +enum ENUM_PROFILER +{ PF_IDLE, PF_HEARTBEAT, NUM_PF - }; +}; - extern unsigned int thecore_profiler[NUM_PF]; +extern unsigned int thecore_profiler[NUM_PF]; - extern int thecore_init(int fps, HEARTFUNC heartbeat_func); - extern int thecore_idle(void); - extern void thecore_shutdown(void); - extern void thecore_destroy(void); - extern int thecore_pulse(void); - extern float thecore_time(void); - extern float thecore_pulse_per_second(void); - extern int thecore_is_shutdowned(void); +int thecore_init(int fps, HEARTFUNC heartbeat_func); +int thecore_idle(void); +void thecore_shutdown(void); +void thecore_destroy(void); +int thecore_pulse(void); +float thecore_time(void); +float thecore_pulse_per_second(void); +int thecore_is_shutdowned(void); - extern void thecore_tick(void); // tics +void thecore_tick(void); // tics -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/libthecore/memcpy.cpp b/src/libthecore/memcpy.cpp index 4853de2..ce2dafc 100644 --- a/src/libthecore/memcpy.cpp +++ b/src/libthecore/memcpy.cpp @@ -126,7 +126,7 @@ "Using prefetches efficiently is more of an art than a science" */ -#ifndef __WIN32__ +#ifndef OS_WINDOWS #include void *(*thecore_memcpy) (void * to, const void * from, size_t len) = memcpy; diff --git a/src/libthecore/memcpy.h b/src/libthecore/memcpy.h index efbf16a..0d7b08d 100644 --- a/src/libthecore/memcpy.h +++ b/src/libthecore/memcpy.h @@ -1,23 +1,10 @@ -#ifndef __INC_LIBTHECORE_MEMCPY_H__ -#define __INC_LIBTHECORE_MEMCPY_H__ +#pragma once -#ifdef __cplusplus -extern "C" -{ -#endif -#ifdef __LIBTHECORE__ - void thecore_find_best_memcpy(); -#endif +void thecore_find_best_memcpy(); -#ifndef __WIN32__ +#ifndef OS_WINDOWS extern void *(*thecore_memcpy) (void * to, const void * from, size_t len); #else #include #define thecore_memcpy memcpy #endif - -#ifdef __cplusplus -}; -#endif - -#endif diff --git a/src/libthecore/signal.cpp b/src/libthecore/signal.cpp index d78d5e6..e949797 100644 --- a/src/libthecore/signal.cpp +++ b/src/libthecore/signal.cpp @@ -1,17 +1,10 @@ -/* - * Filename: signal.c - * Description: ñ׳ Լ. - * - * Author: aka. Cronan - */ -#define __LIBTHECORE__ #include "stdafx.h" -#ifdef __WIN32__ +#ifdef OS_WIN32 void signal_setup() {} void signal_timer_disable() {} void signal_timer_enable(int timeout_seconds) {} -#elif __FreeBSD__ +#elif OS_FREEBSD #define RETSIGTYPE void RETSIGTYPE reap(int sig) diff --git a/src/libthecore/signal.h b/src/libthecore/signal.h index 2d3eeae..a195ef1 100644 --- a/src/libthecore/signal.h +++ b/src/libthecore/signal.h @@ -1,16 +1,4 @@ -#ifndef __INC_LIBTHECORE_SIGNAL_H__ -#define __INC_LIBTHECORE_SIGNAL_H__ - -#ifdef __cplusplus -extern "C" -{ -#endif - extern void signal_setup(); - extern void signal_timer_disable(); - extern void signal_timer_enable(int timeout_seconds); - -#ifdef __cplusplus -}; -#endif - -#endif +#pragma once +void signal_setup(); +void signal_timer_disable(); +void signal_timer_enable(int timeout_seconds); \ No newline at end of file diff --git a/src/libthecore/socket.cpp b/src/libthecore/socket.cpp index 10c2e89..4da0522 100644 --- a/src/libthecore/socket.cpp +++ b/src/libthecore/socket.cpp @@ -1,10 +1,3 @@ -/* - * Filename: socket.c - * Description: ҽ. - * - * Author: aka. Cronan - */ -#define __LIBTHECORE__ #include "stdafx.h" /* Forwards */ @@ -56,7 +49,7 @@ int socket_read(socket_t desc, char* read_point, size_t space_left) return (0); #endif -#ifdef __WIN32__ +#ifdef OS_WINDOWS int wsa_error = WSAGetLastError(); if (wsa_error == WSAEWOULDBLOCK) { return 0; @@ -95,7 +88,7 @@ int socket_write_tcp(socket_t desc, const char *txt, int length) return 0; #endif -#ifdef __WIN32__ +#ifdef OS_WINDOWS int wsa_error = WSAGetLastError(); if (wsa_error == WSAEWOULDBLOCK) { return 0; @@ -157,7 +150,7 @@ int socket_bind(const char * ip, int port, int protocol) } socket_reuse(s); -#ifndef __WIN32__ +#ifndef OS_WINDOWS socket_lingeroff(s); #else // Winsock2: SO_DONTLINGER, SO_KEEPALIVE, SO_LINGER, and SO_OOBINLINE are @@ -171,7 +164,7 @@ int socket_bind(const char * ip, int port, int protocol) sa.sin_family = AF_INET; // ߿θ BIND ip INADDR_ANY //(׽Ʈ Ǽ ) -#ifndef __WIN32__ +#ifndef OS_WINDOWS sa.sin_addr.s_addr = inet_addr(ip); #else sa.sin_addr.s_addr = INADDR_ANY; @@ -209,7 +202,7 @@ int socket_udp_bind(const char * ip, int port) void socket_close(socket_t s) { -#ifdef __WIN32__ +#ifdef OS_WINDOWS closesocket(s); #else close(s); @@ -285,27 +278,27 @@ socket_t socket_connect(const char* host, WORD port) { socket_close(s); -#ifdef __WIN32__ +#ifdef OS_WINDOWS switch (WSAGetLastError()) #else switch (rslt) #endif { -#ifdef __WIN32__ +#ifdef OS_WINDOWS case WSAETIMEDOUT: #else case EINTR: #endif sys_err("HOST %s:%d connection timeout.", host, port); break; -#ifdef __WIN32__ +#ifdef OS_WINDOWS case WSAECONNREFUSED: #else case ECONNREFUSED: #endif sys_err("HOST %s:%d port is not opened. connection refused.", host, port); break; -#ifdef __WIN32__ +#ifdef OS_WINDOWS case WSAENETUNREACH: #else case ENETUNREACH: @@ -325,7 +318,7 @@ socket_t socket_connect(const char* host, WORD port) return (s); } -#ifndef __WIN32__ +#ifndef OS_WINDOWS #ifndef O_NONBLOCK #define O_NONBLOCK O_NDELAY @@ -386,7 +379,7 @@ void socket_dontroute(socket_t s) void socket_lingeroff(socket_t s) { -#ifdef __WIN32__ +#ifdef OS_WINDOWS int linger; linger = 0; #else @@ -405,7 +398,7 @@ void socket_lingeroff(socket_t s) void socket_lingeron(socket_t s) { -#ifdef __WIN32__ +#ifdef OS_WINDOWS int linger; linger = 0; #else @@ -475,7 +468,7 @@ void socket_sndbuf(socket_t s, unsigned int opt) // sec : seconds, usec : microseconds void socket_timeout(socket_t s, long sec, long usec) { -#ifndef __WIN32__ +#ifndef OS_WINDOWS struct timeval rcvopt; struct timeval sndopt; socklen_t optlen = sizeof(rcvopt); @@ -517,7 +510,7 @@ void socket_timeout(socket_t s, long sec, long usec) return; } -#ifndef __WIN32__ +#ifndef OS_WINDOWS sys_log(1, "SYSTEM: %d: TIMEOUT RCV: %d.%d, SND: %d.%d", s, rcvopt.tv_sec, rcvopt.tv_usec, sndopt.tv_sec, sndopt.tv_usec); #endif } diff --git a/src/libthecore/socket.h b/src/libthecore/socket.h index 4ef63ce..13da6fe 100644 --- a/src/libthecore/socket.h +++ b/src/libthecore/socket.h @@ -1,45 +1,28 @@ -/* - * Filename: socket.c - * Description: Լ . - * - * Author: (server), myevan (Client) - */ -#ifndef __INC_LIBTHECORE_SOCKET_H__ -#define __INC_LIBTHECORE_SOCKET_H__ +#pragma once -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -#ifdef __WIN32__ +#ifdef OS_WINDOWS typedef int socklen_t; #else #define INVALID_SOCKET -1 #endif - extern int socket_read(socket_t desc, char* read_point, size_t space_left); - extern int socket_write(socket_t desc, const char *data, size_t length); +int socket_read(socket_t desc, char* read_point, size_t space_left); +int socket_write(socket_t desc, const char *data, size_t length); - extern int socket_udp_read(socket_t desc, char * read_point, size_t space_left, struct sockaddr * from, socklen_t * fromlen); - extern int socket_tcp_bind(const char * ip, int port); - extern int socket_udp_bind(const char * ip, int port); +int socket_udp_read(socket_t desc, char * read_point, size_t space_left, struct sockaddr * from, socklen_t * fromlen); +int socket_tcp_bind(const char * ip, int port); +int socket_udp_bind(const char * ip, int port); - extern socket_t socket_accept(socket_t s, struct sockaddr_in *peer); - extern void socket_close(socket_t s); - extern socket_t socket_connect(const char* host, WORD port); +socket_t socket_accept(socket_t s, struct sockaddr_in *peer); +void socket_close(socket_t s); +socket_t socket_connect(const char* host, WORD port); - extern void socket_nonblock(socket_t s); - extern void socket_block(socket_t s); - extern void socket_dontroute(socket_t s); - extern void socket_lingeroff(socket_t s); - extern void socket_lingeron(socket_t s); +void socket_nonblock(socket_t s); +void socket_block(socket_t s); +void socket_dontroute(socket_t s); +void socket_lingeroff(socket_t s); +void socket_lingeron(socket_t s); - extern void socket_sndbuf(socket_t s, unsigned int opt); - extern void socket_rcvbuf(socket_t s, unsigned int opt); +void socket_sndbuf(socket_t s, unsigned int opt); +void socket_rcvbuf(socket_t s, unsigned int opt); -#ifdef __cplusplus -}; -#endif - -#endif diff --git a/src/libthecore/stdafx.h b/src/libthecore/stdafx.h index 2e43ed2..25dec2c 100644 --- a/src/libthecore/stdafx.h +++ b/src/libthecore/stdafx.h @@ -1,5 +1,4 @@ -#ifndef __INC_LIBTHECORE_STDAFX_H__ -#define __INC_LIBTHECORE_STDAFX_H__ +#pragma once #if defined(__GNUC__) #define INLINE __inline__ @@ -7,7 +6,7 @@ #define INLINE inline #endif -#ifdef __WIN32__ +#ifdef OS_WINDOWS #define WIN32_LEAN_AND_MEAN #include @@ -35,19 +34,14 @@ #define S_ISDIR(m) (m & _S_IFDIR) #define snprintf _snprintf -struct timespec -{ - time_t tv_sec; /* seconds */ - long tv_nsec; /* and nanoseconds */ -}; - #define __USE_SELECT__ #define PATH_MAX _MAX_PATH // C runtime library adjustments + +#ifdef OS_FREEBSD #define strlcat(dst, src, size) strcat_s(dst, size, src) -#define strlcpy(dst, src, size) strncpy_s(dst, size, src, _TRUNCATE) #define strtoull(str, endptr, base) _strtoui64(str, endptr, base) #define strtof(str, endptr) (float)strtod(str, endptr) #define strcasecmp(s1, s2) stricmp(s1, s2) @@ -55,9 +49,9 @@ struct timespec #define atoll(str) _atoi64(str) #define localtime_r(timet, result) localtime_s(result, timet) #define strtok_r(s, delim, ptrptr) strtok_s(s, delim, ptrptr) +#endif -#include -#define __typeof(t) BOOST_TYPEOF(t) +#define __typeof(t) auto // dummy declaration of non-supported signals #define SIGUSR1 30 /* user defined signal 1 */ @@ -78,7 +72,7 @@ inline double rint(double x) #else -#ifndef __FreeBSD__ +#ifndef OS_FREEBSD #define __USE_SELECT__ #ifdef __CYGWIN__ #define _POSIX_SOURCE 1 @@ -112,20 +106,15 @@ inline double rint(double x) #include #include -#ifdef __FreeBSD__ +#ifdef OS_FREEBSD #include #endif #endif -#ifndef false -#define false 0 -#define true (!false) -#endif - #ifndef FALSE #define FALSE false -#define TRUE (!FALSE) +#define TRUE true #endif #include "typedef.h" @@ -141,5 +130,3 @@ inline double rint(double x) #include "utils.h" #include "crypt.h" #include "memcpy.h" - -#endif // __INC_LIBTHECORE_STDAFX_H__ diff --git a/src/libthecore/tea.cpp b/src/libthecore/tea.cpp index 07dd3f4..c7fe43a 100644 --- a/src/libthecore/tea.cpp +++ b/src/libthecore/tea.cpp @@ -1,31 +1,7 @@ -/* - * Filename: tea.c - * Description: TEA ȣȭ - * - * Author: (aka. , Cronan), ۿ (aka. myevan, ڷ) - */ #include "stdafx.h" -/* - * TEA Encryption Module Instruction - * Edited by aka. , Cronan - * - * void tea_code(const DWORD sz, const DWORD sy, const DWORD *key, DWORD *dest) - * void tea_decode(const DWORD sz, const DWORD sy, const DWORD *key, DWORD *dest) - * 8Ʈ ȣ/ȣȭ Ҷ ȴ. key 16 Ʈ Ѵ. - * sz, sy 8Ʈ Ѵ. - * - * int tea_decrypt(DWORD *dest, const DWORD *src, const DWORD *key, int size); - * int tea_encrypt(DWORD *dest, const DWORD *src, const DWORD *key, int size); - * Ѳ 8 Ʈ ̻ ȣ/ȣȭ Ҷ Ѵ. size - * 8 ƴϸ 8 ũ⸦ "÷" ȣȭ Ѵ. - * - * ex. tea_code(pdwSrc[1], pdwSrc[0], pdwKey, pdwDest); - * tea_decrypt(pdwDest, pdwSrc, pdwKey, nSize); - */ - -#define TEA_ROUND 32 // 32 ϸ, . -#define DELTA 0x9E3779B9 // DELTA ٲ . +#define TEA_ROUND 32 +#define DELTA 0x9E3779B9 char tea_nilbuf[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; diff --git a/src/libthecore/typedef.h b/src/libthecore/typedef.h index 1bf9b48..e54a915 100644 --- a/src/libthecore/typedef.h +++ b/src/libthecore/typedef.h @@ -1,12 +1,11 @@ -#ifndef __INC_LIBTHECORE_TYPEDEF_H__ -#define __INC_LIBTHECORE_TYPEDEF_H__ +#pragma once typedef unsigned long int QWORD; typedef unsigned char UBYTE; typedef signed char sbyte; typedef unsigned short sh_int; -#ifndef __WIN32__ +#ifndef OS_WINDOWS #ifndef __cplusplus typedef unsigned char bool; @@ -58,5 +57,3 @@ typedef unsigned __int64 uint64_t; typedef unsigned int uint; #endif - -#endif // __INC_LIBTHECORE_TYPEDEF_H__ diff --git a/src/libthecore/utils.cpp b/src/libthecore/utils.cpp index 5c783de..cc92fcb 100644 --- a/src/libthecore/utils.cpp +++ b/src/libthecore/utils.cpp @@ -346,7 +346,7 @@ int MINMAX(int min, int value, int max) DWORD thecore_random() { -#ifdef __WIN32__ +#ifdef OS_WINDOWS return rand(); #else return random(); @@ -380,7 +380,7 @@ float fnumber(float from, float to) return (((float)thecore_random() / (float)RAND_MAX) * (to - from)) + from; } -#ifndef __WIN32__ +#ifndef OS_WINDOWS void thecore_sleep(struct timeval* timeout) { if (select(0, (fd_set *) 0, (fd_set *) 0, (fd_set *) 0, timeout) < 0) diff --git a/src/libthecore/utils.h b/src/libthecore/utils.h index 346a452..5739e88 100644 --- a/src/libthecore/utils.h +++ b/src/libthecore/utils.h @@ -1,10 +1,4 @@ -#ifndef __INC_LIBTHECORE_UTILS_H__ -#define __INC_LIBTHECORE_UTILS_H__ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ +#pragma once #define SAFE_FREE(p) { if (p) { free( (void *) p); (p) = NULL; } } #define SAFE_DELETE(p) { if (p) { delete (p); (p) = NULL; } } @@ -17,50 +11,44 @@ extern "C" #define str_cmp strcasecmp #define STRNCPY(dst, src, len) do {strncpy(dst, src, len); dst[len] = '\0'; } while(0) - extern char * str_dup(const char * source); // ޸ Ҵ ؼ source Ѱ - extern void printdata(const unsigned char * data, int bytes); // data hex ascii (Ŷ м  ) - extern int filesize(FILE * fp); // ũ + char * str_dup(const char * source); + void printdata(const unsigned char * data, int bytes); + int filesize(FILE * fp); #define core_dump() core_dump_unix(__FILE__, __LINE__) - extern void core_dump_unix(const char *who, WORD line); // ھ +void core_dump_unix(const char *who, WORD line); #define TOKEN(string) if (!str_cmp(token_string, string)) - // src = ū : - extern void parse_token(char * src, char * token, char * value); +void parse_token(char * src, char * token, char * value); - extern void trim_and_lower(const char * src, char * dest, size_t dest_size); +void trim_and_lower(const char * src, char * dest, size_t dest_size); - // ڿ ҹڷ - extern void lower_string(const char * src, char * dest, size_t dest_len); +void lower_string(const char * src, char * dest, size_t dest_len); - // arg1 arg2 ϴ°? (ҹ ) - extern int is_abbrev(char *arg1, char *arg2); +int is_abbrev(char *arg1, char *arg2); - // a b ð 󸶳 ̳ - extern struct timeval * timediff(const struct timeval *a, const struct timeval *b); +struct timeval * timediff(const struct timeval *a, const struct timeval *b); - // a ð b ð - extern struct timeval * timeadd(struct timeval *a, struct timeval *b); +struct timeval * timeadd(struct timeval *a, struct timeval *b); - // ð curr_tm days - extern struct tm * tm_calc(const struct tm *curr_tm, int days); +struct tm * tm_calc(const struct tm *curr_tm, int days); - extern int MAX(int a, int b); // ߿ ū - extern int MIN(int a, int b); // ߿ - extern int MINMAX(int min, int value, int max); // ּ ִ Բ ؼ +int MAX(int a, int b); +int MIN(int a, int b); +int MINMAX(int min, int value, int max); - extern int number_ex(int from, int to, const char *file, int line); // from to +int number_ex(int from, int to, const char *file, int line); #define number(from, to) number_ex(from, to, __FILE__, __LINE__) - float fnumber(float from, float to); +float fnumber(float from, float to); - extern void thecore_sleep(struct timeval * timeout); // timeoutŭ μ - extern DWORD thecore_random(); // Լ +void thecore_sleep(struct timeval * timeout); +DWORD thecore_random(); - extern float get_float_time(); - extern DWORD get_dword_time(); +float get_float_time(); +DWORD get_dword_time(); - extern char * time_str(time_t ct); +char * time_str(time_t ct); #define CREATE(result, type, number) do { \ if (!((result) = (type *) calloc ((number), sizeof(type)))) { \ @@ -72,7 +60,6 @@ extern "C" sys_err("realloc failed [%d] %s", errno, strerror(errno)); \ abort(); } } while(0) - // Next Prev ִ Ʈ ߰ #define INSERT_TO_TW_LIST(item, head, prev, next) \ if (!(head)) \ { \ @@ -127,10 +114,6 @@ extern "C" ((DWORD)(BYTE) (ch2) << 16) | ((DWORD)(BYTE) (ch3) << 24)) #endif // defined(MAKEFOURCC) -#ifdef __cplusplus -} -#endif // __cplusplus - // _countof for gcc/g++ #if !defined(_countof) #if !defined(__cplusplus) @@ -145,8 +128,7 @@ extern "C++" #endif #endif -#ifdef __WIN32__ +#ifdef OS_WINDOWS extern void gettimeofday(struct timeval* t, struct timezone* dummy); #endif -#endif // __INC_UTILS_H__ diff --git a/src/libthecore/xdirent.cpp b/src/libthecore/xdirent.cpp index 8c2c059..cddb02f 100644 --- a/src/libthecore/xdirent.cpp +++ b/src/libthecore/xdirent.cpp @@ -1,6 +1,6 @@ #include "stdafx.h" -#ifdef __WIN32__ +#ifdef OS_WINDOWS /* @@ -19,11 +19,6 @@ #include #include -#ifdef __cplusplus -extern "C" -{ -#endif - struct DIR { long handle; /* -1 for failed rewind */ @@ -130,10 +125,6 @@ void rewinddir(DIR *dir) } } -#ifdef __cplusplus -} -#endif - /* Copyright Kevlin Henney, 1997, 2003. All rights reserved. @@ -149,4 +140,4 @@ void rewinddir(DIR *dir) */ -#endif // #ifdef __WIN32__ \ No newline at end of file +#endif // #ifdef OS_WINDOWS \ No newline at end of file diff --git a/src/libthecore/xdirent.h b/src/libthecore/xdirent.h index a02a0d8..7d16687 100644 --- a/src/libthecore/xdirent.h +++ b/src/libthecore/xdirent.h @@ -1,6 +1,4 @@ -#ifndef DIRENT_INCLUDED -#define DIRENT_INCLUDED - +#pragma once /* Declaration of POSIX directory browsing functions and types for Win32. @@ -11,11 +9,6 @@ */ -#ifdef __cplusplus -extern "C" -{ -#endif - typedef struct DIR DIR; struct dirent @@ -42,9 +35,3 @@ void rewinddir(DIR *); But that said, if there are any problems please get in touch. */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/libthecore/xgetopt.cpp b/src/libthecore/xgetopt.cpp index 868831b..7c23f80 100644 --- a/src/libthecore/xgetopt.cpp +++ b/src/libthecore/xgetopt.cpp @@ -28,7 +28,7 @@ #include "stdafx.h" /////////////////////////////////////////////////////////////////////////////// -#ifdef __WIN32__ +#ifdef OS_WINDOWS /////////////////////////////////////////////////////////////////////////////// // if you are not using precompiled headers then include these lines: @@ -225,4 +225,4 @@ int getopt(int argc, TCHAR *argv[], TCHAR *optstring) return c; } -#endif // #ifdef __WIN32__ \ No newline at end of file +#endif // #ifdef OS_WINDOWS \ No newline at end of file diff --git a/src/libthecore/xgetopt.h b/src/libthecore/xgetopt.h index f6cf073..90a3b18 100644 --- a/src/libthecore/xgetopt.h +++ b/src/libthecore/xgetopt.h @@ -12,12 +12,9 @@ // /////////////////////////////////////////////////////////////////////////////// -#ifndef XGETOPT_H -#define XGETOPT_H +#pragma once extern int optind, opterr, optreset; extern TCHAR *optarg; int getopt(int argc, TCHAR *argv[], TCHAR *optstring); - -#endif //XGETOPT_H diff --git a/src/libthecore/xmd5.cpp b/src/libthecore/xmd5.cpp index bfeb603..a377c72 100644 --- a/src/libthecore/xmd5.cpp +++ b/src/libthecore/xmd5.cpp @@ -1,6 +1,6 @@ #include "stdafx.h" -#ifndef __FreeBSD__ +#ifndef OS_FREEBSD /* * luau (Lib Update/Auto-Update): Simple Update Library @@ -83,7 +83,7 @@ lutil_md5_file (const char *filename, char *buf) MD5Init(&ctx); -#ifndef __WIN32__ +#ifndef OS_WINDOWS f = open(filename,O_RDONLY); #else f = _open(filename, _O_RDONLY); @@ -342,4 +342,4 @@ void MD5Transform(uint32_t buf[4], uint32_t const in[16]) buf[3] += d; } -#endif // #ifndef __FreeBSD__ \ No newline at end of file +#endif // #ifndef OS_FREEBSD \ No newline at end of file diff --git a/src/libthecore/xmd5.h b/src/libthecore/xmd5.h index ac7a63a..29e4e5b 100644 --- a/src/libthecore/xmd5.h +++ b/src/libthecore/xmd5.h @@ -1,4 +1,4 @@ -#ifndef __FreeBSD__ +#ifndef OS_FREEBSD /* * luau (Lib Update/Auto-Update): Simple Update Library @@ -47,9 +47,6 @@ * */ -#ifndef MD5_H -#define MD5_H - #include #define MD5_HASHBYTES 16 @@ -60,10 +57,6 @@ typedef struct MD5Context { unsigned char in[64]; } MD5_CTX; -#ifdef __cplusplus -extern "C" { -#endif - void MD5Init(MD5_CTX *context); void MD5Update(MD5_CTX *context, unsigned char const *buf, unsigned len); void MD5Final(unsigned char digest[MD5_HASHBYTES], MD5_CTX *context); @@ -73,10 +66,4 @@ char* MD5End(MD5_CTX *, char *); char* lutil_md5_file(const char *filename, char *buf); char* lutil_md5_data(const unsigned char *data, unsigned int len, char *buf); -#ifdef __cplusplus -} -#endif - -#endif /* MD5_H */ - -#endif // #ifndef __FreeBSD__ +#endif // #ifndef OS_FREEBSD