⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ts_load_module.c

📁 嵌入式Linux下的触摸屏驱动源代码
💻 C
字号:
/*
 *  tslib/src/ts_load_module.c
 *
 *  Copyright (C) 2001 Russell King.
 *
 * This file is placed under the LGPL.  Please see the file
 * COPYING for more details.
 *
 * $Id: ts_load_module.c,v 1.2 2002/07/01 23:02:57 dlowder Exp $
 *
 * Close a touchscreen device.
 */
#include "config.h"

#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <dlfcn.h>

#include "tslib-private.h"

int ts_load_module(struct tsdev *ts, const char *module, const char *params)
{
	struct tslib_module_info * (*init)(struct tsdev *, const char *);
	struct tslib_module_info *info;
	char fn[1024];
	void *handle;
	int ret;
	char *plugin_directory=NULL;

	if( (plugin_directory = getenv("TSLIB_PLUGINDIR")) != NULL ) {
		//fn = alloca(sizeof(plugin_directory) + strlen(module) + 4);
		strcpy(fn,plugin_directory);
	} else {
		//fn = alloca(sizeof(PLUGIN_DIR) + strlen(module) + 4);
		strcpy(fn, PLUGIN_DIR);
	}

	strcat(fn, "/");
	strcat(fn, module);
	strcat(fn, ".so");

	handle = dlopen(fn, RTLD_NOW);
	if (!handle)
		return -1;

	init = dlsym(handle, "mod_init");
	if (!init) {
		dlclose(handle);
		return -1;
	}

	info = init(ts, params);
	if (!info) {
		dlclose(handle);
		return -1;
	}

	info->handle = handle;

	ret = __ts_attach(ts, info);
	if (ret) {
		info->ops->fini(info);
		dlclose(handle);
	}

	return ret;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -