void recv_command(char *command) { struct tnt_iter i; tnt_iter_reply(&i, tnt); while (tnt_next(&i)) { struct tnt_reply *r = TNT_IREPLY_PTR(&i); printf("%s: respond %s (op: %"PRIu32", reqid: %"PRIu32", code: %"PRIu32", count: %"PRIu32")\n", command, tnt_strerror(tnt), r->op, r->reqid, r->code, r->count); struct tnt_iter it; tnt_iter_list(&it, TNT_REPLY_LIST(r)); while (tnt_next(&it)) { struct tnt_tuple *tu = TNT_ILIST_TUPLE(&it); print_tuple(tu); } tnt_iter_free(&it); } if (i.status == TNT_ITER_FAIL) fail_tnt_perror("tnt_next"); tnt_iter_free(&i); }
int tc_query_foreach(tc_query_t cb, void *cba, char **e) { int rc = -1; struct tnt_iter i; tnt_iter_reply(&i, tc.net); while (tnt_next(&i)) { struct tnt_reply *r = TNT_IREPLY_PTR(&i); if (tnt_error(tc.net) != TNT_EOK) { *e = tc_query_error("%s ERROR, %s", tc_query_op(r), tnt_strerror(tc.net)); goto error; } else if (r->code != 0) { *e = tc_query_error("%s ERROR, %s (%s)", tc_query_op(r), ((r->error) ? r->error : ""), tnt_errcode_str(r->code >> 8)); goto error; } /* invoking callback if supplied */ if (cb) { if (cb(r, cba, e) == -1) goto error; } }