2 * Copyright (c) 2004, Index Data.
3 * See the file LICENSE for details.
5 * $Id: test-init-01.cpp,v 1.2 2004-11-30 21:10:31 adam Exp $
12 Zlint_test_init_01::Zlint_test_init_01()
16 Zlint_test_init_01::~Zlint_test_init_01()
20 Zlint_code Zlint_test_init_01::init(Zlint *z)
23 Z_APDU *apdu = z->create_Z_PDU(Z_APDU_initRequest);
24 Z_InitRequest *init = apdu->u.initRequest;
26 z->msg_check_for("for V3 init");
28 ODR_MASK_ZERO(init->protocolVersion);
29 ODR_MASK_SET(init->protocolVersion, Z_ProtocolVersion_1);
30 ODR_MASK_SET(init->protocolVersion, Z_ProtocolVersion_2);
31 ODR_MASK_SET(init->protocolVersion, Z_ProtocolVersion_3);
33 int r = z->send_Z_PDU(apdu, &len);
36 z->msg_check_fail("unable to send init request");
42 Zlint_code Zlint_test_init_01::recv_gdu(Zlint *z, Z_GDU *gdu)
44 if (gdu->which == Z_GDU_Z3950 &&
45 gdu->u.z3950 && gdu->u.z3950->which == Z_APDU_initResponse)
47 Z_InitResponse *init = gdu->u.z3950->u.initResponse;
48 int ver = z->initResponseGetVersion(init);
49 int result = init->result ? *init->result : 0;
50 if (ver > 3 || ver < 2)
51 z->msg_check_fail("got version %d, expected 2 or 3", ver);
54 z->msg_check_fail("init rejected (result false)");
61 z->msg_check_fail("did not receive init response as expected");