void* dlopen(const char *filename, int flags)
{
	rt_module_t module;
	char *fullpath;
	const char*def_path = MODULE_ROOT_DIR;

	/* check parameters */
	RT_ASSERT(filename != RT_NULL);

	if (filename[0] != '/') /* it's a absolute path, use it directly */
	{
		fullpath = rt_malloc(strlen(def_path) + strlen(filename) + 2);

		/* join path and file name */
		rt_snprintf(fullpath, strlen(def_path) + strlen(filename) + 2, 
			"%s/%s", def_path, filename);
	}
	
	/* find in module list */
	module = rt_module_find(fullpath);
	
	if(module != RT_NULL) module->nref++;
	else module = rt_module_open(fullpath);

	rt_free(fullpath);
	return (void*)module;
}
示例#2
0
文件: program.c 项目: lgnq/mini2440
static void exec_app(rtgui_widget_t* widget, void* parameter)
{
    char path[64];
    rt_module_t module;

    RT_ASSERT(parameter != RT_NULL);

    rt_snprintf(path, sizeof(path), "%s/%s/%s.mo", APP_PATH, 
        (char*)parameter, (char*)parameter);
    
#ifndef _WIN32
    module = rt_module_find((const char*)parameter);
    if(module == RT_NULL)
        rt_module_open(path);
    else
    {
        struct rtgui_app* app;
        RT_ASSERT(module->module_thread);
        app = (struct rtgui_app*)(module->module_thread->user_data);
        
        if(app != RT_NULL) rtgui_app_activate(app);
        else rt_kprintf("application is null\n");
    }
#endif
}