]> jfr.im git - irc/rqf/shadowircd.git/blame - include/modules.h
Add mr_flea (and Taros) to the list of Charybdis contributors.
[irc/rqf/shadowircd.git] / include / modules.h
CommitLineData
212380e3 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
23 *
212380e3 24 */
25
26#ifndef INCLUDED_modules_h
27#define INCLUDED_modules_h
28#include "config.h"
29#include "setup.h"
30#include "parse.h"
31
32#define MAPI_RATBOX 1
33
34#if defined(HAVE_SHL_LOAD)
35#include <dl.h>
36#endif
37#if !defined(STATIC_MODULES) && defined(HAVE_DLFCN_H)
38#include <dlfcn.h>
39#endif
40
41#include "msg.h"
212380e3 42#include "hook.h"
43
44struct module
45{
46 char *name;
47 const char *version;
48 void *address;
49 int core;
50 int mapi_version;
51 void * mapi_header; /* actually struct mapi_mheader_av<mapi_version> */
52};
53
54struct module_path
55{
56 char path[MAXPATHLEN];
57};
58
59#define MAPI_MAGIC_HDR 0x4D410000
60
61#define MAPI_V1 (MAPI_MAGIC_HDR | 0x1)
62
63#define MAPI_MAGIC(x) ((x) & 0xffff0000)
64#define MAPI_VERSION(x) ((x) & 0x0000ffff)
65
66typedef struct Message* mapi_clist_av1;
67
68typedef struct
69{
70 const char * hapi_name;
71 int * hapi_id;
72} mapi_hlist_av1;
73
74typedef struct
75{
76 const char * hapi_name;
77 hookfn fn;
78} mapi_hfn_list_av1;
79
80struct mapi_mheader_av1
81{
82 int mapi_version; /* Module API version */
83 int (*mapi_register) (void); /* Register function;
84 ret -1 = failure (unload) */
85 void (*mapi_unregister) (void); /* Unregister function. */
86 mapi_clist_av1 * mapi_command_list; /* List of commands to add. */
87 mapi_hlist_av1 * mapi_hook_list; /* List of hooks to add. */
88 mapi_hfn_list_av1 *mapi_hfn_list; /* List of hook_add_hook's to do */
89 const char * mapi_module_version; /* Module's version (freeform) */
90};
91
92#ifndef STATIC_MODULES
93# define DECLARE_MODULE_AV1(name,reg,unreg,cl,hl,hfnlist, v) \
94 struct mapi_mheader_av1 _mheader = { MAPI_V1, reg, unreg, cl, hl, hfnlist, v}
95#else
96# define DECLARE_MODULE_AV1(name,reg,unreg,cl,hl,hfnlist, v) \
97 struct mapi_mheader_av1 name ## _mheader = { MAPI_V1, reg, unreg, cl, hl, hfnlist, v}
98void load_static_modules(void);
99#endif
100
101/* add a path */
102void mod_add_path(const char *path);
103void mod_clear_paths(void);
104
105/* load a module */
106extern void load_module(char *path);
107
108/* load all modules */
109extern void load_all_modules(int warn);
110
111/* load core modules */
112extern void load_core_modules(int);
113
114extern int unload_one_module(const char *, int);
115extern int load_one_module(const char *, int);
116extern int load_a_module(const char *, int, int);
117extern int findmodule_byname(const char *);
212380e3 118extern void modules_init(void);
119
120#endif /* INCLUDED_modules_h */