LosaDev source snapshot 2019
This commit is contained in:
commit
c198676e97
20588 files changed
+8812878
No files matched your search
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "Protocol.h"
|
||||
|
||||
// internal protocol
|
||||
enum InternalProtocol
|
||||
{
|
||||
BEGIN_INTERNAL_COMMAND = 0x0000,
|
||||
|
||||
I_CONNECT,
|
||||
I_CLOSE,
|
||||
I_PING,
|
||||
I_FLUSH,
|
||||
|
||||
|
||||
C_COLLABORATE = 0x0080, S_COLLABORATE,
|
||||
C_USERCOUNT,
|
||||
|
||||
END_INTERNAL_COMMAND
|
||||
};
|
||||
|
||||
|
||||
|
||||
#pragma pack()
|
||||
@@ -0,0 +1,286 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
// 네트워크 프로토콜 정의
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
enum Protocol
|
||||
{
|
||||
BEGIN_CLIENT_COMMAND = 0xa000,
|
||||
|
||||
C_PING, S_PING,
|
||||
|
||||
C_SERVICES, S_SERVICES,
|
||||
C_TRANSFER, S_TRANSFER,
|
||||
C_REMOVE, S_REMOVE,
|
||||
C_INSTALL, S_INSTALL,
|
||||
C_PLAY, S_PLAY,
|
||||
C_BACKUP, S_BACKUP,
|
||||
C_REBOOT, S_REBOOT,
|
||||
C_RESOURCE, S_RESOURCE,
|
||||
|
||||
END_CLIENT_COMMAND
|
||||
};
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
const uint32 G_MAXFILESIZE = 1024 * 1024 * 5;
|
||||
|
||||
|
||||
// 결과값
|
||||
struct Result
|
||||
{
|
||||
Result()
|
||||
{
|
||||
result = FALSE;
|
||||
}
|
||||
BOOL result;
|
||||
};
|
||||
|
||||
// 핑
|
||||
struct csPing
|
||||
{
|
||||
};
|
||||
|
||||
struct scPing
|
||||
{
|
||||
scPing()
|
||||
{
|
||||
code = 0;
|
||||
}
|
||||
uint32 code;
|
||||
};
|
||||
|
||||
|
||||
// 서비스 목록요청
|
||||
struct Service
|
||||
{
|
||||
Service()
|
||||
{
|
||||
running = FALSE;
|
||||
console = FALSE;
|
||||
ZeroMemory(service, sizeof(service));
|
||||
}
|
||||
|
||||
BOOL running;
|
||||
BOOL console;
|
||||
TCHAR service[32];
|
||||
};
|
||||
|
||||
struct scServices
|
||||
{
|
||||
scServices()
|
||||
{
|
||||
count = 0;
|
||||
}
|
||||
uint8 count;
|
||||
};
|
||||
|
||||
|
||||
// 파일 전송
|
||||
enum TransferTypes
|
||||
{
|
||||
TRANSFER_BEGIN = 1,
|
||||
TRANSFER_DO,
|
||||
TRANSFER_END
|
||||
};
|
||||
|
||||
struct csTransfer
|
||||
{
|
||||
csTransfer()
|
||||
{
|
||||
type = 0;
|
||||
index = 0;
|
||||
}
|
||||
uint8 type;
|
||||
uint8 index;
|
||||
};
|
||||
|
||||
struct csTransferBegin : csTransfer
|
||||
{
|
||||
csTransferBegin()
|
||||
{
|
||||
length = 0;
|
||||
ZeroMemory(file, sizeof(file));
|
||||
ZeroMemory(folder, sizeof(folder));
|
||||
}
|
||||
uint32 length;
|
||||
TCHAR file[64];
|
||||
TCHAR folder[256];
|
||||
BYTE digest[16];
|
||||
};
|
||||
|
||||
struct csTransferDo : csTransfer
|
||||
{
|
||||
csTransferDo()
|
||||
{
|
||||
length = 0;
|
||||
}
|
||||
uint32 length;
|
||||
};
|
||||
|
||||
struct csTransferEnd : csTransfer
|
||||
{
|
||||
csTransferEnd()
|
||||
{
|
||||
length = 0;
|
||||
}
|
||||
uint32 length;
|
||||
};
|
||||
|
||||
struct scTransfer : Result
|
||||
{
|
||||
scTransfer()
|
||||
{
|
||||
type = 0;
|
||||
index = 0;
|
||||
}
|
||||
uint8 type;
|
||||
uint8 index;
|
||||
};
|
||||
|
||||
struct scTransferFail : scTransfer
|
||||
{
|
||||
scTransferFail()
|
||||
{
|
||||
ZeroMemory(file, sizeof(file));
|
||||
}
|
||||
TCHAR file[256];
|
||||
};
|
||||
|
||||
// 파일 삭제
|
||||
struct csRemove
|
||||
{
|
||||
csRemove()
|
||||
{
|
||||
ZeroMemory(folder, sizeof(folder));
|
||||
}
|
||||
TCHAR folder[256];
|
||||
};
|
||||
|
||||
struct scRemove : Result
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
// 인스톨
|
||||
struct Install
|
||||
{
|
||||
Install()
|
||||
{
|
||||
install = TRUE;
|
||||
ZeroMemory(service, sizeof(service));
|
||||
}
|
||||
BOOL install;
|
||||
TCHAR service[256];
|
||||
};
|
||||
|
||||
struct csInstall : Install
|
||||
{
|
||||
csInstall()
|
||||
{
|
||||
ZeroMemory(file, sizeof(file));
|
||||
ZeroMemory(script, sizeof(script));
|
||||
}
|
||||
TCHAR file[256];
|
||||
TCHAR script[256];
|
||||
};
|
||||
|
||||
struct csUninstall : Install
|
||||
{
|
||||
csUninstall()
|
||||
{
|
||||
clear = FALSE;
|
||||
}
|
||||
BOOL clear;
|
||||
};
|
||||
|
||||
struct scInstall : Result
|
||||
{
|
||||
scInstall()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
// 시작
|
||||
struct Play
|
||||
{
|
||||
Play()
|
||||
{
|
||||
play = TRUE;
|
||||
isDemon = FALSE;
|
||||
ZeroMemory(service, sizeof(service));
|
||||
}
|
||||
BOOL play;
|
||||
BOOL isDemon;
|
||||
TCHAR service[256];
|
||||
};
|
||||
|
||||
struct csPlay : Play
|
||||
{
|
||||
csPlay()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct csStop : Play
|
||||
{
|
||||
};
|
||||
|
||||
struct scPlay : Result
|
||||
{
|
||||
scPlay()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// 백업
|
||||
struct csBackup
|
||||
{
|
||||
csBackup()
|
||||
{
|
||||
ZeroMemory(source, sizeof(source));
|
||||
ZeroMemory(target, sizeof(target));
|
||||
}
|
||||
TCHAR source[256];
|
||||
TCHAR target[256];
|
||||
};
|
||||
|
||||
struct scBackup : Result
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
// 윈도우 재부팅
|
||||
struct csReboot
|
||||
{
|
||||
csReboot()
|
||||
{
|
||||
option = 0;
|
||||
}
|
||||
uint32 option;
|
||||
};
|
||||
|
||||
struct scReboot : Result
|
||||
{
|
||||
};
|
||||
|
||||
// 성능모니터
|
||||
struct scResource : Result
|
||||
{
|
||||
scResource()
|
||||
{
|
||||
cpu = 0;
|
||||
disk = 0;
|
||||
memory = 0;
|
||||
network = 0;
|
||||
}
|
||||
uint32 cpu;
|
||||
uint32 disk;
|
||||
uint32 memory;
|
||||
uint32 network;
|
||||
};
|
||||
|
||||
#pragma pack()
|
||||
@@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
|
||||
#define LuaGlue extern "C" int
|
||||
|
||||
|
||||
struct lua_State;
|
||||
|
||||
extern "C" {
|
||||
typedef int (*LuaFunctionType)(struct lua_State *pLuaState);
|
||||
};
|
||||
|
||||
class cLua
|
||||
{
|
||||
public:
|
||||
cLua();
|
||||
virtual ~cLua();
|
||||
|
||||
public:
|
||||
bool RunScript(const TCHAR *fileName);
|
||||
bool RunString(const TCHAR *command);
|
||||
|
||||
bool AddFunction(const TCHAR *funcName, LuaFunctionType funcType);
|
||||
|
||||
const TCHAR* GetStringArgument(int num, const TCHAR* value=NULL);
|
||||
double GetNumberArgument(int num, double value=0.0);
|
||||
|
||||
void CallFunction(const TCHAR* funcName);
|
||||
void PushString(const TCHAR* arg);
|
||||
void PushNumber(double arg);
|
||||
double GetReturnValue(int args);
|
||||
|
||||
lua_State *GetScriptContext(void) { return m_pLuaContext; }
|
||||
|
||||
public:
|
||||
const TCHAR* GetErrorString(void);
|
||||
|
||||
void SetErrorHandler(void(*pErrorHandler)(const TCHAR *errorCode));
|
||||
void ErrorReport( const TCHAR *format, ... );
|
||||
|
||||
public:
|
||||
const TCHAR* ToTCHAR(const char* string);
|
||||
//WCHAR* Utf8ToUnicode(const char* string);
|
||||
const char* ToANSI(const TCHAR* string);
|
||||
const TCHAR* ToUnicode(const char* string);
|
||||
|
||||
private:
|
||||
BYTE* GetFreeBuffer();
|
||||
|
||||
private:
|
||||
int m_nBufferIndex;
|
||||
|
||||
private:
|
||||
lua_State* m_pLuaContext;
|
||||
void (*m_pErrorHandler)(const TCHAR *errorCode);
|
||||
};
|
||||
Reference in new issue
Block a user