X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fdynamic.cpp;h=a6f758d33bfd437ff5dd8d3009dbb586fc01dd27;hb=6597fe5d4fd2c1cc474fa35a0db21fec480ff47f;hp=08564a0cd92dc1ef2bf17e89816e2dfc18c7f0f3;hpb=124c17e14134a4999afc1a5e981ab7c75b3694b9;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/dynamic.cpp b/src/dynamic.cpp index 08564a0cd..a6f758d33 100644 --- a/src/dynamic.cpp +++ b/src/dynamic.cpp @@ -1,11 +1,15 @@ /* * InspIRCd -- Internet Relay Chat Daemon * - * Copyright (C) 2009 Daniel De Graaf - * Copyright (C) 2007 Oliver Lupton + * Copyright (C) 2017-2019 Sadie Powell + * Copyright (C) 2014 Attila Molnar + * Copyright (C) 2012 Robby + * Copyright (C) 2012 ChrisTX + * Copyright (C) 2009-2010 Daniel De Graaf + * Copyright (C) 2009 Uli Schlachter * Copyright (C) 2007 Robin Burchell * Copyright (C) 2007 Dennis Friis - * Copyright (C) 2003, 2006 Craig Edwards + * Copyright (C) 2006, 2010 Craig Edwards * * 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 @@ -54,36 +58,30 @@ DLLManager::~DLLManager() 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(GetSymbol("inspircd_src_version")); + return srcver ? srcver : ""; } void DLLManager::RetrieveLastError()