2 * ircd-ratbox: A slightly useful ircd.
3 * modules.h: A header for the modules functions.
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
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.
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.
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
25 #ifndef INCLUDED_modules_h
26 #define INCLUDED_modules_h
31 #include "client.h" /* for IDLEN */
33 #define MAPI_CHARYBDIS 2
44 const char *description
;
46 int core
; /* This is int for backwards compat reasons */
47 int origin
; /* Ditto */
49 void *mapi_header
; /* actually struct mapi_mheader_av<mapi_version> */
53 #define MAPI_MAGIC_HDR 0x4D410000
55 #define MAPI_V1 (MAPI_MAGIC_HDR | 0x1)
56 #define MAPI_V2 (MAPI_MAGIC_HDR | 0x2)
58 #define MAPI_MAGIC(x) ((x) & 0xffff0000)
59 #define MAPI_VERSION(x) ((x) & 0x0000ffff)
61 typedef struct Message
* mapi_clist_av1
;
65 const char *hapi_name
;
71 const char *hapi_name
;
73 enum hook_priority priority
;
76 #define MAPI_CAP_CLIENT 1
77 #define MAPI_CAP_SERVER 2
81 int cap_index
; /* Which cap index does this belong to? */
82 const char *cap_name
; /* Capability name */
83 void *cap_ownerdata
; /* Not used much but why not... */
84 unsigned int *cap_id
; /* May be set to non-NULL to store cap id */
87 struct mapi_mheader_av1
89 int mapi_version
; /* Module API version */
90 int (*mapi_register
)(void); /* Register function; ret -1 = failure (unload) */
91 void (*mapi_unregister
)(void); /* Unregister function. */
92 mapi_clist_av1
*mapi_command_list
; /* List of commands to add. */
93 mapi_hlist_av1
*mapi_hook_list
; /* List of hooks to add. */
94 mapi_hfn_list_av1
*mapi_hfn_list
; /* List of hook_add_hook's to do */
95 const char *mapi_module_version
; /* Module's version (freeform) */
98 #define MAPI_ORIGIN_UNKNOWN 0 /* Unknown provenance (AV1 etc.) */
99 #define MAPI_ORIGIN_EXTENSION 1 /* Charybdis extension */
100 #define MAPI_ORIGIN_CORE 2 /* Charybdis core module */
102 struct mapi_mheader_av2
104 int mapi_version
; /* Module API version */
105 int (*mapi_register
)(void); /* Register function; ret -1 = failure (unload) */
106 void (*mapi_unregister
)(void); /* Unregister function. */
107 mapi_clist_av1
*mapi_command_list
; /* List of commands to add. */
108 mapi_hlist_av1
*mapi_hook_list
; /* List of hooks to add. */
109 mapi_hfn_list_av1
*mapi_hfn_list
; /* List of hook_add_hook's to do */
110 mapi_cap_list_av2
*mapi_cap_list
; /* List of CAPs to add */
111 const char *mapi_module_version
; /* Module's version (freeform), replaced with ircd version if NULL */
112 const char *mapi_module_description
; /* Module's description (freeform) */
113 unsigned long int mapi_datecode
; /* Unix timestamp of module's build */
116 #define DECLARE_MODULE_AV1(name, reg, unreg, cl, hl, hfnlist, v) \
117 struct mapi_mheader_av1 _mheader = { MAPI_V1, reg, unreg, cl, hl, hfnlist, v}
119 #define DECLARE_MODULE_AV2(name, reg, unreg, cl, hl, hfnlist, caplist, v, desc) \
120 struct mapi_mheader_av2 _mheader = { MAPI_V2, reg, unreg, cl, hl, hfnlist, caplist, v, desc, DATECODE}
124 char module[BUFSIZE
];
129 void mod_add_path(const char *path
);
130 void mod_clear_paths(void);
132 /* cap-notify utilities */
133 extern void mod_remember_clicaps(void);
134 extern void mod_notify_clicaps(void);
137 extern void load_module(char *path
);
139 /* load all modules */
140 extern void load_all_modules(bool warn
);
142 /* load core modules */
143 extern void load_core_modules(bool);
145 extern bool unload_one_module(const char *, bool);
146 extern bool load_one_module(const char *, int, bool);
147 extern bool load_a_module(const char *, bool, int, bool);
148 extern struct module *findmodule_byname(const char *);
149 extern void init_modules(void);
151 extern rb_dlink_list module_list
;
152 extern rb_dlink_list mod_paths
;
154 #endif /* INCLUDED_modules_h */