本文整理汇总了C++中simple_command函数的典型用法代码示例。如果您正苦于以下问题:C++ simple_command函数的具体用法?C++ simple_command怎么用?C++ simple_command使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了simple_command函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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]);
}
}
示例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;
}
示例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);
}
示例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);
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}