ZNC
trunk
Main Page
Related Pages
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
include
znc
main.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2004-2014 ZNC, see the NOTICE file for details.
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
#ifndef _MAIN_H
18
#define _MAIN_H
19
20
#include <znc/zncconfig.h>
21
#include <
znc/version.h
>
22
23
extern
bool
ZNC_NO_NEED_TO_DO_ANYTHING_ON_MODULE_CALL_EXITER
;
24
#define NOTHING &ZNC_NO_NEED_TO_DO_ANYTHING_ON_MODULE_CALL_EXITER
25
26
#define ALLMODULECALL(macFUNC, macEXITER) \
27
do { \
28
CModules& GMods = CZNC::Get().GetModules(); \
29
bool bAllExit = false; \
30
if (GMods.macFUNC) { \
31
bAllExit = true; \
32
} else { \
33
const map<CString, CUser*>& mUsers = \
34
CZNC::Get().GetUserMap(); \
35
map<CString, CUser*>::const_iterator it; \
36
for (it = mUsers.begin(); it != mUsers.end(); ++it) { \
37
CModules& UMods = it->second->GetModules(); \
38
if (UMods.macFUNC) { \
39
bAllExit = true; \
40
break; \
41
} \
42
const vector<CIRCNetwork*>& mNets = \
43
it->second->GetNetworks(); \
44
vector<CIRCNetwork*>::const_iterator it2; \
45
for (it2 = mNets.begin(); it2 != mNets.end(); ++it2) { \
46
CModules& NMods = (*it2)->GetModules(); \
47
if (NMods.macFUNC) { \
48
bAllExit = true; \
49
break; \
50
} \
51
} \
52
if (bAllExit) break; \
53
} \
54
} \
55
if (bAllExit) *macEXITER = true; \
56
} while (false)
57
58
#define _GLOBALMODULECALL(macFUNC, macUSER, macNETWORK, macCLIENT, macEXITER) \
59
do { \
60
CModules& GMods = CZNC::Get().GetModules(); \
61
CUser* pOldGUser = GMods.GetUser(); \
62
CIRCNetwork* pOldGNetwork = GMods.GetNetwork(); \
63
CClient* pOldGClient = GMods.GetClient(); \
64
GMods.SetUser(macUSER); \
65
GMods.SetNetwork(macNETWORK); \
66
GMods.SetClient(macCLIENT); \
67
if (GMods.macFUNC) { \
68
GMods.SetUser(pOldGUser); \
69
GMods.SetNetwork(pOldGNetwork); \
70
GMods.SetClient(pOldGClient); \
71
*macEXITER = true; \
72
} \
73
GMods.SetUser(pOldGUser); \
74
GMods.SetNetwork(pOldGNetwork); \
75
GMods.SetClient(pOldGClient); \
76
} while (false)
77
78
#define _USERMODULECALL(macFUNC, macUSER, macNETWORK, macCLIENT, macEXITER) \
79
do { \
80
assert(macUSER != NULL); \
81
bool bGlobalExited = false; \
82
_GLOBALMODULECALL(macFUNC, macUSER, macNETWORK, macCLIENT, &bGlobalExited); \
83
if (bGlobalExited) { \
84
*macEXITER = true; \
85
break; \
86
} \
87
CModules& UMods = macUSER->GetModules(); \
88
CIRCNetwork* pOldUNetwork = UMods.GetNetwork(); \
89
CClient* pOldUClient = UMods.GetClient(); \
90
UMods.SetNetwork(macNETWORK); \
91
UMods.SetClient(macCLIENT); \
92
if (UMods.macFUNC) { \
93
UMods.SetNetwork(pOldUNetwork); \
94
UMods.SetClient(pOldUClient); \
95
*macEXITER = true; \
96
} \
97
UMods.SetNetwork(pOldUNetwork); \
98
UMods.SetClient(pOldUClient); \
99
} while (false)
100
101
#define NETWORKMODULECALL(macFUNC, macUSER, macNETWORK, macCLIENT, macEXITER) \
102
do { \
103
assert(macUSER != NULL); \
104
bool bUserExited = false; \
105
_USERMODULECALL(macFUNC, macUSER, macNETWORK, macCLIENT, &bUserExited); \
106
if (bUserExited) { \
107
*macEXITER = true; \
108
break; \
109
} \
110
if (macNETWORK != NULL) { \
111
CModules& NMods = macNETWORK->GetModules(); \
112
CClient* pOldNClient = NMods.GetClient(); \
113
NMods.SetClient(macCLIENT); \
114
if (NMods.macFUNC) { \
115
NMods.SetClient(pOldNClient); \
116
*macEXITER = true; \
117
} \
118
NMods.SetClient(pOldNClient); \
119
} \
120
} while (false)
121
122
#define GLOBALMODULECALL(macFUNC, macEXITER) \
123
_GLOBALMODULECALL(macFUNC, NULL, NULL, NULL, macEXITER)
124
125
#define USERMODULECALL(macFUNC, macUSER, macCLIENT, macEXITER) \
126
_USERMODULECALL(macFUNC, macUSER, NULL, macCLIENT, macEXITER)
127
145
#endif // !_MAIN_H
ZNC_NO_NEED_TO_DO_ANYTHING_ON_MODULE_CALL_EXITER
bool ZNC_NO_NEED_TO_DO_ANYTHING_ON_MODULE_CALL_EXITER
version.h
Generated on Sun Apr 20 2014 00:20:10 for ZNC by
1.8.5