/*
* InspIRCd -- Internet Relay Chat Daemon
*
- * Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
- * Copyright (C) 2007 Oliver Lupton <oliverlupton@gmail.com>
+ * Copyright (C) 2017-2019 Sadie Powell <sadie@witchery.services>
+ * Copyright (C) 2014 Attila Molnar <attilamolnar@hush.com>
+ * Copyright (C) 2012 Robby <robby@chatbelgie.be>
+ * Copyright (C) 2012 ChrisTX <xpipe@hotmail.de>
+ * Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
+ * Copyright (C) 2009 Uli Schlachter <psychon@inspircd.org>
* Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
* Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
- * Copyright (C) 2003, 2006 Craig Edwards <craigedwards@brainbox.cc>
+ * Copyright (C) 2006, 2010 Craig Edwards <brain@inspircd.org>
*
* 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
dlclose(h);
}
-union init_t {
- void* vptr;
- Module* (*fptr)();
-};
-
Module* DLLManager::CallInit()
{
- if (!h)
- return NULL;
-
- init_t initfn;
- initfn.vptr = dlsym(h, MODULE_INIT_STR);
- if (!initfn.vptr)
+ union
{
- RetrieveLastError();
+ void* vptr;
+ Module* (*fptr)();
+ };
+
+ vptr = GetSymbol(MODULE_INIT_STR);
+ if (!vptr)
return NULL;
- }
- return (*initfn.fptr)();
+ return (*fptr)();
}
-std::string DLLManager::GetVersion()
+void* DLLManager::GetSymbol(const char* name)
{
- if (!h)
- return "";
+ return h ? dlsym(h, name) : NULL;
+}
- const char* srcver = (char*)dlsym(h, "inspircd_src_version");
- if (srcver)
- return srcver;
- return "";
+std::string DLLManager::GetVersion()
+{
+ const char* srcver = static_cast<const char*>(GetSymbol("inspircd_src_version"));
+ return srcver ? srcver : "";
}
void DLLManager::RetrieveLastError()