Restructure repository to include all source folders
Move git root from Client/ to src/ to track all source code: - Client: Game client source (moved to Client/Client/) - Server: Game server source - GameTools: Development tools - CryptoSource: Encryption utilities - database: Database scripts - Script: Game scripts - rylCoder_16.02.2008_src: Legacy coder tools - GMFont, Game: Additional resources 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
100
Server/NFAuthTool/NFAuthServer/Nave/NFIni.cpp
Normal file
100
Server/NFAuthTool/NFAuthServer/Nave/NFIni.cpp
Normal file
@@ -0,0 +1,100 @@
|
||||
#include "Nave.h"
|
||||
#include "NFIni.h"
|
||||
|
||||
namespace Nave {
|
||||
|
||||
NFIni::NFIni()
|
||||
{
|
||||
ZeroMemory(m_szFileName, sizeof(m_szFileName));
|
||||
}
|
||||
|
||||
NFIni::~NFIni()
|
||||
{
|
||||
}
|
||||
|
||||
BOOL NFIni::Open(LPCWSTR fileName)
|
||||
{
|
||||
if (!fileName)
|
||||
return FALSE;
|
||||
|
||||
wcsncpy(m_szFileName, fileName, MAX_PATH);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL NFIni::Close()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL NFIni::GetValue(LPCWSTR keyName, LPCWSTR valueName, LPDWORD value)
|
||||
{
|
||||
if (!keyName || !valueName || !value)
|
||||
return FALSE;
|
||||
|
||||
*value = GetPrivateProfileIntW(keyName, valueName, 0, m_szFileName);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL NFIni::GetValue(LPCWSTR keyName, LPCWSTR valueName, FLOAT *value)
|
||||
{
|
||||
if (!keyName || !valueName || !value)
|
||||
return FALSE;
|
||||
|
||||
WCHAR Value[16] = {0,};
|
||||
|
||||
GetPrivateProfileStringW(keyName, valueName, L"", Value, 16, m_szFileName);
|
||||
|
||||
*value = (FLOAT)_wtof(Value);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL NFIni::GetValue(LPCWSTR keyName, LPCWSTR valueName, LPWSTR value, DWORD bufferLength)
|
||||
{
|
||||
if (!keyName || !valueName || !value || bufferLength == 0)
|
||||
return FALSE;
|
||||
|
||||
GetPrivateProfileStringW(keyName, valueName, L"", value, bufferLength, m_szFileName);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL NFIni::SetValue(LPCWSTR keyName, LPCWSTR valueName, DWORD value)
|
||||
{
|
||||
if (!keyName || !valueName)
|
||||
return FALSE;
|
||||
|
||||
WCHAR Value[16] = {0,};
|
||||
_itow(value, Value, 10);
|
||||
|
||||
WritePrivateProfileStringW(keyName, valueName, Value, m_szFileName);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL NFIni::SetValue(LPCWSTR keyName, LPCWSTR valueName, LPCWSTR value)
|
||||
{
|
||||
if (!keyName || !valueName || !value)
|
||||
return FALSE;
|
||||
|
||||
WritePrivateProfileStringW(keyName, valueName, value, m_szFileName);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL NFIni::SetValue(LPCWSTR keyName, LPCWSTR valueName, FLOAT value)
|
||||
{
|
||||
if (!keyName || !valueName)
|
||||
return FALSE;
|
||||
|
||||
WCHAR Value[16] = {0,};
|
||||
swprintf(Value, L"%f", value);
|
||||
|
||||
WritePrivateProfileStringW(keyName, valueName, Value, m_szFileName);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
103
Server/NFAuthTool/NFAuthServer/Nave/NFIni.h
Normal file
103
Server/NFAuthTool/NFAuthServer/Nave/NFIni.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/**
|
||||
* @file NFIni.h
|
||||
* @brief INI <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @remarks
|
||||
* @author <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(edith2580@gmail.com)
|
||||
* @date 2009-04-02
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace Nave {
|
||||
|
||||
/**
|
||||
* @class NFIni
|
||||
* @brief INI<4E><49><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> Ŭ<><C5AC><EFBFBD><EFBFBD>
|
||||
* @remarks NFIni ini; \r\n
|
||||
* ini.Open(L"c:\\Init.ini"); \r\n
|
||||
* ini.SetValue(L"SERVER CONFIG", L"PORT", dwPort); \r\n
|
||||
* ini.Close(); \r\n
|
||||
*
|
||||
* @par
|
||||
* @author Edith
|
||||
* @date 2009-04-04
|
||||
*/
|
||||
class NFIni
|
||||
{
|
||||
public:
|
||||
/// NFIni <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
NFIni();
|
||||
/// NFIni <20>Ҹ<EFBFBD><D2B8><EFBFBD>
|
||||
~NFIni();
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief INI<4E><49><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>.
|
||||
* @param fileName <09><><EFBFBD>ϸ<EFBFBD>
|
||||
* @return <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
BOOL Open(LPCWSTR fileName);
|
||||
|
||||
/**
|
||||
* @brief INI<4E><49><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>.
|
||||
* @return <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
BOOL Close();
|
||||
|
||||
/**
|
||||
* @brief INI<4E><49><EFBFBD>Ͽ<EFBFBD> <20><><EFBFBD><EFBFBD> <20>ֽ<EFBFBD><D6BD>ϴ<EFBFBD>.
|
||||
* @param keyName Key <20≯<EFBFBD>
|
||||
* @param valueName Value <20≯<EFBFBD>
|
||||
* @param value <09><>
|
||||
* @return <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
BOOL SetValue(LPCWSTR keyName, LPCWSTR valueName, LPCWSTR value);
|
||||
/**
|
||||
* @brief INI<4E><49><EFBFBD>Ͽ<EFBFBD> <20><><EFBFBD><EFBFBD> <20>ֽ<EFBFBD><D6BD>ϴ<EFBFBD>.
|
||||
* @param keyName Key <20≯<EFBFBD>
|
||||
* @param valueName Value <20≯<EFBFBD>
|
||||
* @param value <09><>
|
||||
* @return <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
BOOL SetValue(LPCWSTR keyName, LPCWSTR valueName, DWORD value);
|
||||
/**
|
||||
* @brief INI<4E><49><EFBFBD>Ͽ<EFBFBD> <20><><EFBFBD><EFBFBD> <20>ֽ<EFBFBD><D6BD>ϴ<EFBFBD>.
|
||||
* @param keyName Key <20≯<EFBFBD>
|
||||
* @param valueName Value <20≯<EFBFBD>
|
||||
* @param value <09><>
|
||||
* @return <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
BOOL SetValue(LPCWSTR keyName, LPCWSTR valueName, FLOAT value);
|
||||
|
||||
/**
|
||||
* @brief INI<4E><49><EFBFBD>Ͽ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ɴϴ<C9B4>.
|
||||
* @param keyName Key <20≯<EFBFBD>
|
||||
* @param valueName Value <20≯<EFBFBD>
|
||||
* @param value <09><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param bufferLength <09>۹<EFBFBD><DBB9><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @return <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
BOOL GetValue(LPCWSTR keyName, LPCWSTR valueName, LPWSTR value, DWORD bufferLength);
|
||||
/**
|
||||
* @brief INI<4E><49><EFBFBD>Ͽ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ɴϴ<C9B4>.
|
||||
* @param keyName Key <20≯<EFBFBD>
|
||||
* @param valueName Value <20≯<EFBFBD>
|
||||
* @param value <09><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @return <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
BOOL GetValue(LPCWSTR keyName, LPCWSTR valueName, LPDWORD value);
|
||||
/**
|
||||
* @brief INI<4E><49><EFBFBD>Ͽ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ɴϴ<C9B4>.
|
||||
* @param keyName Key <20≯<EFBFBD>
|
||||
* @param valueName Value <20≯<EFBFBD>
|
||||
* @param value <09><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @return <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
BOOL GetValue(LPCWSTR keyName, LPCWSTR valueName, FLOAT *value);
|
||||
|
||||
private:
|
||||
/// INI <20><><EFBFBD>ϸ<EFBFBD>
|
||||
WCHAR m_szFileName[MAX_PATH];
|
||||
};
|
||||
|
||||
}
|
||||
252
Server/NFAuthTool/NFAuthServer/Nave/NFLog.cpp
Normal file
252
Server/NFAuthTool/NFAuthServer/Nave/NFLog.cpp
Normal file
@@ -0,0 +1,252 @@
|
||||
#include "Nave.h"
|
||||
#include "NFStringUtil.h"
|
||||
#include <list>
|
||||
|
||||
#include "NFLog.h"
|
||||
|
||||
namespace Nave {
|
||||
|
||||
HWND NFLog::s_hLogHandel = NULL;
|
||||
BOOL NFLog::s_bEnableLogPrint = TRUE;
|
||||
BOOL NFLog::s_bSaveLogFile = FALSE;
|
||||
int NFLog::s_iLogLimit = NFLog::Info;
|
||||
BOOL NFLog::s_bLogDetail = FALSE;
|
||||
NFLogManager* NFLog::s_pLogManager = NULL;
|
||||
|
||||
|
||||
// Message<67><65> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ڵ<EFBFBD><DAB5><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
void NFLog::SetLogHandel(HWND hListWnd)
|
||||
{
|
||||
s_hLogHandel = hListWnd;
|
||||
}
|
||||
|
||||
void NFLog::SetLogPrint(BOOL enable)
|
||||
{
|
||||
s_bEnableLogPrint = enable;
|
||||
}
|
||||
|
||||
void NFLog::SetLogOutput(BOOL enable, DWORD dwSize)
|
||||
{
|
||||
s_bSaveLogFile = enable;
|
||||
SetLogPrint(enable);
|
||||
|
||||
_DELETE(s_pLogManager);
|
||||
if(s_bSaveLogFile)
|
||||
{
|
||||
s_pLogManager = new NFLogManager();
|
||||
s_pLogManager->Initialize(FALSE);
|
||||
s_pLogManager->SetLogMaxSize(dwSize);
|
||||
}
|
||||
}
|
||||
|
||||
void NFLog::CloseLog()
|
||||
{
|
||||
if(s_pLogManager)
|
||||
{
|
||||
s_pLogManager->Flush();
|
||||
_DELETE(s_pLogManager);
|
||||
}
|
||||
}
|
||||
|
||||
void NFLog::SetLogLimit(int limit)
|
||||
{
|
||||
s_iLogLimit=limit;
|
||||
}
|
||||
|
||||
void NFLog::SetLogDetail(BOOL detail)
|
||||
{
|
||||
s_bLogDetail = detail;
|
||||
}
|
||||
|
||||
void NFLog::AddLogMsg( HWND hWnd, WCHAR* String, int Len )
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD>
|
||||
int iCount = (int)SendMessageW( hWnd, LB_GETCOUNT, 0, 0L )-256;
|
||||
for(int i = 0; i < iCount; ++i)
|
||||
SendMessageW( hWnd, LB_DELETESTRING, 0, 0L );
|
||||
|
||||
// <20>߰<EFBFBD>
|
||||
WCHAR* p;
|
||||
int k;
|
||||
p = String;
|
||||
|
||||
int iAdd = 0;
|
||||
|
||||
k = 0;
|
||||
while( k++ < Len )
|
||||
{
|
||||
switch( *String )
|
||||
{
|
||||
case L'\n':
|
||||
*String = 0;
|
||||
++iAdd;
|
||||
SendMessageW( hWnd, LB_ADDSTRING, 0, (LPARAM)(LPWSTR)p );
|
||||
p = ++String;
|
||||
break;
|
||||
default :
|
||||
++String;
|
||||
}
|
||||
}
|
||||
|
||||
if( *p )
|
||||
{
|
||||
++iAdd;
|
||||
SendMessageW( hWnd, LB_ADDSTRING, 0, (LPARAM)(LPWSTR)p );
|
||||
}
|
||||
|
||||
int Top = (int)SendMessageW( hWnd, LB_GETTOPINDEX, 0, 0L );
|
||||
SendMessageW( hWnd, LB_SETTOPINDEX, Top+iAdd, 0L );
|
||||
}
|
||||
|
||||
void NFLog::LogPrintf( WCHAR* msg, ... )
|
||||
{
|
||||
va_list v;
|
||||
WCHAR buf[1024];
|
||||
int len;
|
||||
|
||||
va_start( v, msg );
|
||||
len = vswprintf( buf, msg, v );
|
||||
|
||||
va_end( v );
|
||||
|
||||
LogPrintf( Info, buf);
|
||||
}
|
||||
|
||||
void NFLog::OutputLog(const WCHAR* log)
|
||||
{
|
||||
static CHAR stDot[4] = "\r\n";
|
||||
static CHAR stTime[32];
|
||||
|
||||
SYSTEMTIME sysTime;
|
||||
GetLocalTime(&sysTime);
|
||||
|
||||
sprintf(stTime, "[%04d.%02d.%02d-%02d:%02d:%02d]", sysTime.wYear, sysTime.wMonth, sysTime.wDay, sysTime.wHour, sysTime.wMinute, sysTime.wSecond);
|
||||
|
||||
Nave::StringA str = stTime;
|
||||
str += ToASCII(log);
|
||||
str += stDot;
|
||||
|
||||
int iSize = str.size();
|
||||
char* pPoint = s_pLogManager->ReserveBuffer(iSize);
|
||||
memcpy(pPoint, str.c_str(), iSize);
|
||||
}
|
||||
|
||||
void NFLog::LogPrintf( int group, WCHAR* msg )
|
||||
{
|
||||
if (group < s_iLogLimit)
|
||||
return;
|
||||
|
||||
if(s_bEnableLogPrint)
|
||||
{
|
||||
if(s_hLogHandel == NULL)
|
||||
{
|
||||
// setlocale <20>Լ<EFBFBD><D4BC><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD> <20>ѱ<EFBFBD><D1B1><EFBFBD> <20><><EFBFBD>µ<EFBFBD>
|
||||
wprintf(msg);
|
||||
wprintf(L"\n");
|
||||
}
|
||||
else
|
||||
AddLogMsg( s_hLogHandel, msg, (int)wcslen(msg) );
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
OutputDebugStringW( msg );
|
||||
OutputDebugStringW( L"\r\n" );
|
||||
#endif
|
||||
if(s_bSaveLogFile)
|
||||
{
|
||||
Nave::StringW tmp = msg;
|
||||
Nave::StringW logmsg;
|
||||
switch (group) {
|
||||
case Info:
|
||||
logmsg=L"[INF] " + tmp;
|
||||
break;
|
||||
case Warning:
|
||||
logmsg=L"[WAR] " + tmp;
|
||||
break;
|
||||
case Error:
|
||||
logmsg=L"[ERR] " + tmp;
|
||||
break;
|
||||
case Exception:
|
||||
logmsg=L"[EXP] " + tmp;
|
||||
break;
|
||||
case Important:
|
||||
logmsg=L"[DET] " + tmp;
|
||||
break;
|
||||
};
|
||||
|
||||
OutputLog(logmsg.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void NFLog::LogPrintf( int group, const WCHAR* pFile, int pLinenum, const WCHAR* pFunc, WCHAR* msg )
|
||||
{
|
||||
if (group < s_iLogLimit)
|
||||
return;
|
||||
|
||||
if(s_bEnableLogPrint)
|
||||
{
|
||||
if(s_hLogHandel == NULL)
|
||||
{
|
||||
wprintf(msg);
|
||||
wprintf(L"\n");
|
||||
}
|
||||
else
|
||||
AddLogMsg( s_hLogHandel, msg, (int)wcslen(msg) );
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
OutputDebugStringW( msg );
|
||||
OutputDebugStringW( L"\r\n" );
|
||||
#endif
|
||||
|
||||
if(s_bSaveLogFile)
|
||||
{
|
||||
Nave::StringW tmp = msg;
|
||||
Nave::StringW logmsg;
|
||||
switch (group) {
|
||||
case Info:
|
||||
logmsg=L"[INF]" + tmp;
|
||||
break;
|
||||
case Warning:
|
||||
logmsg=L"[WAR]" + tmp;
|
||||
break;
|
||||
case Error:
|
||||
logmsg=L"[ERR]" + tmp;
|
||||
break;
|
||||
case Exception:
|
||||
logmsg=L"[EXP]" + tmp;
|
||||
break;
|
||||
case Important:
|
||||
logmsg=L"[DET]" + tmp;
|
||||
break;
|
||||
};
|
||||
|
||||
OutputLog(logmsg.c_str());
|
||||
|
||||
static WCHAR deta[1024];
|
||||
swprintf(deta, L" -> [%s,%d,%s]", pFile, pLinenum, pFunc);
|
||||
OutputLog(deta);
|
||||
}
|
||||
}
|
||||
|
||||
NFLog::Proxy::Proxy(int pGroup, const WCHAR* pFile, int pLinenum, const WCHAR* pFunc) : file(pFile),linenum(pLinenum), func(pFunc), group(pGroup)
|
||||
{
|
||||
}
|
||||
|
||||
void NFLog::Proxy::Log(const WCHAR* msg, ...)
|
||||
{
|
||||
if (group < NFLog::s_iLogLimit)
|
||||
return;
|
||||
|
||||
WCHAR txt[1024];
|
||||
va_list l;
|
||||
va_start(l,msg);
|
||||
_vsnwprintf( txt, 1024, msg, l );
|
||||
va_end(l);
|
||||
if(!NFLog::s_bLogDetail)
|
||||
LogPrintf(group,txt);
|
||||
else
|
||||
LogPrintf(group,file,linenum,func,txt); // <20>̰<EFBFBD> <20><><EFBFBD>ϰ<EFBFBD> <20><>Ÿ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>涧..
|
||||
}
|
||||
|
||||
}
|
||||
142
Server/NFAuthTool/NFAuthServer/Nave/NFLog.h
Normal file
142
Server/NFAuthTool/NFAuthServer/Nave/NFLog.h
Normal file
@@ -0,0 +1,142 @@
|
||||
/**
|
||||
* @file NFLog.h
|
||||
* @brief Log <20><><EFBFBD><EFBFBD> Ŭ<><C5AC><EFBFBD><EFBFBD>
|
||||
* @remarks
|
||||
* @author <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(edith2580@gmail.com)
|
||||
* @date 2009-04-02
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string>
|
||||
|
||||
#include "NFLogManager.h"
|
||||
|
||||
namespace Nave {
|
||||
|
||||
/**
|
||||
* @class NFLog
|
||||
* @brief Log <20><><EFBFBD><EFBFBD> Ŭ<><C5AC><EFBFBD><EFBFBD>
|
||||
* @remarks NFLog::SetLogHandel(hList); // Ư<><C6AF> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>. \r\n
|
||||
* NFLog::EnableLogPrint(TRUE); // <20>α<CEB1> ȭ<>鿡 <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>. \r\n
|
||||
* NFLog::EnableLogOutput(TRUE); // <20>α<CEB1> <20><><EFBFBD>Ϸ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD> \r\n
|
||||
* NFLog::SetLogDetail(TRUE); // <20><><EFBFBD><EFBFBD> <20>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>. \r\n
|
||||
* NFLog::SetLogLimit(NFLog::Proxy::Info) // <20>α<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>. \r\n
|
||||
* // <20>α<EFBFBD> <20><><EFBFBD><EFBFBD> \r\n
|
||||
* LOG_IMPORTANT((L"Test Start")); \r\n
|
||||
* // <20>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>. \r\n
|
||||
* NFLog::CloseLog(); \r\n
|
||||
* @warning NFLog::CloseLog()<29><> ȣ<><C8A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>Ϸ<EFBFBD> <20>αװ<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <20>ʽ<EFBFBD><CABD>ϴ<EFBFBD>.
|
||||
*
|
||||
* @par
|
||||
* @author Edith
|
||||
* @date 2009-04-04
|
||||
*/
|
||||
class NFLog
|
||||
{
|
||||
public:
|
||||
/// <20><> <20>α<EFBFBD><CEB1><EFBFBD> Index Ÿ<><C5B8>
|
||||
enum Groups {
|
||||
Info = 1 << 0,
|
||||
Warning = 1 << 1,
|
||||
Error = 1 << 2,
|
||||
Exception = 1 << 3,
|
||||
Important = 1 << 4,
|
||||
};
|
||||
|
||||
/// <20>α<EFBFBD> <20><><EFBFBD>¿<EFBFBD> <20><><EFBFBD><EFBFBD>ü
|
||||
struct Proxy
|
||||
{
|
||||
/// <20>αװ<CEB1> ȣ<><C8A3><EFBFBD><EFBFBD> <20>Լ<EFBFBD>
|
||||
const WCHAR* func;
|
||||
/// <20>αװ<CEB1> ȣ<><C8A3><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
const WCHAR* file;
|
||||
/// <20>αװ<CEB1> ȣ<><C8A3><EFBFBD><EFBFBD> <20><><EFBFBD>ι<EFBFBD>ȣ
|
||||
int linenum;
|
||||
/// <20>α<EFBFBD><CEB1><EFBFBD> <20><EFBFBD><D7B7><EFBFBD><EFBFBD>̵<EFBFBD>
|
||||
int group;
|
||||
|
||||
Proxy(int pGroup, const WCHAR* pFile, int pLinenum, const WCHAR* pFunc);
|
||||
void Log(const WCHAR* msg, ...);
|
||||
};
|
||||
|
||||
/// Message<67><65> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ڵ<EFBFBD><DAB5><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
static void SetLogHandel(HWND hListWnd);
|
||||
/// ȭ<>鿡 <20>ΰ<EFBFBD><CEB0><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
static void SetLogPrint(BOOL enable = TRUE);
|
||||
/// <20><><EFBFBD>Ϸ<EFBFBD> <20>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
static void SetLogOutput(BOOL enable = TRUE, DWORD dwSize = 100 * 1024 * 1024);
|
||||
/// <20>α<EFBFBD><CEB1><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>. NFLog::Info ~ NFLog::Important
|
||||
static void SetLogLimit(int limit);
|
||||
/// <20><><EFBFBD><EFBFBD> <20>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>.
|
||||
static void SetLogDetail(BOOL detail);
|
||||
|
||||
/// <20>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>. (<28>ӽú<D3BD><C3BA><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>α<CEB1> <20><><EFBFBD>Ϸ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>.)
|
||||
static void CloseLog();
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief hWnd<6E><64> String<6E><67> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
* @param hWnd <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ڵ<EFBFBD>
|
||||
* @param String <09><EFBFBD><DEBD><EFBFBD>
|
||||
* @param Len <09><EFBFBD><DEBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
static void AddLogMsg( HWND hWnd, WCHAR* String, int Len );
|
||||
|
||||
/**
|
||||
* @brief <09><EFBFBD><DEBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>. <20>ܼ<EFBFBD><DCBC>϶<EFBFBD> printf<74><66> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD> Msg<73><67><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param *msg <09><><EFBFBD><EFBFBD> <20><EFBFBD><DEBD><EFBFBD>
|
||||
* @param ... <09><><EFBFBD><EFBFBD>
|
||||
*/
|
||||
static void LogPrintf( WCHAR* msg, ... );
|
||||
|
||||
/**
|
||||
* @brief <09><EFBFBD><DEBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>. <20>ܼ<EFBFBD><DCBC>϶<EFBFBD> printf<74><66> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD> Msg<73><67><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param group <09><EFBFBD><D7B7>ε<EFBFBD><CEB5><EFBFBD>
|
||||
* @param *msg <09><EFBFBD><DEBD><EFBFBD>
|
||||
*/
|
||||
static void LogPrintf( int group, WCHAR* msg );
|
||||
|
||||
/**
|
||||
* @brief <09><EFBFBD><DEBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>. <20>ܼ<EFBFBD><DCBC>϶<EFBFBD> printf<74><66> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>϶<EFBFBD> Msg<73><67><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param group <09><EFBFBD><D7B7>ε<EFBFBD><CEB5><EFBFBD>
|
||||
* @param pFile ȣ<><C8A3><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD>
|
||||
* @param pLinenum ȣ<><C8A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param pFunc ȣ<><C8A3><EFBFBD>Լ<EFBFBD>
|
||||
* @param *msg <09><EFBFBD><DEBD><EFBFBD>
|
||||
*/
|
||||
static void LogPrintf( int group, const WCHAR* pFile, int pLinenum, const WCHAR* pFunc, WCHAR* msg );
|
||||
|
||||
/// <20>α<EFBFBD> <20><><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD> <20>߰<EFBFBD><DFB0>մϴ<D5B4>.
|
||||
static void OutputLog(const WCHAR* log);
|
||||
|
||||
private:
|
||||
/// Message<67><65> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ڵ<EFBFBD>
|
||||
static HWND s_hLogHandel;
|
||||
/// <20>α<EFBFBD><CEB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ȱ<><C8B0>ȭ <20>մϴ<D5B4>.
|
||||
static BOOL s_bEnableLogPrint;
|
||||
/// <20>α<CEB1> <20><><EFBFBD>Ϸ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>.
|
||||
static BOOL s_bSaveLogFile;
|
||||
/// <20>α<EFBFBD> Limit
|
||||
static int s_iLogLimit;
|
||||
/// <20>α<EFBFBD> Detail
|
||||
static BOOL s_bLogDetail;
|
||||
|
||||
/// <20>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> <20>Ŵ<EFBFBD><C5B4><EFBFBD>
|
||||
static NFLogManager* s_pLogManager;
|
||||
};
|
||||
}
|
||||
|
||||
/// Info Log
|
||||
#define LOG_INFO(LOGMESSAGE) {Nave::NFLog::Proxy(Nave::NFLog::Info, __WFILE__, __LINE__,__WFUNCSIG__).Log LOGMESSAGE;}
|
||||
/// Warning Log
|
||||
#define LOG_WARNING(LOGMESSAGE) {Nave::NFLog::Proxy(Nave::NFLog::Warning,__WFILE__, __LINE__,__WFUNCSIG__).Log LOGMESSAGE;}
|
||||
/// Error Log
|
||||
#define LOG_ERROR(LOGMESSAGE) {Nave::NFLog::Proxy(Nave::NFLog::Error,__WFILE__, __LINE__,__WFUNCSIG__).Log LOGMESSAGE;}
|
||||
/// Exeption Log
|
||||
#define LOG_EXCEPTION(LOGMESSAGE) {Nave::NFLog::Proxy(Nave::NFLog::Exception,__WFILE__, __LINE__,__WFUNCSIG__).Log LOGMESSAGE;}
|
||||
/// Important Log
|
||||
#define LOG_IMPORTANT(LOGMESSAGE) {Nave::NFLog::Proxy(Nave::NFLog::Important,__WFILE__, __LINE__,__WFUNCSIG__).Log LOGMESSAGE;}
|
||||
348
Server/NFAuthTool/NFAuthServer/Nave/NFLogManager.cpp
Normal file
348
Server/NFAuthTool/NFAuthServer/Nave/NFLogManager.cpp
Normal file
@@ -0,0 +1,348 @@
|
||||
#include "Nave.h"
|
||||
#include "NFLog.h"
|
||||
#include "NFLogManager.h"
|
||||
|
||||
#include "NFThreadManager.h"
|
||||
|
||||
namespace Nave {
|
||||
|
||||
NFLogThread::NFLogThread() : m_pLogHandle(NULL), m_bCompress(TRUE),
|
||||
m_hFlush(CreateEvent(0, TRUE, FALSE, 0)),
|
||||
m_hFile(INVALID_HANDLE_VALUE), m_dwTotalWritten(0),
|
||||
m_dwMaxFileSize(MAX_FILE_SIZE)
|
||||
{
|
||||
InterlockedExchange(&m_bEnd, FALSE);
|
||||
}
|
||||
|
||||
NFLogThread::~NFLogThread()
|
||||
{
|
||||
if(INVALID_HANDLE_VALUE != m_hFile)
|
||||
{
|
||||
CloseHandle(m_hFile);
|
||||
m_hFile = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
if(0 != m_hFlush)
|
||||
{
|
||||
CloseHandle(m_hFlush);
|
||||
m_hFlush = 0;
|
||||
}
|
||||
}
|
||||
|
||||
VOID NFLogThread::Initialize(NFLogManager* pLog, BOOL bCompress)
|
||||
{
|
||||
m_bCompress = bCompress;
|
||||
m_pLogHandle = pLog;
|
||||
}
|
||||
|
||||
unsigned int NFLogThread::Run()
|
||||
{
|
||||
// <20><><EFBFBD>⼭ m_bEnd<6E><64> TRUE<55><45> <20>ƴϸ<C6B4> <20><><EFBFBD><EFBFBD><EFBFBD>尡 <20>۵<EFBFBD><DBB5>ϰ<EFBFBD> <20>ִ<EFBFBD>.
|
||||
for(;TRUE != InterlockedCompareExchange(&m_bEnd, TRUE, TRUE);)
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD> <20>̺<EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD≯<EFBFBD> 1<>ʰ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ٽ<EFBFBD> Ȯ<><C8AE>.
|
||||
if(WAIT_TIMEOUT == WaitForSingleObject(m_hFlush, 1000))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
WriteLog();
|
||||
};
|
||||
|
||||
WriteLog();
|
||||
return 0;
|
||||
}
|
||||
|
||||
BOOL NFLogThread::End()
|
||||
{
|
||||
InterlockedExchange(&m_bEnd, TRUE);
|
||||
SetEvent(m_hFlush);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL NFLogThread::WriteLog()
|
||||
{
|
||||
// <20>α<CEB1><D7BF><EFBFBD> <20><><EFBFBD>۸<EFBFBD> <20>о<EFBFBD><D0BE>´<EFBFBD>.
|
||||
if(!m_pLogHandle)
|
||||
return FALSE;
|
||||
|
||||
m_pLogHandle->SpliceInWriteBuffer(m_WriteBufferList);
|
||||
|
||||
if(m_WriteBufferList.empty())
|
||||
return TRUE;
|
||||
|
||||
if(INVALID_HANDLE_VALUE == m_hFile)
|
||||
{
|
||||
SetLogFileName();
|
||||
m_hFile = CreateFileW(m_szLogFileName, GENERIC_WRITE,
|
||||
FILE_SHARE_READ, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
|
||||
|
||||
if(INVALID_HANDLE_VALUE == m_hFile)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long dwWritten = 0;
|
||||
|
||||
for(NFLogBuffer::List::iterator itr = m_WriteBufferList.begin();
|
||||
itr != m_WriteBufferList.end(); ++itr)
|
||||
{
|
||||
NFLogBuffer* pLogBuffer = *itr;
|
||||
if(FALSE == WriteFile(m_hFile, pLogBuffer->m_Buffer, pLogBuffer->m_dwUsage, &dwWritten, 0))
|
||||
{
|
||||
LOG_ERROR((L"<EFBFBD>α<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>Ͽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>߽<EFBFBD><DFBD>ϴ<EFBFBD>. ErrorNum : %d, FileHandle:0x%p, <20><><EFBFBD><EFBFBD> ũ<><C5A9>:%d",
|
||||
GetLastError(), m_hFile, pLogBuffer->m_dwUsage));
|
||||
}
|
||||
|
||||
m_dwTotalWritten += dwWritten;
|
||||
}
|
||||
|
||||
m_pLogHandle->SpliceInFreeBuffer(m_WriteBufferList);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>´<EFBFBD>.
|
||||
if(m_dwTotalWritten > m_dwMaxFileSize)
|
||||
{
|
||||
if(INVALID_HANDLE_VALUE != m_hFile) { CloseHandle(m_hFile); m_hFile = INVALID_HANDLE_VALUE; } // <20><><EFBFBD><EFBFBD> <20>ݰ<EFBFBD>...
|
||||
|
||||
m_dwTotalWritten = 0;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL NFLogThread::SetLogFileName()
|
||||
{
|
||||
SYSTEMTIME sysTime;
|
||||
GetLocalTime(&sysTime);
|
||||
|
||||
unsigned long dwSpinCount = 0;
|
||||
WCHAR szProgramName[MAX_PATH];
|
||||
WCHAR szLogFilePrefix[MAX_PATH];
|
||||
|
||||
// <20><><EFBFBD>α<CEB1><D7B7≯<EFBFBD><CCB8><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
Nave::GetProgramName(szProgramName, MAX_PATH);
|
||||
|
||||
if(m_pLogHandle)
|
||||
_snwprintf(szLogFilePrefix, MAX_PATH - 1, L"%s", m_pLogHandle->GetLogFilePrefix());
|
||||
else
|
||||
wcsncpy(szLogFilePrefix, szProgramName, MAX_PATH);
|
||||
|
||||
if (INVALID_FILE_ATTRIBUTES == GetFileAttributesW(szProgramName))
|
||||
{
|
||||
if (!CreateDirectoryW(szProgramName, 0))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
int LogLen = _snwprintf(m_szLogFileName, MAX_PATH,
|
||||
L"%s\\%s-%04d%02d%02d-%02d%02d%02d-%04d.log",
|
||||
szProgramName, szLogFilePrefix, sysTime.wYear, sysTime.wMonth, sysTime.wDay,
|
||||
sysTime.wHour, sysTime.wMinute, sysTime.wSecond, dwSpinCount);
|
||||
|
||||
if(LogLen <= 0)
|
||||
{
|
||||
LOG_ERROR((L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>α<CEB1> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20≯<EFBFBD><CCB8><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>."));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (INVALID_FILE_ATTRIBUTES == GetFileAttributesW(m_szLogFileName))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
++dwSpinCount;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
NFLogManager::NFLogManager(void) : m_lpDetailBuffer(0)
|
||||
{
|
||||
}
|
||||
|
||||
NFLogManager::~NFLogManager(void)
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
BOOL NFLogManager::Initialize(BOOL bCompress, const WCHAR* szLogFilePrefix)
|
||||
{
|
||||
WCHAR strName[MAX_PATH];
|
||||
Nave::GetProgramName(strName, MAX_PATH);
|
||||
wcsncpy(m_szLogFilePrefix, strName, MAX_PATH);
|
||||
|
||||
if(szLogFilePrefix != 0)
|
||||
{
|
||||
wcscat(m_szLogFilePrefix, szLogFilePrefix);
|
||||
}
|
||||
|
||||
// ó<><C3B3><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŭ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
for(int nCount = 0; nCount < DEFAULT_FREE_LOG_BUFFER_NUM; ++nCount)
|
||||
{
|
||||
NFLogBuffer* pDetailBuffer = new NFLogBuffer;
|
||||
if(0 == pDetailBuffer)
|
||||
{
|
||||
LOG_ERROR((L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>α<EFBFBD> <20><><EFBFBD>۸<EFBFBD> <20>Ҵ<EFBFBD><D2B4>ϴ<EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>߽<EFBFBD><DFBD>ϴ<EFBFBD>"));
|
||||
Destroy();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
m_FreeList.push_back(pDetailBuffer);
|
||||
};
|
||||
|
||||
// <20><><EFBFBD>۰<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>켱 1<><31> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
if(m_lpDetailBuffer == 0)
|
||||
{
|
||||
m_lpDetailBuffer = GetBuffer();
|
||||
}
|
||||
|
||||
m_LogSaveThread.Initialize(this, bCompress);
|
||||
|
||||
if(INVALID_HANDLE_VALUE == NFThreadManager::Run(&m_LogSaveThread))
|
||||
{
|
||||
LOG_ERROR((L"Flush<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>带 <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>߽<EFBFBD><DFBD>ϴ<EFBFBD>"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL NFLogManager::Destroy()
|
||||
{
|
||||
Flush();
|
||||
NFThreadManager::Stop(&m_LogSaveThread, INFINITE);
|
||||
|
||||
// <20><>ũ<EFBFBD>Ǵ<EFBFBD>.
|
||||
NFSyncLock CL(&m_LogSync);
|
||||
|
||||
NFLogBuffer* pDetailBuffer;
|
||||
for(NFLogBuffer::List::iterator itr = m_FreeList.begin(); itr != m_FreeList.end(); ++itr)
|
||||
{
|
||||
pDetailBuffer = (*itr);
|
||||
_DELETE(pDetailBuffer);
|
||||
}
|
||||
m_FreeList.clear();
|
||||
|
||||
for(NFLogBuffer::List::iterator itr = m_WriteList.begin(); itr != m_WriteList.end(); ++itr)
|
||||
{
|
||||
pDetailBuffer = (*itr);
|
||||
_DELETE(pDetailBuffer);
|
||||
}
|
||||
m_WriteList.clear();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
VOID NFLogManager::SetLogMaxSize(DWORD dwSize)
|
||||
{
|
||||
m_LogSaveThread.SetLogMaxSize(dwSize);
|
||||
}
|
||||
|
||||
NFLogBuffer* NFLogManager::GetBuffer()
|
||||
{
|
||||
// <20><>ũ<EFBFBD>Ǵ<EFBFBD>.
|
||||
NFSyncLock CL(&m_LogSync);
|
||||
|
||||
NFLogBuffer* pLogBuffer = 0;
|
||||
if(m_FreeList.empty())
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD>۰<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ǽð<C7BD><C3B0><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD><D8B9><EFBFBD><EFBFBD><EFBFBD>. <20><>¿<EFBFBD><C2BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
pLogBuffer = new NFLogBuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
pLogBuffer = m_FreeList.front();
|
||||
m_FreeList.pop_front();
|
||||
}
|
||||
|
||||
if(0 == pLogBuffer)
|
||||
{
|
||||
LOG_ERROR((L"<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>α<EFBFBD> <20><><EFBFBD>۸<EFBFBD> <20>Ҵ<EFBFBD><D2B4><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>."));
|
||||
return 0;
|
||||
}
|
||||
|
||||
pLogBuffer->Initialize();
|
||||
return pLogBuffer;
|
||||
};
|
||||
|
||||
BOOL NFLogManager::Flush()
|
||||
{
|
||||
// <20><><EFBFBD>۸<EFBFBD> <20>ִ´<D6B4>.
|
||||
PushBuffer(&m_lpDetailBuffer);
|
||||
return m_LogSaveThread.FlushSignal();
|
||||
}
|
||||
|
||||
char* NFLogManager::ReserveBuffer(unsigned short usReserve)
|
||||
{
|
||||
NFSyncLock CL(&m_LogSync);
|
||||
|
||||
if(0 == m_lpDetailBuffer)
|
||||
{
|
||||
m_lpDetailBuffer = GetBuffer();
|
||||
}
|
||||
|
||||
if(NFLogBuffer::MAX_LOG_BUFFER < m_lpDetailBuffer->m_dwUsage + usReserve)
|
||||
{
|
||||
Flush(); // <20><><EFBFBD>۰<EFBFBD> <20><>á<EFBFBD><C3A1><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD>.
|
||||
m_lpDetailBuffer = GetBuffer();
|
||||
}
|
||||
|
||||
if(0 == m_lpDetailBuffer)
|
||||
{
|
||||
LOG_ERROR((L"<EFBFBD>α<EFBFBD> <20><><EFBFBD>۰<EFBFBD> 0<>Դϴ<D4B4>."));
|
||||
return 0;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD>ø<EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD> <20>ش翵<D8B4><E7BFB5><EFBFBD><EFBFBD> Ȯ<><C8AE><EFBFBD>Ѵ<EFBFBD>.
|
||||
char* pPoint = &m_lpDetailBuffer->m_Buffer[m_lpDetailBuffer->m_dwUsage];
|
||||
Complete(usReserve);
|
||||
return pPoint;
|
||||
}
|
||||
|
||||
VOID NFLogManager::SpliceInWriteBuffer(NFLogBuffer::List& logBufferList)
|
||||
{
|
||||
NFSyncLock CL(&m_LogSync);
|
||||
|
||||
if(m_WriteList.empty())
|
||||
return;
|
||||
|
||||
// WriteBuffer <20><> <20><><EFBFBD><EFBFBD><EFBFBD>´<EFBFBD>.
|
||||
logBufferList.splice(logBufferList.end(), m_WriteList);
|
||||
}
|
||||
|
||||
VOID NFLogManager::SpliceInFreeBuffer(NFLogBuffer::List& logBufferList)
|
||||
{
|
||||
NFSyncLock CL(&m_LogSync);
|
||||
|
||||
if(logBufferList.empty())
|
||||
return;
|
||||
|
||||
m_FreeList.splice(m_FreeList.end(), logBufferList);
|
||||
}
|
||||
|
||||
VOID NFLogManager::PushBuffer(NFLogBuffer** ppDetailBuffer)
|
||||
{
|
||||
if(0 == *ppDetailBuffer) { return; }
|
||||
|
||||
NFSyncLock CL(&m_LogSync);
|
||||
|
||||
if(0 == (*ppDetailBuffer)->m_dwUsage)
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD> 0<>̴<EFBFBD> <20>ٽ<EFBFBD> Free<65><65> <20><><EFBFBD><EFBFBD>.
|
||||
m_FreeList.push_back(*ppDetailBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_WriteList.push_back(*ppDetailBuffer);
|
||||
}
|
||||
|
||||
// <20>̺κ<CCBA> <20>빮<EFBFBD><EBB9AE> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
*ppDetailBuffer = 0;
|
||||
}
|
||||
|
||||
}
|
||||
241
Server/NFAuthTool/NFAuthServer/Nave/NFLogManager.h
Normal file
241
Server/NFAuthTool/NFAuthServer/Nave/NFLogManager.h
Normal file
@@ -0,0 +1,241 @@
|
||||
/**
|
||||
* @file NFLogManager.h
|
||||
* @brief LogManager Ŭ<><C5AC><EFBFBD><EFBFBD>
|
||||
* @remarks
|
||||
* @author <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(edith2580@gmail.com)
|
||||
* @date 2009-04-02
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string>
|
||||
#include <time.h>
|
||||
#include <list>
|
||||
|
||||
#include "NFSync.h"
|
||||
#include "NFThread.h"
|
||||
|
||||
namespace Nave {
|
||||
|
||||
class NFLogManager;
|
||||
|
||||
/**
|
||||
* @class NFLogBuffer
|
||||
* @brief <20>αװ<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD> <20>α<EFBFBD> <20><><EFBFBD><EFBFBD> <20>̰<EFBFBD> <20><><EFBFBD>Ϸ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD>.
|
||||
* @remarks
|
||||
*
|
||||
* @par
|
||||
* @author Edith
|
||||
* @date 2009-04-04
|
||||
*/
|
||||
class NFLogBuffer
|
||||
{
|
||||
public:
|
||||
/// Write, Free <20><><EFBFBD>۸<EFBFBD> <20><><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD><EFBFBD>ϰ<EFBFBD> <20>Ǵµ<C7B4> typedef<65><66> <20><><EFBFBD>⼭ <20>ߴ<EFBFBD>.
|
||||
typedef std::list<NFLogBuffer*> List;
|
||||
|
||||
enum
|
||||
{
|
||||
MAX_LOG_BUFFER = 65536 /// <20>α<CEB1><D7B9><EFBFBD><EFBFBD><EFBFBD> ũ<><C5A9>
|
||||
};
|
||||
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
unsigned long m_dwUsage;
|
||||
/// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
char m_Buffer[MAX_LOG_BUFFER];
|
||||
|
||||
/// NFLogBuffer <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
NFLogBuffer() : m_dwUsage(0)
|
||||
{
|
||||
}
|
||||
|
||||
/// <20>ʱ<EFBFBD>ȭ <20>Լ<EFBFBD>
|
||||
VOID Initialize()
|
||||
{
|
||||
m_dwUsage = 0;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @class NFLogThread
|
||||
* @brief <20>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> <20>α<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̴<EFBFBD>. <20>αŴ<D7B8><C5B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
* @remarks
|
||||
*
|
||||
* @par
|
||||
* @author Edith
|
||||
* @date 2009-04-04
|
||||
*/
|
||||
class NFLogThread : public NFThread
|
||||
{
|
||||
public:
|
||||
/// NFLogThread <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
NFLogThread();
|
||||
/// NFLogThread <20>Ҹ<EFBFBD><D2B8><EFBFBD>
|
||||
~NFLogThread();
|
||||
|
||||
/**
|
||||
* @brief <09>α<CEB1> <20>ʱ<EFBFBD>ȭ<EFBFBD>Ѵ<EFBFBD>.
|
||||
* @param pLog <09>α<D7B8><DEB4><EFBFBD> <20><>ü
|
||||
* @param bCompress <20><><EFBFBD><EFBFBD><E0BFA9>
|
||||
*/
|
||||
VOID Initialize(NFLogManager* pLog, BOOL bCompress);
|
||||
|
||||
/**
|
||||
* @brief <09>α<EFBFBD><CEB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ũ<>⸦ <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>. <20><>ũ<EFBFBD>Ⱑ <20>Ǹ<EFBFBD> <20>ٸ<EFBFBD> <20><><EFBFBD>Ϸ<EFBFBD> <20>α<CEB1><D7B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
* @param dwSize <20>α<EFBFBD><CEB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ũ<><C5A9> byte <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 10 * 1024 * 1024 <20><> 10<31>ް<EFBFBD>
|
||||
*/
|
||||
inline VOID SetLogMaxSize(DWORD dwSize = MAX_FILE_SIZE) { m_dwMaxFileSize = dwSize; }
|
||||
|
||||
/// <20>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
BOOL FlushSignal() { return PulseEvent(m_hFlush); }
|
||||
|
||||
/// <20>α<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>带 <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
virtual unsigned int Run();
|
||||
/// <20>α<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>带 <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>.
|
||||
virtual BOOL End();
|
||||
|
||||
private:
|
||||
enum
|
||||
{
|
||||
MAX_FILE_SIZE = 100 * 1024 * 1024 /// <20>⺻ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 100<30>ް<EFBFBD>
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief <09>α<EFBFBD><CEB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20≯<EFBFBD><CCB8><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>.
|
||||
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
BOOL SetLogFileName();
|
||||
/**
|
||||
* @brief <09>α<CEB1><D7B9>ۿ<EFBFBD> <20>α<CEB1> Write <20>մϴ<D5B4>.
|
||||
* @return <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
BOOL WriteLog();
|
||||
|
||||
private:
|
||||
/// <20>ش<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>尡 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>·<EFBFBD><C2B7><EFBFBD>
|
||||
volatile LONG m_bEnd;
|
||||
|
||||
/// <20><><EFBFBD><EFBFBD> <20>ش<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>尡 <20>۵<EFBFBD><DBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ȯ<><C8AE><EFBFBD>ϴ<EFBFBD> <20>̺<EFBFBD>Ʈ
|
||||
HANDLE m_hFlush;
|
||||
/// <20>αװ<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>
|
||||
HANDLE m_hFile;
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ũ<EFBFBD><C5A9>
|
||||
DWORD m_dwTotalWritten;
|
||||
|
||||
/// <20>α<EFBFBD> <20><EFBFBD><DEB4><EFBFBD>
|
||||
NFLogManager* m_pLogHandle;
|
||||
/// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
BOOL m_bCompress;
|
||||
|
||||
/// <20><><EFBFBD><EFBFBD> <20>α<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
NFLogBuffer::List m_WriteBufferList;
|
||||
|
||||
/// <20>α<EFBFBD><CEB1><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD≯<EFBFBD>
|
||||
WCHAR m_szLogFileName[MAX_PATH];
|
||||
|
||||
/// <20>α<EFBFBD><CEB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ִ<EFBFBD> ũ<><C5A9>
|
||||
DWORD m_dwMaxFileSize;
|
||||
};
|
||||
|
||||
/**
|
||||
* @class NFLogManager
|
||||
* @brief <20>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>Ҷ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> <20>α<EFBFBD> <20>Ŵ<EFBFBD><C5B4><EFBFBD> Ŭ<><C5AC><EFBFBD><EFBFBD>
|
||||
* @remarks <20>α<EFBFBD> <20>Ŵ<EFBFBD><C5B4><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ֱ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>̱<EFBFBD><CCB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʴ´<CAB4>.\r\n
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD>Ϸα״<CEB1> <20><><EFBFBD>̳ʸ<CCB3><CAB8><EFBFBD><EFBFBD><EFBFBD> <20>ֱ<EFBFBD><D6B1><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> <20>α״<CEB1>. \r\n
|
||||
* <20>ȿ<EFBFBD> <20><><EFBFBD><EFBFBD><EEB0A1> <20>α״<CEB1> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ش<EFBFBD> <20>α<EFBFBD> <20><><EFBFBD><EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD><D8BE>Ѵ<EFBFBD>. \r\n
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>α<EFBFBD><CEB1><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> ó<><C3B3><EFBFBD><EFBFBD> <20><DEB8><F0B8AEBB><EFBFBD> <20><><EFBFBD>۸<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>۰<EFBFBD> <20><> á<><C3A1><EFBFBD><EFBFBD> <20>ش<EFBFBD> <20><><EFBFBD>۸<EFBFBD> \r\n
|
||||
* WriteList<73><74> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ش<EFBFBD> <20><><EFBFBD>۸<EFBFBD> ó<><C3B3><EFBFBD>Ѵ<EFBFBD>. \r\n
|
||||
*
|
||||
* @par
|
||||
* @author Edith
|
||||
* @date 2009-04-04
|
||||
*/
|
||||
class NFLogManager
|
||||
{
|
||||
public:
|
||||
/// NFLogManager <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
NFLogManager(void);
|
||||
/// NFLogManager <20>Ҹ<EFBFBD><D2B8><EFBFBD>
|
||||
~NFLogManager(void);
|
||||
|
||||
/**
|
||||
* @brief <09>α<EFBFBD> <20><EFBFBD><DEB4><EFBFBD><EFBFBD><EFBFBD> <20>ʱ<EFBFBD>ȭ <20>մϴ<D5B4>.
|
||||
* @param bCompress <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @param szLogFilePrefix <09>α<EFBFBD><CEB1><EFBFBD><EFBFBD>ϸ<EFBFBD>
|
||||
* @return <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
BOOL Initialize(BOOL bCompress, const WCHAR* szLogFilePrefix = 0);
|
||||
/// <20>αŴ<D7B8><C5B4><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>.
|
||||
BOOL Destroy();
|
||||
|
||||
/// <20>α<CEB1><D7B9><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
VOID SetLogMaxSize(DWORD dwSize = 10 * 1024 * 1024);
|
||||
|
||||
|
||||
/**
|
||||
* @brief <09>α<EFBFBD><CEB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20≯<EFBFBD>
|
||||
* @return <09>α<EFBFBD><CEB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD≯<EFBFBD>
|
||||
*/
|
||||
const WCHAR* GetLogFilePrefix() const { return m_szLogFilePrefix; }
|
||||
|
||||
/**
|
||||
* @brief <09>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>.
|
||||
* @return <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
BOOL Flush();
|
||||
|
||||
/**
|
||||
* @brief <09><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD> <20>α<EFBFBD> <20><><EFBFBD>۸<EFBFBD> <20><><EFBFBD>մϴ<D5B4>.
|
||||
* @return <09>α<CEB1><D7B9><EFBFBD>
|
||||
*/
|
||||
NFLogBuffer* GetBuffer();
|
||||
|
||||
/**
|
||||
* @brief <20>α<CEB1><D7B9>۸<EFBFBD> <20>Ҵ<EFBFBD><D2B4>Ѵ<EFBFBD>.
|
||||
* @param usReserve <20>Ҵ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @return <09>α<CEB1><D7B9><EFBFBD><EFBFBD><EFBFBD> <20><>ġ<EFBFBD><C4A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
char* ReserveBuffer(unsigned short usReserve);
|
||||
|
||||
/**
|
||||
* @brief <09>Ҵ<EFBFBD><D2B4><EFBFBD> <20>α<CEB1><D7B9>۸<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŵ<EFBFBD>ϴ<EFBFBD>.
|
||||
* @param usRealUse <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
VOID Complete(unsigned short usRealUse) { m_lpDetailBuffer->m_dwUsage += usRealUse; }
|
||||
|
||||
/**
|
||||
* @brief <09><><EFBFBD>»<EFBFBD><C2BB>·<EFBFBD> <20>α<CEB1><D7B9>۸<EFBFBD> <20>Ҵ<EFBFBD><D2B4>մϴ<D5B4>.
|
||||
* @param ppDetailBuffer
|
||||
*/
|
||||
VOID PushBuffer(NFLogBuffer** ppDetailBuffer);
|
||||
|
||||
VOID SpliceInWriteBuffer(NFLogBuffer::List& logBufferList);
|
||||
VOID SpliceInFreeBuffer(NFLogBuffer::List& logBufferList);
|
||||
|
||||
private:
|
||||
enum
|
||||
{
|
||||
DEFAULT_FREE_LOG_BUFFER_NUM = 10 /// <20>ִ<EFBFBD> 10<31><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>۸<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
};
|
||||
|
||||
/// Sync <20><>ü
|
||||
NFSync m_LogSync;
|
||||
|
||||
/// <20>α<EFBFBD> <20><><EFBFBD>ϸ<EFBFBD>
|
||||
WCHAR m_szLogFilePrefix[MAX_PATH];
|
||||
|
||||
/// <20>α<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
NFLogThread m_LogSaveThread;
|
||||
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
NFLogBuffer::List m_FreeList;
|
||||
/// <20><><EFBFBD>Ͽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
NFLogBuffer::List m_WriteList;
|
||||
|
||||
/// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
NFLogBuffer* m_lpDetailBuffer;
|
||||
};
|
||||
|
||||
}
|
||||
128
Server/NFAuthTool/NFAuthServer/Nave/NFSingleton.h
Normal file
128
Server/NFAuthTool/NFAuthServer/Nave/NFSingleton.h
Normal file
@@ -0,0 +1,128 @@
|
||||
/**
|
||||
* @file NFSingleton.h
|
||||
* @brief <09>̱<EFBFBD><CCB1><EFBFBD> Ŭ<><C5AC><EFBFBD><EFBFBD>
|
||||
* @remarks
|
||||
* @author <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(edith2580@gmail.com)
|
||||
* @date 2009-04-02
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
/*
|
||||
#include "NFSingleton.h"
|
||||
|
||||
class Test : public Nave::NFSingleton<Test>
|
||||
{
|
||||
public:
|
||||
Test()
|
||||
{
|
||||
printf("Test::Test()\n");
|
||||
}
|
||||
~Test()
|
||||
{
|
||||
printf("Test::~Test()\n");
|
||||
}
|
||||
|
||||
int GetType()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
INT _tmain(INT argc, WCHAR* argv[])
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD> <20>̱<EFBFBD><CCB1><EFBFBD> <20><>ü<EFBFBD><C3BC> <20><><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD>
|
||||
// <20>Ʒ<EFBFBD><C6B7><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD> <20><><EFBFBD>ؼ<EFBFBD> <20>ѹ<EFBFBD> New<65><77> <20>ϰ<EFBFBD>
|
||||
Test* pTest = new Test;
|
||||
|
||||
|
||||
// <20>ٸ<EFBFBD> <20><>ġ<EFBFBD><C4A1> <20>ٸ<EFBFBD><D9B8>Լ<EFBFBD>.
|
||||
Test::GetInstance().GetType(); <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD> <20>ȴ<EFBFBD>.
|
||||
|
||||
|
||||
delete pTest;
|
||||
}
|
||||
*/
|
||||
|
||||
#pragma warning (disable : 4311)
|
||||
#pragma warning (disable : 4312)
|
||||
|
||||
namespace Nave {
|
||||
|
||||
/**
|
||||
* @class NFSingleton
|
||||
* @brief Ŭ<><C5AC><EFBFBD><EFBFBD> <20><>ü<EFBFBD><C3BC> <20>̱<EFBFBD><CCB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>.
|
||||
* @remarks
|
||||
*
|
||||
* @warning <20>ش<EFBFBD> <20>̱<EFBFBD><CCB1><EFBFBD> <20><>ü<EFBFBD><C3BC> ó<><C3B3> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> new<65><77> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ְ<EFBFBD> \r\n
|
||||
* delete<74><65> <20>ɶ<EFBFBD><C9B6><EFBFBD><EFBFBD><EFBFBD> <20>̱<EFBFBD><CCB1><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD> <20><><EFBFBD>α<CEB1><D7B7><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ɶ<EFBFBD>\r\n
|
||||
* delete<74><65> <20><><EFBFBD>ָ<EFBFBD> <20>ȴ<EFBFBD>.
|
||||
* @par
|
||||
* @author Edith
|
||||
* @date 2009-04-05
|
||||
*/
|
||||
template <typename T> class NFSingleton
|
||||
{
|
||||
|
||||
public:
|
||||
/// NFSingleton <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
NFSingleton (void)
|
||||
{
|
||||
assert( !s_pSingleton && "NFSingleton : You can't create more"
|
||||
" object, because this object is SINGLETON.");
|
||||
|
||||
#if defined( _MSC_VER ) && _MSC_VER < 1200
|
||||
int iOffset = (int)(T*)1 - (int)(NFSingleton <T>*)(T*)1;
|
||||
s_pSingleton = (T*)((int) this + iOffset);
|
||||
#else
|
||||
s_pSingleton = static_cast< T* >( this );
|
||||
#endif
|
||||
}
|
||||
|
||||
/// NFSingleton <20>Ҹ<EFBFBD><D2B8><EFBFBD>
|
||||
~NFSingleton (void)
|
||||
{
|
||||
assert( s_pSingleton && "NFSingleton : This object may be "
|
||||
"destroyed by someone's memory control or other causes.");
|
||||
|
||||
s_pSingleton = 0;
|
||||
}
|
||||
|
||||
/// <20>ش<EFBFBD> <20>̱<EFBFBD><CCB1><EFBFBD> <20><>ü<EFBFBD><C3BC> <20><><EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD><C7B4><EFBFBD> Ȯ<><C8AE><EFBFBD>Ѵ<EFBFBD>.
|
||||
static bool IsAlive()
|
||||
{
|
||||
return s_pSingleton ? true : false;
|
||||
}
|
||||
|
||||
/// <20>̱<EFBFBD><CCB1><EFBFBD> <20><>ü<EFBFBD><C3BC> <20>ν<EFBFBD><CEBD>Ͻ<EFBFBD><CFBD><EFBFBD> <20><><EFBFBD>´<EFBFBD>.
|
||||
static T& GetInstance(void)
|
||||
{
|
||||
assert (s_pSingleton && "NFSingleton : Something is wrong."
|
||||
" This object destroyed by something bad method or"
|
||||
"you didn't create yet!");
|
||||
|
||||
return *s_pSingleton;
|
||||
}
|
||||
|
||||
/// <20>̱<EFBFBD><CCB1><EFBFBD> <20><>ü<EFBFBD><C3BC> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ν<EFBFBD><CEBD>Ͻ<EFBFBD><CFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>´<EFBFBD>
|
||||
static T* GetInstancePtr(void)
|
||||
{
|
||||
assert (s_pSingleton && "NFSingleton : Something is wrong."
|
||||
" This object destroyed by something bad method.");
|
||||
|
||||
return s_pSingleton;
|
||||
}
|
||||
|
||||
private:
|
||||
/// <20>̱<EFBFBD><CCB1><EFBFBD> <20><>ü<EFBFBD><C3BC> <20><><EFBFBD><EFBFBD> <20><>ü<EFBFBD><C3BC> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
static T* s_pSingleton;
|
||||
};
|
||||
|
||||
/// <20>̱<EFBFBD><CCB1><EFBFBD> <20><>ü <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʱ<EFBFBD>ȭ <20>Ѵ<EFBFBD>.
|
||||
template<typename T> T* NFSingleton<T>::s_pSingleton = 0;
|
||||
|
||||
}
|
||||
45
Server/NFAuthTool/NFAuthServer/Nave/NFStringCompare.h
Normal file
45
Server/NFAuthTool/NFAuthServer/Nave/NFStringCompare.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* @file NFStringCompare.h
|
||||
* @brief <09><><EFBFBD>ڿ<EFBFBD> Compare Ŭ<><C5AC><EFBFBD><EFBFBD>
|
||||
* @remarks
|
||||
* @author <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(edith2580@gmail.com)
|
||||
* @date 2009-04-02
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace Nave {
|
||||
|
||||
template <typename fc> inline BOOL Compare(fc i1,const fc& iend1,fc i2,const fc& iend2) {
|
||||
for (;(i1 != iend1) && ( i2 != iend2); ++i1, ++i2) {
|
||||
if ((*i1) != (*i2)) return FALSE;
|
||||
}
|
||||
if ( (i1 == iend1) && ( i2 == iend2)) return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
template <typename fc> inline BOOL Compare(std::pair<fc,fc>& a, std::pair<fc,fc>& b) {
|
||||
Compare(a.first,a.second,b.first,b.second);
|
||||
}
|
||||
|
||||
inline BOOL Compare(std::string::const_iterator i1,const std::string::const_iterator& iend1, const char* i2) {
|
||||
for (;(i1 != iend1) && ( *i2 != 0); ++i1, ++i2) {
|
||||
if ((*i1) != (*i2)) return FALSE;
|
||||
}
|
||||
if ( (i1 == iend1) && ( *i2 == 0)) return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
inline BOOL Compare(std::wstring::const_iterator i1,const std::wstring::const_iterator& iend1, const wchar_t* i2) {
|
||||
for (;(i1 != iend1) && ( *i2 != 0); ++i1, ++i2) {
|
||||
if ((*i1) != (*i2)) return FALSE;
|
||||
}
|
||||
if ( (i1 == iend1) && ( *i2 == 0)) return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
inline BOOL Compare(const std::pair<std::string::const_iterator,std::string::const_iterator>& a, const char* b) {
|
||||
return Compare(a.first,a.second,b);
|
||||
}
|
||||
|
||||
}
|
||||
54
Server/NFAuthTool/NFAuthServer/Nave/NFStringGeneral.cpp
Normal file
54
Server/NFAuthTool/NFAuthServer/Nave/NFStringGeneral.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
#include "NFStringUtil.h"
|
||||
|
||||
namespace Nave {
|
||||
|
||||
std::string Format(char* format, ...) {
|
||||
static char txt[1024];
|
||||
va_list l;
|
||||
va_start(l,format);
|
||||
_vsnprintf( txt, 1024, format, l );
|
||||
va_end(l);
|
||||
return txt;
|
||||
}
|
||||
|
||||
std::wstring Format(wchar_t* format, ...) {
|
||||
static wchar_t txt[1024];
|
||||
va_list l;
|
||||
va_start(l,format);
|
||||
_vsnwprintf( txt, 1024, format, l );
|
||||
va_end(l);
|
||||
return txt;
|
||||
}
|
||||
|
||||
std::wstring RemoveDots(const std::wstring& str2)
|
||||
{
|
||||
std::wstring str=str2;
|
||||
// balal/rear/../reareako.txt
|
||||
|
||||
size_t pos1=str.find(L"/..");
|
||||
while ( pos1 != std::wstring::npos)
|
||||
{
|
||||
BOOL found = FALSE;
|
||||
for ( int i=int(pos1)-1; i >= 0; --i)
|
||||
{
|
||||
if ( str[i] == L'/' )
|
||||
{
|
||||
str=str.substr(0,i)+str.substr(pos1+3);
|
||||
found=TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
str=str.substr(pos1+3);
|
||||
}
|
||||
|
||||
|
||||
pos1=str.find(L"/..");
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
}
|
||||
126
Server/NFAuthTool/NFAuthServer/Nave/NFStringGeneral.h
Normal file
126
Server/NFAuthTool/NFAuthServer/Nave/NFStringGeneral.h
Normal file
@@ -0,0 +1,126 @@
|
||||
/**
|
||||
* @file NFStringGeneral.h
|
||||
* @brief <09><><EFBFBD>ڿ<EFBFBD> <20>Ľ<EFBFBD> <20><> <20><><EFBFBD><EFBFBD>Ŭ<EFBFBD><C5AC><EFBFBD><EFBFBD>
|
||||
* @remarks
|
||||
* @author <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(edith2580@gmail.com)
|
||||
* @date 2009-04-02
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace Nave {
|
||||
|
||||
inline std::pair<const wchar_t*, const wchar_t*> Split(const wchar_t* ibegin,const wchar_t* iend, wchar_t delimiter) {
|
||||
for ( const wchar_t* i=ibegin; i != iend; ++i) {
|
||||
if ( (*i) == delimiter ) {
|
||||
if (i == ibegin) {
|
||||
++ibegin;
|
||||
continue;
|
||||
}
|
||||
return std::pair<const wchar_t*,const wchar_t*>(ibegin,i);
|
||||
}
|
||||
}
|
||||
return std::pair<const wchar_t*,const wchar_t*>(ibegin,iend);
|
||||
}
|
||||
|
||||
template <typename fc> inline std::pair<fc, fc> Split(fc ibegin,const fc& iend, typename fc::value_type delimiter) {
|
||||
|
||||
for ( fc i=ibegin; i != iend; ++i) {
|
||||
if ( (*i) == delimiter ) {
|
||||
if (i == ibegin) {
|
||||
++ibegin;
|
||||
continue;
|
||||
}
|
||||
return std::pair<fc,fc>(ibegin,i);
|
||||
}
|
||||
}
|
||||
return std::pair<fc,fc>(ibegin,iend);
|
||||
}
|
||||
|
||||
template <typename iterator, typename container> void
|
||||
Split(iterator ibegin, const iterator& iend, typename iterator::value_type delimiter,
|
||||
container& result)
|
||||
{
|
||||
std::pair<iterator, iterator> p(ibegin, ibegin);
|
||||
while(p.second!=iend)
|
||||
{
|
||||
p=Split(p.first, iend, delimiter);
|
||||
container::value_type str(p.first, p.second);
|
||||
result.push_back(str);
|
||||
p.first=p.second;
|
||||
}
|
||||
}
|
||||
|
||||
inline void LeftTrim(std::string& s) { s.erase(0, s.find_first_not_of(" ")); }
|
||||
inline void LeftTrim(std::wstring& s) { s.erase(0, s.find_first_not_of(L" ")); }
|
||||
|
||||
inline void RightTrim(std::string& s) { s.resize(s.find_last_not_of(" ") + 1); }
|
||||
inline void RightTrim(std::wstring& s) { s.resize(s.find_last_not_of(L" ") + 1); }
|
||||
|
||||
template <typename fc > inline void Trim(fc& s)
|
||||
{
|
||||
LeftTrim(s);
|
||||
RightTrim(s);
|
||||
}
|
||||
|
||||
|
||||
std::string Format(char* format, ...);
|
||||
std::wstring Format(wchar_t* format, ...);
|
||||
|
||||
std::string PositionalFormat(char* format, ...);
|
||||
std::wstring PositionalFormat(wchar_t* format, ...);
|
||||
|
||||
template <typename fc> inline fc ParseFileNameNoPath(const fc& str) {
|
||||
fc tmp=ParseFileName(str);
|
||||
|
||||
fc::size_type pos = tmp.find_last_of(L"\\/:");
|
||||
|
||||
if (pos != std::wstring::npos)
|
||||
return tmp.substr(pos+1);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Extract filename, "filename|itemname" -> filename
|
||||
|
||||
file name includes path
|
||||
|
||||
"c:\data\bla|something" -> "c:\data\bla"
|
||||
|
||||
*/
|
||||
template <typename fc> inline fc ParseFileName(const fc& str) {
|
||||
std::pair<typename fc::const_iterator,typename fc::const_iterator> pair=Split(str.begin(),str.end(),L'|');
|
||||
return fc(pair.first, pair.second);
|
||||
}
|
||||
|
||||
/**
|
||||
extracts the item name "filename|itenmae" -> itenname
|
||||
|
||||
"c:\data\blabla.xml\hellsemething" -> "something"
|
||||
|
||||
*/
|
||||
|
||||
template <typename fc> inline fc ParseItemName(const fc& str) {
|
||||
std::pair<typename fc::const_iterator,typename fc::const_iterator> pair=Split(str.begin(),str.end(),L'|');
|
||||
if ( pair.second == str.end() ) return fc();
|
||||
return fc(++pair.second, str.end());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
"c:\data\blabla.xml\hellsemething" -> "c:\data"
|
||||
*/
|
||||
|
||||
inline std::wstring ParseFilePath(const std::wstring& str) {
|
||||
std::wstring::size_type pos = str.find_last_of(L"\\/:");
|
||||
if (pos != std::wstring::npos)
|
||||
return str.substr(0,pos);
|
||||
return str;
|
||||
}
|
||||
|
||||
std::wstring RemoveDots(const std::wstring& str2);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,547 @@
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
|
||||
#include "NFStringGenericConversion.h"
|
||||
|
||||
namespace Nave {
|
||||
|
||||
unsigned int Hash(const WCHAR* str)
|
||||
{
|
||||
//wchar_t* p=const_cast<wchar_t*>(str); <--
|
||||
//replaced this, we shouldnt be doing const_cast's for no reason @juhnu
|
||||
const WCHAR* p=str;
|
||||
unsigned int hashcode=0;
|
||||
wchar_t c=0;
|
||||
while(*p)
|
||||
{
|
||||
c=*p; hashcode=(31*hashcode+(c%31))%64000000; ++p;
|
||||
}
|
||||
return hashcode;
|
||||
}
|
||||
unsigned int Hash(const CHAR* str)
|
||||
{
|
||||
//wchar_t* p=const_cast<wchar_t*>(str); <--
|
||||
//replaced this, we shouldnt be doing const_cast's for no reason @juhnu
|
||||
const CHAR* p=str;
|
||||
unsigned int hashcode=0;
|
||||
wchar_t c=0;
|
||||
while(*p)
|
||||
{
|
||||
c=*p;
|
||||
hashcode=(31*hashcode+(c%31))%64000000; ++p;
|
||||
}
|
||||
return hashcode;
|
||||
}
|
||||
|
||||
template<> std::string To(const wchar_t* wstr) {
|
||||
//int iWstrSize = (int)wcslen(wstr);
|
||||
int iSize = WideCharToMultiByte(CP_ACP,0,wstr,-1,NULL,0,NULL,NULL);
|
||||
std::string str(iSize -1, 0);
|
||||
::WideCharToMultiByte(CP_ACP, 0, wstr, -1, &str[0], iSize, NULL, NULL);
|
||||
return str;
|
||||
}
|
||||
|
||||
template<> std::wstring To(const wchar_t* wstr) {
|
||||
//int iWstrSize = (int)wcslen(wstr);
|
||||
std::wstring tstr(wstr);
|
||||
return tstr;
|
||||
}
|
||||
|
||||
template <> std::string To(const wstringIteratorPair& StrPair) {
|
||||
//int iWstrSize = (int)(StrPair.second - StrPair.first);
|
||||
int iSize = WideCharToMultiByte(CP_ACP,0,&(*StrPair.first), -1 ,NULL,0,NULL,NULL);
|
||||
//int iSize = (int)(StrPair.second - StrPair.first);
|
||||
std::string str(iSize -1, 0);
|
||||
::WideCharToMultiByte(CP_ACP, 0, &(*StrPair.first), -1, &str[0], iSize, NULL, NULL);
|
||||
return str;
|
||||
}
|
||||
|
||||
template<> std::string To(const char* str) {
|
||||
std::string tstr(str);
|
||||
return tstr;
|
||||
}
|
||||
|
||||
template<> std::wstring To(const char* str) {
|
||||
//int iStrSize = (int)strlen(str);
|
||||
int iSize = MultiByteToWideChar(CP_ACP,0,str,-1,NULL,0);
|
||||
//int iSize = (int)strlen(str);
|
||||
std::wstring wstr(iSize-1, 0);
|
||||
::MultiByteToWideChar(CP_ACP, 0, str, -1, &wstr[0], iSize);
|
||||
return wstr;
|
||||
}
|
||||
|
||||
template <> std::wstring To(const stringIteratorPair& StrPair) {
|
||||
//int iStrSize =(int)(StrPair.second - StrPair.first);
|
||||
int iSize = MultiByteToWideChar(CP_ACP,0,&(*StrPair.first),-1,NULL,0);
|
||||
//int iSize = (int)(StrPair.second - StrPair.first);
|
||||
std::wstring wstr(iSize-1, 0);
|
||||
::MultiByteToWideChar(CP_ACP, 0, &(*StrPair.first), -1, &wstr[0], iSize);
|
||||
return wstr;
|
||||
}
|
||||
|
||||
template <> std::string To(int value) {
|
||||
char szBuffer[12]; //mamximum 10 + 1 sign + 1 null.
|
||||
_itoa(value, szBuffer, 10);
|
||||
return std::string(szBuffer);
|
||||
}
|
||||
|
||||
template <> std::wstring To(int value) {
|
||||
wchar_t wszBuffer[12];
|
||||
_itow(value, wszBuffer, 10);
|
||||
return std::wstring(wszBuffer);
|
||||
}
|
||||
|
||||
template <> std::string To(short value) {
|
||||
char szBuffer[12];
|
||||
_itoa((int)value, szBuffer, 10);
|
||||
return std::string(szBuffer);
|
||||
}
|
||||
|
||||
template <> std::wstring To(short value) {
|
||||
wchar_t wszBuffer[12];
|
||||
_itow((int)value, wszBuffer, 10);
|
||||
return std::wstring(wszBuffer);
|
||||
}
|
||||
|
||||
template <> std::string To(unsigned short value) {
|
||||
char szBuffer[12];
|
||||
_itoa((int)value, szBuffer, 10);
|
||||
return std::string(szBuffer);
|
||||
}
|
||||
|
||||
template <> std::wstring To(unsigned short value) {
|
||||
wchar_t wszBuffer[12];
|
||||
_itow((int)value, wszBuffer, 10);
|
||||
return std::wstring(wszBuffer);
|
||||
}
|
||||
|
||||
template <> std::string To(unsigned int value) {
|
||||
char szBuffer[24];
|
||||
_ui64toa((unsigned long)value, szBuffer, 10);
|
||||
return std::string(szBuffer);
|
||||
}
|
||||
|
||||
template <> std::wstring To(unsigned int value) {
|
||||
wchar_t wszBuffer[24];
|
||||
_ui64tow((unsigned long)value, wszBuffer, 10);
|
||||
return std::wstring(wszBuffer);
|
||||
}
|
||||
|
||||
template <> std::string To(__int64 value) {
|
||||
char szBuffer[24];
|
||||
_i64toa((unsigned long)value, szBuffer, 10);
|
||||
return std::string(szBuffer);
|
||||
}
|
||||
|
||||
template <> std::wstring To(__int64 value) {
|
||||
wchar_t wszBuffer[24];
|
||||
_ui64tow((unsigned long)value, wszBuffer, 10);
|
||||
return std::wstring(wszBuffer);
|
||||
}
|
||||
|
||||
template <> std::string To(unsigned __int64 value) {
|
||||
char szBuffer[24];
|
||||
_ui64toa((unsigned long)value, szBuffer, 10);
|
||||
return std::string(szBuffer);
|
||||
}
|
||||
|
||||
template <> std::wstring To(unsigned __int64 value) {
|
||||
wchar_t wszBuffer[24];
|
||||
_ui64tow((unsigned long)value, wszBuffer, 10);
|
||||
return std::wstring(wszBuffer);
|
||||
}
|
||||
|
||||
template <> std::string To(long value) {
|
||||
char szBuffer[48];
|
||||
_i64toa(value, szBuffer, 10);
|
||||
return std::string(szBuffer);
|
||||
}
|
||||
|
||||
template <> std::wstring To(long value) {
|
||||
wchar_t wszBuffer[48];
|
||||
_i64tow(value, wszBuffer, 10);
|
||||
return std::wstring(wszBuffer);
|
||||
}
|
||||
|
||||
template <> std::string To(unsigned long value) {
|
||||
char szBuffer[100];
|
||||
_ui64toa(value, szBuffer, 10);
|
||||
return std::string(szBuffer);
|
||||
}
|
||||
|
||||
template <> std::wstring To(unsigned long value) {
|
||||
wchar_t wszBuffer[100];
|
||||
_ui64tow(value, wszBuffer, 10);
|
||||
return std::wstring(wszBuffer);
|
||||
}
|
||||
|
||||
template <> std::string To(float value) {
|
||||
char szBuffer[100];
|
||||
sprintf(szBuffer, "%f", value);
|
||||
return std::string(szBuffer);
|
||||
}
|
||||
|
||||
template <> std::wstring To(float value) {
|
||||
wchar_t wszBuffer[100];
|
||||
swprintf(wszBuffer, L"%f", value);
|
||||
return std::wstring(wszBuffer);
|
||||
}
|
||||
|
||||
template <> std::string To(double value) {
|
||||
char szBuffer[100];
|
||||
sprintf(szBuffer, "%f", value);
|
||||
return std::string(szBuffer);
|
||||
}
|
||||
|
||||
template <> std::wstring To(double value) {
|
||||
wchar_t wszBuffer[100];
|
||||
swprintf(wszBuffer, L"%f", value);
|
||||
return std::wstring(wszBuffer);
|
||||
}
|
||||
|
||||
template <> std::string To(float2 value) {
|
||||
char szBuffer[100*3];
|
||||
sprintf(szBuffer, "(%f, %f)", value.x, value.y);
|
||||
return std::string(szBuffer);
|
||||
}
|
||||
|
||||
template <> std::wstring To(float2 value) {
|
||||
wchar_t wszBuffer[100*3];
|
||||
swprintf(wszBuffer, L"(%f, %f)", value.x, value.y);
|
||||
return std::wstring(wszBuffer);
|
||||
}
|
||||
|
||||
template <> std::string To(float3 value) {
|
||||
char szBuffer[100*4];
|
||||
sprintf(szBuffer, "(%f, %f, %f)", value.x, value.y, value.z);
|
||||
return std::string(szBuffer);
|
||||
}
|
||||
|
||||
template <> std::wstring To(float3 value) {
|
||||
wchar_t wszBuffer[100*4];
|
||||
swprintf(wszBuffer, L"(%f, %f, %f)", value.x, value.y, value.z);
|
||||
return std::wstring(wszBuffer);
|
||||
}
|
||||
|
||||
template <> std::string To(float4 value) {
|
||||
char szBuffer[100*4];
|
||||
sprintf(szBuffer, "(%f, %f, %f, %f)", value.x, value.y, value.z, value.w);
|
||||
return std::string(szBuffer);
|
||||
}
|
||||
|
||||
template <> std::wstring To(float4 value) {
|
||||
wchar_t wszBuffer[100*4];
|
||||
swprintf(wszBuffer, L"(%f, %f, %f, %f)", value.x, value.y, value.z, value.w);
|
||||
return std::wstring(wszBuffer);
|
||||
}
|
||||
|
||||
template <> double To(const char* str) { return atof(str); }
|
||||
template <> double To(const stringIteratorPair& StrPair) { return To<double>(std::string(StrPair.first, StrPair.second)); }
|
||||
|
||||
template <> float To(const char* str) { return (float)To<double>(str); }
|
||||
template <> float To(const stringIteratorPair& StrPair) { return (float)To<double>(StrPair); }
|
||||
|
||||
template <> int To(const char* str) { return atoi(str); }
|
||||
template <> int To(const stringIteratorPair& StrPair) { return To<int>(std::string(StrPair.first, StrPair.second)); }
|
||||
|
||||
template <> double To(const wchar_t* wstr) { return _wtof(wstr); }
|
||||
template <> double To(const wstringIteratorPair& StrPair) { return To<double>(std::wstring(StrPair.first, StrPair.second)); }
|
||||
|
||||
template <> float To(const wchar_t* wstr) { return (float)To<double>(wstr); }
|
||||
template <> float To(const wstringIteratorPair& StrPair) { return (float)To<double>(StrPair); }
|
||||
|
||||
template <> int To(const wchar_t* str) { return _wtoi(str); }
|
||||
template <> int To(const wstringIteratorPair& StrPair) { return To<int>(std::wstring(StrPair.first, StrPair.second)); }
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
template <> short To(const wchar_t* str) { return (short)_wtoi(str); }
|
||||
template <> short To(const wstringIteratorPair& StrPair) { return To<short>(std::wstring(StrPair.first, StrPair.second)); }
|
||||
|
||||
template <> long To(const wchar_t* str) { return _wtol(str); }
|
||||
template <> long To(const wstringIteratorPair& StrPair) { return To<long>(std::wstring(StrPair.first, StrPair.second)); }
|
||||
|
||||
template <> unsigned int To(const wchar_t* str) { return (unsigned int)_wtoi(str); }
|
||||
template <> unsigned int To(const wstringIteratorPair& StrPair) { return To<unsigned int>(std::wstring(StrPair.first, StrPair.second)); }
|
||||
|
||||
template <> unsigned short To(const wchar_t* str) { return (unsigned short)_wtoi(str); }
|
||||
template <> unsigned short To(const wstringIteratorPair& StrPair) { return To<unsigned short>(std::wstring(StrPair.first, StrPair.second)); }
|
||||
|
||||
template <> unsigned long To(const wchar_t* str) { return (unsigned long)_wtol(str); }
|
||||
template <> unsigned long To(const wstringIteratorPair& StrPair) { return To<unsigned long>(std::wstring(StrPair.first, StrPair.second)); }
|
||||
*/
|
||||
|
||||
namespace Private {
|
||||
template<typename T>
|
||||
class Tokens {};
|
||||
|
||||
template<>
|
||||
class Tokens<char> {
|
||||
public:
|
||||
static const char Minus = '-';
|
||||
static const char LeftParenthesis = '(';
|
||||
static const char RightParenthesis = ')';
|
||||
static const char Comma = ',';
|
||||
static const char Point = '.';
|
||||
static const char Null = '\0';
|
||||
static const char Zero = '0';
|
||||
static const char Nine = '9';
|
||||
static const char Space = ' ';
|
||||
static const char Tab = '\t';
|
||||
static const char LineFeed = '\n';
|
||||
static const char CarriageReturn = '\r';
|
||||
};
|
||||
|
||||
template<>
|
||||
class Tokens<wchar_t> {
|
||||
public:
|
||||
static const wchar_t Minus = L'-';
|
||||
static const wchar_t LeftParenthesis = L'(';
|
||||
static const wchar_t RightParenthesis = L')';
|
||||
static const wchar_t Comma = L',';
|
||||
static const wchar_t Point = L'.';
|
||||
static const wchar_t Null = L'\0';
|
||||
static const wchar_t Zero = L'0';
|
||||
static const wchar_t Nine = L'9';
|
||||
static const wchar_t Space = L' ';
|
||||
static const wchar_t Tab = L'\t';
|
||||
static const wchar_t LineFeed = L'\n';
|
||||
static const wchar_t CarriageReturn = L'\r';
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
BOOL GetToken(T** pStr, T tToken) {
|
||||
if( **pStr == tToken ) { (*pStr)++; return TRUE; }
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
BOOL IsNumber(T tChar) {
|
||||
return (Tokens<T>::Zero <= tChar && tChar <= Tokens<T>::Nine) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
BOOL IsWhiteSpace(T tChar) {
|
||||
return (tChar == Tokens<T>::Space || tChar == Tokens<T>::Tab ||
|
||||
tChar == Tokens<T>::LineFeed || tChar == Tokens<T>::CarriageReturn) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void SkipWhitespace(T** pStr) {
|
||||
while( IsWhiteSpace(**pStr) ) (*pStr)++;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void SkipNumbers(T** pStr) {
|
||||
while( IsNumber(**pStr) ) (*pStr)++;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void SkipFloat(T** pStr) {
|
||||
//sign
|
||||
GetToken(pStr, Tokens<T>::Minus);
|
||||
//number before point
|
||||
SkipNumbers(pStr);
|
||||
//point
|
||||
GetToken(pStr, Tokens<T>::Point);
|
||||
//number after point
|
||||
SkipNumbers(pStr);
|
||||
}
|
||||
}
|
||||
|
||||
template <> float2 To(const char* str) {
|
||||
using namespace Private;
|
||||
|
||||
float2 ret;
|
||||
char* pRead = const_cast<char*>(str);
|
||||
|
||||
//(
|
||||
SkipWhitespace(&pRead);
|
||||
if( !GetToken(&pRead, '(') ) return ret;
|
||||
//x
|
||||
SkipWhitespace(&pRead);
|
||||
ret.x = To<float>(pRead);
|
||||
SkipFloat(&pRead);
|
||||
//,
|
||||
SkipWhitespace(&pRead);
|
||||
if( !GetToken(&pRead, ',') ) return ret;
|
||||
//y
|
||||
SkipWhitespace(&pRead);
|
||||
ret.y = To<float>(pRead);
|
||||
SkipFloat(&pRead);
|
||||
//need not check )
|
||||
return ret;
|
||||
}
|
||||
template<> float2 To(const stringIteratorPair &StrPair) { return To<float2>(std::string(StrPair.first, StrPair.second).c_str()); }
|
||||
|
||||
template <> float3 To(const char* str) {
|
||||
using namespace Private;
|
||||
|
||||
float3 ret;
|
||||
char* pRead = const_cast<char*>(str);
|
||||
|
||||
//(
|
||||
SkipWhitespace(&pRead);
|
||||
if( !GetToken(&pRead, '(') ) return ret;
|
||||
//x
|
||||
SkipWhitespace(&pRead);
|
||||
ret.x = To<float>(pRead);
|
||||
SkipFloat(&pRead);
|
||||
//,
|
||||
SkipWhitespace(&pRead);
|
||||
if( !GetToken(&pRead, ',') ) return ret;
|
||||
//y
|
||||
SkipWhitespace(&pRead);
|
||||
ret.y = To<float>(pRead);
|
||||
SkipFloat(&pRead);
|
||||
//,
|
||||
SkipWhitespace(&pRead);
|
||||
if( !GetToken(&pRead, ',') ) return ret;
|
||||
//z
|
||||
SkipWhitespace(&pRead);
|
||||
ret.z = To<float>(pRead);
|
||||
SkipFloat(&pRead);
|
||||
//need not check )
|
||||
return ret;
|
||||
}
|
||||
template<> float3 To(const stringIteratorPair &StrPair) { return To<float3>(std::string(StrPair.first, StrPair.second).c_str()); }
|
||||
|
||||
template <> float4 To(const char* str) {
|
||||
using namespace Private;
|
||||
|
||||
float4 ret;
|
||||
char* pRead = const_cast<char*>(str);
|
||||
|
||||
//(
|
||||
SkipWhitespace(&pRead);
|
||||
if( !GetToken(&pRead, '(') ) return ret;
|
||||
//x
|
||||
SkipWhitespace(&pRead);
|
||||
ret.x = To<float>(pRead);
|
||||
SkipFloat(&pRead);
|
||||
//,
|
||||
SkipWhitespace(&pRead);
|
||||
if( !GetToken(&pRead, ',') ) return ret;
|
||||
//y
|
||||
SkipWhitespace(&pRead);
|
||||
ret.y = To<float>(pRead);
|
||||
SkipFloat(&pRead);
|
||||
//,
|
||||
SkipWhitespace(&pRead);
|
||||
if( !GetToken(&pRead, ',') ) return ret;
|
||||
//z
|
||||
SkipWhitespace(&pRead);
|
||||
ret.z = To<float>(pRead);
|
||||
SkipFloat(&pRead);
|
||||
//,
|
||||
SkipWhitespace(&pRead);
|
||||
if( !GetToken(&pRead, ',') ) return ret;
|
||||
//w
|
||||
SkipWhitespace(&pRead);
|
||||
ret.w = To<float>(pRead);
|
||||
SkipFloat(&pRead);
|
||||
//need not check )
|
||||
return ret;
|
||||
}
|
||||
template<> float4 To(const stringIteratorPair &StrPair) { return To<float4>(std::string(StrPair.first, StrPair.second).c_str()); }
|
||||
|
||||
template <> float2 To(const wchar_t* str) {
|
||||
using namespace Private;
|
||||
|
||||
float2 ret;
|
||||
wchar_t* pRead = const_cast<wchar_t*>(str);
|
||||
|
||||
//(
|
||||
SkipWhitespace(&pRead);
|
||||
if( !GetToken(&pRead, L'(') ) return ret;
|
||||
//x
|
||||
SkipWhitespace(&pRead);
|
||||
ret.x = To<float>(pRead);
|
||||
SkipFloat(&pRead);
|
||||
//,
|
||||
SkipWhitespace(&pRead);
|
||||
if( !GetToken(&pRead, L',') ) return ret;
|
||||
//y
|
||||
SkipWhitespace(&pRead);
|
||||
ret.y = To<float>(pRead);
|
||||
SkipFloat(&pRead);
|
||||
//need not check )
|
||||
return ret;
|
||||
}
|
||||
template<> float2 To(const wstringIteratorPair &StrPair) { return To<float2>(std::wstring(StrPair.first, StrPair.second).c_str()); }
|
||||
|
||||
template <> float3 To(const wchar_t* str) {
|
||||
using namespace Private;
|
||||
|
||||
float3 ret;
|
||||
wchar_t* pRead = const_cast<wchar_t*>(str);
|
||||
|
||||
//(
|
||||
SkipWhitespace(&pRead);
|
||||
if( !GetToken(&pRead, L'(') ) return ret;
|
||||
//x
|
||||
SkipWhitespace(&pRead);
|
||||
ret.x = To<float>(pRead);
|
||||
SkipFloat(&pRead);
|
||||
//,
|
||||
SkipWhitespace(&pRead);
|
||||
if( !GetToken(&pRead, L',') ) return ret;
|
||||
//y
|
||||
SkipWhitespace(&pRead);
|
||||
ret.y = To<float>(pRead);
|
||||
SkipFloat(&pRead);
|
||||
//,
|
||||
SkipWhitespace(&pRead);
|
||||
if( !GetToken(&pRead, L',') ) return ret;
|
||||
//z
|
||||
SkipWhitespace(&pRead);
|
||||
ret.z = To<float>(pRead);
|
||||
SkipFloat(&pRead);
|
||||
//need not check )
|
||||
return ret;
|
||||
}
|
||||
template<> float3 To(const wstringIteratorPair &StrPair) { return To<float3>(std::wstring(StrPair.first, StrPair.second).c_str()); }
|
||||
|
||||
template <> float4 To(const wchar_t* str) {
|
||||
using namespace Private;
|
||||
|
||||
float4 ret;
|
||||
wchar_t* pRead = const_cast<wchar_t*>(str);
|
||||
|
||||
//(
|
||||
SkipWhitespace(&pRead);
|
||||
if( !GetToken(&pRead, L'(') ) return ret;
|
||||
//x
|
||||
SkipWhitespace(&pRead);
|
||||
ret.x = To<float>(pRead);
|
||||
SkipFloat(&pRead);
|
||||
//,
|
||||
SkipWhitespace(&pRead);
|
||||
if( !GetToken(&pRead, L',') ) return ret;
|
||||
//y
|
||||
SkipWhitespace(&pRead);
|
||||
ret.y = To<float>(pRead);
|
||||
SkipFloat(&pRead);
|
||||
//,
|
||||
SkipWhitespace(&pRead);
|
||||
if( !GetToken(&pRead, L',') ) return ret;
|
||||
//z
|
||||
SkipWhitespace(&pRead);
|
||||
ret.z = To<float>(pRead);
|
||||
SkipFloat(&pRead);
|
||||
//,
|
||||
SkipWhitespace(&pRead);
|
||||
if( !GetToken(&pRead, L',') ) return ret;
|
||||
//w
|
||||
SkipWhitespace(&pRead);
|
||||
ret.w = To<float>(pRead);
|
||||
SkipFloat(&pRead);
|
||||
//need not check )
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<> float4 To(const wstringIteratorPair &StrPair) { return To<float4>(std::wstring(StrPair.first, StrPair.second).c_str()); }
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* @file NFStringGenericConversion.h
|
||||
* @brief <09><><EFBFBD>ڿ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ŭ<><C5AC><EFBFBD><EFBFBD>
|
||||
* @remarks
|
||||
* @author <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(edith2580@gmail.com)
|
||||
* @date 2009-04-02
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "NFTypes.h"
|
||||
|
||||
namespace Nave {
|
||||
|
||||
/**
|
||||
|
||||
Conversions work like
|
||||
|
||||
|
||||
To<float>("123");
|
||||
To<float>(L"123");
|
||||
|
||||
To<std::string>(L"hello world");
|
||||
To<std::wstring>("hello world");
|
||||
|
||||
*/
|
||||
|
||||
unsigned int Hash(const WCHAR* str);
|
||||
unsigned int Hash(const CHAR* str);
|
||||
|
||||
typedef std::pair<std::string::const_iterator,std::string::const_iterator> stringIteratorPair;
|
||||
typedef std::pair<std::wstring::const_iterator,std::wstring::const_iterator> wstringIteratorPair;
|
||||
|
||||
template <typename T1, typename T2> T1 To(T2 value);
|
||||
//generic conversion functions from string to actual type, also supports single(ascii)-wide(unicode conversions) character, if conversion to
|
||||
//some type is not supported you will get a LINKING error
|
||||
template <typename T> T To(const char* str);
|
||||
template <typename T> inline T To(char* str) { return To<T>((const char*)str); }
|
||||
template <typename T> inline T To(const std::string& str) { return To<T>(str.c_str()); }
|
||||
template <typename T> T To(const stringIteratorPair& StrPair);
|
||||
|
||||
template <typename T> T To(const wchar_t* wstr);
|
||||
template <typename T> inline T To(wchar_t* wstr) { return To<T>((const wchar_t*)wstr); }
|
||||
template <typename T> inline T To(const std::wstring& wstr) { return To<T>(wstr.c_str()); }
|
||||
template <typename T> T To(const wstringIteratorPair& StrPair);
|
||||
|
||||
|
||||
//methods for converting between upper and lower case, supports both single and wide byte conversions
|
||||
template <typename fc> inline void ToUpperCase(fc& s) { std::transform(s.begin(),s.end(),s.begin(),toupper); }
|
||||
template <typename fc> inline void ToLowerCase(fc& s) { std::transform(s.begin(),s.end(),s.begin(),tolower); }
|
||||
|
||||
template <typename T> inline float ToFloat(const T& p) { return To<float>(p); }
|
||||
template <typename T> inline float ToFloat(const T* p) { return To<float>(p); }
|
||||
|
||||
template <typename T> inline double ToDouble(const T& p) { return To<double>(p); }
|
||||
template <typename T> inline double ToDouble(const T* p) { return To<double>(p); }
|
||||
|
||||
template <typename T> inline int ToInt(const T& p) { return To<int>(p); }
|
||||
template <typename T> inline int ToInt(const T* p) { return To<int>(p); }
|
||||
|
||||
template <typename T> inline float2 ToFloat2(const T& p) { return To<float2>(p); }
|
||||
template <typename T> inline float2 ToFloat2(const T* p) { return To<float2>(p); }
|
||||
|
||||
template <typename T> inline float3 ToFloat3(const T& p) { return To<float3>(p); }
|
||||
template <typename T> inline float3 ToFloat3(const T* p) { return To<float3>(p); }
|
||||
|
||||
template <typename T> inline float4 ToFloat4(const T& p) { return To<float4>(p); }
|
||||
template <typename T> inline float4 ToFloat4(const T* p) { return To<float4>(p); }
|
||||
|
||||
//@deprecated: convenience methods for single - wide byte conversions
|
||||
inline Nave::String ToString(const std::string p)
|
||||
{
|
||||
return To<std::wstring>(p);
|
||||
}
|
||||
inline Nave::String ToString(const std::wstring p)
|
||||
{
|
||||
return p;
|
||||
}
|
||||
|
||||
template <typename T> inline Nave::String ToNumber(const T& p)
|
||||
{
|
||||
Nave::String pstr = To<Nave::String>(p);
|
||||
return ToString(pstr);
|
||||
}
|
||||
template <typename T> inline Nave::String ToNumber(const T* p)
|
||||
{
|
||||
Nave::String pstr = To<Nave::String>(p);
|
||||
return ToString(pstr);
|
||||
}
|
||||
|
||||
template <typename T> inline std::string ToASCII(const T& p) { return To<std::string>(p); }
|
||||
template <typename T> inline std::string ToASCII(const T* p) { return To<std::string>(p); }
|
||||
|
||||
template <typename T> inline std::wstring ToUnicode(const T& p) { return To<std::wstring>(p); }
|
||||
template <typename T> inline std::wstring ToUnicode(const T* p) { return To<std::wstring>(p); }
|
||||
|
||||
}
|
||||
24
Server/NFAuthTool/NFAuthServer/Nave/NFStringUtil.h
Normal file
24
Server/NFAuthTool/NFAuthServer/Nave/NFStringUtil.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* @file NFStringUtil.h
|
||||
* @brief <09><><EFBFBD>ڿ<EFBFBD> <20><>ƿ<EFBFBD><C6BF>Ƽ <20><><EFBFBD><EFBFBD>
|
||||
* @remarks
|
||||
* @author <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(edith2580@gmail.com)
|
||||
* @date 2009-04-02
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
#include <tchar.h>
|
||||
#include <stddef.h> // <20><><EFBFBD>ø<EFBFBD> <20><><EFBFBD>̺귯<CCBA><EAB7AF> <20><><EFBFBD><EFBFBD>?
|
||||
#include <conio.h>
|
||||
|
||||
#include "NFStringGenericConversion.h"
|
||||
#include "NFStringGeneral.h"
|
||||
#include "NFStringCompare.h"
|
||||
80
Server/NFAuthTool/NFAuthServer/Nave/NFSync.h
Normal file
80
Server/NFAuthTool/NFAuthServer/Nave/NFSync.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* @file NFSync.h
|
||||
* @brief Sync Ŭ<><C5AC><EFBFBD><EFBFBD>
|
||||
* @remarks
|
||||
* @author <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(edith2580@gmail.com)
|
||||
* @date 2009-04-02
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
namespace Nave {
|
||||
|
||||
/**
|
||||
* @class NFSync
|
||||
* @brief Sync Ŭ<><C5AC><EFBFBD><EFBFBD>
|
||||
* @remarks
|
||||
* NFSync Sync; \r\n
|
||||
* NFSyncLock CL(&Sync);
|
||||
*
|
||||
* @par
|
||||
* @author Edith
|
||||
* @date 2009-04-05
|
||||
*/
|
||||
class NFSync
|
||||
{
|
||||
public:
|
||||
NFSync(VOID)
|
||||
{
|
||||
InitializeCriticalSection(&m_Sync);
|
||||
}
|
||||
|
||||
~NFSync(VOID)
|
||||
{
|
||||
DeleteCriticalSection(&m_Sync);
|
||||
}
|
||||
|
||||
inline VOID Enter(VOID)
|
||||
{
|
||||
EnterCriticalSection(&m_Sync);
|
||||
}
|
||||
|
||||
inline VOID Leave(VOID)
|
||||
{
|
||||
LeaveCriticalSection(&m_Sync);
|
||||
}
|
||||
|
||||
private:
|
||||
CRITICAL_SECTION m_Sync;
|
||||
};
|
||||
|
||||
/**
|
||||
* @class NFSyncLock
|
||||
* @brief <20>̱۽<CCB1><DBBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ũ
|
||||
* @remarks
|
||||
*
|
||||
* @par
|
||||
* @author Edith
|
||||
* @date 2009-04-05
|
||||
*/
|
||||
class NFSyncLock
|
||||
{
|
||||
public:
|
||||
NFSyncLock(LPVOID lpVoid)
|
||||
{
|
||||
m_pThis = (NFSync*)lpVoid;
|
||||
m_pThis->Enter();
|
||||
}
|
||||
|
||||
~NFSyncLock(VOID)
|
||||
{
|
||||
if(m_pThis)
|
||||
m_pThis->Leave();
|
||||
}
|
||||
|
||||
private:
|
||||
NFSync *m_pThis;
|
||||
};
|
||||
|
||||
}
|
||||
61
Server/NFAuthTool/NFAuthServer/Nave/NFThread.h
Normal file
61
Server/NFAuthTool/NFAuthServer/Nave/NFThread.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* @file NFThread.h
|
||||
* @brief Auto Thread <20><><EFBFBD><EFBFBD> Ŭ<><C5AC><EFBFBD><EFBFBD>
|
||||
* @remarks
|
||||
* @author <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(edith2580@gmail.com)
|
||||
* @date 2009-04-02
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
namespace Nave {
|
||||
|
||||
/**
|
||||
* @class NFThread
|
||||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ü Ŭ<><C5AC><EFBFBD><EFBFBD>
|
||||
* @remarks
|
||||
*
|
||||
* @par
|
||||
* @author Edith
|
||||
* @date 2009-04-05
|
||||
*/
|
||||
class NFThread
|
||||
{
|
||||
public:
|
||||
NFThread() : m_hThreadHandle(INVALID_HANDLE_VALUE)
|
||||
{
|
||||
}
|
||||
|
||||
~NFThread()
|
||||
{
|
||||
}
|
||||
|
||||
typedef unsigned int(__stdcall *LPThreadFunc)(void*);
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
static inline unsigned int __stdcall ThreadFunc(void* pArg);
|
||||
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ڵ<EFBFBD><DAB5><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
inline HANDLE GetHandle() { return m_hThreadHandle; }
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ڵ<EFBFBD><DAB5><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
inline void SetHandle(HANDLE hHandle) { m_hThreadHandle = hHandle; }
|
||||
|
||||
/// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Ǵ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ִ´<D6B4>.
|
||||
virtual unsigned int Run() = 0;
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20>ִ<EFBFBD> <20><>ƾ<EFBFBD><C6BE> <20>ִ´<D6B4>.
|
||||
virtual BOOL End() = 0;
|
||||
|
||||
private:
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>
|
||||
HANDLE m_hThreadHandle;
|
||||
|
||||
// friend class NFThreadManager;
|
||||
};
|
||||
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ȣ<><C8A3><EFBFBD>Լ<EFBFBD>
|
||||
inline unsigned int __stdcall NFThread::ThreadFunc(void* pArg)
|
||||
{
|
||||
return static_cast<NFThread*>(pArg)->Run();
|
||||
}
|
||||
}
|
||||
129
Server/NFAuthTool/NFAuthServer/Nave/NFThreadManager.cpp
Normal file
129
Server/NFAuthTool/NFAuthServer/Nave/NFThreadManager.cpp
Normal file
@@ -0,0 +1,129 @@
|
||||
#include "Nave.h"
|
||||
#include "NFThread.h"
|
||||
#include "NFThreadManager.h"
|
||||
|
||||
namespace Nave {
|
||||
|
||||
HANDLE NFThreadManager::Run(NFThread* lpThread)
|
||||
{
|
||||
unsigned int nThreadID = 0;
|
||||
HANDLE hThread = reinterpret_cast<HANDLE>(_beginthreadex(0,
|
||||
0, NFThread::ThreadFunc, lpThread, 0, &nThreadID));
|
||||
|
||||
lpThread->SetHandle(hThread);
|
||||
return hThread;
|
||||
}
|
||||
|
||||
BOOL NFThreadManager::Stop(NFThread* lpThread, unsigned long dwTimeout)
|
||||
{
|
||||
if(0 == lpThread)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
HANDLE hThread = lpThread->GetHandle();
|
||||
if(INVALID_HANDLE_VALUE == hThread)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
lpThread->SetHandle(INVALID_HANDLE_VALUE);
|
||||
lpThread->End();
|
||||
WaitForSingleObject(hThread, dwTimeout);
|
||||
return (TRUE == CloseHandle(hThread));
|
||||
}
|
||||
|
||||
NFThreadManager::NFThreadManager() : m_nThreadNum(0), m_bUnRegStarted(FALSE)
|
||||
{
|
||||
for(int i = 0; i < MAX_THREAD_NUM; ++i)
|
||||
{
|
||||
m_lpThreads[i] = NULL;
|
||||
m_hThreads[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
NFThreadManager::~NFThreadManager()
|
||||
{
|
||||
UnRegister();
|
||||
}
|
||||
|
||||
BOOL NFThreadManager::Register(NFThread* llpThread)
|
||||
{
|
||||
unsigned int nThreadID = 0;
|
||||
unsigned int nThreadIndex = 0;
|
||||
|
||||
if(0 == llpThread)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Lock
|
||||
{
|
||||
Nave::NFSyncLock Sync(&m_ThreadLock);
|
||||
|
||||
if(MAX_THREAD_NUM <= m_nThreadNum || TRUE == m_bUnRegStarted)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
nThreadIndex = m_nThreadNum;
|
||||
++m_nThreadNum;
|
||||
}
|
||||
|
||||
m_lpThreads[nThreadIndex] = llpThread;
|
||||
|
||||
m_hThreads[nThreadIndex] = reinterpret_cast<HANDLE>(_beginthreadex(0, 0,
|
||||
NFThread::ThreadFunc, llpThread, 0, &nThreadID));
|
||||
|
||||
return (0 != m_hThreads[nThreadIndex]);
|
||||
}
|
||||
|
||||
BOOL NFThreadManager::UnRegister()
|
||||
{
|
||||
{
|
||||
Nave::NFSyncLock Sync(&m_ThreadLock);
|
||||
|
||||
if(0 == m_nThreadNum)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>۵Ǹ<DBB5>, <20><><EFBFBD>̻<EFBFBD><CCBB><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
m_bUnRegStarted = TRUE;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> & <20><><EFBFBD><EFBFBD>.
|
||||
for(int i = 0; i < (int)m_nThreadNum; ++i)
|
||||
{
|
||||
if(m_lpThreads[i])
|
||||
{
|
||||
m_lpThreads[i]->End();
|
||||
}
|
||||
}
|
||||
|
||||
WaitForMultipleObjects(m_nThreadNum, m_hThreads, TRUE, INFINITE);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ҹ<EFBFBD>.
|
||||
for(int i = 0; i < MAX_THREAD_NUM; ++i)
|
||||
{
|
||||
_DELETE(m_lpThreads[i]);
|
||||
|
||||
if(m_hThreads[i])
|
||||
{
|
||||
CloseHandle(m_hThreads[i]);
|
||||
m_hThreads[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
||||
Nave::NFSyncLock Sync(&m_ThreadLock);
|
||||
|
||||
m_nThreadNum = 0;
|
||||
m_bUnRegStarted = FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
75
Server/NFAuthTool/NFAuthServer/Nave/NFThreadManager.h
Normal file
75
Server/NFAuthTool/NFAuthServer/Nave/NFThreadManager.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* @file NFThreadManager.h
|
||||
* @brief Auto ThreadManager Ŭ<><C5AC><EFBFBD><EFBFBD>
|
||||
* @remarks
|
||||
* @author <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(edith2580@gmail.com)
|
||||
* @date 2009-04-02
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define WINDOWS_LEAN_AND_MEAN
|
||||
|
||||
#include <windows.h>
|
||||
#include <process.h>
|
||||
|
||||
#include "NFSync.h"
|
||||
#include "NFThread.h"
|
||||
|
||||
namespace Nave {
|
||||
/**
|
||||
* @class NFThreadManager
|
||||
* @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ŵ<EFBFBD><C5B4><EFBFBD>
|
||||
* @remarks
|
||||
* 1) NFThread <20><> <20><><EFBFBD>ӹ<EFBFBD><D3B9><EFBFBD> <20>༮ \r\n
|
||||
* \r\n
|
||||
* Nave::NFThreadManager::Run(this); \r\n
|
||||
* Nave::NFThreadManager::Stop(this, 2000); \r\n
|
||||
* \r\n
|
||||
* 2) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ŵ<EFBFBD><C5B4><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD> \r\n
|
||||
* Nave::NFThreadManager::GetInstance().Register( new CTest(this) ); \r\n
|
||||
* \r\n
|
||||
* // <20>Ҹ<EFBFBD><D2B8><EFBFBD> <20>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD> UnRegister<65><72> ȣ<><C8A3><EFBFBD>Ǿ<EFBFBD><C7BE><DEB8><F0B8AEBF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.. \r\n
|
||||
*
|
||||
* @par
|
||||
* @author Edith
|
||||
* @date 2009-04-05
|
||||
*/
|
||||
class NFThreadManager : public Nave::NFSingleton<NFThreadManager>
|
||||
{
|
||||
public:
|
||||
/// NFThreadManager <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
NFThreadManager();
|
||||
/// NFThreadManager <20>Ҹ<EFBFBD><D2B8><EFBFBD>
|
||||
virtual ~NFThreadManager();
|
||||
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD>带 <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>. <20>ִ<EFBFBD> 32<33><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20>ִ<EFBFBD>.
|
||||
BOOL Register(NFThread* lpThread);
|
||||
/// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>带 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ų<EFBFBD><C5B2>.
|
||||
BOOL UnRegister();
|
||||
|
||||
/// <20>Ŵ<EFBFBD><C5B4><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʰ<EFBFBD>, <20>׳<EFBFBD> <20><><EFBFBD><EFBFBD> <20><>Ų<EFBFBD><C5B2>.
|
||||
static HANDLE Run(NFThread* lpThread);
|
||||
/// <20>Ŵ<EFBFBD><C5B4><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʰ<EFBFBD>, <20>׳<EFBFBD> <20><><EFBFBD><EFBFBD> <20><>Ų<EFBFBD><C5B2>.
|
||||
static BOOL Stop(NFThread* lpThread, unsigned long dwTimeout = INFINITE);
|
||||
|
||||
private:
|
||||
enum {
|
||||
MAX_THREAD_NUM = 32 /// <20>ִ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
};
|
||||
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ü <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
NFThread* m_lpThreads[MAX_THREAD_NUM];
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ڵ<EFBFBD>
|
||||
HANDLE m_hThreads[MAX_THREAD_NUM];
|
||||
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Lock
|
||||
Nave::NFSync m_ThreadLock;
|
||||
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
Nave::uint32 m_nThreadNum;
|
||||
/// UnRegister<65><72> <20><><EFBFBD><EFBFBD><E0BFA9>
|
||||
Nave::uint32 m_bUnRegStarted;
|
||||
};
|
||||
|
||||
}
|
||||
322
Server/NFAuthTool/NFAuthServer/Nave/NFTokenizer.cpp
Normal file
322
Server/NFAuthTool/NFAuthServer/Nave/NFTokenizer.cpp
Normal file
@@ -0,0 +1,322 @@
|
||||
#include "Nave.h"
|
||||
#include "NFTokenizer.h"
|
||||
|
||||
namespace Nave {
|
||||
|
||||
NFTokenizerA::NFTokenizerA(const std::string& _str, const std::string& _delim)
|
||||
{
|
||||
|
||||
if ((_str.length() == 0) || (_delim.length() == 0)) return;
|
||||
|
||||
token_str = _str;
|
||||
delim = _delim;
|
||||
|
||||
/*
|
||||
Remove sequential delimiter
|
||||
*/
|
||||
unsigned int curr_pos = 0;
|
||||
|
||||
while(true)
|
||||
{
|
||||
if ((curr_pos = token_str.find(delim,curr_pos)) != std::string::npos)
|
||||
{
|
||||
curr_pos += delim.length();
|
||||
|
||||
while(token_str.find(delim,curr_pos) == curr_pos)
|
||||
{
|
||||
token_str.erase(curr_pos,delim.length());
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
Trim leading delimiter
|
||||
*/
|
||||
if (token_str.find(delim,0) == 0)
|
||||
{
|
||||
token_str.erase(0,delim.length());
|
||||
}
|
||||
|
||||
/*
|
||||
Trim ending delimiter
|
||||
*/
|
||||
curr_pos = 0;
|
||||
if ((curr_pos = token_str.rfind(delim)) != std::string::npos)
|
||||
{
|
||||
if (curr_pos != (token_str.length() - delim.length())) return;
|
||||
token_str.erase(token_str.length() - delim.length(),delim.length());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
int NFTokenizerA::CountTokens()
|
||||
{
|
||||
|
||||
unsigned int prev_pos = 0;
|
||||
int num_tokens = 0;
|
||||
|
||||
if (token_str.length() > 0)
|
||||
{
|
||||
num_tokens = 0;
|
||||
|
||||
unsigned int curr_pos = 0;
|
||||
while(true)
|
||||
{
|
||||
if ((curr_pos = token_str.find(delim,curr_pos)) != std::string::npos)
|
||||
{
|
||||
num_tokens++;
|
||||
prev_pos = curr_pos;
|
||||
curr_pos += delim.length();
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
return ++num_tokens;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool NFTokenizerA::HasMoreTokens()
|
||||
{
|
||||
return (token_str.length() > 0);
|
||||
}
|
||||
|
||||
std::string NFTokenizerA::NextToken()
|
||||
{
|
||||
|
||||
if (token_str.length() == 0)
|
||||
return "";
|
||||
|
||||
std::string tmp_str = "";
|
||||
unsigned int pos = token_str.find(delim,0);
|
||||
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
tmp_str = token_str.substr(0,pos);
|
||||
token_str = token_str.substr(pos+delim.length(),token_str.length()-pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp_str = token_str.substr(0,token_str.length());
|
||||
token_str = "";
|
||||
}
|
||||
|
||||
return tmp_str;
|
||||
}
|
||||
|
||||
int NFTokenizerA::NextIntToken()
|
||||
{
|
||||
return atoi(NextToken().c_str());
|
||||
}
|
||||
|
||||
double NFTokenizerA::NextFloatToken()
|
||||
{
|
||||
return atof(NextToken().c_str());
|
||||
}
|
||||
|
||||
std::string NFTokenizerA::NextToken(const std::string& delimiter)
|
||||
{
|
||||
if (token_str.length() == 0)
|
||||
return "";
|
||||
|
||||
std::string tmp_str = "";
|
||||
unsigned int pos = token_str.find(delimiter,0);
|
||||
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
tmp_str = token_str.substr(0,pos);
|
||||
token_str = token_str.substr(pos + delimiter.length(),token_str.length() - pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp_str = token_str.substr(0,token_str.length());
|
||||
token_str = "";
|
||||
}
|
||||
|
||||
return tmp_str;
|
||||
}
|
||||
|
||||
std::string& NFTokenizerA::RemainingString()
|
||||
{
|
||||
return token_str;
|
||||
}
|
||||
|
||||
std::string NFTokenizerA::FilterNextToken(const std::string& filterStr)
|
||||
{
|
||||
std::string tmp_str = NextToken();
|
||||
unsigned int currentPos = 0;
|
||||
|
||||
while((currentPos = tmp_str.find(filterStr,currentPos)) != std::string::npos)
|
||||
{
|
||||
tmp_str.erase(currentPos,filterStr.length());
|
||||
}
|
||||
|
||||
return tmp_str;
|
||||
}
|
||||
|
||||
|
||||
// unicode type
|
||||
NFTokenizerW::NFTokenizerW(const std::wstring& _str, const std::wstring& _delim)
|
||||
{
|
||||
|
||||
if ((_str.length() == 0) || (_delim.length() == 0)) return;
|
||||
|
||||
token_str = _str;
|
||||
delim = _delim;
|
||||
|
||||
/*
|
||||
Remove sequential delimiter
|
||||
*/
|
||||
unsigned int curr_pos = 0;
|
||||
|
||||
while(true)
|
||||
{
|
||||
if ((curr_pos = token_str.find(delim,curr_pos)) != std::wstring::npos)
|
||||
{
|
||||
curr_pos += delim.length();
|
||||
|
||||
while(token_str.find(delim,curr_pos) == curr_pos)
|
||||
{
|
||||
token_str.erase(curr_pos,delim.length());
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
Trim leading delimiter
|
||||
*/
|
||||
if (token_str.find(delim,0) == 0)
|
||||
{
|
||||
token_str.erase(0,delim.length());
|
||||
}
|
||||
|
||||
/*
|
||||
Trim ending delimiter
|
||||
*/
|
||||
curr_pos = 0;
|
||||
if ((curr_pos = token_str.rfind(delim)) != std::wstring::npos)
|
||||
{
|
||||
if (curr_pos != (token_str.length() - delim.length())) return;
|
||||
token_str.erase(token_str.length() - delim.length(),delim.length());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int NFTokenizerW::CountTokens()
|
||||
{
|
||||
unsigned int prev_pos = 0;
|
||||
int num_tokens = 0;
|
||||
|
||||
if (token_str.length() > 0)
|
||||
{
|
||||
num_tokens = 0;
|
||||
|
||||
unsigned int curr_pos = 0;
|
||||
while(true)
|
||||
{
|
||||
if ((curr_pos = token_str.find(delim,curr_pos)) != std::wstring::npos)
|
||||
{
|
||||
num_tokens++;
|
||||
prev_pos = curr_pos;
|
||||
curr_pos += delim.length();
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
return ++num_tokens;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool NFTokenizerW::HasMoreTokens()
|
||||
{
|
||||
return (token_str.length() > 0);
|
||||
}
|
||||
|
||||
std::wstring NFTokenizerW::NextToken()
|
||||
{
|
||||
|
||||
if (token_str.length() == 0)
|
||||
return L"";
|
||||
|
||||
std::wstring tmp_str = L"";
|
||||
unsigned int pos = token_str.find(delim,0);
|
||||
|
||||
if (pos != std::wstring::npos)
|
||||
{
|
||||
tmp_str = token_str.substr(0,pos);
|
||||
token_str = token_str.substr(pos+delim.length(),token_str.length()-pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp_str = token_str.substr(0,token_str.length());
|
||||
token_str = L"";
|
||||
}
|
||||
|
||||
return tmp_str;
|
||||
}
|
||||
|
||||
int NFTokenizerW::NextIntToken()
|
||||
{
|
||||
return _wtoi(NextToken().c_str());
|
||||
}
|
||||
|
||||
double NFTokenizerW::NextFloatToken()
|
||||
{
|
||||
return _wtof(NextToken().c_str());
|
||||
}
|
||||
|
||||
std::wstring NFTokenizerW::NextToken(const std::wstring& delimiter)
|
||||
{
|
||||
if (token_str.length() == 0)
|
||||
return L"";
|
||||
|
||||
std::wstring tmp_str = L"";
|
||||
unsigned int pos = token_str.find(delimiter,0);
|
||||
|
||||
if (pos != std::wstring::npos)
|
||||
{
|
||||
tmp_str = token_str.substr(0,pos);
|
||||
token_str = token_str.substr(pos + delimiter.length(),token_str.length() - pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp_str = token_str.substr(0,token_str.length());
|
||||
token_str = L"";
|
||||
}
|
||||
|
||||
return tmp_str;
|
||||
}
|
||||
|
||||
std::wstring& NFTokenizerW::RemainingString()
|
||||
{
|
||||
return token_str;
|
||||
}
|
||||
|
||||
std::wstring NFTokenizerW::FilterNextToken(const std::wstring& filterStr)
|
||||
{
|
||||
std::wstring tmp_str = NextToken();
|
||||
unsigned int currentPos = 0;
|
||||
|
||||
while((currentPos = tmp_str.find(filterStr,currentPos)) != std::wstring::npos)
|
||||
{
|
||||
tmp_str.erase(currentPos,filterStr.length());
|
||||
}
|
||||
|
||||
return tmp_str;
|
||||
}
|
||||
|
||||
}
|
||||
120
Server/NFAuthTool/NFAuthServer/Nave/NFTokenizer.h
Normal file
120
Server/NFAuthTool/NFAuthServer/Nave/NFTokenizer.h
Normal file
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
* @file NFTokenizer.h
|
||||
* @brief Tokenizer Ŭ<><C5AC><EFBFBD><EFBFBD>
|
||||
* @remarks
|
||||
* @author <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(edith2580@gmail.com)
|
||||
* @date 2009-04-02
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
namespace Nave {
|
||||
|
||||
/**
|
||||
* @class NFTokenizerA
|
||||
* @brief <09><>Ƽ<EFBFBD><C6BC><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> Tokenizer
|
||||
* @remarks
|
||||
* Nave::String tempStr = L"01|02|03|04|05|06|07|08|09|10|11|12"; \r\n
|
||||
* \r\n
|
||||
* Nave::NFTokenizer strtok = Nave::NFTokenizer(tempStr, L"|"); \r\n
|
||||
* \r\n
|
||||
* LOG_IMPORTANT((L"Number Of Tokens: %d"), strtok.CountTokens()); \r\n
|
||||
* LOG_IMPORTANT((L"String: %s"), strtok.RemainingString().c_str()); \r\n
|
||||
* \r\n
|
||||
* int cnt = strtok.CountTokens(); \r\n
|
||||
* Nave::String finalString = L""; \r\n
|
||||
* \r\n
|
||||
* for(int i = 0; i < cnt; i++) \r\n
|
||||
* { \r\n
|
||||
* Nave::String tempStr = L""; \r\n
|
||||
* \r\n
|
||||
* LOG_IMPORTANT((L"Token[%d] ----> [%s]"), i, strtok.NextToken().c_str());\r\n
|
||||
* LOG_IMPORTANT((L"Token Count : %d"), strtok.CountTokens()); \r\n
|
||||
* \r\n
|
||||
* finalString += tempStr; \r\n
|
||||
* } \r\n
|
||||
* \r\n
|
||||
* LOG_IMPORTANT((L"Final String : %s"), finalString.c_str());
|
||||
*
|
||||
* @par
|
||||
* @author Edith
|
||||
* @date 2009-04-05
|
||||
*/
|
||||
class NFTokenizerA
|
||||
{
|
||||
public:
|
||||
NFTokenizerA(const std::string& _str, const std::string& _delim);
|
||||
~NFTokenizerA(){};
|
||||
|
||||
int CountTokens();
|
||||
bool HasMoreTokens();
|
||||
std::string NextToken();
|
||||
int NextIntToken();
|
||||
double NextFloatToken();
|
||||
std::string NextToken(const std::string& delim);
|
||||
std::string& RemainingString();
|
||||
std::string FilterNextToken(const std::string& filterStr);
|
||||
|
||||
private:
|
||||
std::string token_str;
|
||||
std::string delim;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @class NFTokenizerW
|
||||
* @brief <09><><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><DAB5><EFBFBD> Tokenizer
|
||||
* @remarks
|
||||
* Nave::String tempStr = L"01|02|03|04|05|06|07|08|09|10|11|12"; \r\n
|
||||
* \r\n
|
||||
* Nave::NFTokenizer strtok = Nave::NFTokenizer(tempStr, L"|"); \r\n
|
||||
* \r\n
|
||||
* LOG_IMPORTANT((L"Number Of Tokens: %d"), strtok.CountTokens()); \r\n
|
||||
* LOG_IMPORTANT((L"String: %s"), strtok.RemainingString().c_str()); \r\n
|
||||
* \r\n
|
||||
* int cnt = strtok.CountTokens(); \r\n
|
||||
* Nave::String finalString = L""; \r\n
|
||||
* \r\n
|
||||
* for(int i = 0; i < cnt; i++) \r\n
|
||||
* { \r\n
|
||||
* Nave::String tempStr = L""; \r\n
|
||||
* \r\n
|
||||
* LOG_IMPORTANT((L"Token[%d] ----> [%s]"), i, strtok.NextToken().c_str());\r\n
|
||||
* LOG_IMPORTANT((L"Token Count : %d"), strtok.CountTokens()); \r\n
|
||||
* \r\n
|
||||
* finalString += tempStr; \r\n
|
||||
* } \r\n
|
||||
* \r\n
|
||||
* LOG_IMPORTANT((L"Final String : %s"), finalString.c_str());
|
||||
* @par
|
||||
* @author Edith
|
||||
* @date 2009-04-05
|
||||
*/
|
||||
class NFTokenizerW
|
||||
{
|
||||
public:
|
||||
NFTokenizerW(const std::wstring& _str, const std::wstring& _delim);
|
||||
~NFTokenizerW(){};
|
||||
|
||||
int CountTokens();
|
||||
bool HasMoreTokens();
|
||||
std::wstring NextToken();
|
||||
int NextIntToken();
|
||||
double NextFloatToken();
|
||||
std::wstring NextToken(const std::wstring& delim);
|
||||
std::wstring& RemainingString();
|
||||
std::wstring FilterNextToken(const std::wstring& filterStr);
|
||||
|
||||
private:
|
||||
std::wstring token_str;
|
||||
std::wstring delim;
|
||||
};
|
||||
|
||||
typedef NFTokenizerW NFTokenizer;
|
||||
|
||||
}
|
||||
93
Server/NFAuthTool/NFAuthServer/Nave/NFTypes.h
Normal file
93
Server/NFAuthTool/NFAuthServer/Nave/NFTypes.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
* @file NFTypes.h
|
||||
* @brief Nave Basic Type <20><><EFBFBD><EFBFBD>
|
||||
* @remarks
|
||||
* @author <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(edith2580@gmail.com)
|
||||
* @date 2009-04-02
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <d3dx9math.h>
|
||||
#include <atltypes.h>
|
||||
|
||||
#pragma warning (disable : 4996)
|
||||
|
||||
namespace Nave {
|
||||
|
||||
/*
|
||||
int * signed, signed int System dependent
|
||||
unsigned int * unsigned System dependent
|
||||
__int8 1 char, signed char -128 to 127
|
||||
__int16 2 short, short int, signed short int -32,768 to 32,767
|
||||
__int32 4 signed, signed int -2,147,483,648 to 2,147,483,647
|
||||
__int64 8 none -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
|
||||
bool 1 none false or true
|
||||
char 1 signed char -128 to 127
|
||||
unsigned char 1 none 0 to 255
|
||||
short 2 short int, signed short int -32,768 to 32,767
|
||||
unsigned short 2 unsigned short int 0 to 65,535
|
||||
long 4 long int, signed long int -2,147,483,648 to 2,147,483,647
|
||||
long long 8 none (but equivalent to __int64) -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
|
||||
unsigned long 4 unsigned long int 0 to 4,294,967,295
|
||||
enum * none Same as int
|
||||
float 4 none 3.4E +/- 38 (7 digits)
|
||||
double 8 none 1.7E +/- 308 (15 digits)
|
||||
long double same as double none same as double
|
||||
wchar_t 2 __wchar_t 0 to 65,535
|
||||
|
||||
|
||||
strlen _tcslen
|
||||
strcpy _tcscpy
|
||||
strncpy _tcsncpy
|
||||
strcat _tcscat
|
||||
strcmp _tcscmp
|
||||
strncmp _tcsncmp
|
||||
stricmp _tcsicmp
|
||||
strnicmp _tcsnicmp
|
||||
sscanf _stscanf
|
||||
|
||||
strtok _tcstok
|
||||
|
||||
_strdate _tstrdate
|
||||
_strtime _tstrtime
|
||||
|
||||
sprintf _stprintf
|
||||
printf _tprintf
|
||||
|
||||
atoi _tstoi
|
||||
atof _tstof
|
||||
|
||||
fopen _tfopen
|
||||
fprintf _ftprintf
|
||||
fgets _fgetts
|
||||
*/
|
||||
|
||||
|
||||
// AddFontResource : Ư<><C6AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ttf<74><66>Ʈ<EFBFBD><C6AE> <20>ε<EFBFBD><CEB5>Ѵ<EFBFBD>, <20><><EFBFBD>Ѵ<EFBFBD><D1B4><EFBFBD> ReleaseAddFone <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
// res = AddFontResource("C:\Fonts\Nordic__.ttf")
|
||||
// <20><>Ʈ<EFBFBD><C6AE><EFBFBD><EFBFBD>Ʈ EnumFontFamilies
|
||||
// gdi+<2B><><EFBFBD><EFBFBD> <20><>Ʈ<EFBFBD><C6AE><EFBFBD><EFBFBD> PrivateFontCollection::AddFontFile(...)
|
||||
|
||||
// basic value types
|
||||
typedef std::wstring StringW; /// std::wstring
|
||||
typedef std::string StringA; /// std::string
|
||||
|
||||
typedef StringW String; /// default string
|
||||
|
||||
typedef char int8; /// -128 to 127
|
||||
typedef short int16; /// -32,768 to 32,767
|
||||
typedef long int32; /// -2,147,483,648 to 2,147,483,647
|
||||
typedef __int64 int64; /// -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
|
||||
|
||||
typedef unsigned char uint8; /// 0 to 255
|
||||
typedef unsigned short int uint16; /// 0 to 65535
|
||||
typedef unsigned long uint32; /// 0 to 4,294,967,295
|
||||
typedef unsigned __int64 uint64; /// 0 to 18,446,744,073,709,551,615
|
||||
|
||||
typedef D3DXVECTOR2 float2; /// 2vector float
|
||||
typedef D3DXVECTOR3 float3; /// 3vector float
|
||||
typedef D3DXVECTOR4 float4; /// 4vector float
|
||||
}
|
||||
|
||||
396
Server/NFAuthTool/NFAuthServer/Nave/Nave.cpp
Normal file
396
Server/NFAuthTool/NFAuthServer/Nave/Nave.cpp
Normal file
@@ -0,0 +1,396 @@
|
||||
#include "Nave.h"
|
||||
|
||||
namespace Nave {
|
||||
|
||||
HWND hMainWnd = NULL;
|
||||
HINSTANCE hInstance = NULL;
|
||||
|
||||
void EnableLFH()
|
||||
{
|
||||
HANDLE hHeap[1025];
|
||||
UINT uEA = GetProcessHeaps(1024, hHeap);
|
||||
|
||||
for (UINT i=0; i<uEA; ++i)
|
||||
{
|
||||
ULONG HeapFragValue = 2;
|
||||
|
||||
HeapSetInformation(hHeap[i],
|
||||
HeapCompatibilityInformation,
|
||||
&HeapFragValue,
|
||||
sizeof(HeapFragValue) );
|
||||
}
|
||||
}
|
||||
|
||||
void SetLocale(CHAR* pLocale)
|
||||
{
|
||||
::setlocale(LC_ALL, pLocale);
|
||||
}
|
||||
|
||||
DWORD GetGUID()
|
||||
{
|
||||
static DWORD s_dwPerGUID = 0;
|
||||
|
||||
return ++s_dwPerGUID;
|
||||
}
|
||||
|
||||
SIZE GetStringSize( const WCHAR* string, HFONT font )
|
||||
{
|
||||
HWND hWnd = Nave::hMainWnd;
|
||||
HDC hDC = ::GetDC(hWnd);
|
||||
|
||||
SIZE size;
|
||||
HFONT hOldFont = (HFONT)SelectObject(hDC, font);
|
||||
|
||||
GetTextExtentPoint32W(hDC, string, (INT)wcslen(string), &size);
|
||||
|
||||
TEXTMETRICW tm;
|
||||
GetTextMetricsW(hDC, &tm);
|
||||
size.cx -= tm.tmOverhang;
|
||||
|
||||
SelectObject(hDC, hOldFont);
|
||||
::ReleaseDC(hWnd, hDC);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
POINT GetMousePos()
|
||||
{
|
||||
POINT Point;
|
||||
GetCursorPos(&Point);
|
||||
ScreenToClient(hMainWnd, &Point);
|
||||
return Point;
|
||||
}
|
||||
|
||||
POINT GetMousePos( HWND wnd )
|
||||
{
|
||||
POINT Point;
|
||||
GetCursorPos(&Point);
|
||||
ScreenToClient(wnd, &Point);
|
||||
return Point;
|
||||
}
|
||||
|
||||
HWND IsWindowFromPoint()
|
||||
{
|
||||
POINT Point;
|
||||
GetCursorPos(&Point);
|
||||
return WindowFromPoint(Point);
|
||||
}
|
||||
|
||||
INT GetProgramName( LPWSTR buf, INT len )
|
||||
{
|
||||
WCHAR szDrive[MAX_PATH], szDir[MAX_PATH], szFilename[MAX_PATH], szExt[MAX_PATH];
|
||||
|
||||
// Figure out what the report file will be named, and store it away
|
||||
GetModuleFileNameW(0, buf, len);
|
||||
|
||||
LPWSTR pszDot = buf;
|
||||
|
||||
// Look for the '.' before the "EXE" extension. Replace '.' to '\0'
|
||||
if((pszDot = wcsrchr( pszDot, L'.')))
|
||||
{
|
||||
*pszDot = 0;
|
||||
}
|
||||
|
||||
_wsplitpath(buf, szDrive, szDir, szFilename, szExt);
|
||||
wcsncpy(buf, szFilename, len);
|
||||
|
||||
return (INT)wcslen( buf );
|
||||
}
|
||||
|
||||
INT GetProgramDir( LPWSTR buf, INT len )
|
||||
{
|
||||
WCHAR* ProgDir;
|
||||
INT result;
|
||||
|
||||
result = GetModuleFileNameW( hInstance, buf, len - 1 );
|
||||
if( result == 0 )
|
||||
return 0;
|
||||
|
||||
WCHAR pgmPtr[1024];
|
||||
wcscpy( pgmPtr, buf );
|
||||
|
||||
ProgDir = buf;
|
||||
ProgDir += wcslen( pgmPtr ) - 1;
|
||||
while( *ProgDir != L'\\' && ProgDir != pgmPtr )
|
||||
ProgDir--;
|
||||
|
||||
*ProgDir = 0;
|
||||
return (INT)wcslen( buf );
|
||||
}
|
||||
|
||||
INT GetDir( LPCWSTR path, LPWSTR buf )
|
||||
{
|
||||
wcscpy(buf, path);
|
||||
|
||||
WCHAR* ProgDir;
|
||||
ProgDir = buf;
|
||||
ProgDir += wcslen(buf);
|
||||
while( *ProgDir != L'\\')
|
||||
{
|
||||
ProgDir[0] = 0;
|
||||
ProgDir--;
|
||||
}
|
||||
|
||||
ProgDir[0] = 0;
|
||||
return (INT)wcslen( buf );
|
||||
}
|
||||
|
||||
BOOL GetLine( const CHAR* sBuf, INT maxsBuf, CHAR* tBuf, INT maxtBuf, LONG& index )
|
||||
{
|
||||
ZeroMemory(tBuf, sizeof(tBuf));
|
||||
INT DestIndex = index;
|
||||
|
||||
CHAR* pLine = "\n";
|
||||
INT pLen = strlen(pLine);
|
||||
|
||||
for(INT i = 0; i < maxsBuf; i++)
|
||||
{
|
||||
if(index+i >= maxtBuf)
|
||||
break;
|
||||
|
||||
if(strncmp(&sBuf[index+i], pLine, pLen) == 0)
|
||||
{
|
||||
CopyMemory(tBuf, sBuf+index, i);
|
||||
index += (i+pLen);
|
||||
tBuf[i] = 0;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
INT len = maxsBuf-index;
|
||||
if(maxtBuf <= len)
|
||||
len = maxtBuf-index;
|
||||
|
||||
CopyMemory(tBuf, sBuf+index, len);
|
||||
tBuf[len] = 0;
|
||||
index += len;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
VOID GetString( const CHAR* sBuf, CHAR* tBuf, INT len, LONG& index )
|
||||
{
|
||||
CopyMemory(tBuf, sBuf+index, len);
|
||||
tBuf[len] = 0;
|
||||
index += len;
|
||||
}
|
||||
|
||||
BYTE GetByte( const CHAR* sBuf, LONG& index )
|
||||
{
|
||||
INT t_index = index;
|
||||
index += sizeof(BYTE);
|
||||
return *(BYTE*)(sBuf+t_index);
|
||||
}
|
||||
|
||||
SHORT GetShort( const CHAR* sBuf, LONG& index )
|
||||
{
|
||||
INT t_index = index;
|
||||
index += sizeof(SHORT);
|
||||
return *(SHORT*)(sBuf+t_index);
|
||||
}
|
||||
|
||||
INT GetInt( const CHAR* sBuf, LONG& index )
|
||||
{
|
||||
INT t_index = index;
|
||||
index += sizeof(INT);
|
||||
return *(INT*)(sBuf+t_index);
|
||||
}
|
||||
|
||||
DWORD GetDWORD( const CHAR* sBuf, LONG& index )
|
||||
{
|
||||
INT t_index = index;
|
||||
index += sizeof(DWORD);
|
||||
return *(DWORD*)(sBuf+t_index);
|
||||
}
|
||||
|
||||
FLOAT GetFloat( const CHAR* sBuf, LONG& index )
|
||||
{
|
||||
INT t_index = index;
|
||||
index += sizeof(FLOAT);
|
||||
return *(FLOAT*)(sBuf+t_index);
|
||||
}
|
||||
|
||||
DOUBLE GetDouble( const CHAR* sBuf, LONG& index )
|
||||
{
|
||||
INT t_index = index;
|
||||
index += sizeof(DOUBLE);
|
||||
return *(DOUBLE*)(sBuf+t_index);
|
||||
}
|
||||
|
||||
VOID SetString( CHAR* tBuf, const CHAR* sBuf, INT len, LONG& index )
|
||||
{
|
||||
CopyMemory(tBuf+index, sBuf, len);
|
||||
index += len;
|
||||
}
|
||||
|
||||
VOID SetByte( CHAR* tBuf, BYTE sByte, LONG& index )
|
||||
{
|
||||
*(tBuf+index) = (BYTE)sByte;
|
||||
index++;
|
||||
}
|
||||
|
||||
VOID SetShort( CHAR* tBuf, SHORT sShort, LONG& index )
|
||||
{
|
||||
SHORT temp = (SHORT)sShort;
|
||||
|
||||
CopyMemory( tBuf+index, &temp, sizeof(SHORT));
|
||||
index += sizeof(SHORT);
|
||||
}
|
||||
|
||||
VOID SetInt( CHAR* tBuf, INT sInt, LONG& index )
|
||||
{
|
||||
CopyMemory( tBuf+index, &sInt, sizeof(INT));
|
||||
index += sizeof(INT);
|
||||
}
|
||||
|
||||
VOID SetDWORD( CHAR* tBuf, DWORD sDword, LONG& index )
|
||||
{
|
||||
CopyMemory( tBuf+index, &sDword, sizeof(DWORD));
|
||||
index += sizeof(DWORD);
|
||||
}
|
||||
|
||||
VOID SetFloat( CHAR* tBuf, FLOAT sFloat, LONG& index )
|
||||
{
|
||||
CopyMemory( tBuf+index, &sFloat, sizeof(FLOAT));
|
||||
index += sizeof(FLOAT);
|
||||
}
|
||||
|
||||
VOID SetDouble( CHAR* tBuf, DOUBLE sDouble, LONG& index )
|
||||
{
|
||||
CopyMemory( tBuf+index, &sDouble, sizeof(DOUBLE));
|
||||
index += sizeof(DOUBLE);
|
||||
}
|
||||
|
||||
BOOL GetLine( const WCHAR* sBuf, INT maxsBuf, WCHAR* tBuf, INT maxtBuf, LONG& index )
|
||||
{
|
||||
ZeroMemory(tBuf, sizeof(tBuf));
|
||||
INT DestIndex = index;
|
||||
|
||||
WCHAR* pLine = L"\n";
|
||||
INT pLen = wcslen(pLine);
|
||||
|
||||
for(INT i = 0; i < maxsBuf; i++)
|
||||
{
|
||||
if(index+i >= maxtBuf)
|
||||
break;
|
||||
|
||||
if(wcsncmp(&sBuf[index+i], pLine, pLen) == 0)
|
||||
{
|
||||
CopyMemory(tBuf, sBuf+index, sizeof(WCHAR)*i);
|
||||
index += (i+pLen);
|
||||
tBuf[index-1] = 0;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
INT len = maxsBuf-index;
|
||||
CopyMemory(tBuf, sBuf+index, sizeof(WCHAR)*len);
|
||||
tBuf[len] = 0;
|
||||
index += len;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
VOID GetString( const WCHAR* sBuf, WCHAR* tBuf, INT len, LONG& index )
|
||||
{
|
||||
CopyMemory(tBuf, sBuf+index, sizeof(WCHAR)*len);
|
||||
tBuf[len] = 0;
|
||||
index += len;
|
||||
}
|
||||
|
||||
BYTE GetByte( const WCHAR* sBuf, LONG& index )
|
||||
{
|
||||
INT t_index = index;
|
||||
index += sizeof(BYTE);
|
||||
return *(BYTE*)(sBuf+t_index);
|
||||
}
|
||||
|
||||
SHORT GetShort( const WCHAR* sBuf, LONG& index )
|
||||
{
|
||||
INT t_index = index;
|
||||
index += sizeof(SHORT);
|
||||
return *(SHORT*)(sBuf+t_index);
|
||||
}
|
||||
|
||||
INT GetInt( const WCHAR* sBuf, LONG& index )
|
||||
{
|
||||
INT t_index = index;
|
||||
index += sizeof(INT);
|
||||
return *(INT*)(sBuf+t_index);
|
||||
}
|
||||
|
||||
DWORD GetDWORD( const WCHAR* sBuf, LONG& index )
|
||||
{
|
||||
INT t_index = index;
|
||||
index += sizeof(DWORD);
|
||||
return *(DWORD*)(sBuf+t_index);
|
||||
}
|
||||
|
||||
FLOAT GetFloat( const WCHAR* sBuf, LONG& index )
|
||||
{
|
||||
INT t_index = index;
|
||||
index += sizeof(FLOAT);
|
||||
return *(FLOAT*)(sBuf+t_index);
|
||||
}
|
||||
|
||||
DOUBLE GetDouble( const WCHAR* sBuf, LONG& index )
|
||||
{
|
||||
INT t_index = index;
|
||||
index += sizeof(DOUBLE);
|
||||
return *(DOUBLE*)(sBuf+t_index);
|
||||
}
|
||||
|
||||
VOID SetString( WCHAR* tBuf, const WCHAR* sBuf, INT len, LONG& index )
|
||||
{
|
||||
CopyMemory(tBuf+index, sBuf, sizeof(WCHAR)*len);
|
||||
index += len;
|
||||
}
|
||||
|
||||
VOID SetByte( WCHAR* tBuf, BYTE sByte, LONG& index )
|
||||
{
|
||||
*(tBuf+index) = (BYTE)sByte;
|
||||
index++;
|
||||
}
|
||||
|
||||
VOID SetShort( WCHAR* tBuf, SHORT sShort, LONG& index )
|
||||
{
|
||||
SHORT temp = (SHORT)sShort;
|
||||
|
||||
CopyMemory( tBuf+index, &temp, sizeof(SHORT));
|
||||
index += sizeof(SHORT);
|
||||
}
|
||||
|
||||
VOID SetInt( WCHAR* tBuf, INT sInt, LONG& index )
|
||||
{
|
||||
CopyMemory( tBuf+index, &sInt, sizeof(INT));
|
||||
index += sizeof(INT);
|
||||
}
|
||||
|
||||
VOID SetDWORD( WCHAR* tBuf, DWORD sDword, LONG& index )
|
||||
{
|
||||
CopyMemory( tBuf+index, &sDword, sizeof(DWORD));
|
||||
index += sizeof(DWORD);
|
||||
}
|
||||
|
||||
VOID SetFloat( WCHAR* tBuf, FLOAT sFloat, LONG& index )
|
||||
{
|
||||
CopyMemory( tBuf+index, &sFloat, sizeof(FLOAT));
|
||||
index += sizeof(FLOAT);
|
||||
}
|
||||
|
||||
VOID SetDouble( WCHAR* tBuf, DOUBLE sDouble, LONG& index )
|
||||
{
|
||||
CopyMemory( tBuf+index, &sDouble, sizeof(DOUBLE));
|
||||
index += sizeof(DOUBLE);
|
||||
}
|
||||
|
||||
VOID Read( const char* sBuf, void* tBuf, INT len, LONG& seek )
|
||||
{
|
||||
CopyMemory(tBuf, &sBuf[seek], len);
|
||||
seek += len;
|
||||
}
|
||||
|
||||
VOID Write( const void* sBuf, char* tBuf, INT len, LONG& seek )
|
||||
{
|
||||
CopyMemory(&tBuf[seek], sBuf, len);
|
||||
seek += len;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
436
Server/NFAuthTool/NFAuthServer/Nave/Nave.h
Normal file
436
Server/NFAuthTool/NFAuthServer/Nave/Nave.h
Normal file
@@ -0,0 +1,436 @@
|
||||
/**
|
||||
* @file Nave.h
|
||||
* @brief Nave Library Core Header
|
||||
* @remarks NaveGDK <20><><EFBFBD>̺귯<CCBA><EAB7AF><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Header
|
||||
* @author <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(edith2580@gmail.com)
|
||||
* @date 2009-04-02
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʴ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Windows <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>.
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
#pragma comment(lib,"winmm.lib")
|
||||
#pragma comment(lib,"imm32.lib")
|
||||
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
#include <WCHAR.h>
|
||||
#include <stddef.h>
|
||||
#include <conio.h>
|
||||
|
||||
#include "NFTypes.h"
|
||||
#include "NFSingleton.h"
|
||||
|
||||
/// <20><><EFBFBD>ڿ<EFBFBD> <20>տ<EFBFBD> L<><4C> <20><><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD> WCHAR Ÿ<><C5B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ȯ<EFBFBD><C8AF>
|
||||
#define WIDEN2(x) L ## x
|
||||
/// CHAR<41><52> <20><><EFBFBD><EFBFBD> WCHAR<41><52> <20><>ȯ<EFBFBD>ϱ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
#define WIDEN(x) WIDEN2(x)
|
||||
/// __FILE__ <20><> WCHAR<41><52> <20><><EFBFBD><EFBFBD>
|
||||
#define __WFILE__ WIDEN(__FILE__)
|
||||
/// __FUNCSIG__ <20><> WCHAR<41><52> <20><><EFBFBD><EFBFBD>
|
||||
#define __WFUNCSIG__ WIDEN(__FUNCSIG__)
|
||||
|
||||
/// <20><><EFBFBD><EFBFBD> <20><>ü DELETE <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#ifndef _DELETE
|
||||
#define _DELETE(p) { if(p) { delete (p); (p)=NULL; } }
|
||||
#endif
|
||||
/// <20>迭<EFBFBD><E8BFAD> <20><>ü DELETE <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#ifndef _DELETE_ARRAY
|
||||
#define _DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } }
|
||||
#endif
|
||||
/// RELEASE <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#ifndef _RELEASE
|
||||
#define _RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
|
||||
#endif
|
||||
|
||||
/// MAKEINTRESOURCE <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define MIS(a) MAKEINTRESOURCEW(a)
|
||||
/// InvalidateRect <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
#define Redraw(hWnd, bErase) InvalidateRect(hWnd, NULL, bErase)
|
||||
|
||||
/// DWORD <20><><EFBFBD><EFBFBD> Alpha <20><><EFBFBD>ϱ<EFBFBD>
|
||||
#define GetAColor(Color) ((BYTE)((Color)>>24)&0xff)
|
||||
/// DWORD <20><><EFBFBD><EFBFBD> Red <20><><EFBFBD>ϱ<EFBFBD>
|
||||
#define GetRColor(Color) ((BYTE)((Color)>>16)&0xff)
|
||||
/// DWORD <20><><EFBFBD><EFBFBD> Green <20><><EFBFBD>ϱ<EFBFBD>
|
||||
#define GetGColor(Color) ((BYTE)(((WORD)(Color)) >> 8)&0xff)
|
||||
/// DWORD <20><><EFBFBD><EFBFBD> Blue <20><><EFBFBD>ϱ<EFBFBD>
|
||||
#define GetBColor(Color) ((BYTE)(Color)&0xff)
|
||||
|
||||
namespace Nave {
|
||||
|
||||
/// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ڵ<EFBFBD>
|
||||
extern HWND hMainWnd;
|
||||
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ν<EFBFBD><CEBD>Ͻ<EFBFBD>
|
||||
extern HINSTANCE hInstance;
|
||||
|
||||
/**
|
||||
* @brief LFH <20><EFBFBD><DEB8><EFBFBD>Ǯ<EFBFBD><C7AE> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>
|
||||
* @remarks
|
||||
* Low-Fragmentation Heap<61><70> <20><><EFBFBD><EFBFBD> \r\n
|
||||
* <09><><EFBFBD>α<CEB1><D7B7><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ҷ<EFBFBD> <20>ѹ<EFBFBD>ȣ<EFBFBD><C8A3><EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD>. \r\n
|
||||
* <09><><EFBFBD><EFBFBD><EFBFBD>Ű<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ǹ<EFBFBD>(F5) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϹǷ<CFB9> CTRL+F5<46><35> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> \r\n
|
||||
* Low-Fragmentation Heap<61><70> <20><><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>, TRUE<55><45> <20><><EFBFBD>ϵǴ°<C7B4><C2B0><EFBFBD> <20>˼<EFBFBD><CBBC>ִ<EFBFBD>. \r\n
|
||||
* \r\n
|
||||
* Low-Fragmentation Heap<61><70> <20><><EFBFBD><EFBFBD> \r\n
|
||||
* Ư<><C6AF><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1><D7B7>Ӵ<EFBFBD> <20>Ű澲<C5B0><E6BEB2> <20>ʾƵ<CABE>, <20><EFBFBD><DEB8><EFBFBD>Ǯ<EFBFBD><C7AE> <20><><EFBFBD><EFBFBD>, \r\n
|
||||
* <09><><EFBFBD>α<CEB1><D7B7><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ϼ<EFBFBD><CFBC>ִ<EFBFBD>. \r\n
|
||||
* <09><EFBFBD><DEB8><EFBFBD> <20><><EFBFBD><EFBFBD>ȭ<EFBFBD><C8AD> <20><><EFBFBD><EFBFBD><EFBFBD>Ҽ<EFBFBD><D2BC>ְ<EFBFBD>, <20><><EFBFBD><DEB8><F0B8AEBB><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ȿ<><C8BF><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. \r\n
|
||||
* Ư<><C6AF>, <20><>Ƽ<EFBFBD>ھ<EFBFBD> <20>ý<EFBFBD><C3BD>ۿ<EFBFBD><DBBF><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ִ<EFBFBD>. \r\n
|
||||
* \r\n
|
||||
* Low-Fragmentation Heap<61><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> \r\n
|
||||
* <09><> <20>Լ<EFBFBD><D4BC><EFBFBD> ȣ<><C8A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʾƵ<CABE>, <20><><EFBFBD>ڵ尡 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Win2000Pro Sp4<70>̻<EFBFBD><CCBB><EFBFBD> \r\n
|
||||
* OS<4F><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϹǷ<CFB9>, Win98<39><38> <20><><EFBFBD><EFBFBD><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD> <20>Ѵٸ<D1B4>, <20>ּ<EFBFBD>ȭ<EFBFBD><C8AD><EFBFBD>Ѿ<EFBFBD> <20>Ѵ<EFBFBD>. \r\n
|
||||
* \r\n
|
||||
* <09><><EFBFBD><EFBFBD>Ÿ<EFBFBD><C5B8> <20><><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD> ȣ<><C8A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʾƵ<CABE> <20>⺻<EFBFBD><E2BABB><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>. \r\n
|
||||
* 16K<36><4B><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><DEB8> <20>Ҵ<EFBFBD><D2B4>ϸ<EFBFBD>, LFH<46><48> <20><DEB8> <20>Ҵ<EFBFBD>, \r\n
|
||||
* <09><><EFBFBD>̻<EFBFBD><CCBB><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ҵ<EFBFBD><D2B4>ȴ<EFBFBD>. \r\n
|
||||
*/
|
||||
void EnableLFH();
|
||||
|
||||
/**
|
||||
* @brief <09><><EFBFBD>α<CEB1><D7B7><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>.
|
||||
* @param pLocale <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @remarks wprintf <20><> <20><><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD> <20><><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD> <20>ֿܼ<DCBC> <20><><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD> <20><><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ؾ<EFBFBD><D8BE><EFBFBD>. \r\n
|
||||
* <09>ѱ<EFBFBD><D1B1><EFBFBD> : Korean \r\n
|
||||
* <09><><EFBFBD><EFBFBD> : English \r\n
|
||||
*/
|
||||
void SetLocale(CHAR* pLocale);
|
||||
|
||||
/**
|
||||
* @brief <09><><EFBFBD>ӿ<EFBFBD><D3BF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Object<63><74> GUID<49><44> <20><><EFBFBD><EFBFBD><EFBFBD>´<EFBFBD>
|
||||
* @return <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> GUID<49><44> 0x00000001 ~ 0xFFFFFFFF <20><><EFBFBD><EFBFBD>
|
||||
*/
|
||||
DWORD GetGUID();
|
||||
|
||||
/**
|
||||
* @brief String<6E><67> ũ<><C5A9>Pixel<65><6C> <20><><EFBFBD>Ѵ<EFBFBD>.
|
||||
* @param string <09><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>Ʈ<EFBFBD><C6AE>
|
||||
* @param font <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>Ʈ
|
||||
* @return <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> String<6E><67> ũ<><C5A9>
|
||||
*/
|
||||
SIZE GetStringSize( const WCHAR* string, HFONT font );
|
||||
|
||||
/**
|
||||
* @brief <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ŀ<><C4BF><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>´<EFBFBD>.
|
||||
* @return Main<69><6E><EFBFBD><EFBFBD><EFBFBD>쿡<EFBFBD><ECBFA1><EFBFBD><EFBFBD> <20><><EFBFBD>콺 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* @warning Nave::hMainWnd <20><> <20><><EFBFBD><EFBFBD><EFBFBD>Ǿ<EFBFBD><C7BE>־<EFBFBD><D6BE><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
*/
|
||||
POINT GetMousePos();
|
||||
|
||||
/**
|
||||
* @brief <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ŀ<><C4BF><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>´<EFBFBD>.
|
||||
* @param wnd <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ڵ<EFBFBD>
|
||||
* @return <09><><EFBFBD><EFBFBD><EFBFBD>쿡<EFBFBD><ECBFA1><EFBFBD><EFBFBD> <20><><EFBFBD>콺 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
POINT GetMousePos( HWND wnd );
|
||||
|
||||
/**
|
||||
* @brief <09><><EFBFBD><EFBFBD> <20><><EFBFBD>콺<EFBFBD><ECBDBA> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>쿡 <20>ö<EFBFBD><C3B6><EFBFBD> <20>ִ<EFBFBD><D6B4><EFBFBD>
|
||||
* @return <09><><EFBFBD>콺<EFBFBD><ECBDBA> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ڵ<EFBFBD>
|
||||
*/
|
||||
HWND IsWindowFromPoint();
|
||||
|
||||
/**
|
||||
* @brief <09><><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1><D7B7><EFBFBD> <20≯<EFBFBD><CCB8><EFBFBD> <20><><EFBFBD>Ѵ<EFBFBD>
|
||||
* @param buf <09><><EFBFBD>ø<EFBFBD><C3B8><EFBFBD><EFBFBD>̼<EFBFBD><CCBC><EFBFBD> <20≯<EFBFBD><CCB8><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param len <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ũ<><C5A9>
|
||||
* @return <09><><EFBFBD>ø<EFBFBD><C3B8><EFBFBD><EFBFBD>̼<EFBFBD> <20≯<EFBFBD><CCB8><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
*/
|
||||
INT GetProgramName( LPWSTR buf, INT len );
|
||||
|
||||
/**
|
||||
* @brief <09><><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1><D7B7><EFBFBD> <20><><EFBFBD>θ<EFBFBD> <20><><EFBFBD>Ѵ<EFBFBD>.
|
||||
* @param buf <09><><EFBFBD>ø<EFBFBD><C3B8><EFBFBD><EFBFBD>̼<EFBFBD><CCBC><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>丮<EFBFBD><E4B8AE> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param len <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ũ<><C5A9>
|
||||
* @return <09><><EFBFBD>ø<EFBFBD><C3B8><EFBFBD><EFBFBD>̼<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>丮<EFBFBD><E4B8AE> <20><><EFBFBD><EFBFBD>
|
||||
*/
|
||||
INT GetProgramDir( LPWSTR buf, INT len );
|
||||
|
||||
/**
|
||||
* @brief Path<74><68><EFBFBD><EFBFBD> <20><><EFBFBD>θ<EFBFBD> <20><><EFBFBD>Ѵ<EFBFBD>
|
||||
* @param path <09><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param buf <09><><EFBFBD>ο<EFBFBD><CEBF><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>丮
|
||||
* @return <09><><EFBFBD><EFBFBD><EFBFBD>丮<EFBFBD><E4B8AE> <20><><EFBFBD><EFBFBD>
|
||||
*/
|
||||
INT GetDir( LPCWSTR path, LPWSTR buf );
|
||||
|
||||
|
||||
/**
|
||||
* @brief <09><><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD><EFBFBD><EFBFBD> 1Line<6E><65> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD>δ<EFBFBD> <20>Ѷ<EFBFBD><D1B6><EFBFBD><EFBFBD><EFBFBD> \n<><6E><EFBFBD><EFBFBD> <20><><EFBFBD>еȴ<D0B5>.
|
||||
* @param sBuf <09>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param maxsBuf <09>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD> ũ<><C5A9>
|
||||
* @param tBuf <09><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param maxtBuf <09><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> ũ<><C5A9>
|
||||
* @param index <09>ҽ<EFBFBD> <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ
|
||||
* @return <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
BOOL GetLine( const CHAR* sBuf, INT maxsBuf, CHAR* tBuf, INT maxtBuf, LONG& index );
|
||||
|
||||
/**
|
||||
* @brief <09><><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD>δ<EFBFBD>.
|
||||
* @param sBuf <09>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param tBuf <09><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param len <09><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> ũ<><C5A9>
|
||||
* @param index <20>ҽ<EFBFBD> <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ
|
||||
*/
|
||||
VOID GetString( const CHAR* sBuf, CHAR* tBuf, INT len, LONG& index );
|
||||
|
||||
/**
|
||||
* @brief 1<><31><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD>δ<EFBFBD>.
|
||||
* @param sBuf <09>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param index <20>ҽ<EFBFBD> <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ
|
||||
* @return BYTE <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
BYTE GetByte( const CHAR* sBuf, LONG& index );
|
||||
|
||||
/**
|
||||
* @brief 2<><32><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD>δ<EFBFBD>.
|
||||
* @param sBuf <09>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param index <20>ҽ<EFBFBD> <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ
|
||||
* @return SHORT <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
SHORT GetShort( const CHAR* sBuf, LONG& index );
|
||||
|
||||
/**
|
||||
* @brief 4<><34><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD>δ<EFBFBD>.
|
||||
* @param sBuf <09>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param index <20>ҽ<EFBFBD> <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ
|
||||
* @return INT <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
INT GetInt( const CHAR* sBuf, LONG& index );
|
||||
|
||||
/**
|
||||
* @brief 4<><34><EFBFBD><EFBFBD>Ʈ <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD>δ<EFBFBD>.
|
||||
* @param sBuf <09>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param index <20>ҽ<EFBFBD> <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ
|
||||
* @return DWORD <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
DWORD GetDWORD( const CHAR* sBuf, LONG& index );
|
||||
|
||||
/**
|
||||
* @brief 4<><34><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD>δ<EFBFBD>.
|
||||
* @param sBuf <09>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param index <20>ҽ<EFBFBD> <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ
|
||||
* @return FLOAT <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
FLOAT GetFloat( const CHAR* sBuf, LONG& index );
|
||||
|
||||
/**
|
||||
* @brief 8<><38><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD>δ<EFBFBD>.
|
||||
* @param sBuf <09>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param index <20>ҽ<EFBFBD> <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ
|
||||
* @return DOUBLE <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
DOUBLE GetDouble( const CHAR* sBuf, LONG& index );
|
||||
|
||||
/**
|
||||
* @brief <09><><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>
|
||||
* @param tBuf <09><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param sBuf <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>
|
||||
* @param len <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param index <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ
|
||||
*/
|
||||
VOID SetString( CHAR* tBuf, const CHAR* sBuf, INT len, LONG& index );
|
||||
|
||||
/**
|
||||
* @brief 1<><31><EFBFBD><EFBFBD>Ʈ BYTE<54><45> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
* @param tBuf <09><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param sByte <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>
|
||||
* @param index <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ
|
||||
*/
|
||||
VOID SetByte( CHAR* tBuf, BYTE sByte, LONG& index );
|
||||
|
||||
/**
|
||||
* @brief 2<><32><EFBFBD><EFBFBD>Ʈ SHORT<52><54> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
* @param tBuf <09><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param sShort <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>
|
||||
* @param index <09><><EFBFBD><EFBFBD> <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ
|
||||
*/
|
||||
VOID SetShort( CHAR* tBuf, SHORT sShort, LONG& index );
|
||||
|
||||
/**
|
||||
* @brief 4<><34><EFBFBD><EFBFBD>Ʈ INT<4E><54> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
* @param tBuf <09><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param sInt <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>
|
||||
* @param index <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ
|
||||
*/
|
||||
VOID SetInt( CHAR* tBuf, INT sInt, LONG& index);
|
||||
|
||||
/**
|
||||
* @brief 4<><34><EFBFBD><EFBFBD>Ʈ DWORD<52><44> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
* @param tBuf <09><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param sDword <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>
|
||||
* @param index <09><><EFBFBD><EFBFBD> <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ
|
||||
*/
|
||||
VOID SetDWORD( CHAR* tBuf, DWORD sDword, LONG& index );
|
||||
|
||||
/**
|
||||
* @brief 4<><34><EFBFBD><EFBFBD>Ʈ FLOAT<41><54> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
* @param tBuf <09><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param sFloat <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>
|
||||
* @param index <09><><EFBFBD><EFBFBD> <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ
|
||||
*/
|
||||
VOID SetFloat( CHAR* tBuf, FLOAT sFloat, LONG& index );
|
||||
|
||||
/**
|
||||
* @brief 8<><38><EFBFBD><EFBFBD>Ʈ double<6C><65> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
* @param tBuf <09><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param sDouble <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>
|
||||
* @param index <09><><EFBFBD><EFBFBD> <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ
|
||||
*/
|
||||
VOID SetDouble( CHAR* tBuf, DOUBLE sDouble, LONG& index );
|
||||
|
||||
|
||||
/**
|
||||
* @brief <09><><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD><EFBFBD><EFBFBD> 1Line<6E><65> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD>δ<EFBFBD> <20>Ѷ<EFBFBD><D1B6><EFBFBD><EFBFBD><EFBFBD> \n<><6E><EFBFBD><EFBFBD> <20><><EFBFBD>еȴ<D0B5>.
|
||||
* @param sBuf <09>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param maxsBuf <09>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD> ũ<><C5A9>
|
||||
* @param tBuf <09><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param maxtBuf <09><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> ũ<><C5A9>
|
||||
* @param index <09>ҽ<EFBFBD> <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ
|
||||
* @return <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
BOOL GetLine( const WCHAR* sBuf, INT maxsBuf, WCHAR* tBuf, INT maxtBuf, LONG& index );
|
||||
|
||||
/**
|
||||
* @brief <09><><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD>δ<EFBFBD>.
|
||||
* @param sBuf <09>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param tBuf <09><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param len <09><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> ũ<><C5A9>
|
||||
* @param index <20>ҽ<EFBFBD> <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ
|
||||
*/
|
||||
VOID GetString( const WCHAR* sBuf, WCHAR* tBuf, INT len, LONG& index );
|
||||
|
||||
/**
|
||||
* @brief 1<><31><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD>δ<EFBFBD>.
|
||||
* @param sBuf <09>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param index <20>ҽ<EFBFBD> <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ
|
||||
* @return BYTE <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
BYTE GetByte( const WCHAR* sBuf, LONG& index );
|
||||
|
||||
/**
|
||||
* @brief 2<><32><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD>δ<EFBFBD>.
|
||||
* @param sBuf <09>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param index <20>ҽ<EFBFBD> <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ
|
||||
* @return SHORT <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
SHORT GetShort( const WCHAR* sBuf, LONG& index );
|
||||
|
||||
/**
|
||||
* @brief 4<><34><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD>δ<EFBFBD>.
|
||||
* @param sBuf <09>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param index <20>ҽ<EFBFBD> <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ
|
||||
* @return INT <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
INT GetInt( const WCHAR* sBuf, LONG& index );
|
||||
|
||||
/**
|
||||
* @brief 4<><34><EFBFBD><EFBFBD>Ʈ <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD>δ<EFBFBD>.
|
||||
* @param sBuf <09>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param index <20>ҽ<EFBFBD> <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ
|
||||
* @return DWORD <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
DWORD GetDWORD( const WCHAR* sBuf, LONG& index );
|
||||
|
||||
/**
|
||||
* @brief 4<><34><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD>δ<EFBFBD>.
|
||||
* @param sBuf <09>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param index <20>ҽ<EFBFBD> <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ
|
||||
* @return FLOAT <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
FLOAT GetFloat( const WCHAR* sBuf, LONG& index );
|
||||
|
||||
/**
|
||||
* @brief 8<><38><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD>δ<EFBFBD>.
|
||||
* @param sBuf <09>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param index <20>ҽ<EFBFBD> <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ
|
||||
* @return DOUBLE <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
DOUBLE GetDouble( const WCHAR* sBuf, LONG& index );
|
||||
|
||||
/**
|
||||
* @brief <09><><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>
|
||||
* @param tBuf <09><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param sBuf <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>
|
||||
* @param len <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param index <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ
|
||||
*/
|
||||
VOID SetString( WCHAR* tBuf, const WCHAR* sBuf, INT len, LONG& index );
|
||||
|
||||
/**
|
||||
* @brief 1<><31><EFBFBD><EFBFBD>Ʈ BYTE<54><45> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
* @param tBuf <09><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param sByte <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>
|
||||
* @param index <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ
|
||||
*/
|
||||
VOID SetByte( WCHAR* tBuf, BYTE sByte, LONG& index );
|
||||
|
||||
/**
|
||||
* @brief 2<><32><EFBFBD><EFBFBD>Ʈ SHORT<52><54> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
* @param tBuf <09><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param sShort <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>
|
||||
* @param index <09><><EFBFBD><EFBFBD> <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ
|
||||
*/
|
||||
VOID SetShort( WCHAR* tBuf, SHORT sShort, LONG& index );
|
||||
|
||||
/**
|
||||
* @brief 4<><34><EFBFBD><EFBFBD>Ʈ INT<4E><54> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
* @param tBuf <09><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param sInt <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>
|
||||
* @param index <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ
|
||||
*/
|
||||
VOID SetInt( WCHAR* tBuf, INT sInt, LONG& index);
|
||||
|
||||
/**
|
||||
* @brief 4<><34><EFBFBD><EFBFBD>Ʈ DWORD<52><44> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
* @param tBuf <09><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param sDword <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>
|
||||
* @param index <09><><EFBFBD><EFBFBD> <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ
|
||||
*/
|
||||
VOID SetDWORD( WCHAR* tBuf, DWORD sDword, LONG& index );
|
||||
|
||||
/**
|
||||
* @brief 4<><34><EFBFBD><EFBFBD>Ʈ FLOAT<41><54> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
* @param tBuf <09><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param sFloat <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>
|
||||
* @param index <09><><EFBFBD><EFBFBD> <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ
|
||||
*/
|
||||
VOID SetFloat( WCHAR* tBuf, FLOAT sFloat, LONG& index );
|
||||
|
||||
/**
|
||||
* @brief 8<><38><EFBFBD><EFBFBD>Ʈ double<6C><65> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
* @param tBuf <09><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param sDouble <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>
|
||||
* @param index <09><><EFBFBD><EFBFBD> <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ
|
||||
*/
|
||||
VOID SetDouble( WCHAR* tBuf, DOUBLE sDouble, LONG& index );
|
||||
|
||||
|
||||
/**
|
||||
* @brief <09><><EFBFBD>̳ʸ<CCB3> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Read <20><><EFBFBD>Դϴ<D4B4>.
|
||||
* @param sBuf <09>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param tBuf <09><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param len <09><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param seek <09>ҽ<EFBFBD> <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ
|
||||
*/
|
||||
VOID Read( const char* sBuf, void* tBuf, INT len, LONG& seek );
|
||||
|
||||
/**
|
||||
* @brief <09><><EFBFBD>̳ʸ<CCB3> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Write <20>մϴ<D5B4>.
|
||||
* @param sBuf <09><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param tBuf <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>
|
||||
* @param len <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* @param seek <09><><EFBFBD><EFBFBD> <20><><EFBFBD>ۿ<EFBFBD><DBBF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ
|
||||
*/
|
||||
VOID Write( const void* sBuf, char* tBuf, INT len, LONG& seek );
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user