~ubuntu-branches/ubuntu/trusty/charybdis/trusty-proposed

« back to all changes in this revision

Viewing changes to include/modules.h

  • Committer: Package Import Robot
  • Author(s): Antoine Beaupré
  • Date: 2011-11-10 23:07:37 UTC
  • Revision ID: package-import@ubuntu.com-20111110230737-kqo6qsglp5oh02hr
Tags: upstream-3.3.0
Import upstream version 3.3.0

Show diffs side-by-side

added added

removed removed

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