亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? linux_usbfs.c

?? 最新的libusb庫
?? C
?? 第 1 頁 / 共 4 頁
字號:
	}	r = get_config_descriptor(DEVICE_CTX(dev), fd, config_index, buffer, len);	close(fd);	*host_endian = 1;	return r;}/* cache the active config descriptor in memory. a value of -1 means that * we aren't sure which one is active, so just assume the first one.  * only for usbfs. */static int cache_active_config(struct libusb_device *dev, int fd,	int active_config){	struct linux_device_priv *priv = __device_priv(dev);	struct libusb_config_descriptor config;	unsigned char tmp[8];	unsigned char *buf;	int idx;	int r;	if (active_config == -1) {		idx = 0;	} else {		r = usbi_get_config_index_by_value(dev, active_config, &idx);		if (r < 0)			return r;		if (idx == -1)			return LIBUSB_ERROR_NOT_FOUND;	}	r = get_config_descriptor(DEVICE_CTX(dev), fd, idx, tmp, sizeof(tmp));	if (r < 0) {		usbi_err(DEVICE_CTX(dev), "first read error %d", r);		return r;	}	usbi_parse_descriptor(tmp, "bbw", &config, 1);	buf = malloc(config.wTotalLength);	if (!buf)		return LIBUSB_ERROR_NO_MEM;	r = get_config_descriptor(DEVICE_CTX(dev), fd, idx, buf,		config.wTotalLength);	if (r < 0) {		free(buf);		return r;	}	if (priv->config_descriptor)		free(priv->config_descriptor);	priv->config_descriptor = buf;	return 0;}/* send a control message to retrieve active configuration */static int usbfs_get_active_config(struct libusb_device *dev, int fd){	int active_config;	int r;	struct usbfs_ctrltransfer ctrl = {		.bmRequestType = LIBUSB_ENDPOINT_IN,		.bRequest = LIBUSB_REQUEST_GET_CONFIGURATION,		.wValue = 0,		.wIndex = 0,		.wLength = 1,		.timeout = 1000,		.data = &active_config	};	r = ioctl(fd, IOCTL_USBFS_CONTROL, &ctrl);	if (r < 0) {		if (errno == ENODEV)			return LIBUSB_ERROR_NO_DEVICE;		usbi_err(DEVICE_CTX(dev),			"get_configuration failed ret=%d errno=%d", r, errno);		return LIBUSB_ERROR_IO;	}	return active_config;}static int initialize_device(struct libusb_device *dev, uint8_t busnum,	uint8_t devaddr, const char *sysfs_dir){	struct linux_device_priv *priv = __device_priv(dev);	unsigned char *dev_buf;	char path[PATH_MAX];	int fd;	int active_config = 0;	int device_configured = 1;	ssize_t r;	dev->bus_number = busnum;	dev->device_address = devaddr;	if (sysfs_dir) {		priv->sysfs_dir = malloc(strlen(sysfs_dir) + 1);		if (!priv->sysfs_dir)			return LIBUSB_ERROR_NO_MEM;		strcpy(priv->sysfs_dir, sysfs_dir);	}	if (sysfs_has_descriptors)		return 0;	/* cache device descriptor in memory so that we can retrieve it later	 * without waking the device up (op_get_device_descriptor) */	priv->dev_descriptor = NULL;	priv->config_descriptor = NULL;	if (sysfs_can_relate_devices) {		int tmp = sysfs_get_active_config(dev, &active_config);		if (tmp < 0)			return tmp;		if (active_config == -1)			device_configured = 0;	}	__get_usbfs_path(dev, path);	fd = open(path, O_RDWR);	if (fd < 0 && errno == EACCES) {		fd = open(path, O_RDONLY);		/* if we only have read-only access to the device, we cannot		 * send a control message to determine the active config. just		 * assume the first one is active. */		active_config = -1;	}	if (fd < 0) {		usbi_err(DEVICE_CTX(dev), "open failed, ret=%d errno=%d", fd, errno);		return LIBUSB_ERROR_IO;	}	if (!sysfs_can_relate_devices) {		if (active_config == -1) {			/* if we only have read-only access to the device, we cannot			 * send a control message to determine the active config. just			 * assume the first one is active. */			usbi_warn(DEVICE_CTX(dev), "access to %s is read-only; cannot "				"determine active configuration descriptor", path);		} else {			active_config = usbfs_get_active_config(dev, fd);			if (active_config < 0) {				close(fd);				return active_config;			} else if (active_config == 0) {				/* some buggy devices have a configuration 0, but we're				 * reaching into the corner of a corner case here, so let's				 * not support buggy devices in these circumstances.				 * stick to the specs: a configuration value of 0 means				 * unconfigured. */				usbi_dbg("assuming unconfigured device");				device_configured = 0;			}		}	}	dev_buf = malloc(DEVICE_DESC_LENGTH);	if (!dev_buf) {		close(fd);		return LIBUSB_ERROR_NO_MEM;	}	r = read(fd, dev_buf, DEVICE_DESC_LENGTH);	if (r < 0) {		usbi_err(DEVICE_CTX(dev),			"read descriptor failed ret=%d errno=%d", fd, errno);		free(dev_buf);		close(fd);		return LIBUSB_ERROR_IO;	} else if (r < DEVICE_DESC_LENGTH) {		usbi_err(DEVICE_CTX(dev), "short descriptor read (%d)", r);		free(dev_buf);		close(fd);		return LIBUSB_ERROR_IO;	}	/* bit of a hack: set num_configurations now because cache_active_config()	 * calls usbi_get_config_index_by_value() which uses it */	dev->num_configurations = dev_buf[DEVICE_DESC_LENGTH - 1];	if (device_configured) {		r = cache_active_config(dev, fd, active_config);		if (r < 0) {			close(fd);			free(dev_buf);			return r;		}	}	close(fd);	priv->dev_descriptor = dev_buf;	return 0;}static int enumerate_device(struct libusb_context *ctx,	struct discovered_devs **_discdevs, uint8_t busnum, uint8_t devaddr,	const char *sysfs_dir){	struct discovered_devs *discdevs;	unsigned long session_id;	int need_unref = 0;	struct libusb_device *dev;	int r = 0;	/* FIXME: session ID is not guaranteed unique as addresses can wrap and	 * will be reused. instead we should add a simple sysfs attribute with	 * a session ID. */	session_id = busnum << 8 | devaddr;	usbi_dbg("busnum %d devaddr %d session_id %ld", busnum, devaddr,		session_id);	dev = usbi_get_device_by_session_id(ctx, session_id);	if (dev) {		usbi_dbg("using existing device for %d/%d (session %ld)",			busnum, devaddr, session_id);	} else {		usbi_dbg("allocating new device for %d/%d (session %ld)",			busnum, devaddr, session_id);		dev = usbi_alloc_device(ctx, session_id);		if (!dev)			return LIBUSB_ERROR_NO_MEM;		need_unref = 1;		r = initialize_device(dev, busnum, devaddr, sysfs_dir);		if (r < 0)			goto out;		r = usbi_sanitize_device(dev);		if (r < 0)			goto out;	}	discdevs = discovered_devs_append(*_discdevs, dev);	if (!discdevs)		r = LIBUSB_ERROR_NO_MEM;	else		*_discdevs = discdevs;out:	if (need_unref)		libusb_unref_device(dev);	return r;}/* open a bus directory and adds all discovered devices to discdevs. on * failure (non-zero return) the pre-existing discdevs should be destroyed * (and devices freed). on success, the new discdevs pointer should be used * as it may have been moved. */static int usbfs_scan_busdir(struct libusb_context *ctx,	struct discovered_devs **_discdevs, uint8_t busnum){	DIR *dir;	char dirpath[PATH_MAX];	struct dirent *entry;	struct discovered_devs *discdevs = *_discdevs;	int r = 0;	snprintf(dirpath, PATH_MAX, "%s/%03d", usbfs_path, busnum);	usbi_dbg("%s", dirpath);	dir = opendir(dirpath);	if (!dir) {		usbi_err(ctx, "opendir '%s' failed, errno=%d", dirpath, errno);		/* FIXME: should handle valid race conditions like hub unplugged		 * during directory iteration - this is not an error */		return LIBUSB_ERROR_IO;	}	while ((entry = readdir(dir))) {		int devaddr;		if (entry->d_name[0] == '.')			continue;		devaddr = atoi(entry->d_name);		if (devaddr == 0) {			usbi_dbg("unknown dir entry %s", entry->d_name);			continue;		}		r = enumerate_device(ctx, &discdevs, busnum, (uint8_t) devaddr, NULL);		if (r < 0)			goto out;	}	*_discdevs = discdevs;out:	closedir(dir);	return r;}static int usbfs_get_device_list(struct libusb_context *ctx,	struct discovered_devs **_discdevs){	struct dirent *entry;	DIR *buses = opendir(usbfs_path);	struct discovered_devs *discdevs = *_discdevs;	int r = 0;	if (!buses) {		usbi_err(ctx, "opendir buses failed errno=%d", errno);		return LIBUSB_ERROR_IO;	}	while ((entry = readdir(buses))) {		struct discovered_devs *discdevs_new = discdevs;		int busnum;		if (entry->d_name[0] == '.')			continue;		busnum = atoi(entry->d_name);		if (busnum == 0) {			usbi_dbg("unknown dir entry %s", entry->d_name);			continue;		}		r = usbfs_scan_busdir(ctx, &discdevs_new, busnum);		if (r < 0)			goto out;		discdevs = discdevs_new;	}out:	closedir(buses);	*_discdevs = discdevs;	return r;}static int sysfs_scan_device(struct libusb_context *ctx,	struct discovered_devs **_discdevs, const char *devname,	int *usbfs_fallback){	int r;	FILE *fd;	char filename[PATH_MAX];	int busnum;	int devaddr;	usbi_dbg("scan %s", devname);	/* determine descriptors presence ahead of time, we need to know this	 * when we reach initialize_device */	if (sysfs_has_descriptors == -1) {		struct stat statbuf;		snprintf(filename, PATH_MAX, "%s/%s/descriptors", SYSFS_DEVICE_PATH,			devname);		r = stat(filename, &statbuf);		if (r == 0 && S_ISREG(statbuf.st_mode)) {			usbi_dbg("sysfs descriptors available");			sysfs_has_descriptors = 1;		} else {			usbi_dbg("sysfs descriptors not available");			sysfs_has_descriptors = 0;		}	}	snprintf(filename, PATH_MAX, "%s/%s/busnum", SYSFS_DEVICE_PATH, devname);	fd = fopen(filename, "r");	if (!fd) {		if (errno == ENOENT) {			usbi_dbg("busnum not found, cannot relate sysfs to usbfs, "				"falling back on pure usbfs");			sysfs_can_relate_devices = 0;			*usbfs_fallback = 1;			return LIBUSB_ERROR_OTHER;		}		usbi_err(ctx, "open busnum failed, errno=%d", errno);		return LIBUSB_ERROR_IO;	}	sysfs_can_relate_devices = 1;	r = fscanf(fd, "%d", &busnum);	fclose(fd);	if (r != 1) {		usbi_err(ctx, "fscanf busnum returned %d, errno=%d", r, errno);		return LIBUSB_ERROR_IO;	}	snprintf(filename, PATH_MAX, "%s/%s/devnum", SYSFS_DEVICE_PATH, devname);	fd = fopen(filename, "r");	if (!fd) {		usbi_err(ctx, "open devnum failed, errno=%d", errno);		return LIBUSB_ERROR_IO;	}	r = fscanf(fd, "%d", &devaddr);	fclose(fd);	if (r != 1) {		usbi_err(ctx, "fscanf devnum returned %d, errno=%d", r, errno);		return LIBUSB_ERROR_IO;	}	usbi_dbg("bus=%d dev=%d", busnum, devaddr);	if (busnum > 255 || devaddr > 255)		return LIBUSB_ERROR_INVALID_PARAM;	return enumerate_device(ctx, _discdevs, busnum & 0xff, devaddr & 0xff,		devname);}static int sysfs_get_device_list(struct libusb_context *ctx,	struct discovered_devs **_discdevs, int *usbfs_fallback){	struct discovered_devs *discdevs = *_discdevs;	DIR *devices = opendir(SYSFS_DEVICE_PATH);	struct dirent *entry;	int r = 0;	if (!devices) {		usbi_err(ctx, "opendir devices failed errno=%d", errno);		return LIBUSB_ERROR_IO;	}	while ((entry = readdir(devices))) {		struct discovered_devs *discdevs_new = discdevs;		if ((!isdigit(entry->d_name[0]) && strncmp(entry->d_name, "usb", 3))				|| strchr(entry->d_name, ':'))			continue;		r = sysfs_scan_device(ctx, &discdevs_new, entry->d_name,			usbfs_fallback);		if (r < 0)			goto out;		discdevs = discdevs_new;	}	out:	closedir(devices);	*_discdevs = discdevs;	return r;}static int op_get_device_list(struct libusb_context *ctx,	struct discovered_devs **_discdevs){	/* we can retrieve device list and descriptors from sysfs or usbfs.	 * sysfs is preferable, because if we use usbfs we end up resuming	 * any autosuspended USB devices. however, sysfs is not available	 * everywhere, so we need a usbfs fallback too.	 *	 * as described in the "sysfs vs usbfs" comment, sometimes we have	 * sysfs but not enough information to relate sysfs devices to usbfs	 * nodes. the usbfs_fallback variable is used to indicate that we should	 * fall back on usbfs.	 */	if (sysfs_can_relate_devices != 0) {		int usbfs_fallback = 0;		int r = sysfs_get_device_list(ctx, _discdevs, &usbfs_fallback);		if (!usbfs_fallback)			return r;	}	return usbfs_get_device_list(ctx, _discdevs);}static int op_open(struct libusb_device_handle *handle){	struct linux_device_handle_priv *hpriv = __device_handle_priv(handle);	char filename[PATH_MAX];	__get_usbfs_path(handle->dev, filename);	hpriv->fd = open(filename, O_RDWR);	if (hpriv->fd < 0) {		if (errno == EACCES) {			fprintf(stderr, "libusb couldn't open USB device %s: "				"Permission denied.\n"				"libusb requires write access to USB device nodes.\n",				filename);			return LIBUSB_ERROR_ACCESS;		} else if (errno == ENOENT) {			return LIBUSB_ERROR_NO_DEVICE;		} else {			usbi_err(HANDLE_CTX(handle),				"open failed, code %d errno %d", hpriv->fd, errno);			return LIBUSB_ERROR_IO;		}	}	return usbi_add_pollfd(HANDLE_CTX(handle), hpriv->fd, POLLOUT);}static void op_close(struct libusb_device_handle *dev_handle){	int fd = __device_handle_priv(dev_handle)->fd;	usbi_remove_pollfd(HANDLE_CTX(dev_handle), fd);	close(fd);}static int op_get_configuration(struct libusb_device_handle *handle,	int *config){	int r;	if (sysfs_can_relate_devices != 1)		return LIBUSB_ERROR_NOT_SUPPORTED;	r = sysfs_get_active_config(handle->dev, config);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲女人的天堂| 自拍偷拍亚洲欧美日韩| 国产清纯在线一区二区www| 中文字幕在线不卡国产视频| 五月婷婷久久丁香| 成人国产精品免费观看视频| 欧美一级视频精品观看| 国产精品久久久99| 久久精品免费看| 欧美三级三级三级| 国产精品女主播av| 国模冰冰炮一区二区| 欧美亚洲国产一区二区三区va| 亚洲精品在线观看视频| 亚洲高清久久久| 色综合一个色综合亚洲| 久久久精品国产免费观看同学| 日韩在线一区二区| 欧美三级一区二区| 亚洲激情五月婷婷| 99久久婷婷国产综合精品电影| 欧美一区二区不卡视频| 亚洲午夜一区二区| 色哟哟国产精品| 中文字幕国产一区二区| 国产裸体歌舞团一区二区| 91精品国产欧美一区二区| 亚洲一区视频在线| 色激情天天射综合网| 自拍偷拍亚洲综合| 色综合久久久久久久久| 亚洲视频狠狠干| 91色综合久久久久婷婷| 亚洲视频在线观看三级| 成人黄动漫网站免费app| 亚洲国产成人午夜在线一区| 国产尤物一区二区| 中文字幕+乱码+中文字幕一区| 国产盗摄精品一区二区三区在线| 久久夜色精品国产欧美乱极品| 另类的小说在线视频另类成人小视频在线 | 国产精品99久久久久久久vr | 国产精品一区免费在线观看| 欧美精品一区二区三区在线 | 国产亚洲va综合人人澡精品 | 国产毛片精品一区| 精品免费一区二区三区| 美女视频免费一区| 久久久久久久久久久久久久久99| 国产东北露脸精品视频| 国产精品久久久久久久午夜片| av男人天堂一区| 亚洲一区电影777| 欧美猛男男办公室激情| 久久不见久久见免费视频7| 久久伊99综合婷婷久久伊| 国产成人综合在线观看| 国产精品免费av| 欧美亚洲自拍偷拍| 韩国视频一区二区| 国产日韩在线不卡| 91视频免费观看| 日韩一区欧美二区| 国产欧美在线观看一区| 色哟哟欧美精品| 蜜臀av一区二区在线免费观看| 久久精品亚洲国产奇米99| 97国产精品videossex| 午夜精品久久久久久久99水蜜桃 | 亚洲视频香蕉人妖| 91麻豆精品国产自产在线 | 免播放器亚洲一区| 日本一区二区三区免费乱视频| 91久久奴性调教| 日韩国产精品大片| 国产精品久久久久一区二区三区 | 日本成人中文字幕在线视频| 国产欧美日韩精品一区| 欧美日韩和欧美的一区二区| 国产精品一区二区在线观看不卡| 亚洲欧美日韩在线播放| 日韩欧美自拍偷拍| 91久久精品网| 中文字幕一区二区日韩精品绯色| 美日韩黄色大片| 国产91综合网| 日韩免费看的电影| 日本一区中文字幕| 91福利小视频| 一区二区三区日韩在线观看| 国产盗摄一区二区| 国产日韩av一区| 国产成人av一区| 欧美区视频在线观看| 97精品视频在线观看自产线路二| 日韩你懂的在线观看| 亚洲大尺度视频在线观看| 不卡的看片网站| 中文字幕av不卡| 99在线热播精品免费| 久久久噜噜噜久久中文字幕色伊伊| 亚洲第一激情av| 欧美日韩一区二区三区视频| 亚洲精品久久久蜜桃| 国产精品亚洲视频| 1024国产精品| 欧美三级午夜理伦三级中视频| 日本一区二区在线不卡| 精品写真视频在线观看| www.久久久久久久久| 亚洲电影视频在线| 欧美日韩一区高清| 中文字幕免费在线观看视频一区| 亚洲欧美国产三级| 日韩欧美亚洲国产精品字幕久久久| 首页国产欧美久久| 国产精品1区2区3区在线观看| 成人av电影在线网| 亚洲女同女同女同女同女同69| 欧美精品日韩一本| 欧美在线视频日韩| 紧缚奴在线一区二区三区| 亚洲专区一二三| 国产精品成人网| 精品成a人在线观看| 69久久夜色精品国产69蝌蚪网| 91小视频在线免费看| av在线不卡网| 不卡av电影在线播放| 高清久久久久久| 成人综合在线观看| 高清免费成人av| 波多野结衣91| eeuss鲁片一区二区三区在线观看| 日本视频一区二区| 日本欧洲一区二区| 男男成人高潮片免费网站| 日本女优在线视频一区二区| 日韩精品免费视频人成| 麻豆久久久久久| 豆国产96在线|亚洲| 9色porny自拍视频一区二区| 91影视在线播放| 欧美中文字幕一区| 欧美亚洲国产一区在线观看网站| 欧美性猛交xxxxxx富婆| 欧美日韩在线不卡| 欧美精品久久99久久在免费线| 555www色欧美视频| 欧美麻豆精品久久久久久| 欧美大片在线观看| 国产免费观看久久| 亚洲欧美欧美一区二区三区| 亚洲国产成人av网| 久久精品理论片| 色久综合一二码| 91精品久久久久久久91蜜桃 | 午夜欧美大尺度福利影院在线看| 亚洲成在人线在线播放| 亚洲制服丝袜在线| 国产酒店精品激情| 色综合天天综合网天天看片| 欧美亚一区二区| 欧美一区二区三区日韩视频| 久久久国产精华| 一区二区三区日韩欧美| 卡一卡二国产精品| 91视频国产观看| 日韩欧美www| 最好看的中文字幕久久| 国产一区二区不卡在线| 色狠狠桃花综合| 久久你懂得1024| 午夜精品久久一牛影视| 丰满放荡岳乱妇91ww| 欧美高清视频一二三区 | 综合自拍亚洲综合图不卡区| 午夜精品国产更新| 成人黄色免费短视频| 欧美一卡2卡3卡4卡| 亚洲一区二区欧美| 国产成人激情av| 在线不卡中文字幕| 1000精品久久久久久久久| 久久国产综合精品| 欧美乱妇一区二区三区不卡视频| 日本一区二区三区国色天香| 亚洲18色成人| 色哟哟国产精品| 中文字幕第一区第二区| 日韩电影免费一区| 91网站视频在线观看| 久久看人人爽人人| 精品中文字幕一区二区小辣椒| 日本乱人伦一区| 中文字幕视频一区二区三区久| 久久精品国产**网站演员| 欧美日韩五月天| 日本系列欧美系列| 欧美巨大另类极品videosbest |