1 /************************************************************************ 2 * Unreal Internet Relay Chat Daemon, include/modules.h 3 * (C) Carsten V. Munk 2000 <stskeeps@tspre.org> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 1, or (at your option) 8 * any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 * 19 * $Id$ 20 */ 21 #ifndef MODULES_H 22 #define MODULES_H 23 #include "types.h" 24 #define MAXCUSTOMHOOKS 30 25 #define MAXHOOKTYPES 100 26 #define MAXCALLBACKS 30 27 #define MAXEFUNCTIONS 60 28 #if defined(_WIN32) 29 #define MOD_EXTENSION "dll" 30 #define DLLFUNC _declspec(dllexport) 31 #define irc_dlopen(x,y) LoadLibrary(x) 32 #define irc_dlclose FreeLibrary 33 #define irc_dlsym(x,y,z) z = (void *)GetProcAddress(x,y) 34 #define irc_dlerror our_dlerror 35 #elif defined(HPUX) 36 #define MOD_EXTENSION "so" 37 #define irc_dlopen(x,y) shl_load(x,y,0L) 38 #define irc_dlsym(x,y,z) shl_findsym(x,y,z) 39 #define irc_dlclose shl_unload 40 #define irc_dlerror() strerror(errno) 41 #else 42 #define MOD_EXTENSION "so" 43 #define irc_dlopen dlopen 44 #define irc_dlclose dlclose 45 #if defined(UNDERSCORE) 46 #define irc_dlsym(x,y,z) z = obsd_dlsym(x,y) 47 #else 48 #define irc_dlsym(x,y,z) z = dlsym(x,y) 49 #endif 50 #define irc_dlerror dlerror 51 #define DLLFUNC 52 #endif 53 54 #define EVENT(x) void (x) (void *data) 55 56 /* Casts to int, void, void *, and char * function pointers */ 57 #define TO_INTFUNC(x) (int (*)())(x) 58 #define TO_VOIDFUNC(x) (void (*)())(x) 59 #define TO_PVOIDFUNC(x) (void *(*)())(x) 60 #define TO_PCHARFUNC(x) (char *(*)())(x) 61 62 typedef struct _mod_symboltable Mod_SymbolDepTable; 63 typedef struct _event Event; 64 typedef struct _eventinfo EventInfo; 65 typedef struct _irchook Hook; 66 typedef struct _hooktype Hooktype; 67 typedef struct _irccallback Callback; 68 typedef struct _ircefunction Efunction; 69 70 /* 71 * Module header that every module must include, with the name of 72 * mod_header 73 */ 74 75 typedef struct _ModuleHeader { 76 char *name; 77 char *version; 78 char *description; 79 char *modversion; 80 Mod_SymbolDepTable *symdep; 81 } ModuleHeader; 82 83 /* 84 * One piece of Borg ass.. 85 */ 86 typedef struct _Module Module; 87 88 typedef struct _ModuleChild 89 { 90 struct _ModuleChild *prev, *next; 91 Module *child; /* Aww. aint it cute? */ 92 } ModuleChild; 93 94 typedef struct { 95 int size; 96 int module_load; 97 Module *handle; 98 } ModuleInfo; 99 100 101 #define MOBJ_EVENT 0x0001 102 #define MOBJ_HOOK 0x0002 103 #define MOBJ_COMMAND 0x0004 104 #define MOBJ_HOOKTYPE 0x0008 105 #define MOBJ_VERSIONFLAG 0x0010 106 #define MOBJ_SNOMASK 0x0020 107 #define MOBJ_UMODE 0x0040 108 #define MOBJ_CMDOVERRIDE 0x0080 109 #define MOBJ_EXTBAN 0x0100 110 #define MOBJ_CALLBACK 0x0200 111 #define MOBJ_ISUPPORT 0x0400 112 #define MOBJ_EFUNCTION 0x0800 113 #define MOBJ_CMODE 0x1000 114 115 typedef struct { 116 long mode; 117 char flag; 118 int (*allowed)(aClient *sptr, int what); 119 char unloaded; 120 Module *owner; 121 } Umode; 122 123 typedef struct { 124 long mode; 125 char flag; 126 int (*allowed)(aClient *sptr, int what); 127 char unloaded; 128 Module *owner; 129 } Snomask; 130 131 #ifdef EXTCMODE 132 #define EXCHK_ACCESS 0 /* Check access */ 133 #define EXCHK_ACCESS_ERR 1 /* Check access and send error if needed */ 134 #define EXCHK_PARAM 2 /* Check parameter and send error if needed */ 135 136 #define EXSJ_SAME 0 /* Parameters are the same */ 137 #define EXSJ_WEWON 1 /* We won! w00t */ 138 #define EXSJ_THEYWON 2 /* They won :( */ 139 140 /* return values for EXCHK_ACCESS*: */ 141 #define EX_DENY 0 /* Disallowed, except in case of operoverride */ 142 #define EX_ALLOW 1 /* Allowed */ 143 #define EX_ALWAYS_DENY -1 /* Disallowed, even in case of operoverride 144 * (eg: for operlevel modes like +A) 145 */ 146 147 /** Extended channel mode table. 148 * This table contains all extended channelmode info like the flag, mode, their 149 * functions, etc.. 150 */ 151 typedef unsigned long Cmode_t; 152 153 #define EXTCM_PAR_HEADER struct _CmodeParam *prev, *next; char flag; 154 155 typedef struct _CmodeParam { 156 EXTCM_PAR_HEADER 157 /** other fields are placed after this header in your own paramstruct */ 158 } CmodeParam; 159 160 typedef struct { 161 /** mode character (like 'Z') */ 162 char flag; 163 164 /** unique flag (like 0x10) */ 165 Cmode_t mode; 166 167 /** # of paramters (1 or 0) */ 168 int paracount; 169 170 /** access and parameter checking. 171 * aClient *: the client 172 * aChannel *: the channel 173 * para *: the parameter (NULL for paramless modes) 174 * int: check type (see EXCHK_*) 175 * int: what (MODE_ADD or MODE_DEL) 176 * return value: 1=ok, 0=bad 177 */ 178 int (*is_ok)(aClient *,aChannel *, char *para, int, int); 179 180 /** NOTE: The routines below are NULL for paramless modes */ 181 182 /** Store parameter in memory for channel. 183 * aExtCMtableParam *: the list (usually chptr->mode.extmodeparams). 184 * char *: the parameter. 185 * return value: the head of the list, RTFS if you wonder why. 186 * design notes: only alloc a new paramstruct if you need to, search for 187 * any current one first (like in case of mode +y 5 and then +y 6 later without -y). 188 */ 189 CmodeParam * (*put_param)(CmodeParam *, char *); 190 191 /** Get readable string version" of the stored parameter. 192 * aExtCMtableParam *: the list (usually chptr->mode.extmodeparams). 193 * return value: a pointer to the string (temp. storage) 194 */ 195 char * (*get_param)(CmodeParam *); 196 197 /** Convert input parameter to output. 198 * Like +l "1aaa" becomes "1". 199 * char *: the input parameter. 200 * return value: pointer to output string (temp. storage) 201 */ 202 char * (*conv_param)(char *); 203 204 /** free and remove parameter from list. 205 * aExtCMtableParam *: the list (usually chptr->mode.extmodeparams). 206 */ 207 void (*free_param)(CmodeParam *); 208 209 /** duplicate a struct and return a pointer to duplicate. 210 * This is usually just a malloc + memcpy. 211 * aExtCMtableParam *: source struct itself (no list). 212 * return value: pointer to newly allocated struct. 213 */ 214 CmodeParam * (*dup_struct)(CmodeParam *); 215 216 /** Compares 2 parameters and decides who wins the sjoin fight. 217 * When syncing channel modes (m_sjoin) a parameter conflict may occur, things like 218 * +l 5 vs +l 10. This function should determinate who wins the fight, this decision 219 * should of course not be random but the same at every server on the net. 220 * examples of such comparisons are "highest wins" (+l) and a strcmp() check (+k/+L). 221 * aChannel *: channel the fight is about. 222 * aExtCMtableParam *: our parameter 223 * aExtCMtableParam *: their parameter 224 */ 225 int (*sjoin_check)(aChannel *, CmodeParam *, CmodeParam *); 226 227 /** Local channel mode? Prevents remote servers from setting/unsetting this */ 228 char local; 229 230 /** Is this mode being unloaded? 231 * This is set to 1 if the chanmode module providing this mode is unloaded 232 * and we are waiting to see if in our new round of loads a "new" chanmode 233 * module will popup to take this mode. This only happens during a rehash, 234 * should never be 0 outside an internal rehash. 235 */ 236 char unloaded; 237 238 /** Module owner */ 239 Module *owner; 240 } Cmode; 241 242 typedef struct { 243 char flag; 244 int paracount; 245 int (*is_ok)(aClient *,aChannel *, char *para, int, int); 246 CmodeParam * (*put_param)(CmodeParam *, char *); 247 char * (*get_param)(CmodeParam *); 248 char * (*conv_param)(char *); 249 void (*free_param)(CmodeParam *); 250 CmodeParam * (*dup_struct)(CmodeParam *); 251 int (*sjoin_check)(aChannel *, CmodeParam *, CmodeParam *); 252 char local; 253 } CmodeInfo; 254 #endif 255 256 /*** Extended bans ***/ 257 258 #define EXBCHK_ACCESS 0 /* Check access */ 259 #define EXBCHK_ACCESS_ERR 1 /* Check access and send error */ 260 #define EXBCHK_PARAM 2 /* Check if the parameter is valid */ 261 262 #define EXBTYPE_BAN 0 /* a ban */ 263 #define EXBTYPE_EXCEPT 1 /* an except */ 264 #define EXBTYPE_INVEX 2 /* an invite exception */ 265 266 #define EXTBANTABLESZ 32 267 268 typedef enum ExtbanOptions { EXTBOPT_CHSVSMODE=0x1, EXTBOPT_ACTMODIFIER=0x2, EXTBOPT_NOSTACKCHILD=0x4, EXTBOPT_INVEX=0x8 } ExtbanOptions; 269 270 typedef struct { 271 /** extbans module */ 272 Module *owner; 273 /** extended ban character */ 274 char flag; 275 276 /** extban options */ 277 ExtbanOptions options; 278 279 /** access checking [optional]. 280 * aClient *: the client 281 * aChannel *: the channel 282 * para: the ban parameter 283 * int: check type (see EXBCHK_*) 284 * int: what (MODE_ADD or MODE_DEL) 285 * int: what2 (EXBTYPE_BAN or EXBTYPE_EXCEPT) 286 * return value: 1=ok, 0=bad 287 * NOTE: just set this of NULL if you want only +hoaq to place/remove bans as usual. 288 * NOTE2: This has not been tested yet!! 289 */ 290 int (*is_ok)(aClient *, aChannel *, char *para, int, int, int); 291 292 /** Convert input parameter to output [optional]. 293 * like with normal bans '+b blah' gets '+b blah!*@*', and it allows 294 * you to limit the length of the ban too. You can set this to NULL however 295 * to use the value as-is. 296 * char *: the input parameter. 297 * return value: pointer to output string (temp. storage) 298 */ 299 char * (*conv_param)(char *); 300 301 /** Checks if the user is affected by this ban [required]. 302 * Called from is_banned. 303 * aClient *: the client 304 * aChannel *: the channel 305 * para: the ban entry 306 * int: a value of BANCHK_* (see struct.h) 307 */ 308 int (*is_banned)(aClient *, aChannel *, char *, int); 309 } Extban; 310 311 typedef struct { 312 char flag; 313 ExtbanOptions options; 314 int (*is_ok)(aClient *, aChannel *, char *para, int, int, int); 315 char * (*conv_param)(char *); 316 int (*is_banned)(aClient *, aChannel *, char *, int); 317 } ExtbanInfo; 318 319 320 typedef struct _command { 321 struct _command *prev, *next; 322 aCommand *cmd, *tok; 323 } Command; 324 325 typedef struct _versionflag { 326 struct _versionflag *prev, *next; 327 char flag; 328 ModuleChild *parents; 329 } Versionflag; 330 331 typedef struct _isupport { 332 struct _isupport *prev, *next; 333 char *token; 334 char *value; 335 Module *owner; 336 } Isupport; 337 338 typedef struct _ModuleObject { 339 struct _ModuleObject *prev, *next; 340 short type; 341 union { 342 Event *event; 343 Hook *hook; 344 Command *command; 345 Hooktype *hooktype; 346 Versionflag *versionflag; 347 Snomask *snomask; 348 Umode *umode; 349 Cmdoverride *cmdoverride; 350 Extban *extban; 351 Callback *callback; 352 Efunction *efunction; 353 Isupport *isupport; 354 Cmode *cmode; 355 } object; 356 } ModuleObject; 357 358 struct _irchook { 359 Hook *prev, *next; 360 short type; 361 union { 362 int (*intfunc)(); 363 void (*voidfunc)(); 364 char *(*pcharfunc)(); 365 } func; 366 Module *owner; 367 }; 368 369 struct _irccallback { 370 Callback *prev, *next; 371 short type; 372 union { 373 int (*intfunc)(); 374 void (*voidfunc)(); 375 char *(*pcharfunc)(); 376 } func; 377 Module *owner; 378 char willberemoved; /* will be removed on next rehash? (eg the 'old'/'current' one) */ 379 }; 380 381 /* Definition of an efunction: a MANDATORY Extern Function (in a module), 382 * for things like do_join, join_channel, etc. 383 * The difference between callbacks and efunctions are: 384 * - efunctions are mandatory, while callbacks can be optional (depends!) 385 * - efunctions are ment for internal usage, so 3rd party modules are not allowed 386 * to add them. 387 * - all efunctions are declared as function pointers in modules.c 388 */ 389 struct _ircefunction { 390 Efunction *prev, *next; 391 short type; 392 union { 393 int (*intfunc)(); 394 void (*voidfunc)(); 395 void *(*pvoidfunc)(); 396 char *(*pcharfunc)(); 397 } func; 398 Module *owner; 399 char willberemoved; /* will be removed on next rehash? (eg the 'old'/'current' one) */ 400 }; 401 402 struct _hooktype { 403 short id; 404 char *string; 405 ModuleChild *parents; 406 }; 407 /* 408 * What we use to keep track internally of the modules 409 */ 410 411 #define MODERR_NOERROR 0 412 #define MODERR_EXISTS 1 413 #define MODERR_NOSPACE 2 414 #define MODERR_INVALID 3 415 #define MODERR_NOTFOUND 4 416 417 unsigned int ModuleGetError(Module *module); 418 const char *ModuleGetErrorStr(Module *module); 419 unsigned int ModuleGetOptions(Module *module); 420 unsigned int ModuleSetOptions(Module *module, unsigned int options); 421 422 struct _Module 423 { 424 struct _Module *prev, *next; 425 ModuleHeader *header; /* The module's header */ 426 #ifdef _WIN32 427 HMODULE dll; /* Return value of LoadLibrary */ 428 #elif defined(HPUX) 429 shl_t dll; 430 #else 431 void *dll; /* Return value of dlopen */ 432 #endif 433 unsigned char flags; /* 8-bits for flags .. [<- this is misleading, there's mod->flags = .. everywhere] */ 434 ModuleChild *children; 435 ModuleObject *objects; 436 ModuleInfo modinfo; /* Used to store handle info for module */ 437 unsigned char options; 438 unsigned char errorcode; 439 char *tmp_file; 440 unsigned long mod_sys_version; 441 unsigned int compiler_version; 442 }; 443 /* 444 * Symbol table 445 */ 446 447 #define MOD_OPT_PERM 0x0001 /* Permanent module (not unloadable) */ 448 #define MOD_OPT_OFFICIAL 0x0002 /* Official module, do not set "tainted" */ 449 450 struct _mod_symboltable 451 { 452 #ifndef STATIC_LINKING 453 char *symbol; 454 #else 455 void *realfunc; 456 #endif 457 vFP *pointer; 458 #ifndef STATIC_LINKING 459 char *module; 460 #endif 461 }; 462 463 #ifndef STATIC_LINKING 464 #define MOD_Dep(name, container,module) {#name, (vFP *) &container, module} 465 #else 466 #define MOD_Dep(name, container,module) {(void *)&name, (vFP *) &container} 467 #endif 468 /* Event structs */ 469 struct _event { 470 Event *prev, *next; 471 char *name; 472 time_t every; 473 long howmany; 474 vFP event; 475 void *data; 476 time_t last; 477 Module *owner; 478 }; 479 480 #define EMOD_EVERY 0x0001 481 #define EMOD_HOWMANY 0x0002 482 #define EMOD_NAME 0x0004 483 #define EMOD_EVENT 0x0008 484 #define EMOD_DATA 0x0010 485 486 struct _eventinfo { 487 int flags; 488 long howmany; 489 time_t every; 490 char *name; 491 vFP event; 492 void *data; 493 }; 494 495 496 /* Huh? Why are those not marked as extern?? -- Syzop */ 497 498 #define EventAdd(name, every, howmany, event, data) EventAddEx(NULL, name, every, howmany, event, data) 499 Event *EventAddEx(Module *, char *name, long every, long howmany, 500 vFP event, void *data); 501 Event *EventDel(Event *event); 502 Event *EventMarkDel(Event *event); 503 Event *EventFind(char *name); 504 int EventMod(Event *event, EventInfo *mods); 505 void DoEvents(void); 506 void EventStatus(aClient *sptr); 507 void SetupEvents(void); 508 void LockEventSystem(void); 509 void UnlockEventSystem(void); 510 extern MODVAR Hook *Hooks[MAXHOOKTYPES]; 511 extern MODVAR Hooktype Hooktypes[MAXCUSTOMHOOKS]; 512 extern MODVAR Callback *Callbacks[MAXCALLBACKS], *RCallbacks[MAXCALLBACKS]; 513 extern MODVAR Efunction *Efunctions[MAXEFUNCTIONS]; 514 515 void Module_Init(void); 516 char *Module_Create(char *path); 517 void Init_all_testing_modules(void); 518 void Unload_all_loaded_modules(void); 519 void Unload_all_testing_modules(void); 520 int Module_Unload(char *name, int unload); 521 vFP Module_Sym(char *name); 522 vFP Module_SymX(char *name, Module **mptr); 523 int Module_free(Module *mod); 524 525 #ifdef __OpenBSD__ 526 void *obsd_dlsym(void *handle, char *symbol); 527 #endif 528 529 Versionflag *VersionflagAdd(Module *module, char flag); 530 void VersionflagDel(Versionflag *vflag, Module *module); 531 532 Isupport *IsupportAdd(Module *module, const char *token, const char *value); 533 void IsupportSetValue(Isupport *isupport, const char *value); 534 void IsupportDel(Isupport *isupport); 535 Isupport *IsupportFind(const char *token); 536 537 #define add_Hook(hooktype, func) HookAddMain(NULL, hooktype, func, NULL, NULL) 538 #define HookAdd(hooktype, func) HookAddMain(NULL, hooktype, func, NULL, NULL) 539 #define HookAddEx(module, hooktype, func) HookAddMain(module, hooktype, func, NULL, NULL) 540 #define HookAddVoid(hooktype, func) HookAddMain(NULL, hooktype, NULL, func, NULL) 541 #define HookAddVoidEx(module, hooktype, func) HookAddMain(module, hooktype, NULL, func, NULL) 542 #define HookAddPChar(hooktype, func) HookAddMain(NULL, hooktype, NULL, NULL, func) 543 #define HookAddPCharEx(module, hooktype, func) HookAddMain(module, hooktype, NULL, NULL, func) 544 #define add_HookX(hooktype, func1, func2, func3) HookAddMain(NULL, hooktype, func1, func2, func3) 545 546 Hook *HookAddMain(Module *module, int hooktype, int (*intfunc)(), void (*voidfunc)(), char *(*pcharfunc)()); 547 Hook *HookDel(Hook *hook); 548 549 Hooktype *HooktypeAdd(Module *module, char *string, int *type); 550 void HooktypeDel(Hooktype *hooktype, Module *module); 551 552 #define RunHook0(hooktype) do { Hook *h; for (h = Hooks[hooktype]; h; h = h->next)(*(h->func.intfunc))(); } while(0) 553 #define RunHook(hooktype,x) do { Hook *h; for (h = Hooks[hooktype]; h; h = h->next) (*(h->func.intfunc))(x); } while(0) 554 #define RunHookReturn(hooktype,x,ret) do { Hook *h; for (h = Hooks[hooktype]; h; h = h->next) if((*(h->func.intfunc))(x) ret) return -1; } while(0) 555 #define RunHookReturnInt(hooktype,x,retchk) \ 556 { \ 557 int retval; \ 558 Hook *h; \ 559 for (h = Hooks[hooktype]; h; h = h->next) \ 560 { \ 561 retval = (*(h->func.intfunc))(x); \ 562 if (retval retchk) return retval; \ 563 } \ 564 } 565 #define RunHookReturnInt2(hooktype,x,y,retchk) \ 566 { \ 567 int retval; \ 568 Hook *h; \ 569 for (h = Hooks[hooktype]; h; h = h->next) \ 570 { \ 571 retval = (*(h->func.intfunc))(x,y); \ 572 if (retval retchk) return retval; \ 573 } \ 574 } 575 576 #define RunHookReturnVoid(hooktype,x,ret) do { Hook *h; for (h = Hooks[hooktype]; h; h = h->next) if((*(h->func.intfunc))(x) ret) return; } while(0) 577 #define RunHook2(hooktype,x,y) do { Hook *h; for (h = Hooks[hooktype]; h; h = h->next) (*(h->func.intfunc))(x,y); } while(0) 578 #define RunHook3(hooktype,a,b,c) do { Hook *h; for (h = Hooks[hooktype]; h; h = h->next) (*(h->func.intfunc))(a,b,c); } while(0) 579 #define RunHook4(hooktype,a,b,c,d) do { Hook *h; for (h = Hooks[hooktype]; h; h = h->next) (*(h->func.intfunc))(a,b,c,d); } while(0) 580 #define RunHook5(hooktype,a,b,c,d,e) do { Hook *h; for (h = Hooks[hooktype]; h; h = h->next) (*(h->func.intfunc))(a,b,c,d,e); } while(0) 581 #define RunHook6(hooktype,a,b,c,d,e,f) do { Hook *h; for (h = Hooks[hooktype]; h; h = h->next) (*(h->func.intfunc))(a,b,c,d,e,f); } while(0) 582 #define RunHook7(hooktype,a,b,c,d,e,f,g) do { Hook *h; for (h = Hooks[hooktype]; h; h = h->next) (*(h->func.intfunc))(a,b,c,d,e,f,g); } while(0) 583 584 #define CallbackAdd(cbtype, func) CallbackAddMain(NULL, cbtype, func, NULL, NULL) 585 #define CallbackAddEx(module, cbtype, func) CallbackAddMain(module, cbtype, func, NULL, NULL) 586 #define CallbackAddVoid(cbtype, func) CallbackAddMain(NULL, cbtype, NULL, func, NULL) 587 #define CallbackAddVoidEx(module, cbtype, func) CallbackAddMain(module, cbtype, NULL, func, NULL) 588 #define CallbackAddPChar(cbtype, func) CallbackAddMain(NULL, cbtype, NULL, NULL, func) 589 #define CallbackAddPCharEx(module, cbtype, func) CallbackAddMain(module, cbtype, NULL, NULL, func) 590 591 extern Callback *CallbackAddMain(Module *module, int cbtype, int (*intfunc)(), void (*voidfunc)(), char *(*pcharfunc)()); 592 extern Callback *CallbackDel(Callback *cb); 593 594 #define EfunctionAdd(module, cbtype, func) EfunctionAddMain(module, cbtype, func, NULL, NULL, NULL) 595 #define EfunctionAddVoid(module, cbtype, func) EfunctionAddMain(module, cbtype, NULL, func, NULL, NULL) 596 #define EfunctionAddPVoid(module, cbtype, func) EfunctionAddMain(module, cbtype, NULL, NULL, func, NULL) 597 #define EfunctionAddPChar(module, cbtype, func) EfunctionAddMain(module, cbtype, NULL, NULL, NULL, func) 598 599 extern Efunction *EfunctionAddMain(Module *module, int eftype, int (*intfunc)(), void (*voidfunc)(), void *(*pvoidfunc)(), char *(*pcharfunc)()); 600 extern Efunction *EfunctionDel(Efunction *cb); 601 602 Command *CommandAdd(Module *module, char *cmd, char *tok, int (*func)(), unsigned char params, int flags); 603 void CommandDel(Command *command); 604 int CommandExists(char *name); 605 Cmdoverride *CmdoverrideAdd(Module *module, char *cmd, iFP function); 606 void CmdoverrideDel(Cmdoverride *ovr); 607 int CallCmdoverride(Cmdoverride *ovr, aClient *cptr, aClient *sptr, int parc, char *parv[]); 608 609 /* Hook types */ 610 #define HOOKTYPE_LOCAL_QUIT 1 611 #define HOOKTYPE_LOCAL_NICKCHANGE 2 612 #define HOOKTYPE_LOCAL_CONNECT 3 613 #define HOOKTYPE_REHASHFLAG 4 614 #define HOOKTYPE_PRE_LOCAL_PART 5 615 #define HOOKTYPE_CONFIGPOSTTEST 6 616 #define HOOKTYPE_REHASH 7 617 #define HOOKTYPE_PRE_LOCAL_CONNECT 8 618 #define HOOKTYPE_PRE_LOCAL_QUIT 9 619 #define HOOKTYPE_GUEST 10 620 #define HOOKTYPE_SERVER_CONNECT 11 621 #define HOOKTYPE_SERVER_QUIT 12 622 #define HOOKTYPE_STATS 13 623 #define HOOKTYPE_LOCAL_JOIN 14 624 #define HOOKTYPE_CONFIGTEST 15 625 #define HOOKTYPE_CONFIGRUN 16 626 /* If you ever change the number of usermsg & chanmsg, notify Syzop first, kthx! ;p */ 627 #define HOOKTYPE_USERMSG 17 628 #define HOOKTYPE_CHANMSG 18 629 #define HOOKTYPE_LOCAL_PART 19 630 #define HOOKTYPE_LOCAL_KICK 20 631 #define HOOKTYPE_LOCAL_CHANMODE 21 632 #define HOOKTYPE_LOCAL_TOPIC 22 633 #define HOOKTYPE_LOCAL_OPER 23 634 #define HOOKTYPE_UNKUSER_QUIT 24 635 #define HOOKTYPE_LOCAL_PASS 25 636 #define HOOKTYPE_REMOTE_CONNECT 26 637 #define HOOKTYPE_REMOTE_QUIT 27 638 #define HOOKTYPE_PRE_LOCAL_JOIN 28 639 #define HOOKTYPE_PRE_LOCAL_KICK 29 640 #define HOOKTYPE_PRE_LOCAL_TOPIC 30 641 #define HOOKTYPE_REMOTE_NICKCHANGE 31 642 #define HOOKTYPE_CHANNEL_CREATE 32 643 #define HOOKTYPE_CHANNEL_DESTROY 33 644 #define HOOKTYPE_REMOTE_CHANMODE 34 645 #define HOOKTYPE_TKL_EXCEPT 35 646 #define HOOKTYPE_UMODE_CHANGE 36 647 #define HOOKTYPE_TOPIC 37 648 #define HOOKTYPE_REHASH_COMPLETE 38 649 #define HOOKTYPE_TKL_ADD 39 650 #define HOOKTYPE_TKL_DEL 40 651 #define HOOKTYPE_LOCAL_KILL 41 652 #define HOOKTYPE_LOG 42 653 #define HOOKTYPE_REMOTE_JOIN 43 654 #define HOOKTYPE_REMOTE_PART 44 655 #define HOOKTYPE_REMOTE_KICK 45 656 #define HOOKTYPE_LOCAL_SPAMFILTER 46 657 #define HOOKTYPE_SILENCED 47 658 #define HOOKTYPE_POST_SERVER_CONNECT 48 659 #define HOOKTYPE_RAWPACKET_IN 49 660 #define HOOKTYPE_LOCAL_NICKPASS 50 661 #define HOOKTYPE_PACKET 51 662 #define HOOKTYPE_HANDSHAKE 52 663 #define HOOKTYPE_AWAY 53 664 665 /* Hook return values */ 666 #define HOOK_CONTINUE 0 667 #define HOOK_ALLOW -1 668 #define HOOK_DENY 1 669 670 /* Callback types */ 671 #define CALLBACKTYPE_CLOAK 1 672 #define CALLBACKTYPE_CLOAKKEYCSUM 2 673 #define CALLBACKTYPE_CLOAK_EX 3 674 675 /* Efunction types */ 676 #define EFUNC_DO_JOIN 1 677 #define EFUNC_JOIN_CHANNEL 2 678 #define EFUNC_CAN_JOIN 3 679 #define EFUNC_DO_MODE 4 680 #define EFUNC_SET_MODE 5 681 #define EFUNC_M_UMODE 6 682 #define EFUNC_REGISTER_USER 7 683 #define EFUNC_TKL_HASH 8 684 #define EFUNC_TKL_TYPETOCHAR 9 685 #define EFUNC_TKL_ADD_LINE 10 686 #define EFUNC_TKL_DEL_LINE 11 687 #define EFUNC_TKL_CHECK_LOCAL_REMOVE_SHUN 12 688 #define EFUNC_TKL_EXPIRE 13 689 #define EFUNC_TKL_CHECK_EXPIRE 14 690 #define EFUNC_FIND_TKLINE_MATCH 15 691 #define EFUNC_FIND_SHUN 16 692 #define EFUNC_FIND_SPAMFILTER_USER 17 693 #define EFUNC_FIND_QLINE 18 694 #define EFUNC_FIND_TKLINE_MATCH_ZAP 19 695 #define EFUNC_TKL_STATS 20 696 #define EFUNC_TKL_SYNCH 21 697 #define EFUNC_M_TKL 22 698 #define EFUNC_PLACE_HOST_BAN 23 699 #define EFUNC_DOSPAMFILTER 24 700 #define EFUNC_DOSPAMFILTER_VIRUSCHAN 25 701 #define EFUNC_FIND_TKLINE_MATCH_ZAP_EX 26 702 #define EFUNC_SEND_LIST 27 703 #define EFUNC_STRIPBADWORDS_CHANNEL 28 704 #define EFUNC_STRIPBADWORDS_MESSAGE 29 705 #define EFUNC_STRIPBADWORDS_QUIT 30 706 #define EFUNC_STRIPCOLORS 31 707 #define EFUNC_STRIPCONTROLCODES 32 708 #define EFUNC_SPAMFILTER_BUILD_USER_STRING 33 709 #define EFUNC_IS_SILENCED 34 710 #define EFUNC_SEND_PROTOCTL_SERVERS 35 711 #define EFUNC_VERIFY_LINK 36 712 #define EFUNC_SEND_SERVER_MESSAGE 37 713 714 /* Module flags */ 715 #define MODFLAG_NONE 0x0000 716 #define MODFLAG_LOADED 0x0001 /* Fully loaded */ 717 #define MODFLAG_TESTING 0x0002 /* Not yet initialized */ 718 #define MODFLAG_INIT 0x0004 /* Initialized */ 719 #define MODFLAG_DELAYED 0x0008 /* Delayed unload */ 720 721 /* Module function return values */ 722 #define MOD_SUCCESS 0 723 #define MOD_FAILED -1 724 #define MOD_DELAY 2 725 726 #define CONFIG_MAIN 1 727 #define CONFIG_SET 2 728 #define CONFIG_BAN 3 729 #define CONFIG_EXCEPT 4 730 #define CONFIG_DENY 5 731 #define CONFIG_ALLOW 6 732 #define CONFIG_CLOAKKEYS 7 733 734 #ifdef DYNAMIC_LINKING 735 #define MOD_HEADER(name) Mod_Header 736 #define MOD_TEST(name) Mod_Test 737 #define MOD_INIT(name) Mod_Init 738 #define MOD_LOAD(name) Mod_Load 739 #define MOD_UNLOAD(name) Mod_Unload 740 #else 741 #define MOD_HEADER(name) name##_Header 742 #define MOD_TEST(name) name##_Test 743 #define MOD_INIT(name) name##_Init 744 #define MOD_LOAD(name) name##_Load 745 #define MOD_UNLOAD(name) name##_Unload 746 #endif 747 748 #define CLOAK_KEYCRC RCallbacks[CALLBACKTYPE_CLOAKKEYCSUM]->func.pcharfunc() 749 750 #ifdef DYNAMIC_LINKING 751 #include "modversion.h" 752 #endif 753 754 #endif 755 756