diff options
author | Sadie Powell <sadie@witchery.services> | 2020-02-02 17:07:34 +0000 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2020-02-02 20:32:49 +0000 |
commit | aed712ba8e087232fcd9f71db4311687a7ce4398 (patch) | |
tree | fe06900c63293fabab60faf863bf97a390a0df20 /include/moduledefs.h | |
parent | fda43fc0ff5ecf87d877cc341961c9da4affae76 (diff) |
Make loading modules considerably more robust and user friendly.
Diffstat (limited to 'include/moduledefs.h')
-rw-r--r-- | include/moduledefs.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/include/moduledefs.h b/include/moduledefs.h new file mode 100644 index 000000000..a2bac63cb --- /dev/null +++ b/include/moduledefs.h @@ -0,0 +1,47 @@ +/* + * InspIRCd -- Internet Relay Chat Daemon + * + * Copyright (C) 2020 Sadie Powell <sadie@witchery.services> + * + * This file is part of InspIRCd. InspIRCd is free software: you can + * redistribute it and/or modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + + +#pragma once + +class Module; + +/** The version of the InspIRCd ABI which is presently in use. */ +#define MODULE_ABI 3010 + +/** Stringifies the value of a symbol. */ +#define MODULE_STRINGIFY_SYM1(DEF) MODULE_STRINGIFY_SYM2(DEF) +#define MODULE_STRINGIFY_SYM2(DEF) #DEF + +/** The name of the symbol which contains the ABI that a module was compiled against. */ +#define MODULE_SYM_ABI inspircd_module_abi +#define MODULE_STR_ABI MODULE_STRINGIFY_SYM1(MODULE_SYM_ABI) + +/** The name of the symbol which creates a new Module instance. */ +#define MODULE_SYM_INIT inspircd_module_init +#define MODULE_STR_INIT MODULE_STRINGIFY_SYM1(MODULE_SYM_INIT) + +/** The name of the symbol which contains the version that a module was compiled against. */ +#define MODULE_SYM_VERSION inspircd_module_version +#define MODULE_STR_VERSION MODULE_STRINGIFY_SYM1(MODULE_SYM_VERSION) + +/** Defines the interface that a shared library must expose in order to be a module. */ +#define MODULE_INIT(klass) \ + extern "C" DllExport const uint32_t MODULE_SYM_ABI = MODULE_ABI; \ + extern "C" DllExport const char MODULE_SYM_VERSION[] = INSPIRCD_VERSION; \ + extern "C" DllExport Module* MODULE_SYM_INIT() { return new klass; } |