]>
Commit | Line | Data |
---|---|---|
212380e3 AC |
1 | /* |
2 | * ircd-ratbox: A slightly useful ircd. | |
3 | * modules.h: A header for the modules functions. | |
4 | * | |
5 | * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center | |
6 | * Copyright (C) 1996-2002 Hybrid Development Team | |
7 | * Copyright (C) 2002-2004 ircd-ratbox development team | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License as published by | |
11 | * the Free Software Foundation; either version 2 of the License, or | |
12 | * (at your option) any later version. | |
13 | * | |
14 | * This program is distributed in the hope that it will be useful, | |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | * GNU General Public License for more details. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License | |
20 | * along with this program; if not, write to the Free Software | |
21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | |
22 | * USA | |
212380e3 AC |
23 | */ |
24 | ||
25 | #ifndef INCLUDED_modules_h | |
26 | #define INCLUDED_modules_h | |
27 | #include "config.h" | |
28 | #include "setup.h" | |
29 | #include "parse.h" | |
30 | ||
31 | #define MAPI_RATBOX 1 | |
32 | ||
f272e7ab | 33 | #include <ltdl.h> |
212380e3 AC |
34 | |
35 | #include "msg.h" | |
212380e3 AC |
36 | #include "hook.h" |
37 | ||
38 | struct module | |
39 | { | |
40 | char *name; | |
41 | const char *version; | |
f272e7ab | 42 | lt_dlhandle address; |
212380e3 AC |
43 | int core; |
44 | int mapi_version; | |
45 | void * mapi_header; /* actually struct mapi_mheader_av<mapi_version> */ | |
46 | }; | |
47 | ||
212380e3 AC |
48 | #define MAPI_MAGIC_HDR 0x4D410000 |
49 | ||
50 | #define MAPI_V1 (MAPI_MAGIC_HDR | 0x1) | |
51 | ||
52 | #define MAPI_MAGIC(x) ((x) & 0xffff0000) | |
53 | #define MAPI_VERSION(x) ((x) & 0x0000ffff) | |
54 | ||
55 | typedef struct Message* mapi_clist_av1; | |
56 | ||
57 | typedef struct | |
58 | { | |
59 | const char * hapi_name; | |
60 | int * hapi_id; | |
61 | } mapi_hlist_av1; | |
62 | ||
63 | typedef struct | |
64 | { | |
65 | const char * hapi_name; | |
66 | hookfn fn; | |
67 | } mapi_hfn_list_av1; | |
68 | ||
69 | struct mapi_mheader_av1 | |
70 | { | |
71 | int mapi_version; /* Module API version */ | |
72 | int (*mapi_register) (void); /* Register function; | |
73 | ret -1 = failure (unload) */ | |
74 | void (*mapi_unregister) (void); /* Unregister function. */ | |
75 | mapi_clist_av1 * mapi_command_list; /* List of commands to add. */ | |
76 | mapi_hlist_av1 * mapi_hook_list; /* List of hooks to add. */ | |
77 | mapi_hfn_list_av1 *mapi_hfn_list; /* List of hook_add_hook's to do */ | |
78 | const char * mapi_module_version; /* Module's version (freeform) */ | |
79 | }; | |
80 | ||
2a19fc3f | 81 | #define DECLARE_MODULE_AV1(name,reg,unreg,cl,hl,hfnlist, v) \ |
212380e3 | 82 | struct mapi_mheader_av1 _mheader = { MAPI_V1, reg, unreg, cl, hl, hfnlist, v} |
212380e3 AC |
83 | |
84 | /* add a path */ | |
85 | void mod_add_path(const char *path); | |
86 | void mod_clear_paths(void); | |
87 | ||
88 | /* load a module */ | |
89 | extern void load_module(char *path); | |
90 | ||
91 | /* load all modules */ | |
92 | extern void load_all_modules(int warn); | |
93 | ||
94 | /* load core modules */ | |
95 | extern void load_core_modules(int); | |
96 | ||
97 | extern int unload_one_module(const char *, int); | |
98 | extern int load_one_module(const char *, int); | |
99 | extern int load_a_module(const char *, int, int); | |
100 | extern int findmodule_byname(const char *); | |
212380e3 AC |
101 | extern void modules_init(void); |
102 | ||
103 | #endif /* INCLUDED_modules_h */ |