]>
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 | |
81204be8 | 27 | #include "serno.h" |
212380e3 AC |
28 | #include "config.h" |
29 | #include "setup.h" | |
30 | #include "parse.h" | |
31 | ||
8e9c6a75 | 32 | #define MAPI_CHARYBDIS 2 |
212380e3 | 33 | |
f272e7ab | 34 | #include <ltdl.h> |
212380e3 AC |
35 | |
36 | #include "msg.h" | |
212380e3 AC |
37 | #include "hook.h" |
38 | ||
39 | struct module | |
40 | { | |
41 | char *name; | |
42 | const char *version; | |
0eb7d9c0 | 43 | const char *description; |
f272e7ab | 44 | lt_dlhandle address; |
212380e3 | 45 | int core; |
c63aeb44 | 46 | int origin; |
212380e3 | 47 | int mapi_version; |
8e9c6a75 | 48 | void *mapi_header; /* actually struct mapi_mheader_av<mapi_version> */ |
212380e3 AC |
49 | }; |
50 | ||
212380e3 AC |
51 | #define MAPI_MAGIC_HDR 0x4D410000 |
52 | ||
53 | #define MAPI_V1 (MAPI_MAGIC_HDR | 0x1) | |
8e9c6a75 | 54 | #define MAPI_V2 (MAPI_MAGIC_HDR | 0x2) |
212380e3 AC |
55 | |
56 | #define MAPI_MAGIC(x) ((x) & 0xffff0000) | |
57 | #define MAPI_VERSION(x) ((x) & 0x0000ffff) | |
58 | ||
59 | typedef struct Message* mapi_clist_av1; | |
60 | ||
61 | typedef struct | |
62 | { | |
8e9c6a75 EM |
63 | const char *hapi_name; |
64 | int *hapi_id; | |
212380e3 AC |
65 | } mapi_hlist_av1; |
66 | ||
67 | typedef struct | |
68 | { | |
8e9c6a75 EM |
69 | const char *hapi_name; |
70 | hookfn fn; | |
212380e3 AC |
71 | } mapi_hfn_list_av1; |
72 | ||
8e9c6a75 EM |
73 | |
74 | #define MAPI_CAP_CLIENT 1 | |
75 | #define MAPI_CAP_SERVER 2 | |
76 | ||
77 | typedef struct | |
78 | { | |
79 | int cap_index; /* Which cap index does this belong to? */ | |
80 | const char *cap_name; /* Capability name */ | |
81 | void *cap_ownerdata; /* Not used much but why not... */ | |
eeabf33a | 82 | unsigned int *cap_id; /* May be set to non-NULL to store cap id */ |
8e9c6a75 EM |
83 | } mapi_cap_list_av2; |
84 | ||
212380e3 AC |
85 | struct mapi_mheader_av1 |
86 | { | |
8e9c6a75 EM |
87 | int mapi_version; /* Module API version */ |
88 | int (*mapi_register)(void); /* Register function; ret -1 = failure (unload) */ | |
89 | void (*mapi_unregister)(void); /* Unregister function. */ | |
90 | mapi_clist_av1 *mapi_command_list; /* List of commands to add. */ | |
91 | mapi_hlist_av1 *mapi_hook_list; /* List of hooks to add. */ | |
92 | mapi_hfn_list_av1 *mapi_hfn_list; /* List of hook_add_hook's to do */ | |
93 | const char *mapi_module_version; /* Module's version (freeform) */ | |
212380e3 AC |
94 | }; |
95 | ||
c63aeb44 | 96 | #define MAPI_ORIGIN_UNKNOWN 0 /* Unknown provenance (AV1 etc.) */ |
216d70e9 EM |
97 | #define MAPI_ORIGIN_EXTENSION 1 /* Charybdis extension */ |
98 | #define MAPI_ORIGIN_CORE 2 /* Charybdis core module */ | |
c63aeb44 | 99 | |
8e9c6a75 EM |
100 | struct mapi_mheader_av2 |
101 | { | |
102 | int mapi_version; /* Module API version */ | |
103 | int (*mapi_register)(void); /* Register function; ret -1 = failure (unload) */ | |
104 | void (*mapi_unregister)(void); /* Unregister function. */ | |
105 | mapi_clist_av1 *mapi_command_list; /* List of commands to add. */ | |
106 | mapi_hlist_av1 *mapi_hook_list; /* List of hooks to add. */ | |
107 | mapi_hfn_list_av1 *mapi_hfn_list; /* List of hook_add_hook's to do */ | |
108 | mapi_cap_list_av2 *mapi_cap_list; /* List of CAPs to add */ | |
109 | const char *mapi_module_version; /* Module's version (freeform), replaced with ircd version if NULL */ | |
110 | const char *mapi_module_description; /* Module's description (freeform) */ | |
81204be8 | 111 | unsigned long int mapi_datecode; /* Unix timestamp of module's build */ |
8e9c6a75 EM |
112 | }; |
113 | ||
114 | #define DECLARE_MODULE_AV1(name, reg, unreg, cl, hl, hfnlist, v) \ | |
212380e3 | 115 | struct mapi_mheader_av1 _mheader = { MAPI_V1, reg, unreg, cl, hl, hfnlist, v} |
212380e3 | 116 | |
216d70e9 | 117 | #define DECLARE_MODULE_AV2(name, reg, unreg, cl, hl, hfnlist, caplist, v, desc) \ |
81204be8 | 118 | struct mapi_mheader_av2 _mheader = { MAPI_V2, reg, unreg, cl, hl, hfnlist, caplist, v, desc, DATECODE} |
8e9c6a75 | 119 | |
212380e3 AC |
120 | /* add a path */ |
121 | void mod_add_path(const char *path); | |
122 | void mod_clear_paths(void); | |
123 | ||
124 | /* load a module */ | |
125 | extern void load_module(char *path); | |
126 | ||
127 | /* load all modules */ | |
128 | extern void load_all_modules(int warn); | |
129 | ||
130 | /* load core modules */ | |
131 | extern void load_core_modules(int); | |
132 | ||
133 | extern int unload_one_module(const char *, int); | |
216d70e9 EM |
134 | extern int load_one_module(const char *, int, int); |
135 | extern int load_a_module(const char *, int, int, int); | |
212380e3 | 136 | extern int findmodule_byname(const char *); |
212380e3 AC |
137 | extern void modules_init(void); |
138 | ||
139 | #endif /* INCLUDED_modules_h */ |