// load one specific plugin bool Plugins::load_plugin (const string& path) { typedef const char* (*__plugin_version__)(void); typedef Sass_Function_List (*__plugin_load_fns__)(void); typedef Sass_Importer_List (*__plugin_load_imps__)(void); if (LOAD_LIB(plugin, path)) { // try to load initial function to query libsass version suppor if (LOAD_LIB_FN(__plugin_version__, plugin_version, "libsass_get_version")) { // get the libsass version of the plugin if (!compatibility(plugin_version())) return false; // try to get import address for "libsass_load_functions" if (LOAD_LIB_FN(__plugin_load_fns__, plugin_load_functions, "libsass_load_functions")) { Sass_Function_List fns = plugin_load_functions(); while (fns && *fns) { functions.push_back(*fns); ++ fns; } } // try to get import address for "libsass_load_importers" if (LOAD_LIB_FN(__plugin_load_imps__, plugin_load_importers, "libsass_load_importers")) { Sass_Importer_List imps = plugin_load_importers(); while (imps && *imps) { importers.push_back(*imps); ++ imps; } } // try to get import address for "libsass_load_headers" if (LOAD_LIB_FN(__plugin_load_imps__, plugin_load_headers, "libsass_load_headers")) { Sass_Importer_List imps = plugin_load_headers(); while (imps && *imps) { headers.push_back(*imps); ++ imps; } } // success return true; } else { // print debug message to stderr (should not happen) cerr << "failed loading 'libsass_support' in <" << path << ">" << endl; if (const char* dlsym_error = dlerror()) cerr << dlsym_error << endl; CLOSE_LIB(plugin); } } else { // print debug message to stderr (should not happen) cerr << "failed loading plugin <" << path << ">" << endl; if (const char* dlopen_error = dlerror()) cerr << dlopen_error << endl; } return false; }
static lib_handle load_library(char* errmsg) { # if defined(_WIN32) || defined(_WIN64) || defined(__LCC__) const char *PvLibName = "PvAPI.dll"; # else const char *PvLibName = "libPvAPI.so"; # endif lib_handle lib; union tPvLibFnConv conv; errmsg[0] = 0; # if defined(_WIN32) || defined (_WIN64) || defined(__LCC__) lib = LoadLibrary(PvLibName); # else lib = dlopen(PvLibName, RTLD_NOW | RTLD_LOCAL); # endif if(lib == NULL) { sprintf(errmsg, "Could not open library: %s", PvLibName); } else { LOAD_LIB_FN(ss_PvInitializeNoDiscovery, conv, lib, "PvInitializeNoDiscovery"); LOAD_LIB_FN(ss_PvCameraOpenByAddr, conv, lib, "PvCameraOpenByAddr"); LOAD_LIB_FN(ss_PvCaptureStart, conv, lib, "PvCaptureStart"); LOAD_LIB_FN(ss_PvAttrUint32Set, conv, lib, "PvAttrUint32Set"); LOAD_LIB_FN(ss_PvAttrEnumSet, conv, lib, "PvAttrEnumSet"); LOAD_LIB_FN(ss_PvCommandRun, conv, lib, "PvCommandRun"); LOAD_LIB_FN(ss_PvAttrUint32Get, conv, lib, "PvAttrUint32Get"); LOAD_LIB_FN(ss_PvCaptureQueueFrame, conv, lib, "PvCaptureQueueFrame"); LOAD_LIB_FN(ss_PvCaptureEnd, conv, lib, "PvCaptureEnd"); LOAD_LIB_FN(ss_PvCaptureQueueClear, conv, lib, "PvCaptureQueueClear"); LOAD_LIB_FN(ss_PvCameraClose, conv, lib, "PvCameraClose"); LOAD_LIB_FN(ss_PvUnInitialize, conv, lib, "PvUnInitialize"); } return lib; }