2 * Copyright (c) 2004, Index Data.
3 * See the file LICENSE for details.
5 * $Id: test-init-04.cpp,v 1.5 2005-08-11 18:53:01 adam Exp $
12 #define REFID_BUF1 "zlint\000check1"
15 Zlint_test_init_04::Zlint_test_init_04()
19 Zlint_test_init_04::~Zlint_test_init_04()
23 Zlint_code Zlint_test_init_04::init(Zlint *z)
26 Z_APDU *apdu = z->create_Z_PDU(Z_APDU_initRequest);
27 Z_InitRequest *init = apdu->u.initRequest;
29 z->msg_check_for("for referenceID for init");
31 ODR_MASK_SET(init->protocolVersion, Z_ProtocolVersion_3);
32 init->referenceId = z->mk_refid(REFID_BUF1, REFID_LEN1);
34 int r = z->send_Z_PDU(apdu, &len);
37 z->msg_check_fail("unable to send init request");
43 Zlint_code Zlint_test_init_04::recv_gdu(Zlint *z, Z_GDU *gdu)
45 if (gdu->which == Z_GDU_Z3950 &&
46 gdu->u.z3950 && gdu->u.z3950->which == Z_APDU_initResponse)
48 Z_InitResponse *init = gdu->u.z3950->u.initResponse;
50 if (!init->referenceId)
51 z->msg_check_fail("missing referenceID from init response");
52 else if (init->referenceId->len != REFID_LEN1
53 || memcmp(init->referenceId->buf, REFID_BUF1, REFID_LEN1))
54 z->msg_check_fail("reference ID does not match");
58 z->msg_check_fail("did not receive init response as expected");
65 * indent-tabs-mode: nil
67 * vim: shiftwidth=4 tabstop=8 expandtab