-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMySQLPlugin.hpp
66 lines (54 loc) · 1.63 KB
/
MySQLPlugin.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#pragma once
#include "../pinc.h"
//extern "C"
//{
#ifdef WIN32
#include "mysql/windows/include/mysql.h"
#else
#include "mysql/unix/include/mysql.h"
#endif
//}
#define MYSQL_CONNECTION_COUNT 4
class CMySQLPlugin
{
public:
CMySQLPlugin();
~CMySQLPlugin();
// No copy class.
CMySQLPlugin(const CMySQLPlugin& Other_) = delete;
void operator = (const CMySQLPlugin& Other_) = delete;
int OnInit();
static void OnInfoRequest(pluginInfo_t* Info_);
void Clear();
/* MySQL-documented */
void OnScript_Real_Connect();
void OnScript_Close();
void OnScript_Affected_Rows();
void OnScript_Query();
void OnScript_Num_Rows();
void OnScript_Num_Fields();
void OnScript_Fetch_Row();
/* MySQL-custom */
void OnScript_Fetch_Rows();
static CMySQLPlugin* g_MySQLPlugin;
private:
// Maintenance methods.
static const char* const getName();
static const char* const getDescription();
static const char* const getShortDescription();
static unsigned int getMajorVersion();
static unsigned int getMinorVersion();
// Script methods.
int getHandleIndexForScriptArg(const int ArgNum_) const;
void checkConnection(const int HandleIndex_) const;
void checkQuery(const int HandleIndex_) const;
void pluginError(const char* const Format_, ...) const;
// Members.
MYSQL m_MySQL[MYSQL_CONNECTION_COUNT];
MYSQL_RES* m_MySQLResults[MYSQL_CONNECTION_COUNT];
bool m_MySQLInUse[MYSQL_CONNECTION_COUNT];
unsigned int m_MYSQLErrNo[MYSQL_CONNECTION_COUNT];
};
void InitPlugin();
CMySQLPlugin* const GetPlugin();
void FreePlugin();