Example #1
0
bool ll_set_library(LibLoader *ll, char *filename)
{
    LIBRARY_HANDLE handle;

    handle = LIBRARY_OPEN(filename);
    
    if( !handle) {
#ifdef WIN32
        OUTPUT_ERR("problem opening library\n");
#else 
        OUTPUT_ERR("problem opening library: %s\n", dlerror());
#endif
        return false;
    }

    loaded_libs = util_grow_buffer_to_size(loaded_libs,
                                           &loaded_libs_cap,
                                           loaded_libs_size+1,
                                           sizeof(*loaded_libs));

    loaded_libs[loaded_libs_size++] = handle;

    ll->_prev_handle = handle;

    return true;
}
Example #2
0
Module* Module::loadModule(std::string filename){
    LIBRARY_HANDLE library = LIBRARY_OPEN(filename.c_str());
    APIVerFn apiverfn = NULL;
    ModuleFn modulefn = NULL;
    apiverfn = reinterpret_cast<APIVerFn>(LIBRARY_FUNC(library,"getAPIVersion"));
    if(apiverfn == NULL){
        LIBRARY_FREE(library);
        return NULL;
    }
    if(apiverfn() != WRATHION_MODULE_API_VERSION){
        LIBRARY_FREE(library);
        return NULL;
    }
    modulefn = reinterpret_cast<ModuleFn>(LIBRARY_FUNC(library,"getModule"));
    if(modulefn == NULL){
        LIBRARY_FREE(library);
        return NULL;
    }
    loadedLibraries.push_back(library);
    Module *mod = modulefn();
    return mod;
}
Example #3
0
Plugin *
Plugin::open_plugin (Application * appstate, const std::string filename) {
	typedef Plugin * (*Plugin_Main) (Application *, Handle *);
      				
	if (filename.length() == 0)
		return NULL;

	// Get a handle to the shared library we're attempting to open.
	Handle * platform = new Handle;
	if ((platform->handle = LIBRARY_OPEN (filename.c_str())) == NULL) {
		fprintf (stderr, "%s\n", LIBRARY_ERROR());
		exit(1);
	}

	// Grab the main method from the plugin so we can execute to get an object back.
	Plugin_Main plugin_main;
	if ((plugin_main = (Plugin_Main)LIBRARY_SYM(platform->handle, "PluginFactoryCreate")) == NULL) {
		fprintf (stderr, "%s\n", LIBRARY_ERROR());
		exit(1);
	}

	// Execute the method, return an object, and basically go on our merry way.
	return plugin_main (appstate, platform);
}