X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fdynamic.cpp;h=27662a3516bccbc704fec1655e83a6692c7e611b;hb=428a5e3d0f5060d43c56a8a8595c8102241ce7ea;hp=704c4d9ddc7736f20f48c92a1d7937e789f536ba;hpb=deb6822302cb9009adc3450dd405817cc0dae9cd;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/dynamic.cpp b/src/dynamic.cpp index 704c4d9dd..27662a351 100644 --- a/src/dynamic.cpp +++ b/src/dynamic.cpp @@ -1,17 +1,25 @@ -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ +/* + * InspIRCd -- Internet Relay Chat Daemon * - * InspIRCd: (C) 2002-2009 InspIRCd Development Team - * See: http://wiki.inspircd.org/Credits + * Copyright (C) 2009 Daniel De Graaf + * Copyright (C) 2007 Oliver Lupton + * Copyright (C) 2007 Robin Burchell + * Copyright (C) 2007 Dennis Friis + * Copyright (C) 2003, 2006 Craig Edwards * - * This program is free but copyrighted software; see - * the file COPYING for details. + * 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 . */ -/* $Core */ #include "inspircd.h" #include "dynamic.h" @@ -19,13 +27,12 @@ #include #endif -DLLManager::DLLManager(InspIRCd*, const char *fname) +DLLManager::DLLManager(const char *fname) { - err = NULL; - if (!strstr(fname,".so")) { err = "This doesn't look like a module file to me..."; + h = NULL; return; } @@ -33,7 +40,6 @@ DLLManager::DLLManager(InspIRCd*, const char *fname) if (!h) { err = dlerror(); - return; } } @@ -44,24 +50,34 @@ DLLManager::~DLLManager() dlclose(h); } +union init_t { + void* vptr; + Module* (*fptr)(); +}; - -bool DLLManager::GetSymbol(void** v, const char* sym_name) +Module* DLLManager::CallInit() { - /* - * try extract a symbol from the library - * get any error message is there is any - */ + if (!h) + return NULL; - if (h) + init_t initfn; + initfn.vptr = dlsym(h, MODULE_INIT_STR); + if (!initfn.vptr) { - dlerror(); // clear value - *v = dlsym(h, sym_name); err = dlerror(); - if (!*v || err) - return false; + return NULL; } - /* succeeded :) */ - return true; + return (*initfn.fptr)(); +} + +std::string DLLManager::GetVersion() +{ + if (!h) + return ""; + + const char* srcver = (char*)dlsym(h, "inspircd_src_version"); + if (srcver) + return srcver; + return "Unversioned module"; }