]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/moduledefs.h
82207524ce1d960926543613918a40a7f7163fbe
[user/henk/code/inspircd.git] / include / moduledefs.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2020 Sadie Powell <sadie@witchery.services>
5  *
6  * This file is part of InspIRCd.  InspIRCd is free software: you can
7  * redistribute it and/or modify it under the terms of the GNU General Public
8  * License as published by the Free Software Foundation, version 2.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18
19
20 #pragma once
21
22 class Module;
23
24 /** The version of the InspIRCd ABI which is presently in use. */
25 #define MODULE_ABI 3015UL
26
27 /** Stringifies the value of a symbol. */
28 #define MODULE_STRINGIFY_SYM1(DEF) MODULE_STRINGIFY_SYM2(DEF)
29 #define MODULE_STRINGIFY_SYM2(DEF) #DEF
30
31 /** The name of the symbol which contains the ABI that a module was compiled against. */
32 #define MODULE_SYM_ABI inspircd_module_abi
33 #define MODULE_STR_ABI MODULE_STRINGIFY_SYM1(MODULE_SYM_ABI)
34
35 /** The name of the symbol which creates a new Module instance. */
36 #define MODULE_SYM_INIT inspircd_module_init
37 #define MODULE_STR_INIT MODULE_STRINGIFY_SYM1(MODULE_SYM_INIT)
38
39 /** The name of the symbol which contains the version that a module was compiled against. */
40 #define MODULE_SYM_VERSION inspircd_module_version
41 #define MODULE_STR_VERSION MODULE_STRINGIFY_SYM1(MODULE_SYM_VERSION)
42
43 /** Defines the interface that a shared library must expose in order to be a module. */
44 #define MODULE_INIT(klass) \
45         extern "C" DllExport const unsigned long MODULE_SYM_ABI = MODULE_ABI; \
46         extern "C" DllExport const char MODULE_SYM_VERSION[] = INSPIRCD_VERSION; \
47         extern "C" DllExport Module* MODULE_SYM_INIT() { return new klass; }