From d4140b3c2673dbeca01f87df5d46d89c9bc532c7 Mon Sep 17 00:00:00 2001 From: "Robin Burchell w00t@inspircd.org" Date: Tue, 4 Nov 2008 20:28:49 +0000 Subject: New MODULE_INIT macro. I'm going to regret this. git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1546 5417fbe8-f217-4b02-8779-1006273d7864 --- include/services.h | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'include/services.h') diff --git a/include/services.h b/include/services.h index 7ff9f1b0b..7ee4f5738 100644 --- a/include/services.h +++ b/include/services.h @@ -179,16 +179,36 @@ extern int strncasecmp(const char *, const char *, size_t); #endif -#ifndef _WIN32 - #define MODULE_INIT(x) \ - extern "C" int anope_modinit(int argc, char **argv) \ + +/** This definition is used as shorthand for the various classes + * and functions needed to make a module loadable by the OS. + * It defines the class factory and external init_module function. + */ +#ifdef _WIN32 + #define MODULE_INIT(y) \ + extern "C" DllExport Module *init_module(const std::string &creator) \ { \ - return AnopeInit(argc, argv); \ + return new y(creator); \ + } \ + BOOLEAN WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID Reserved) \ + { \ + switch ( nReason ) \ + { \ + case DLL_PROCESS_ATTACH: \ + case DLL_PROCESS_DETACH: \ + break; \ + } \ + return TRUE; \ } #else - #error Not yet supported on Windows, XXX + #define MODULE_INIT(y) \ + extern "C" DllExport Module *init_module(const std::string &creator) \ + { \ + return new y(creator); \ + } #endif + /* Miscellaneous definitions. */ #include "defs.h" #include "slist.h" -- cgit