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