1 /* This file is part of the yazpp toolkit.
2 * Copyright (C) 1998-2009 Index Data and Mike Taylor
3 * See the file LICENSE for details.
10 #define REFID_BUF1 "zlint\000check1"
12 #define REFID_BUF2 "zlint\000check2"
15 Zlint_test_init_05::Zlint_test_init_05()
17 m_init_response_no = 0;
20 Zlint_test_init_05::~Zlint_test_init_05()
24 Zlint_code Zlint_test_init_05::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 double init");
32 /* send double init with differnet refID's */
33 ODR_MASK_SET(init->protocolVersion, Z_ProtocolVersion_3);
34 ODR_MASK_SET(init->options, Z_Options_concurrentOperations);
35 init->referenceId = z->mk_refid(REFID_BUF1, REFID_LEN1);
37 int r = z->send_Z_PDU(apdu, &len);
40 z->msg_check_fail("unable to send init request");
44 apdu = z->create_Z_PDU(Z_APDU_initRequest);
45 init = apdu->u.initRequest;
47 ODR_MASK_SET(init->protocolVersion, Z_ProtocolVersion_3);
48 ODR_MASK_SET(init->options, Z_Options_concurrentOperations);
50 init->referenceId = z->mk_refid(REFID_BUF2, REFID_LEN2);
52 r = z->send_Z_PDU(apdu, &len);
55 z->msg_check_fail("unable to send init request");
61 Zlint_code Zlint_test_init_05::recv_gdu(Zlint *z, Z_GDU *gdu)
63 if (gdu->which == Z_GDU_Z3950 &&
64 gdu->u.z3950 && gdu->u.z3950->which == Z_APDU_initResponse)
66 Z_InitResponse *init = gdu->u.z3950->u.initResponse;
67 int result = init->result ? *init->result : 0;
69 if (m_init_response_no == 0)
71 if (!init->referenceId)
73 z->msg_check_fail("missing referenceID from "
74 "first init response");
77 else if (init->referenceId->len != REFID_LEN1
78 || memcmp(init->referenceId->buf, REFID_BUF1, REFID_LEN1))
80 z->msg_check_fail("reference ID does not match from "
81 "first init response");
87 if (!init->referenceId)
88 z->msg_check_fail("missing referenceID from "
89 "second init response");
90 else if (init->referenceId->len != REFID_LEN2
91 || memcmp(init->referenceId->buf, REFID_BUF2, REFID_LEN2))
92 z->msg_check_fail("reference ID does not match from "
93 "second init response");
98 z->msg_check_fail("init rejected (result false)");
103 if (m_init_response_no == 0)
105 m_init_response_no++;
106 return TEST_CONTINUE;
113 z->msg_check_fail("did not receive init response as expected");
114 return TEST_FINISHED;
121 * c-file-style: "Stroustrup"
122 * indent-tabs-mode: nil
124 * vim: shiftwidth=4 tabstop=8 expandtab