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;
}
Exemplo n.º 2
0
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
}
Exemplo n.º 3
0
void do_modules(const char *path)
{
	char *fn;
	DIR  *dir;

	fn = rt_malloc(FILENAME_MAX);
	if (fn == RT_NULL)
	{
		rt_kprintf("out of memory\n");
		return;
	}

	dir = opendir(path);
	if (dir != RT_NULL)
	{
		struct dirent* dirent;
		struct stat s;

		do
		{
			dirent = readdir(dir);
			if (dirent == RT_NULL) break;
			rt_memset(&s, 0, sizeof(struct stat));

			/* build full path for each file */
			if (path[strlen(path) - 1] != '/')
				rt_sprintf(fn, "%s/%s", path, dirent->d_name);
			else
				rt_sprintf(fn, "%s%s", path, dirent->d_name);

			if (strstr(fn, ".mo") != RT_NULL)
			{
				/* execute this module */
				rt_module_open(fn);
			}
		} while (dirent != RT_NULL);

		closedir(dir);
	}
	else rt_kprintf("open %s directory failed\n", path);

	rt_free(fn);
}
/* 打开按钮的回调函数 */
static void open_btn_onbutton(rtgui_widget_t *widget, struct rtgui_event *event)
{
    rtgui_filelist_view_t *view;
    rtgui_workbench_t *workbench;
    rtgui_rect_t rect;

    /* 获得顶层的workbench */
    workbench = RTGUI_WORKBENCH(rtgui_widget_get_toplevel(widget));
    rtgui_widget_get_rect(RTGUI_WIDGET(workbench), &rect);

    /* WIN32平台上和真实设备上的初始路径处理 */
#ifdef _WIN32
    view = rtgui_filelist_view_create(workbench, "d:\\", "*.*", &rect);
#else
    view = rtgui_filelist_view_create(workbench, "/", "*.*", &rect);
#endif
    /* 模态显示一个文件列表视图,以提供给用户选择图像文件 */
    if (rtgui_container_show(RTGUI_CONTAINER(view), RT_TRUE) == RTGUI_MODAL_OK)
    {
        char path[32], name[8];

        /* 设置文件路径的标签 */
        rtgui_filelist_view_get_fullpath(view, path, sizeof(path));

        rt_memset(name, 0, sizeof(name));

        /* 获得应用模块的类型 */
        if (rt_strstr(path, ".mo") != RT_NULL || rt_strstr(path, ".so") != RT_NULL)
        {
            rt_module_open(path);
        }
    }

    /* 删除 文件列表 视图 */
    rtgui_container_destroy(RTGUI_CONTAINER(view));
    rtgui_container_show(_view, RT_FALSE);
}
Exemplo n.º 5
0
int wlan_wpa_init(void)
{
    rt_module_open(WPA_BIN_FILE);

    return 0;
}
Exemplo n.º 6
0
void exec(const char* module)
{
    rt_module_open(module);
}
Exemplo n.º 7
0
static void launch_ext_mo(void *param)
{
    rt_kprintf("try open mo %s\n", param);
    rt_module_open((char *)param);
}