static Z_InitRequest *zget_InitRequest(ODR o) { Z_InitRequest *r = (Z_InitRequest *)odr_malloc(o, sizeof(*r)); r->referenceId = 0; r->options = (Odr_bitmask *)odr_malloc(o, sizeof(*r->options)); ODR_MASK_ZERO(r->options); r->protocolVersion = (Odr_bitmask *) odr_malloc(o, sizeof(*r->protocolVersion)); ODR_MASK_SET(r->options, Z_Options_search); ODR_MASK_SET(r->options, Z_Options_present); ODR_MASK_ZERO(r->protocolVersion); ODR_MASK_SET(r->protocolVersion, Z_ProtocolVersion_1); ODR_MASK_SET(r->protocolVersion, Z_ProtocolVersion_2); r->preferredMessageSize = odr_intdup(o, 1024*1024); r->maximumRecordSize = odr_intdup(o, 1024*1024); r->idAuthentication = 0; r->implementationId = "81"; r->implementationName = "YAZ"; r->implementationVersion = YAZ_VERSION #ifdef YAZ_VERSION_SHA1 " " YAZ_VERSION_SHA1 #endif ; r->userInformationField = 0; r->otherInfo = 0; return r; }
static Z_InitResponse *zget_InitResponse(ODR o) { Z_InitResponse *r = (Z_InitResponse *)odr_malloc(o, sizeof(*r)); r->referenceId = 0; r->options = (Odr_bitmask *)odr_malloc(o, sizeof(*r->options)); ODR_MASK_ZERO(r->options); r->protocolVersion = (Odr_bitmask *)odr_malloc(o, sizeof(*r->protocolVersion)); ODR_MASK_ZERO(r->protocolVersion); r->preferredMessageSize = odr_intdup(o, 30*1024); r->maximumRecordSize = odr_intdup(o, 30*1024); r->result = odr_booldup(o, 1); r->implementationId = "81"; r->implementationName = "YAZ"; r->implementationVersion = YAZ_VERSION #ifdef YAZ_VERSION_SHA1 " " YAZ_VERSION_SHA1 #endif ; r->userInformationField = 0; r->otherInfo = 0; return r; }
Zlint_code Zlint_test_init_01::init(Zlint *z) { int len; Z_APDU *apdu = z->create_Z_PDU(Z_APDU_initRequest); Z_InitRequest *init = apdu->u.initRequest; z->msg_check_for("for V3 init"); ODR_MASK_ZERO(init->protocolVersion); ODR_MASK_SET(init->protocolVersion, Z_ProtocolVersion_1); ODR_MASK_SET(init->protocolVersion, Z_ProtocolVersion_2); ODR_MASK_SET(init->protocolVersion, Z_ProtocolVersion_3); int r = z->send_Z_PDU(apdu, &len); if (r < 0) { z->msg_check_fail("unable to send init request"); return TEST_FINISHED; } return TEST_CONTINUE; }
int yaz_init_opt_encode(Z_Options *opt, const char *opt_str, int *error_pos) { const char *cp = opt_str; ODR_MASK_ZERO(opt); while (*cp) { char this_opt[42]; size_t i, j; if (*cp == ' ' || *cp == ',') { cp++; continue; } for (i = 0; i < (sizeof(this_opt)-1) && cp[i] && cp[i] != ' ' && cp[i] != ','; i++) this_opt[i] = cp[i]; this_opt[i] = 0; for (j = 0; opt_array[j].name; j++) { if (yaz_matchstr(this_opt, opt_array[j].name) == 0) { ODR_MASK_SET(opt, opt_array[j].opt); break; } } if (!opt_array[j].name) { if (error_pos) { *error_pos = cp - opt_str; return -1; } } cp += i; } return 0; }