本文整理汇总了C++中check_ret函数的典型用法代码示例。如果您正苦于以下问题:C++ check_ret函数的具体用法?C++ check_ret怎么用?C++ check_ret使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了check_ret函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: test_invalid_mem
static void test_invalid_mem(void)
{
unsigned long *p;
tst_resm(TINFO, "test_invalid_mem -1");
TEST(ltp_syscall(__NR_migrate_pages, 0, sane_max_node, -1, -1));
check_ret(-1);
check_errno(EFAULT);
tst_resm(TINFO, "test_invalid_mem invalid prot");
p = mmap(NULL, getpagesize(), PROT_NONE,
MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
if (p == MAP_FAILED)
tst_brkm(TBROK | TERRNO, cleanup, "mmap");
TEST(ltp_syscall(__NR_migrate_pages, 0, sane_max_node, p, p));
check_ret(-1);
check_errno(EFAULT);
if (munmap(p, getpagesize()) < 0)
tst_brkm(TBROK | TERRNO, cleanup, "munmap");
tst_resm(TINFO, "test_invalid_mem unmmaped");
TEST(ltp_syscall(__NR_migrate_pages, 0, sane_max_node, p, p));
check_ret(-1);
check_errno(EFAULT);
}
开发者ID:JanyHuang,项目名称:ltp,代码行数:25,代码来源:migrate_pages01.c
示例2: fetch_results
static int
fetch_results(CS_COMMAND * command)
{
CS_INT result_type, int_result, copied, rows_read;
CS_SMALLINT ind = 0;
CS_DATAFMT datafmt;
int result = 0;
memset(&datafmt, 0, sizeof(datafmt));
datafmt.datatype = CS_INT_TYPE;
datafmt.count = 1;
check_ret("ct_results", ct_results(command, &result_type));
do {
if (result_type == CS_ROW_RESULT) {
check_ret("ct_bind", ct_bind(command, 1, &datafmt, &int_result, &copied, &ind));
check_ret("ct_fetch", ct_fetch(command, CS_UNUSED, CS_UNUSED, CS_UNUSED, &rows_read));
printf("received %d bytes\n", (int) int_result);
result_len = int_result;
}
if (result_type == CS_CMD_FAIL) {
result = 1;
}
} while (ct_results(command, &result_type) == CS_SUCCEED);
return result;
}
开发者ID:FreeTDS,项目名称:freetds,代码行数:26,代码来源:long_binary.c
示例3: do_put
static int do_put(int argc, char **argv)
{
u8 buf[256];
int r, err = 1;
size_t count = 0;
unsigned int idx = 0;
sc_path_t path;
sc_file_t *file = NULL;
const char *filename;
FILE *outf = NULL;
if (argc < 1 || argc > 2)
return usage(do_put);
if (arg_to_path(argv[0], &path, 0) != 0)
return usage(do_put);
filename = (argc == 2) ? argv[1] : path_to_filename(&path, '_');
outf = fopen(filename, "rb");
if (outf == NULL) {
perror(filename);
goto err;
}
r = sc_select_file(card, &path, &file);
if (r) {
check_ret(r, SC_AC_OP_SELECT, "unable to select file", current_file);
goto err;
}
count = file->size;
while (count) {
int c = count > sizeof(buf) ? sizeof(buf) : count;
r = fread(buf, 1, c, outf);
if (r < 0) {
perror("fread");
goto err;
}
if (r != c)
count = c = r;
r = sc_update_binary(card, idx, buf, c, 0);
if (r < 0) {
check_ret(r, SC_AC_OP_READ, "update failed", file);
goto err;
}
if (r != c) {
printf("expecting %d, wrote only %d bytes.\n", c, r);
goto err;
}
idx += c;
count -= c;
}
printf("Total of %d bytes written.\n", idx);
err = 0;
err:
sc_file_free(file);
if (outf)
fclose(outf);
select_current_path_or_die();
return -err;
}
开发者ID:jpki,项目名称:OpenSC,代码行数:60,代码来源:opensc-explorer.c
示例4: main
int
main(int argc, char **argv)
{
int verbose = 0;
CS_COMMAND *command;
CS_CONNECTION *connection;
CS_CONTEXT *context;
unsigned char buffer[65536];
CS_INT buffer_len = 8192;
CS_SMALLINT ind = 0;
CS_DATAFMT datafmt;
CS_INT ret;
int i;
printf("-- begin --\n");
check_ret("try_ctlogin", try_ctlogin(&context, &connection, &command, verbose));
check_ret("cs_config", cs_config(context, CS_SET, CS_MESSAGE_CB, (CS_VOID *) csmsg_callback, unused, 0));
execute_sql(command, "if object_id('mps_table') is not null drop table mps_table");
execute_sql(command, "if object_id('mps_rpc') is not null drop procedure mps_rpc");
/* if this query fails probably we are using wrong database vendor or version */
ret = execute_sql(command, "create procedure mps_rpc (@varbinary_param varbinary(max)) as "
"insert mps_table values (@varbinary_param) " "select len(varbinary_data) from mps_table");
if (ret != 0) {
try_ctlogout(context, connection, command, verbose);
return 0;
}
execute_sql(command, "create table mps_table (varbinary_data varbinary(max))");
if (argc > 1)
buffer_len = atoi(argv[1]);
if (buffer_len < 0 || buffer_len > sizeof(buffer))
return 1;
printf("sending %d bytes\n", buffer_len);
for (i = 0; i < buffer_len; i++)
buffer[i] = (rand() % 16);
memset(&datafmt, 0, sizeof(datafmt));
strcpy(datafmt.name, "@varbinary_param");
datafmt.namelen = nullterm;
datafmt.datatype = CS_IMAGE_TYPE;
datafmt.status = CS_INPUTVALUE;
check_ret("ct_command", ct_command(command, CS_RPC_CMD, "mps_rpc", nullterm, unused));
check_ret("ct_setparam", ct_setparam(command, &datafmt, buffer, &buffer_len, &ind));
check_ret("ct_send", ct_send(command));
fetch_results(command);
execute_sql(command, "drop table mps_table");
execute_sql(command, "drop procedure mps_rpc");
try_ctlogout(context, connection, command, verbose);
printf("-- end --\n");
return (result_len == buffer_len) ? 0 : 1;
}
开发者ID:FreeTDS,项目名称:freetds,代码行数:59,代码来源:long_binary.c
示例5: execute_sql
static int
execute_sql(CS_COMMAND * command, const char *sql)
{
printf("executing sql: %s\n", sql);
check_ret("ct_command", ct_command(command, CS_LANG_CMD, sql, nullterm, unused));
check_ret("ct_send", ct_send(command));
return fetch_results(command);
}
开发者ID:FreeTDS,项目名称:freetds,代码行数:8,代码来源:long_binary.c
示例6: do_ls
static int do_ls(int argc, char **argv)
{
u8 buf[256], *cur = buf;
int r, count;
if (argc)
goto usage;
r = sc_list_files(card, buf, sizeof(buf));
if (r < 0) {
check_ret(r, SC_AC_OP_LIST_FILES, "unable to receive file listing", current_file);
return -1;
}
count = r;
printf("FileID\tType Size\n");
while (count >= 2) {
sc_path_t path;
sc_file_t *file = NULL;
if (current_path.type != SC_PATH_TYPE_DF_NAME) {
path = current_path;
sc_append_path_id(&path, cur, 2);
} else {
if (sc_path_set(&path, SC_PATH_TYPE_FILE_ID, cur, 2, 0, 0) != SC_SUCCESS) {
printf("unable to set path.\n");
die(1);
}
}
r = sc_select_file(card, &path, &file);
if (r) {
check_ret(r, SC_AC_OP_SELECT, "unable to select file", current_file);
return -1;
}
file->id = (cur[0] << 8) | cur[1];
cur += 2;
count -= 2;
print_file(file);
sc_file_free(file);
r = sc_select_file(card, ¤t_path, NULL);
if (r) {
printf("unable to select parent DF: %s\n", sc_strerror(r));
die(1);
}
}
return 0;
usage:
puts("Usage: ls");
return -1;
}
开发者ID:guadalinex-archive,项目名称:guadalinex-v5,代码行数:49,代码来源:opensc-explorer.c
示例7: test_sane_nodes
static void test_sane_nodes(void)
{
tst_resm(TINFO, "test_empty_mask");
TEST(ltp_syscall(__NR_migrate_pages, 0, sane_max_node,
sane_old_nodes, sane_new_nodes));
check_ret(0);
}
开发者ID:JanyHuang,项目名称:ltp,代码行数:7,代码来源:migrate_pages01.c
示例8: send_msg
static void send_msg(t_env *e, char *msg)
{
if (e->sfd != NOT_LOGGED && e->chan != NULL)
send(e->sfd, msg, strlen(msg) + 1, 0);
else
check_ret(e, (e->sfd == NOT_LOGGED) ? NOT_LOG_SRV : NOT_LOG_CHAN);
}
开发者ID:Tovitch,项目名称:PSU_2014_myirc,代码行数:7,代码来源:run_clt.c
示例9: read_and_util_print_binary_file
static int read_and_util_print_binary_file(sc_file_t *file)
{
unsigned int idx = 0;
u8 buf[128];
size_t count;
int r;
count = file->size;
while (count) {
int c = count > sizeof(buf) ? sizeof(buf) : count;
r = sc_read_binary(card, idx, buf, c, 0);
if (r < 0) {
check_ret(r, SC_AC_OP_READ, "read failed", file);
return -1;
}
if ((r != c) && (card->type != SC_CARD_TYPE_BELPIC_EID)) {
printf("expecting %d, got only %d bytes.\n", c, r);
return -1;
}
if ((r == 0) && (card->type == SC_CARD_TYPE_BELPIC_EID))
break;
util_hex_dump_asc(stdout, buf, r, idx);
idx += r;
count -= r;
}
return 0;
}
开发者ID:LudovicRousseau,项目名称:pkg-opensc,代码行数:28,代码来源:opensc-explorer.c
示例10: fdcb
void
net::do_write()
{
if (write_queue_.empty()) {
fdcb(fd_, selwrite, 0);
return;
}
strbuf data = write_queue_.pop_front();
uint32_t size = data.len();
int res = write(fd_, (void*) &size, sizeof(uint32_t));
if (res != sizeof(uint32_t))
fatal << "write failed()";
res = data.tosuio()->output(fd_);
check_ret(res, "write()");
// Schedule write again.
if (data.tosuio()->resid()){
//warn << "Scheduling write again\n";
fdcb(fd_, selwrite, wrap(this, &net::do_write_partial, data));
return;
}
}
开发者ID:sga001,项目名称:vex,代码行数:27,代码来源:net.cpp
示例11: read_and_util_print_binary_file
static int read_and_util_print_binary_file(sc_file_t *file)
{
unsigned char *buf = NULL;
int r;
size_t size;
if (file->size) {
size = file->size;
} else {
size = 1024;
}
buf = malloc(size);
if (!buf)
return -1;
r = sc_read_binary(card, 0, buf, size, 0);
if (r < 0) {
check_ret(r, SC_AC_OP_READ, "read failed", file);
return -1;
}
if ((r == 0) && (card->type == SC_CARD_TYPE_BELPIC_EID))
return -1;
util_hex_dump_asc(stdout, buf, r, 0);
free(buf);
return 0;
}
开发者ID:martinpaljak,项目名称:OpenSC,代码行数:28,代码来源:opensc-explorer.c
示例12: do_update_record
static int do_update_record(int argc, char **argv)
{
u8 buf[240];
size_t buflen;
int r, i, err = 1;
int rec, offs;
sc_path_t path;
sc_file_t *file;
if (argc != 4)
return usage(do_update_record);
if (arg_to_path(argv[0], &path, 0) != 0)
return usage(do_update_record);
rec = strtol(argv[1],NULL,10);
offs = strtol(argv[2],NULL,10);
printf("in: %i; %i; %s\n", rec, offs, argv[3]);
r = sc_select_file(card, &path, &file);
if (r) {
check_ret(r, SC_AC_OP_SELECT, "unable to select file", current_file);
return -1;
}
if (file->ef_structure != SC_FILE_EF_LINEAR_VARIABLE) {
printf("EF structure should be SC_FILE_EF_LINEAR_VARIABLE\n");
goto err;
} else if (rec < 1 || rec > file->record_count) {
printf("Invalid record number %i\n", rec);
goto err;
}
r = sc_read_record(card, rec, buf, sizeof(buf), SC_RECORD_BY_REC_NR);
if (r<0) {
printf("Cannot read record %i; return %i\n", rec, r);
goto err;;
}
buflen = sizeof(buf) - offs;
i = parse_string_or_hexdata(argv[3], buf + offs, &buflen);
if (!i) {
printf("unable to parse data\n");
goto err;
}
r = sc_update_record(card, rec, buf, r, SC_RECORD_BY_REC_NR);
if (r<0) {
printf("Cannot update record %i; return %i\n", rec, r);
goto err;
}
printf("Total of %d bytes written to record %i at %i offset.\n",
i, rec, offs);
err = 0;
err:
sc_file_free(file);
select_current_path_or_die();
return -err;
}
开发者ID:LudovicRousseau,项目名称:pkg-opensc,代码行数:60,代码来源:opensc-explorer.c
示例13: test_invalid_pid
static void test_invalid_pid(void)
{
pid_t invalid_pid = -1;
tst_resm(TINFO, "test_invalid_pid -1");
TEST(ltp_syscall(__NR_migrate_pages, invalid_pid, sane_max_node,
sane_old_nodes, sane_new_nodes));
check_ret(-1);
check_errno(ESRCH);
tst_resm(TINFO, "test_invalid_pid unused pid");
invalid_pid = tst_get_unused_pid(cleanup);
TEST(ltp_syscall(__NR_migrate_pages, invalid_pid, sane_max_node,
sane_old_nodes, sane_new_nodes));
check_ret(-1);
check_errno(ESRCH);
}
开发者ID:JanyHuang,项目名称:ltp,代码行数:17,代码来源:migrate_pages01.c
示例14: test_invalid_masksize
static void test_invalid_masksize(void)
{
tst_resm(TINFO, "test_invalid_masksize");
TEST(ltp_syscall(__NR_migrate_pages, 0, -1, sane_old_nodes,
sane_new_nodes));
check_ret(-1);
check_errno(EINVAL);
}
开发者ID:JanyHuang,项目名称:ltp,代码行数:8,代码来源:migrate_pages01.c
示例15: do_update_binary
static int do_update_binary(int argc, char **argv)
{
u8 buf[240];
int r, err = 1, in_len;
int offs;
sc_path_t path;
sc_file_t *file;
char *in_str;
if (argc < 2 || argc > 3)
goto usage;
if (arg_to_path(argv[0], &path, 0) != 0)
goto usage;
offs = strtol(argv[1],NULL,10);
in_str = argv[2];
printf("in: %i; %s\n", offs, in_str);
if (*in_str=='\"') {
in_len = strlen(in_str)-2 >= sizeof(buf) ? sizeof(buf)-1 : strlen(in_str)-2;
strncpy((char *) buf, in_str+1, in_len);
} else {
in_len = hex2binary(buf, sizeof(buf), in_str);
if (!in_len) {
printf("unable to parse hex value\n");
return -1;
}
}
r = sc_select_file(card, &path, &file);
if (r) {
check_ret(r, SC_AC_OP_SELECT, "unable to select file", current_file);
return -1;
}
if (file->ef_structure != SC_FILE_EF_TRANSPARENT) {
printf("EF structure should be SC_FILE_EF_TRANSPARENT\n");
goto err;
}
r = sc_update_binary(card, offs, buf, in_len, 0);
if (r < 0) {
printf("Cannot update %04X; return %i\n", file->id, r);
goto err;
}
printf("Total of %d bytes written to %04X at %i offset.\n",
r, file->id, offs);
err = 0;
err:
sc_file_free(file);
select_current_path_or_die();
return -err;
usage:
printf("Usage: update <file id> offs <hex value> | <'\"' enclosed string>\n");
return -1;
}
开发者ID:emilianobonassi,项目名称:OpenSC,代码行数:58,代码来源:opensc-explorer.c
示例16: do_ls
static int do_ls(int argc, char **argv)
{
u8 buf[256], *cur = buf;
int r, count;
r = sc_list_files(card, buf, sizeof(buf));
if (r < 0) {
check_ret(r, SC_AC_OP_LIST_FILES, "unable to receive file listing", current_file);
return -1;
}
count = r;
printf("FileID\tType Size\n");
while (count >= 2) {
sc_path_t path;
sc_file_t *file = NULL;
char filename[10];
int i = 0;
int matches = 0;
/* construct file name */
sprintf(filename, "%02X%02X", cur[0], cur[1]);
/* compare file name against patterns */
for (i = 0; i < argc; i++) {
if (pattern_match(argv[i], filename)) {
matches = 1;
break;
}
}
/* if any filename pattern were given, filter only matching file names */
if (argc == 0 || matches) {
if (current_path.type != SC_PATH_TYPE_DF_NAME) {
path = current_path;
sc_append_path_id(&path, cur, 2);
} else {
if (sc_path_set(&path, SC_PATH_TYPE_FILE_ID, cur, 2, 0, 0) != SC_SUCCESS) {
printf("unable to set path.\n");
die(1);
}
}
r = sc_select_file(card, &path, &file);
if (r) {
printf(" %02X%02X unable to select file, %s\n", cur[0], cur[1], sc_strerror(r));
} else {
file->id = (cur[0] << 8) | cur[1];
print_file(file);
sc_file_free(file);
}
}
cur += 2;
count -= 2;
select_current_path_or_die();
}
return 0;
}
开发者ID:martinpaljak,项目名称:OpenSC,代码行数:57,代码来源:opensc-explorer.c
示例17: do_cd
static int do_cd(int argc, char **argv)
{
sc_path_t path;
sc_file_t *file;
int r;
if (argc != 1)
goto usage;
if (strcmp(argv[0], "..") == 0) {
path = current_path;
if (path.len < 4) {
printf("unable to go up, already in MF.\n");
return -1;
}
if (path.type == SC_PATH_TYPE_DF_NAME) {
sc_format_path("3F00", &path);
}
else {
path.len -= 2;
}
r = sc_select_file(card, &path, &file);
if (r) {
printf("unable to go up: %s\n", sc_strerror(r));
return -1;
}
if (current_file)
sc_file_free(current_file);
current_file = file;
current_path = path;
return 0;
}
if (arg_to_path(argv[0], &path, 0) != 0)
goto usage;
r = sc_select_file(card, &path, &file);
if (r) {
check_ret(r, SC_AC_OP_SELECT, "unable to select DF", current_file);
return -1;
}
if ((file->type != SC_FILE_TYPE_DF) && (card->type != SC_CARD_TYPE_BELPIC_EID)) {
printf("Error: file is not a DF.\n");
sc_file_free(file);
select_current_path_or_die();
return -1;
}
current_path = path;
if (current_file)
sc_file_free(current_file);
current_file = file;
return 0;
usage:
puts("Usage: cd <file_id>|aid:<DF name>");
return -1;
}
开发者ID:emilianobonassi,项目名称:OpenSC,代码行数:57,代码来源:opensc-explorer.c
示例18: inetsocket
// Listen for connections
void
net::tcp_listen(int port, cbsb cb)
{
int ret;
int tmp_socket;
// Init socket bound to port
tmp_socket = inetsocket(SOCK_STREAM, port);
check_ret(tmp_socket, "inetsocket()");
// Make fd asynchronous
make_async(tmp_socket);
// Listen for a connection
ret = listen(tmp_socket, LISTEN_BACKLOG);
check_ret(ret, "listen()");
// Schedule event to accept incoming connection
fdcb(tmp_socket, selread, wrap(this, &net::tcp_accept, tmp_socket, cb));
}
开发者ID:sga001,项目名称:vex,代码行数:21,代码来源:net.cpp
示例19: __attribute__
int __INIT__ __attribute__(noreturn)
{
__LOG_RW("BEGIN:");
check_ret();
if ( check_ret == 1 )
{
printf("Warning! It is dangerous to continue, because it appears this program doesn't have the correct permissions available to write in a logfile. Please try to resolve the issue, and restart the program.\n");
abort();
}
}
开发者ID:R3HAX,项目名称:0xSH,代码行数:11,代码来源:main.c
示例20: do_cd
static int do_cd(int argc, char **argv)
{
sc_path_t path;
sc_file_t *file;
int r;
if (argc != 1)
goto usage;
if (strcmp(argv[0], "..") == 0) {
if (current_path.len < 4) {
printf("unable to go up, already in MF.\n");
return -1;
}
path = current_path;
path.len -= 2;
r = sc_select_file(card, &path, &file);
if (r) {
printf("unable to go up: %s\n", sc_strerror(r));
return -1;
}
sc_file_free(current_file);
current_file = file;
current_path = path;
return 0;
}
if (arg_to_path(argv[0], &path, 0) != 0)
goto usage;
r = sc_select_file(card, &path, &file);
if (r) {
check_ret(r, SC_AC_OP_SELECT, "unable to select DF", current_file);
return -1;
}
if ((file->type != SC_FILE_TYPE_DF) && !(card->caps & SC_CARD_CAP_NO_FCI)) {
printf("Error: file is not a DF.\n");
sc_file_free(file);
r = sc_select_file(card, ¤t_path, NULL);
if (r) {
printf("unable to select parent file: %s\n", sc_strerror(r));
die(1);
}
return -1;
}
current_path = path;
sc_file_free(current_file);
current_file = file;
return 0;
usage:
puts("Usage: cd <file_id>|aid:<DF name>");
return -1;
}
开发者ID:guadalinex-archive,项目名称:guadalinex-v5,代码行数:52,代码来源:opensc-explorer.c
注:本文中的check_ret函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论