fixed crash bug in cmd_NeonServ.mod/cmd_neonserv_set.c
[NeonServV5.git] / src / modules / module.h
1 /* module.h - NeonServ v5.6
2  * Copyright (C) 2011-2012  Philipp Kreil (pk910)
3  * 
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  * 
14  * You should have received a copy of the GNU General Public License 
15  * along with this program. If not, see <http://www.gnu.org/licenses/>. 
16  */
17 #ifndef _module_h
18 #define _module_h
19 #define DND_FUNCTIONS 1 /* DoNotDefine_Functions */
20 #include "../overall.h"
21 #include "../version.h"
22 #include "../mysqlConn.h"
23 #include "../log.h"
24
25 extern void **global;
26 extern int module_id;
27
28 /**** global function list ****/
29 /* 000 */ #define getStartTime ((time_t (*)(void))global[0])
30 /* 001 */ #define getRunningThreads ((int (*)(void))global[1])
31 /* 002 */ #define getCurrentSecondsOfDay ((int (*)(void))global[2])
32 /* 003 */ #define stricmp ((int (*)(const char *, const char *))global[3])
33 /* 004 */ #define stricmplen ((int (*)(const char *, const char *, int))global[4])
34 #ifdef ENABLE_MUTEX_DEBUG
35 /* 005 */ #define xmutex ((void (*)(int, pthread_mutex_t *, const char *, unsigned int))global[005])
36 /* 006 */ #define mutex_debug ((void (*)(pthread_mutex_t *))global[006])
37 #endif
38 /* 007 */ #define restart_bot ((void (*)(int))global[7])
39 /* 008 */ #define stop_bot ((void (*)(void))global[8])
40 /* 009 */ #define reload_config ((void (*)(void))global[9])
41 /* 010 */ #define printf_log ((void (*)(char *, int, const char *, ...))global[10])
42 #ifdef HAVE_THREADS
43 /* 011 */ #define getCurrentThreadID ((int (*)(void))global[11])
44 #endif
45 /* 012 */ #define getMatchingChannelBan ((struct BanNode* (*)(struct ChanNode *, char *))global[12])
46 /* 013 */ #define getChannelBot ((struct ClientSocket* (*)(struct ChanNode *, int))global[13])
47 /* 014 */ #define requestOp ((void (*)(struct UserNode *, struct ChanNode *))global[14])
48 /* 015 */ #define channel_ban_timeout ((void (*)(void *))global[15])
49 /* 016 */ #define general_event_privctcp ((void (*)(struct UserNode *, struct UserNode *, char *, char *))global[16])
50 /* 017 */ #define set_bot_alias ((void (*)(int, char *))global[17])
51 /* 018 */ #define resolve_botid ((const char * (*)(int))global[18])
52 /* 019 */ #define resolve_botalias ((int (*)(const char *))global[19])
53 /* 020 */ #define is_valid_chan ((int (*)(const char *))global[20])
54 /* 021 */ #define getAllChans ((struct ChanNode* (*)(struct ChanNode *))global[21])
55 /* 022 */ #define getChanByName ((struct ChanNode* (*)(const char *))global[22])
56 /* 023 */ #define getChannelCount ((int (*)(void))global[23])
57 /* 024 */ #define getChanUserCount ((int (*)(void))global[24])
58 /* 025 */ #define getChanBanCount ((int (*)(void))global[25])
59 /* 026 */ #define isUserOnChan ((int (*)(struct UserNode *, struct ChanNode *))global[26])
60 /* 027 */ #define getChanUser ((struct ChanUser* (*)(struct UserNode *, struct ChanNode *))global[27])
61 /* 028 */ #define getChannelUsers ((struct ChanUser* (*)(struct ChanNode *, struct ChanUser *))global[28])
62 /* 029 */ #define getUserChannels ((struct ChanUser* (*)(struct UserNode *, struct ChanUser *))global[29])
63 /* 030 */ #define create_socket ((struct ClientSocket* (*)(char *, int, char *, char *, char *, char *, char *))global[30])
64 /* 031 */ #define connect_socket ((void (*)(struct ClientSocket *))global[31])
65 /* 032 */ #define close_socket ((int (*)(struct ClientSocket *))global[32])
66 /* 033 */ #define destroy_socket ((int (*)(struct ClientSocket *))global[33])
67 /* 034 */ #define write_socket ((int (*)(struct ClientSocket *, char*, int))global[34])
68 /* 035 */ #define putsock ((void (*)(struct ClientSocket *, const char *, ...))global[35])
69 /* 036 */ #define getBots ((struct ClientSocket* (*)(int, struct ClientSocket *))global[36])
70 /* 037 */ #define get_int_field ((int (*)(char *))global[37])
71 /* 038 */ #define get_string_field ((char * (*)(char *))global[38])
72 /* 039 */ #define _loadUserSettings ((void (*)(struct UserNode *))global[39])
73 /* 040 */ #define isGodMode ((int (*)(struct UserNode *))global[40])
74 /* 041 */ #define getChanDefault ((char * (*)(char *))global[41])
75 /* 042 */ #define getChannelAccess ((int (*)(struct UserNode *, struct ChanNode *))global[42])
76 /* 043 */ #define checkChannelAccess ((int (*)(struct UserNode *, struct ChanNode *, char *, int))global[43])
77 /* 044 */ #define _loadChannelSettings ((void (*)(struct ChanNode *))global[44])
78 /* 045 */ #define isUserProtected ((int (*)(struct ChanNode *, struct UserNode *, struct UserNode *))global[45])
79 /* 046 */ #define getBanAffectingMask ((char * (*)(struct ChanNode *, char *))global[46])
80 /* 047 */ #define renameAccount ((int (*)(char *, char *))global[47])
81 /* 048 */ #define deleteUser ((void (*)(int))global[48])
82 /* 049 */ #define logEvent ((void (*)(struct Event *))global[49])
83 /* 050 */ #define lookup_authname ((void (*)(char *, int, authlookup_callback_t, void *))global[50])
84 /* 051 */ #define bind_join ((int (*)(join_func_t *, int))global[51])
85 /* 052 */ #define unbind_join ((void (*)(join_func_t *))global[52])
86 /* 053 */ #define bind_nick ((int (*)(nick_func_t *, int))global[53])
87 /* 054 */ #define unbind_nick ((void (*)(nick_func_t *))global[54])
88 /* 055 */ #define bind_part ((int (*)(part_func_t *, int))global[55])
89 /* 056 */ #define unbind_part ((void (*)(part_func_t *))global[56])
90 /* 057 */ #define bind_reload ((int (*)(reload_func_t *, int))global[57])
91 /* 058 */ #define unbind_reload ((void (*)(reload_func_t *))global[58])
92 /* 059 */ #define bind_kick ((int (*)(kick_func_t *, int))global[59])
93 /* 060 */ #define unbind_kick ((void (*)(kick_func_t *))global[60])
94 /* 061 */ #define bind_topic ((int (*)(topic_func_t *, int))global[61])
95 /* 062 */ #define unbind_topic ((void (*)(topic_func_t *))global[62])
96 /* 063 */ #define bind_mode ((int (*)(mode_func_t *, int))global[63])
97 /* 064 */ #define unbind_mode ((void (*)(mode_func_t *))global[64])
98 /* 065 */ #define bind_chanmsg ((int (*)(chanmsg_func_t *, int))global[65])
99 /* 066 */ #define unbind_chanmsg ((void (*)(chanmsg_func_t *))global[66])
100 /* 067 */ #define bind_privmsg ((int (*)(privmsg_func_t *, int))global[67])
101 /* 068 */ #define unbind_privmsg ((void (*)(privmsg_func_t *))global[68])
102 /* 069 */ #define bind_channotice ((int (*)(channotice_func_t *, int))global[69])
103 /* 070 */ #define unbind_channotice ((void (*)(channotice_func_t *))global[70])
104 /* 071 */ #define bind_privnotice ((int (*)(privnotice_func_t *, int))global[71])
105 /* 072 */ #define unbind_privnotice ((void (*)(privnotice_func_t *))global[72])
106 /* 073 */ #define bind_chanctcp ((int (*)(chanctcp_func_t *, int))global[73])
107 /* 074 */ #define unbind_chanctcp ((void (*)(chanctcp_func_t *))global[74])
108 /* 075 */ #define bind_privctcp ((int (*)(privctcp_func_t *, int))global[75])
109 /* 076 */ #define unbind_privctcp ((void (*)(privctcp_func_t *))global[76])
110 /* 077 */ #define bind_invite ((int (*)(invite_func_t *, int))global[77])
111 /* 078 */ #define unbind_invite ((void (*)(invite_func_t *))global[78])
112 /* 079 */ #define bind_raw ((int (*)(raw_func_t *, int))global[79])
113 /* 080 */ #define unbind_raw ((void (*)(raw_func_t *))global[80])
114 /* 081 */ #define bind_bot_ready ((int (*)(bot_ready_func_t *, int))global[81])
115 /* 082 */ #define unbind_bot_ready ((void (*)(bot_ready_func_t *))global[82])
116 /* 083 */ #define bind_registered ((int (*)(registered_func_t *, int))global[83])
117 /* 084 */ #define unbind_registered ((void (*)(registered_func_t *))global[84])
118 /* 085 */ #define bind_freeuser ((int (*)(freeuser_func_t *, int))global[85])
119 /* 086 */ #define unbind_freeuser ((void (*)(freeuser_func_t *))global[86])
120 /* 087 */ #define bind_freechan ((int (*)(freechan_func_t *, int))global[87])
121 /* 088 */ #define unbind_freechan ((void (*)(freechan_func_t *))global[88])
122 /* 089 */ #define reply ((void (*)(struct ClientSocket *, struct UserNode *, const char *, ...))global[89])
123 /* 090 */ #define merge_argv ((char * (*)(char **, int, int))global[90])
124 /* 091 */ #define merge_argv_char ((char * (*)(char **, int, int, char))global[91])
125 /* 092 */ #define get_language_by_tag ((struct language * (*)(char *))global[92])
126 /* 093 */ #define get_language_by_name ((struct language * (*)(char *))global[93])
127 /* 094 */ #define get_default_language ((struct language * (*)(void))global[94])
128 /* 095 */ #define load_language ((void (*)(char *, char *))global[95])
129 /* 096 */ #define register_default_language_table ((void (*)(const struct default_language_entry *))global[96])
130 /* 097 */ #define get_language_string ((char * (*)(struct UserNode *, const char *))global[97])
131 /* 098 */ #define build_language_string ((char * (*)(struct UserNode *, char *, const char *, ...))global[98])
132 #ifdef ENABLE_MEMORY_DEBUG
133 /* 099 */ #define xmalloc ((void * (*)(unsigned int, const char *, unsigned int))global[99])
134 /* 100 */ #define xcalloc ((void * (*)(unsigned int, unsigned int, const char *, unsigned int))global[100])
135 /* 101 */ #define xstrdup ((char * (*)(const char *, const char *, unsigned int))global[101])
136 /* 102 */ #define xfree ((void (*)(void *))global[102])
137 #endif
138 /* 103 */ #define getMemoryInfoFiles ((struct memoryInfoFiles * (*)(void))global[103])
139 /* 104 */ #define freeMemoryInfoFiles ((void (*)(struct memoryInfoFiles *))global[104])
140 /* 105 */ #define getMemoryInfoLines ((struct memoryInfoLines * (*)(const char *))global[105])
141 /* 106 */ #define freeMemoryInfoLines ((void (*)(struct memoryInfoLines *))global[106])
142 /* 107 */ #define get_botwise_prefered_bot ((struct ClientSocket * (*)(int, int))global[107])
143 /* 108 */ #define register_command ((int (*)(int, char *, int, cmd_bind_t *, int, char *, int, unsigned int))global[108])
144 /* 109 */ #define set_trigger_callback ((int (*)(int, int, trigger_callback_t *))global[109])
145 /* 110 */ #define flush_trigger_cache ((int (*)(int, int))global[110])
146 /* 111 */ #define changeBotwiseChannelTrigger ((int (*)(int, int, struct ChanNode *, char *))global[111])
147 /* 112 */ #define bind_botwise_cmd_to_function ((int (*)(int, int, char *, struct cmd_function *))global[112])
148 /* 113 */ #define bind_botwise_cmd_to_command ((int (*)(int, int, char *, char *))global[113])
149 /* 114 */ #define unbind_botwise_cmd ((int (*)(int, int, char *))global[114])
150 /* 115 */ #define unbind_botwise_allcmd ((int (*)(int, int))global[115])
151 /* 116 */ #define bind_botwise_set_parameters ((void (*)(int, int, char *, char *))global[116])
152 /* 117 */ #define bind_botwise_set_global_access ((void (*)(int, int, char *, int))global[117])
153 /* 118 */ #define bind_botwise_set_channel_access ((void (*)(int, int, char *, char *))global[118])
154 /* 119 */ #define bind_botwise_set_bind_flags ((void (*)(int, int, char *, unsigned int))global[119])
155 /* 120 */ #define find_botwise_cmd_binding ((struct cmd_binding * (*)(int, int, char *))global[120])
156 /* 121 */ #define bind_botwise_unbound_required_functions ((void (*)(int, int))global[121])
157 /* 122 */ #define find_cmd_function ((struct cmd_function * (*)(int , char *))global[122])
158 /* 123 */ /* deprecated */
159 /* 124 */ #define register_command_alias ((void (*)(int, char *))global[124])
160 /* 125 */ #define getAllBinds ((struct cmd_binding * (*)(struct cmd_binding *))global[125])
161 /* 126 */ #define createModeNode ((struct ModeNode * (*)(struct ChanNode *))global[126])
162 /* 127 */ #define freeModeNode ((void (*)(struct ModeNode *))global[127])
163 /* 128 */ #define isModeSet ((int (*)(struct ModeNode *, char))global[128])
164 /* 129 */ #define isModeAffected ((int (*)(struct ModeNode *, char))global[129])
165 /* 130 */ #define getModeValue ((void * (*)(struct ModeNode *, char))global[130])
166 /* 131 */ #define getModeType ((unsigned int (*)(struct ModeNode *, char))global[131])
167 /* 132 */ #define parseModes ((void (*)(struct ModeNode *, char *, char **, int))global[132])
168 /* 133 */ #define parseModeString ((void (*)(struct ModeNode *, char *))global[133])
169 /* 134 */ #define parseMode ((int (*)(struct ModeNode *, int, char, char *))global[134])
170 /* 135 */ #define getModeString ((void (*)(struct ModeNode *, char *))global[135])
171 /* 136 */ #define getFullModeString ((void (*)(struct ModeNode *, char *))global[136])
172 /* 137 */ #define mysql_use ((MYSQL_RES * (*)(void))global[137])
173 /* 138 */ #define mysql_free ((void (*)(void))global[138])
174 /* 139 */ #define printf_mysql_query ((void (*)(const char *, ...))global[139])
175 /* 140 */ #define printf_long_mysql_query ((void (*)(int, const char *, ...))global[140])
176 /* 141 */ #define escape_string ((char * (*)(const char *))global[141])
177 /* 142 */ #define get_mysql_conn ((MYSQL * (*)(void))global[142])
178 /* 143 */ #define timeq_add ((struct timeq_entry * (*)(int, int, timeq_callback_t *, void *))global[143])
179 /* 144 */ #define timeq_uadd ((struct timeq_entry * (*)(int, int, timeq_callback_t *, void *))global[144])
180 /* 145 */ #define timeq_add_name ((struct timeq_entry * (*)(char *, int, int, timeq_callback_t *, void *))global[145])
181 /* 146 */ #define timeq_uadd_name ((struct timeq_entry * (*)(char *, int, int, timeq_callback_t *, void *))global[146])
182 /* 147 */ #define timeq_del ((int (*)(struct timeq_entry *))global[147])
183 /* 148 */ #define timeq_del_name ((int (*)(char *))global[148])
184 /* 149 */ #define timeq_name_exists ((int (*)(char *))global[149])
185 /* 150 */ #define match ((int (*)(const char *, const char *))global[150])
186 /* 151 */ #define table_init ((struct Table * (*)(int, int, int))global[151])
187 /* 152 */ #define table_add ((int (*)(struct Table *, char **))global[152])
188 /* 153 */ #define table_change ((int (*)(struct Table *, int, char **))global[153])
189 /* 154 */ #define table_change_field ((int (*)(struct Table *, int, int, char *))global[154])
190 /* 155 */ #define table_set_bold ((int (*)(struct Table *, int, int))global[155])
191 /* 156 */ #define table_end ((char ** (*)(struct Table *))global[156])
192 /* 157 */ #define table_free ((void (*)(struct Table *))global[157])
193 /* 158 */ #define timeToStr ((char * (*)(struct UserNode *, int, int, char *))global[158])
194 /* 159 */ #define strToTime ((int (*)(struct UserNode *, char *))global[159])
195 /* 160 */ #define initModeBuffer ((struct ModeBuffer * (*)(struct ClientSocket *, struct ChanNode *))global[160])
196 /* 161 */ #define modeBufferSet ((void (*)(struct ModeBuffer *, int, char, char *))global[161])
197 /* 162 */ #define flushModeBuffer ((void (*)(struct ModeBuffer *))global[162])
198 /* 163 */ #define freeModeBuffer ((void (*)(struct ModeBuffer *))global[163])
199 /* 164 */ #define is_ircmask ((int (*)(const char *))global[164])
200 /* 165 */ #define generate_banmask ((char * (*)(struct UserNode *, char *))global[165])
201 /* 166 */ #define make_banmask ((char * (*)(char *, char *))global[166])
202 /* 167 */ #define isFakeHost ((int (*)(char *))global[167])
203 /* 168 */ #define mask_match ((int (*)(char *, struct UserNode *))global[168])
204 /* 169 */ #define crc32 ((unsigned long (*)(const char *))global[169])
205 /* 170 */ #define is_valid_nick ((int (*)(const char *))global[170])
206 /* 171 */ #define getUserByNick ((struct UserNode * (*)(const char *))global[171])
207 /* 172 */ #define getUserByMask ((struct UserNode * (*)(const char *))global[172])
208 /* 173 */ #define countUsersWithHost ((int (*)(char *))global[173])
209 /* 174 */ #define getAuthFakehost ((char * (*)(char *))global[174])
210 /* 175 */ #define searchUserByNick ((struct UserNode * (*)(const char *))global[175])
211 /* 176 */ #define getAllUsers ((struct UserNode * (*)(struct UserNode *))global[176])
212 /* 177 */ #define getUsersWithAuth ((struct UserNode * (*)(const char *, struct UserNode *))global[177])
213 /* 178 */ #define getUserCount ((int (*)(void))global[178])
214 /* 179 */ #define createTempUser ((struct UserNode * (*)(const char *))global[179])
215 /* 180 */ #define createTempUserMask ((struct UserNode * (*)(const char *))global[180])
216 /* 181 */ #define get_userlist ((void (*)(struct ChanNode *, int, userlist_callback_t, void *))global[181])
217 /* 182 */ #define _get_userlist_with_invisible ((void (*)(struct ChanNode *, int, userlist_callback_t, void *, int))global[182])
218 /* 183 */ #define get_userauth ((void (*)(struct UserNode *, int, userauth_callback_t, void *))global[183])
219 /* 184 */ #define get_compilation ((const char * (*)(void))global[184])
220 /* 185 */ #define get_creation ((const char * (*)(void))global[185])
221 /* 186 */ #define get_revision ((const char * (*)(void))global[186])
222 /* 187 */ #define get_codelines ((const char * (*)(void))global[187])
223 /* 188 */ #define get_patchlevel ((const int (*)(void))global[188])
224 /* 189 */ #define get_module_name ((char * (*)(int))global[189])
225 /* 190 */ #define isUserModeSet ((int (*)(struct UserNode *, char))global[190])
226 /* 191 */ #define module_global_cmd_register_neonbackup ((void (*)(char *))global[191])
227 /* 192 */ #define module_global_cmd_unregister_neonbackup ((void (*)(char *))global[192])
228 /* 193 */ #define module_neonbackup_recover_chan ((void (*)(struct ChanNode *))global[193])
229 /* 194 */ #define requestInvite ((void (*)(struct UserNode *, struct ChanNode *))global[194])
230 /* 195 */ #define is_stable_revision ((const int (*)(void))global[195])
231 /* 196 */ #define get_dev_revision ((const char * (*)(void))global[196])
232 /* 197 */ #define bind_freeclient ((int (*)(freeclient_func_t *, int))global[197])
233 /* 198 */ #define unbind_freeclient ((void (*)(freeclient_func_t *))global[198])
234
235 #define MODULE_HEADER(initfunc,startfunc,stopfunc) \
236     void **global = NULL; \
237     int module_id = 0; \
238     int init_module(void **functions, int modid) { \
239         global = functions; \
240         module_id = modid; \
241         return initfunc(); \
242     } \
243     void start_module(int type) { \
244         startfunc(type); \
245     } \
246     void stop_module(int type) { \
247         stopfunc(type); \
248     } \
249     int modversion() { \
250         return MODULE_VERSION; \
251     }
252
253 #endif