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