lib files are building
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -9,6 +9,9 @@ target_link_libraries(db
|
||||
libsql
|
||||
libthecore
|
||||
libredis
|
||||
|
||||
# external
|
||||
mariadbclient
|
||||
)
|
||||
|
||||
if (WIN32)
|
||||
|
||||
@@ -3239,7 +3239,7 @@ int CClientManager::Process()
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __WIN32__
|
||||
#ifdef OS_WINDOWS
|
||||
if (_kbhit()) {
|
||||
int c = _getch();
|
||||
switch (c) {
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
// vim:ts=8 sw=4
|
||||
#ifndef __INC_METIN2_DB_DBMANAGER_H__
|
||||
#define __INC_METIN2_DB_DBMANAGER_H__
|
||||
|
||||
// 디비 커넥션 클래스의 목적은... 디비에 접속해서 쿼리보내고 결과 받아오는
|
||||
// 모든 일들을 처리한다.
|
||||
// 코드 by 꼬붕 후로그래머 아노아~ = _=)b
|
||||
#include <mysql/mysql.h>
|
||||
#include <mysql.h>
|
||||
|
||||
#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))
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "AuctionManager.h"
|
||||
#endif
|
||||
#include <signal.h>
|
||||
#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);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "../../libthecore/include/stdafx.h"
|
||||
|
||||
#ifndef __WIN32__
|
||||
#ifndef OS_WINDOWS
|
||||
#include <semaphore.h>
|
||||
#else
|
||||
#define isdigit iswdigit
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
void WriteVersion()
|
||||
{
|
||||
#ifndef __WIN32__
|
||||
#ifndef OS_WINDOWS
|
||||
FILE* fp(fopen("VERSION.txt", "w"));
|
||||
|
||||
if (NULL != fp)
|
||||
|
||||
@@ -9,6 +9,9 @@ target_link_libraries(game
|
||||
libsql
|
||||
libthecore
|
||||
liblua
|
||||
|
||||
# external
|
||||
mariadbclient
|
||||
)
|
||||
|
||||
if (WIN32)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "ClientPackageCryptInfo.h"
|
||||
#include "../../common/stl.h"
|
||||
|
||||
#ifndef __FreeBSD__
|
||||
#ifndef OS_FREEBSD
|
||||
#include "../../libthecore/include/xdirent.h"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "HackShield_Impl.h"
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#ifdef OS_FREEBSD
|
||||
|
||||
#include "char.h"
|
||||
#include "packet.h"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#ifdef OS_FREEBSD
|
||||
// Live build only
|
||||
#define UNIX
|
||||
#include <AntiCpXSvr.h>
|
||||
@@ -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<DWORD, AHNHS_CLIENT_HANDLE> ClientHandleContainer;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "stdafx.h"
|
||||
#include "MarkManager.h"
|
||||
|
||||
#ifdef __WIN32__
|
||||
#ifdef OS_WINDOWS
|
||||
#include <direct.h>
|
||||
#endif
|
||||
|
||||
@@ -31,14 +31,14 @@ static Pixel * LoadOldGuildMarkImageFile()
|
||||
bool GuildMarkConvert(const std::vector<DWORD> & 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<DWORD> & 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
|
||||
|
||||
@@ -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; ++i )
|
||||
@@ -85,7 +85,7 @@ void CXTrapManager::NotifyMapFileChanged( const std::string& fileName, eFileUpda
|
||||
|
||||
bool CXTrapManager::LoadXTrapModule()
|
||||
{
|
||||
#ifdef __FreeBSD__
|
||||
#ifdef OS_FREEBSD
|
||||
//first load client mapfile
|
||||
bool bClientMapFileLoaded = false;
|
||||
for(int i=0; i<CSFILE_NUM; ++i )
|
||||
@@ -154,7 +154,7 @@ bool CXTrapManager::LoadXTrapModule()
|
||||
|
||||
bool CXTrapManager::LoadClientMapFile( unsigned int iMapIndex )
|
||||
{
|
||||
#ifdef __FreeBSD__
|
||||
#ifdef OS_FREEBSD
|
||||
//index check
|
||||
if( iMapIndex >= CSFILE_NUM )
|
||||
{
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
*/
|
||||
#include "stdafx.h"
|
||||
|
||||
#ifndef __WIN32__
|
||||
#ifndef OS_WINDOWS
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifdef __FreeBSD__
|
||||
#ifdef OS_FREEBSD
|
||||
#include <md5.h>
|
||||
#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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "stdafx.h"
|
||||
#ifdef __FreeBSD__
|
||||
#ifdef OS_FREEBSD
|
||||
#include <md5.h>
|
||||
#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";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "stdafx.h"
|
||||
#include <sstream>
|
||||
#ifndef __WIN32__
|
||||
#ifndef OS_WINDOWS
|
||||
#include <ifaddrs.h>
|
||||
#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();
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -69,7 +69,7 @@ class DESC_MANAGER : public singleton<DESC_MANAGER>
|
||||
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
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "dev_log.h"
|
||||
// #include "HackShield_Impl.h"
|
||||
|
||||
#ifndef __WIN32__
|
||||
#ifndef OS_WINDOWS
|
||||
#include "limit_time.h"
|
||||
#endif
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -64,13 +64,13 @@
|
||||
// #include "XTrapManager.h"
|
||||
#include "DragonSoul.h"
|
||||
#include <boost/bind.hpp>
|
||||
#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 <gtest/gtest.h>
|
||||
// #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
|
||||
// // <Factor> 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) {
|
||||
|
||||
@@ -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__)
|
||||
|
||||
@@ -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__)
|
||||
|
||||
@@ -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__)
|
||||
|
||||
@@ -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__)
|
||||
|
||||
@@ -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__)
|
||||
|
||||
@@ -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__)
|
||||
|
||||
@@ -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__)
|
||||
|
||||
@@ -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__)
|
||||
|
||||
@@ -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__)
|
||||
|
||||
@@ -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__)
|
||||
|
||||
@@ -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__)
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#include <cctype>
|
||||
#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__)
|
||||
|
||||
@@ -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__)
|
||||
|
||||
@@ -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__)
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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, ...);
|
||||
|
||||
@@ -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<WORD>(a) | (static_cast<WORD>(b) << 8);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
void WriteVersion()
|
||||
{
|
||||
#ifndef __WIN32__
|
||||
#ifndef OS_WINDOWS
|
||||
FILE* fp = fopen("version.txt", "w");
|
||||
|
||||
if (fp)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../../libthecore/include/stdafx.h"
|
||||
#include "libthecore/stdafx.h"
|
||||
#include "attribute.h"
|
||||
|
||||
#define SET_BIT(var,bit) ((var) |= (bit))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "../../libthecore/include/memcpy.h"
|
||||
#include "../../common/stl.h"
|
||||
#include "libthecore/memcpy.h"
|
||||
#include "common/stl.h"
|
||||
#include "grid.h"
|
||||
#include <algorithm>
|
||||
CGrid::CGrid(int w, int h) : m_iWidth(w), m_iHeight(h)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "../../libthecore/include/stdafx.h"
|
||||
#include "libthecore/stdafx.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "targa.h"
|
||||
|
||||
@@ -9,7 +9,7 @@ using namespace std;
|
||||
|
||||
double _random()
|
||||
{
|
||||
#ifndef __WIN32__
|
||||
#ifndef OS_WINDOWS
|
||||
return random() / (2147483648.0);
|
||||
#else
|
||||
return rand() / (2147483648.0);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#ifdef __WIN32__
|
||||
#ifdef OS_WINDOWS
|
||||
#include <windows.h>
|
||||
#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());
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#ifndef __WIN32__
|
||||
#ifndef OS_WINDOWS
|
||||
#include <sys/time.h>
|
||||
#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);
|
||||
|
||||
@@ -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 <string>
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <mysql/mysql.h>
|
||||
#include <mysql/errmsg.h>
|
||||
#include <mysql/mysqld_error.h>
|
||||
#include <mysql.h>
|
||||
#include <errmsg.h>
|
||||
#include <mysqld_error.h>
|
||||
|
||||
#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;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "stdafx.h"
|
||||
#include "Semaphore.h"
|
||||
|
||||
#ifndef __WIN32__
|
||||
#ifndef OS_WINDOWS
|
||||
|
||||
CSemaphore::CSemaphore() : m_hSem(NULL)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef __INC_METIN_II_SEMAPHORE_H__
|
||||
#define __INC_METIN_II_SEMAPHORE_H__
|
||||
|
||||
#ifndef __WIN32__
|
||||
#ifndef OS_WINDOWS
|
||||
#include <semaphore.h>
|
||||
#else
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
class CSemaphore
|
||||
{
|
||||
private:
|
||||
#ifndef __WIN32__
|
||||
#ifndef OS_WINDOWS
|
||||
sem_t * m_hSem;
|
||||
#else
|
||||
HANDLE m_hSem;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#ifndef __WIN32__
|
||||
#ifndef OS_WINDOWS
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.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();
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
#include "../libthecore/include/stdafx.h"
|
||||
#include "libthecore/stdafx.h"
|
||||
#include "AsyncSQL.h"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#pragma once
|
||||
static DWORD SP_boxes[8][64]=
|
||||
{
|
||||
/* 0 */
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 <URL:http://www.cl.cam.ac.uk/ftp/users/djw3/tea.ps>.
|
||||
/* 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 <URL:http://www.cl.cam.ac.uk/ftp/users/djw3/tea.ps>.
|
||||
|
||||
This implementation is based on their code in
|
||||
<URL:http://www.cl.cam.ac.uk/ftp/users/djw3/xtea.ps> */
|
||||
This implementation is based on their code in
|
||||
<URL:http://www.cl.cam.ac.uk/ftp/users/djw3/xtea.ps>
|
||||
*/
|
||||
|
||||
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);
|
||||
|
||||
@@ -278,4 +278,3 @@ int DES_Decrypt(DWORD *DstBuffer, const DWORD * SrcBuffer, const DWORD *KeyAddre
|
||||
|
||||
return Length;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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", "<EFBFBD>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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -126,7 +126,7 @@
|
||||
"Using prefetches efficiently is more of an art than a science"
|
||||
*/
|
||||
|
||||
#ifndef __WIN32__
|
||||
#ifndef OS_WINDOWS
|
||||
|
||||
#include <string.h>
|
||||
void *(*thecore_memcpy) (void * to, const void * from, size_t len) = memcpy;
|
||||
|
||||
@@ -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 <cstring>
|
||||
#define thecore_memcpy memcpy
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 <windows.h>
|
||||
@@ -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 <boost/__typeof/__typeof.hpp>
|
||||
#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 <pthread.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#ifdef OS_FREEBSD
|
||||
#include <sys/event.h>
|
||||
#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__
|
||||
|
||||
@@ -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 };
|
||||
|
||||
|
||||
@@ -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__
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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__
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#ifdef __WIN32__
|
||||
#ifdef OS_WINDOWS
|
||||
|
||||
/*
|
||||
|
||||
@@ -19,11 +19,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#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__
|
||||
#endif // #ifdef OS_WINDOWS
|
||||
@@ -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
|
||||
|
||||
@@ -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__
|
||||
#endif // #ifdef OS_WINDOWS
|
||||
@@ -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
|
||||
|
||||
@@ -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__
|
||||
#endif // #ifndef OS_FREEBSD
|
||||
@@ -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 <sys/types.h>
|
||||
|
||||
#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
|
||||
|
||||
Reference in New Issue
Block a user