/* LibRCC - plugin's abstraction Copyright (C) 2005-2018 Suren A. Chilingaryan This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1 or later as published by the Free Software Foundation. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include #include #include #include "internal.h" #include "rcchome.h" #include "plugin.h" #ifdef RCC_PLUGINS # include # ifndef RTLD_NOW # define RTLD_NOW 0 # endif #endif /* RCC_PLUGINS */ rcc_library_handle rccLibraryOpen(char *filename) { #ifdef RCC_PLUGINS if (filename) return (rcc_library_handle)dlopen(filename, RTLD_NOW); #endif /* RCC_PLUGINS */ return NULL; } void rccLibraryClose(rcc_library_handle handle) { #ifdef RCC_PLUGINS if (handle) dlclose(handle); #endif /* RCC_PLUGINS */ } void* rccLibraryFind(rcc_library_handle handle, const char *symbol) { #ifdef RCC_PLUGINS if ((handle)||(symbol)) return dlsym(handle, symbol); #endif /* RCC_PLUGINS */ return NULL; } static rcc_plugin_handle_s rcc_engine_handles[RCC_MAX_PLUGINS]; int rccPluginInit() { unsigned int i; for (i=0;isn = strdup(name); if (plugin->sn) { plugin->handle = (rcc_library_handle)res; plugin->info_function = infofunc; return plugin; } else rccLibraryClose(res); } else rccLibraryClose(res); } break; default: return NULL; } #endif /* RCC_PLUGINS */ return NULL; } rcc_engine *rccPluginEngineGetInfo(const char *name, const char *language) { rcc_plugin_handle handle; rcc_plugin_engine_info_function infofunc; handle = rccPluginLoad(RCC_PLUGIN_TYPE_ENGINE, name); if (!handle) return NULL; infofunc = (rcc_plugin_engine_info_function)(handle->info_function); if (!infofunc) return NULL; return infofunc(language); }