-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.h
130 lines (117 loc) · 5.82 KB
/
main.h
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
* Copyright (C) 2004-2011 See the AUTHORS file for details.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*/
#ifndef _MAIN_H
#define _MAIN_H
#include "zncconfig.h"
// The following defines are for #if comparison (preprocessor only likes ints)
#define VERSION_MAJOR 0
#define VERSION_MINOR 203
// This one is for display purpose
#define VERSION (VERSION_MAJOR + VERSION_MINOR / 1000.0)
// You can add -DVERSION_EXTRA="stuff" to your CXXFLAGS!
#ifndef VERSION_EXTRA
#define VERSION_EXTRA ""
#endif
#define NOTHING (void)0
#define ALLMODULECALL(macFUNC, macEXITER) \
do { \
CModules& GMods = CZNC::Get().GetModules(); \
if (GMods.macFUNC) { \
macEXITER; \
} else { \
const map<CString, CUser*>& mUsers = \
CZNC::Get().GetUserMap(); \
map<CString, CUser*>::const_iterator it; \
for (it = mUsers.begin(); it != mUsers.end(); ++it) { \
CModules& UMods = it->second->GetModules(); \
if (UMods.macFUNC) { \
macEXITER; \
} \
const vector<CIRCNetwork*>& mNets = \
it->second->GetNetworks(); \
vector<CIRCNetwork*>::const_iterator it2; \
for (it2 = mNets.begin(); it2 != mNets.end(); ++it2) { \
CModules& NMods = (*it2)->GetModules(); \
if (NMods.macFUNC) { \
macEXITER; \
} \
} \
} \
} \
} while (false)
#define _GLOBALMODULECALL(macFUNC, macUSER, macNETWORK, macCLIENT, macEXITER) \
do { \
CModules& GMods = CZNC::Get().GetModules(); \
CUser* pOldGUser = GMods.GetUser(); \
CIRCNetwork* pOldGNetwork = GMods.GetNetwork(); \
CClient* pOldGClient = GMods.GetClient(); \
GMods.SetUser(macUSER); \
GMods.SetNetwork(macNETWORK); \
GMods.SetClient(macCLIENT); \
if (GMods.macFUNC) { \
GMods.SetUser(pOldGUser); \
GMods.SetNetwork(pOldGNetwork); \
GMods.SetClient(pOldGClient); \
macEXITER; \
} \
GMods.SetUser(pOldGUser); \
GMods.SetClient(pOldGClient); \
} while (false)
#define _USERMODULECALL(macFUNC, macUSER, macNETWORK, macCLIENT, macEXITER) \
do { \
assert(macUSER != NULL); \
_GLOBALMODULECALL(macFUNC, macUSER, macNETWORK, macCLIENT, macEXITER); \
CModules& UMods = macUSER->GetModules(); \
CIRCNetwork* pOldUNetwork = UMods.GetNetwork(); \
CClient* pOldUClient = UMods.GetClient(); \
UMods.SetNetwork(macNETWORK); \
UMods.SetClient(macCLIENT); \
if (UMods.macFUNC) { \
UMods.SetNetwork(pOldUNetwork); \
UMods.SetClient(pOldUClient); \
macEXITER; \
} \
UMods.SetNetwork(pOldUNetwork); \
UMods.SetClient(pOldUClient); \
} while (false)
#define NETWORKMODULECALL(macFUNC, macUSER, macNETWORK, macCLIENT, macEXITER) \
do { \
assert(macUSER != NULL); \
_USERMODULECALL(macFUNC, macUSER, macNETWORK, macCLIENT, macEXITER); \
if (macNETWORK != NULL) { \
CModules& NMods = macNETWORK->GetModules(); \
CClient* pOldNClient = NMods.GetClient(); \
NMods.SetClient(macCLIENT); \
if (NMods.macFUNC) { \
NMods.SetClient(pOldNClient); \
macEXITER; \
} \
NMods.SetClient(pOldNClient); \
} \
} while (false)
#define GLOBALMODULECALL(macFUNC, macEXITER) \
_GLOBALMODULECALL(macFUNC, NULL, NULL, NULL, macEXITER)
#define USERMODULECALL(macFUNC, macUSER, macCLIENT, macEXITER) \
_USERMODULECALL(macFUNC, macUSER, NULL, macCLIENT, macEXITER)
/** @mainpage
* Welcome to the API documentation for ZNC.
*
* To write your own module, you should start with writing a new class which
* inherits from CModule. Use #MODCONSTRUCTOR for the module's constructor and
* call #MODULEDEFS at the end of your source file.
* Congratulations, you just wrote your first module. <br>
* For global modules, the procedure is similar. Instead of #MODULEDEFS call
* #GLOBALMODULEDEFS.
*
* If you want your module to actually do something, you should override some
* of the hooks from CModule. These are the functions whose names start with
* "On". They are called when the associated event happens.
*
* Feel free to also look at existing modules.
*/
#endif // !_MAIN_H