Пример #1
0
DECLARE_TEST( library, lookup )
{
	object_t lib = 0;
	object_t otherlib = 0;
	void* symbol = 0;

#if FOUNDATION_PLATFORM_WINDOWS
	const char* libraryname = "kernel32";
	const char* symbolname = "ExitProcess";
#elif FOUNDATION_PLATFORM_APPLE
	const char* libraryname = "dl";
	const char* symbolname = "dlsym";
#elif FOUNDATION_PLATFORM_POSIX
	const char* libraryname = "dl";
	const char* symbolname = "dlsym";
#else
	const char* libraryname = "somelib";
	const char* symbolname = "somesym";
#endif
	
	lib = library_load( libraryname );
	EXPECT_NE( lib, 0 );

	otherlib = library_load( libraryname );
	EXPECT_EQ( lib, otherlib );

	library_unload( otherlib );
	library_unload( 0 );
	otherlib = 0;

	log_set_suppress( 0, ERRORLEVEL_WARNING );
	EXPECT_EQ( library_load( "this_library_should_not_exist" ), 0 );
	log_set_suppress( 0, ERRORLEVEL_DEBUG );
	
	EXPECT_TRUE( library_valid( lib ) );
	EXPECT_FALSE( library_valid( 0 ) );

	symbol = library_symbol( lib, symbolname );
	EXPECT_NE( symbol, 0 );
	
	EXPECT_EQ( library_symbol( 0, symbolname ), 0 );

	library_unload( lib );
	EXPECT_EQ( library_symbol( lib, symbolname ), 0 );

	EXPECT_FALSE( library_valid( lib ) );
	
	return 0;
}
Пример #2
0
void _system_shutdown( void )
{
	if( _system_library_iphlpapi )
		library_unload( _system_library_iphlpapi );
	_system_library_iphlpapi = 0;

	event_stream_deallocate( _system_event_stream );
	_system_event_stream = 0;
}
Пример #3
0
	void unload(const std::string &module_name)
	{
		auto it = m_module_info.find(module_name);
		if(it == m_module_info.end()){
			assert(nullptr && "Failed to get class info");
			return;
		}
		void *module = it->second.module;
		library_unload(module);
		m_module_info.erase(module_name);
	}
Пример #4
0
bool PluginHandler_addPlugin(const char* basePath, const char* plugin) {
    void* (* initPlugin)(RegisterPlugin* registerPlugin, void* private_data);
    struct PluginPrivateData data;
    object_t lib = 0;

    const char* filename = 0;
    void* function;

    if (!basePath || !plugin)
        goto error;

    filename = buildLoadingPath(basePath, plugin);

    lib = library_load(filename);

    if (!library_valid(lib)) {
        // TODO: Show error message
        pd_error("Unable to open %s\n", filename);
        goto error;
    }

    if (!(function = library_symbol(lib, "InitPlugin"))) {
        // TODO: Show error message
        pd_error("Unable to find InitPlugin function in plugin %s\n", filename);
        goto error;
    }

    *(void**)(&initPlugin) = function;

    data.name = plugin;
    data.lib = lib;
    data.fullFilename = filename;

    initPlugin(registerPlugin, (void*)&data);

    return true;

    error:

    if (library_valid(lib))
        library_unload(lib);

    return false;
}
Пример #5
0
void PluginHandler_unloadAllPlugins() {
    // TODO: Actually unload everything

    for (int i = 0; i < PRODBG_PLUGIN_COUNT; ++i) {
        int count = array_size(s_plugins[i]);

        for (int t = 0; t < count; ++t) {
            PluginData* plugin = s_plugins[i][t];
            library_unload(plugin->lib);
            free((void*)plugin->fullFilename);
            free(plugin);
        }

        array_clear(s_plugins[i]);
    }

    //for (int i = 0; i < PRODBG_PLUGIN_COUNT; ++i)
    //	free(s_plugins[i]);
}
Пример #6
0
static void removePlugin(PluginData* pluginData) {
    // Remove the plugin data

    for (int i = 0; i < PRODBG_PLUGIN_COUNT; ++i) {
        int count = array_size(s_plugins[i]);

        for (int t = 0; t < count; ++t) {
            PluginData* plugin = s_plugins[i][t];

            if (pluginData != plugin)
                continue;

            printf("removed plugin %s\n", plugin->fullFilename);

            library_unload(plugin->lib);
            free((void*)plugin->fullFilename);
            free(plugin);
            array_erase(s_plugins[i], t);

            return;
        }
    }
}