1 /* This file is part of the yazpp toolkit.
2 * Copyright (C) 1998-2012 Index Data and Mike Taylor
3 * See the file LICENSE for details.
10 #include <yaz/charneg.h>
11 #include <yaz/otherinfo.h>
15 Zlint_test_init_08::Zlint_test_init_08()
20 Zlint_test_init_08::~Zlint_test_init_08()
24 Zlint_code Zlint_test_init_08::init(Zlint *z)
27 Z_APDU *apdu = z->create_Z_PDU(Z_APDU_initRequest);
28 Z_InitRequest *init = apdu->u.initRequest;
30 z->msg_check_for("for init message sizes %d", m_no);
32 /* set all options.. see what target really supports .. */
33 ODR_MASK_SET(init->protocolVersion, Z_ProtocolVersion_3);
35 *init->maximumRecordSize = m_no * m_no * 100000 + 2000;
36 *init->preferredMessageSize = m_no * m_no *100000 + 2000;
38 int r = z->send_Z_PDU(apdu, &len);
41 z->msg_check_fail("unable to send init request");
47 Zlint_code Zlint_test_init_08::recv_gdu(Zlint *z, Z_GDU *gdu)
49 if (gdu->which == Z_GDU_Z3950 &&
50 gdu->u.z3950 && gdu->u.z3950->which == Z_APDU_initResponse)
52 Z_InitResponse *init = gdu->u.z3950->u.initResponse;
54 if (m_no * m_no * 100000 + 2000 < *init->maximumRecordSize)
55 z->msg_check_fail("maximumRecordSize bigger than proposed size");
56 if (m_no * m_no * 100000 + 2000 < *init->preferredMessageSize)
57 z->msg_check_fail("preferredMessage bigger than proposed size");
66 z->msg_check_fail("did not receive init response as expected");
70 Zlint_code Zlint_test_init_08::recv_fail(Zlint *z, int reason)
72 z->msg_check_fail("target closed connection");
84 * c-file-style: "Stroustrup"
85 * indent-tabs-mode: nil
87 * vim: shiftwidth=4 tabstop=8 expandtab