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:
64
Server/AdminTool/AdminToolLibrary/parser/ServerInfo.cpp
Normal file
64
Server/AdminTool/AdminToolLibrary/parser/ServerInfo.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
#include "stdafx.h"
|
||||
#include "ServerInfo.h"
|
||||
//#include "string.h"
|
||||
|
||||
const char* CServerInfo::ms_szInfoFileName = "AdminToolServerSetup.ini";
|
||||
|
||||
CServerInfo::CServerInfo()
|
||||
{
|
||||
Reload(ms_szInfoFileName);
|
||||
}
|
||||
|
||||
|
||||
CServerInfo::~CServerInfo()
|
||||
{
|
||||
m_ServerInfoTable.clear( );
|
||||
}
|
||||
|
||||
const char* CServerInfo::GetFileName( )
|
||||
{
|
||||
return CServerInfo::ms_szInfoFileName;
|
||||
}
|
||||
|
||||
bool CServerInfo::Reload(const char* szFileName)
|
||||
{
|
||||
m_ServerInfoTable.clear();
|
||||
|
||||
FILE* lpFile = fopen(szFileName, "rt");
|
||||
if(NULL == lpFile)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const int MAX_LINE = 4096;
|
||||
char szBuffer[MAX_LINE];
|
||||
|
||||
std::string szKeyString;
|
||||
|
||||
while(0 != fgets(szBuffer, MAX_LINE, lpFile))
|
||||
{
|
||||
char* szKey = strtok(szBuffer, " =\t\n");
|
||||
char* szValue = strtok(NULL, " =\t\n");
|
||||
|
||||
if(NULL != szKey && NULL != szValue && '[' != szKey[0] && '#' != szKey[0])
|
||||
{
|
||||
szKeyString.assign(szKey);
|
||||
m_ServerInfoTable[szKeyString] = szValue;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(lpFile);
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* CServerInfo::GetValue(const char* szKeyName)
|
||||
{
|
||||
const int MAX_BUFFER = 256;
|
||||
char szBuffer[MAX_BUFFER];
|
||||
|
||||
strncpy(szBuffer, szKeyName, MAX_BUFFER);
|
||||
szBuffer[MAX_BUFFER - 1] = 0;
|
||||
|
||||
ServerInfoTable::iterator finditr = m_ServerInfoTable.find(szBuffer);
|
||||
return (finditr != m_ServerInfoTable.end()) ? finditr->second.c_str() : NULL;
|
||||
}
|
||||
25
Server/AdminTool/AdminToolLibrary/parser/ServerInfo.h
Normal file
25
Server/AdminTool/AdminToolLibrary/parser/ServerInfo.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef _SERVER_INFO_H_
|
||||
#define _SERVER_INFO_H_
|
||||
|
||||
#include <Pattern/Singleton.h>
|
||||
|
||||
// ½ºÅ©¸³Æ® ÆÄÀÏ ( Key = Value )
|
||||
class CServerInfo : public CStaticSingleton<CServerInfo>
|
||||
{
|
||||
public:
|
||||
|
||||
CServerInfo();
|
||||
~CServerInfo();
|
||||
|
||||
bool Reload(const char* szFileName = ms_szInfoFileName);
|
||||
const char* GetValue(const char* szKeyName);
|
||||
const char* GetFileName();
|
||||
private:
|
||||
|
||||
typedef std::map<std::string, std::string> ServerInfoTable;
|
||||
|
||||
ServerInfoTable m_ServerInfoTable;
|
||||
static const char* ms_szInfoFileName;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user