• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ simple_command函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中simple_command函数的典型用法代码示例。如果您正苦于以下问题:C++ simple_command函数的具体用法?C++ simple_command怎么用?C++ simple_command使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了simple_command函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: do_log_sense

static void do_log_sense(int fd)
{
	unsigned char cdb[32];
	unsigned char buf[16*1024];
	unsigned cdb_len = cdb_log_sense(cdb, 0, 0, sizeof(buf));
	int buf_len;

	buf_len = simple_command(fd, cdb, cdb_len, buf, sizeof(buf));

	if (buf_len < 0) {
		printf("error while reading log sense list, nothing to show\n");
		return;
	}

	if (!log_sense_is_valid(buf, buf_len)) {
		printf("log sense page is invalid\n");
		return;
	}

	if (buf[0] != 0 || buf[1] != 0) {
		printf("expected to receive log page 0 subpage 0\n");
		return;
	}

	uint16_t num_pages = get_uint16(buf, 2);
	uint16_t i;
	for (i = 0; i < num_pages; i++) {
		dump_log_sense(fd, buf[4 + i], 0);
	}

	cdb_len = cdb_log_sense(cdb, 0, 0xff, sizeof(buf));
	buf_len = simple_command(fd, cdb, cdb_len, buf, sizeof(buf));

	if (buf_len < 0) {
		printf("error while reading list of log subpages, nothing to show\n");
		return;
	}

	if (!log_sense_is_valid(buf, buf_len)) {
		printf("log sense list must have at least 4 bytes\n");
		return;
	}

	if (buf[0] != 0x40 || buf[1] != 0xFF) {
		printf("expected to receive log page 0 (spf=1) subpage 0xFF\n");
		return;
	}

	num_pages = get_uint16(buf, 2);
	for (i = 0; i < num_pages; i++) {
		uint8_t page = buf[4 + i*2] & 0x3F;
		uint8_t subpage = buf[4 + i*2 + 1];
		if (subpage == 0) {
			printf("Skipping page %02X subpage %02X since subpage is 00 it was already retrieved above\n", page, subpage);
			continue;
		}
		dump_log_sense(fd, page, subpage);
	}
}
开发者ID:baruch,项目名称:libscsicmd,代码行数:59,代码来源:collect_raw_data.c


示例2: chirp_client_fstatfs

INT64_T chirp_client_fstatfs(struct chirp_client * c, INT64_T fd, struct chirp_statfs * info, time_t stoptime)
{
	INT64_T result = simple_command(c, stoptime, "fstatfs %lld\n", fd);
	if(result >= 0)
		result = get_statfs_result(c, info, stoptime);
	return result;
}
开发者ID:brenden,项目名称:cctools,代码行数:7,代码来源:chirp_client.c


示例3: chirp_client_audit

INT64_T chirp_client_audit(struct chirp_client * c, const char *path, struct chirp_audit ** list, time_t stoptime)
{
	INT64_T result;
	struct chirp_audit *entry;
	int i, actual;
	char line[CHIRP_LINE_MAX];

	char safepath[CHIRP_LINE_MAX];
	url_encode(path, safepath, sizeof(safepath));

	result = simple_command(c, stoptime, "audit %s\n", safepath);
	if(result <= 0)
		return result;

	*list = malloc(sizeof(struct chirp_audit) * result);
	entry = *list;

	for(i = 0; i < result; i++) {
		actual = link_readline(c->link, line, sizeof(line), stoptime);
		if(actual <= 0) {
			free(*list);
			result = -1;
			errno = ECONNRESET;
			break;
		} else {
			sscanf(line, "%s %" SCNd64 " %" SCNd64 " %" SCNd64 , entry->name, &entry->nfiles, &entry->ndirs, &entry->nbytes);
		}
		entry++;
	}

	return result;
}
开发者ID:brenden,项目名称:cctools,代码行数:32,代码来源:chirp_client.c


示例4: simple_command

CHIRP_SEARCH *chirp_client_opensearch(struct chirp_client *c, const char *path, const char *pattern, int flags, time_t stoptime) {
	INT64_T result = simple_command(c, stoptime, "search %s %s %d\n", pattern, path, flags);
	char p[CHIRP_PATH_MAX];
        size_t buffer_size = 2048;
        char *buffer = malloc(buffer_size);
	size_t l, i=0;

	if (result == 0) {
		while (link_readline(c->link, p, sizeof(p), stoptime)) {
	                if (strcmp(p, "") == 0) break;
			while ((l = (size_t)snprintf(buffer+i, buffer_size-i, p)) >= buffer_size-i) {
				buffer_size *= 2;
				char *rbuffer = (char*) realloc(buffer, buffer_size);
				if (rbuffer==NULL) return NULL;
				buffer = rbuffer;
			}
			i += l;
		}

		if (i==0) *buffer = '\0';

		CHIRP_SEARCH *result = malloc(sizeof(CHIRP_SEARCH));
		result->entry = (struct chirp_searchent*) malloc(sizeof(struct chirp_searchent));
		result->entry->info = NULL;
		result->entry->path = NULL;
		result->data = buffer;
		result->i = 0;
		return result;
	} else 
		return NULL;
}
开发者ID:brenden,项目名称:cctools,代码行数:31,代码来源:chirp_client.c


示例5: chirp_client_getlongdir

INT64_T chirp_client_getlongdir(struct chirp_client * c, const char *path, chirp_longdir_t callback, void *arg, time_t stoptime)
{
	char name[CHIRP_LINE_MAX];
	struct chirp_stat info;
	int result;

	char safepath[CHIRP_LINE_MAX];
	url_encode(path, safepath, sizeof(safepath));

	result = simple_command(c, stoptime, "getlongdir %s\n", safepath);
	if(result < 0)
		return result;

	while(link_readline(c->link, name, sizeof(name), stoptime)) {

		if(!name[0])
			return 0;

		if(get_stat_result(c, &info, stoptime) >= 0) {
			callback(name, &info, arg);
		} else {
			break;
		}
	}

	c->broken = 1;
	errno = ECONNRESET;
	return -1;
}
开发者ID:brenden,项目名称:cctools,代码行数:29,代码来源:chirp_client.c


示例6: chirp_client_openacl

INT64_T chirp_client_openacl(struct chirp_client * c, const char *path, time_t stoptime)
{
	char safepath[CHIRP_LINE_MAX];
	url_encode(path, safepath, sizeof(safepath));

	return simple_command(c, stoptime, "getacl %s\n", safepath);
}
开发者ID:brenden,项目名称:cctools,代码行数:7,代码来源:chirp_client.c


示例7: do_receive_diagnostic

static void do_receive_diagnostic(int fd)
{
	unsigned char cdb[32];
	unsigned char buf[16*1024];
	unsigned cdb_len = cdb_receive_diagnostics(cdb, true, 0, sizeof(buf));
	int buf_len;

	buf_len = simple_command(fd, cdb, cdb_len, buf, sizeof(buf));

	if (buf_len < 0) {
		printf("error while reading response buffer, nothing to show\n");
		return;
	}

	if (recv_diag_is_valid(buf, buf_len)) {
		printf("receive diagnostics list must have at least 4 bytes\n");
		return;
	}

	if (recv_diag_get_page_code(buf) != 0) {
		printf("expected to receive receive diagnostics page 0\n");
		return;
	}

	uint16_t num_pages = recv_diag_get_len(buf);
	uint16_t i;
	for (i = 0; i < num_pages; i++) {
		dump_rcv_diag_page(fd, buf[4 + i]);
	}
}
开发者ID:baruch,项目名称:libscsicmd,代码行数:30,代码来源:collect_raw_data.c


示例8: chirp_client_getfile_buffer

INT64_T chirp_client_getfile_buffer(struct chirp_client * c, const char *path, char **buffer, time_t stoptime)
{
	INT64_T length;
	INT64_T result;

	char safepath[CHIRP_LINE_MAX];
	url_encode(path, safepath, sizeof(safepath));

	*buffer = 0;

	length = simple_command(c, stoptime, "getfile %s\n", safepath);
	if(length <= 0)
		return length;

	*buffer = malloc(length + 1);
	if(!*buffer) {
		c->broken = 1;
		errno = ENOMEM;
		return -1;
	}

	result = link_read(c->link, *buffer, length, stoptime);
	if(result < 0) {
		free(*buffer);
		c->broken = 1;
		return -1;
	}

	(*buffer)[length] = 0;

	return result;
}
开发者ID:brenden,项目名称:cctools,代码行数:32,代码来源:chirp_client.c


示例9: do_ata_smart_read_log_addr

static int do_ata_smart_read_log_addr(int fd, unsigned char *buf, unsigned buf_sz, uint8_t log_addr, uint8_t block_count)
{
	uint8_t cdb[32];
	int cdb_len;

	cdb_len = cdb_ata_smart_read_log(cdb, log_addr, block_count);
	return simple_command(fd, cdb, cdb_len, buf, buf_sz);
}
开发者ID:baruch,项目名称:libscsicmd,代码行数:8,代码来源:collect_raw_data.c


示例10: do_ata_read_log_ext_page

static int do_ata_read_log_ext_page(int fd, uint8_t *buf, unsigned buf_sz, unsigned log_addr, unsigned page)
{
	uint8_t cdb[32];
	int cdb_len;

	cdb_len = cdb_ata_read_log_ext(cdb, 1, page, log_addr);
	return simple_command(fd, cdb, cdb_len, buf, buf_sz);
}
开发者ID:baruch,项目名称:libscsicmd,代码行数:8,代码来源:collect_raw_data.c


示例11: do_read_defect_data_12

static void do_read_defect_data_12(int fd, bool plist, bool glist, uint8_t format, bool count_only)
{
	unsigned char cdb[32];
	unsigned char buf[512];
	unsigned cdb_len = cdb_read_defect_data_12(cdb, plist, glist, format, count_only ? 8 : sizeof(buf));

	simple_command(fd, cdb, cdb_len, buf, sizeof(buf));
}
开发者ID:baruch,项目名称:libscsicmd,代码行数:8,代码来源:collect_raw_data.c


示例12: do_read_capacity_16

static void do_read_capacity_16(int fd)
{
	unsigned char cdb[32];
	unsigned char buf[512];
	unsigned cdb_len = cdb_read_capacity_16(cdb, sizeof(buf));

	simple_command(fd, cdb, cdb_len, buf, sizeof(buf));
}
开发者ID:baruch,项目名称:libscsicmd,代码行数:8,代码来源:collect_raw_data.c


示例13: dump_rcv_diag_page

static void dump_rcv_diag_page(int fd, uint8_t page)
{
	unsigned char cdb[32];
	unsigned char buf[16*1024];
	unsigned cdb_len = cdb_receive_diagnostics(cdb, true, page, sizeof(buf));

	simple_command(fd, cdb, cdb_len, buf, sizeof(buf));
}
开发者ID:baruch,项目名称:libscsicmd,代码行数:8,代码来源:collect_raw_data.c


示例14: do_mode_sense_6_type

static void do_mode_sense_6_type(int fd, bool disable_block_desc, page_control_e page_control)
{
	unsigned char cdb[32];
	unsigned char buf[255];
	unsigned cdb_len = cdb_mode_sense_6(cdb, disable_block_desc, page_control, 0x3F, 0xFF, sizeof(buf));

	simple_command(fd, cdb, cdb_len, buf, sizeof(buf));
}
开发者ID:baruch,项目名称:libscsicmd,代码行数:8,代码来源:collect_raw_data.c


示例15: dump_log_sense

static void dump_log_sense(int fd, uint8_t page, uint8_t subpage)
{
	unsigned char cdb[32];
	unsigned char buf[16*1024];
	unsigned cdb_len = cdb_log_sense(cdb, page, subpage, sizeof(buf));

	simple_command(fd, cdb, cdb_len, buf, sizeof(buf));
}
开发者ID:baruch,项目名称:libscsicmd,代码行数:8,代码来源:collect_raw_data.c


示例16: dump_evpd

static void dump_evpd(int fd, uint8_t evpd_page)
{
	unsigned char cdb[32];
	unsigned char buf[512];
	unsigned cdb_len = cdb_inquiry(cdb, true, evpd_page, sizeof(buf));

	simple_command(fd, cdb, cdb_len, buf, sizeof(buf));
}
开发者ID:baruch,项目名称:libscsicmd,代码行数:8,代码来源:collect_raw_data.c


示例17: chirp_client_lremovexattr

INT64_T chirp_client_lremovexattr(struct chirp_client *c, const char *path, const char *name, time_t stoptime)
{
	char safepath[CHIRP_LINE_MAX];
	url_encode(path, safepath, sizeof(safepath));
	INT64_T result = simple_command(c, stoptime, "lremovexattr %s %s\n", safepath, name);
	if (result == -1 && errno == EINVAL) errno = ENOATTR;
	return result;
}
开发者ID:brenden,项目名称:cctools,代码行数:8,代码来源:chirp_client.c


示例18: chirp_client_statfs

INT64_T chirp_client_statfs(struct chirp_client * c, const char *path, struct chirp_statfs * info, time_t stoptime)
{
	char safepath[CHIRP_LINE_MAX];
	url_encode(path, safepath, sizeof(safepath));
	INT64_T result = simple_command(c, stoptime, "statfs %s\n", safepath);
	if(result >= 0)
		result = get_statfs_result(c, info, stoptime);
	return result;
}
开发者ID:brenden,项目名称:cctools,代码行数:9,代码来源:chirp_client.c


示例19: do_ata_check_power_mode

static void do_ata_check_power_mode(int fd)
{
	uint8_t cdb[32];
	int cdb_len;

	printf("Check power mode\n");
	cdb_len = cdb_ata_check_power_mode(cdb);
	simple_command(fd, cdb, cdb_len, NULL, 0);
}
开发者ID:baruch,项目名称:libscsicmd,代码行数:9,代码来源:collect_raw_data.c


示例20: do_ata_identify_16

static void do_ata_identify_16(int fd)
{
	uint8_t cdb[32];
	int cdb_len;
	uint8_t buf[512];

	cdb_len = cdb_ata_identify_16(cdb);

	simple_command(fd, cdb, cdb_len, buf, sizeof(buf));
}
开发者ID:baruch,项目名称:libscsicmd,代码行数:10,代码来源:collect_raw_data.c



注:本文中的simple_command函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ simple_heap_insert函数代码示例发布时间:2022-05-30
下一篇:
C++ simpleUPnPcommand函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap