2006-03-14 19:36:18 +00:00
|
|
|
#ifndef _INCLUDE_BINLOG_H
|
|
|
|
#define _INCLUDE_BINLOG_H
|
|
|
|
|
|
|
|
#if defined BINLOG_ENABLED
|
|
|
|
|
|
|
|
#include "CString.h"
|
|
|
|
|
|
|
|
#define BINLOG_MAGIC 0x414D424C
|
2006-08-21 03:11:19 +00:00
|
|
|
#define BINLOG_VERSION 0x0300
|
2006-03-14 19:36:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Format of binlog:
|
2006-03-16 06:36:01 +00:00
|
|
|
* uint32 magic
|
|
|
|
* uint16 version
|
|
|
|
* uint8 sizeof(time_t)
|
|
|
|
* uint32 num plugins
|
2006-03-14 19:36:18 +00:00
|
|
|
* [
|
2006-03-16 06:36:01 +00:00
|
|
|
* uint8 status codes
|
|
|
|
* str[int8] filename
|
2006-08-21 03:11:19 +00:00
|
|
|
* if(status==2)
|
|
|
|
* uint32 num filenames
|
2006-03-16 06:36:01 +00:00
|
|
|
* uint32 num natives
|
|
|
|
* uint32 num publics
|
2006-08-21 03:11:19 +00:00
|
|
|
* if (status==2)
|
|
|
|
* [
|
|
|
|
* str[uint8] file name
|
|
|
|
* ]
|
2006-03-14 19:36:18 +00:00
|
|
|
* [
|
2006-03-16 06:36:01 +00:00
|
|
|
* str[uint8] native name
|
2006-03-14 19:36:18 +00:00
|
|
|
* ]
|
|
|
|
* [
|
2006-03-16 06:36:01 +00:00
|
|
|
* str[uint8] public name
|
2006-03-14 19:36:18 +00:00
|
|
|
* ]
|
2006-03-19 21:41:11 +00:00
|
|
|
* ]
|
|
|
|
* [
|
|
|
|
* uint8 operation code
|
|
|
|
* time_t realtime
|
|
|
|
* float gametime
|
|
|
|
* int32 plugin id
|
|
|
|
* <extra info>
|
|
|
|
* ]
|
2006-08-21 03:46:20 +00:00
|
|
|
* If filename id is 0 skip as plugin was not in debug mode, if -1 there was an error.
|
2006-03-14 19:36:18 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
enum BinLogOp
|
|
|
|
{
|
2006-03-15 13:43:06 +00:00
|
|
|
BinLog_Start=1,
|
2006-03-14 19:36:18 +00:00
|
|
|
BinLog_End,
|
2006-08-21 03:46:20 +00:00
|
|
|
BinLog_NativeCall, //<int32 native id> <int32_t num_params> <int32_t filename id>
|
2006-03-16 06:36:01 +00:00
|
|
|
BinLog_NativeError, //<int32 errornum> <str[int16] string>
|
2006-08-21 04:18:13 +00:00
|
|
|
BinLog_NativeRet, //<cell value>
|
2006-08-21 03:46:20 +00:00
|
|
|
BinLog_CallPubFunc, //<int32 public id> <int32_t filename id>
|
|
|
|
BinLog_SetLine, //<int32 line no#> <int32_t filename id>
|
2006-03-14 19:36:18 +00:00
|
|
|
BinLog_Registered, //<string title> <string version>
|
2006-03-16 06:36:01 +00:00
|
|
|
BinLog_FormatString, //<int32 param#> <int32 maxlen> <str[int16] string>
|
|
|
|
BinLog_NativeParams, //<int32 num> <cell ...>
|
|
|
|
BinLog_GetString, //<cell addr> <string[int16]>
|
|
|
|
BinLog_SetString, //<cell addr> <int maxlen> <string[int16]>
|
2006-03-14 19:36:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class BinLog
|
|
|
|
{
|
2006-03-19 21:41:11 +00:00
|
|
|
public:
|
|
|
|
BinLog() : m_state(false)
|
|
|
|
{
|
|
|
|
};
|
2006-03-14 19:36:18 +00:00
|
|
|
public:
|
|
|
|
bool Open();
|
|
|
|
void Close();
|
2006-03-15 13:43:06 +00:00
|
|
|
void WriteOp(BinLogOp op, int plug, ...);
|
2006-03-14 19:36:18 +00:00
|
|
|
private:
|
2006-03-19 21:41:11 +00:00
|
|
|
void WritePluginDB(FILE *fp);
|
|
|
|
private:
|
2006-03-14 19:36:18 +00:00
|
|
|
String m_logfile;
|
2006-03-19 21:41:11 +00:00
|
|
|
bool m_state;
|
2006-03-14 19:36:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern BinLog g_BinLog;
|
2006-03-16 06:36:01 +00:00
|
|
|
extern int g_binlog_level;
|
2006-03-17 22:50:13 +00:00
|
|
|
extern int g_binlog_maxsize;
|
2006-03-16 06:36:01 +00:00
|
|
|
|
|
|
|
#endif //BINLOG_ENABLED
|
2006-03-14 19:36:18 +00:00
|
|
|
|
|
|
|
#endif //_INCLUDE_BINLOG_H
|