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_07::Zlint_test_init_07()
19 Zlint_test_init_07::~Zlint_test_init_07()
23 Zlint_code Zlint_test_init_07::init(Zlint *z)
26 Z_APDU *apdu = z->create_Z_PDU(Z_APDU_initRequest);
27 Z_InitRequest *init = apdu->u.initRequest;
28 Z_OtherInformation **oi;
30 z->msg_check_for("for character set negotiation");
32 /* set all options.. see what target really supports .. */
33 ODR_MASK_SET(init->protocolVersion, Z_ProtocolVersion_3);
34 yaz_oi_APDU(apdu, &oi);
37 z->msg_check_fail("encoding failure");
42 Z_OtherInformationUnit *p0;
43 const char *negotiationCharset[] = {
52 if ((p0=yaz_oi_update(oi, z->odr_encode(), NULL, 0, 0))) {
53 ODR_MASK_SET(init->options, Z_Options_negotiationModel);
55 p0->which = Z_OtherInfo_externallyDefinedInfo;
56 p0->information.externallyDefinedInfo =
58 yaz_set_proposal_charneg(
60 negotiationCharset, 5,
61 (const char**)&yazLang, yazLang ? 1 : 0, 1);
64 int r = z->send_Z_PDU(apdu, &len);
67 z->msg_check_fail("unable to send init request");
73 Zlint_code Zlint_test_init_07::recv_gdu(Zlint *z, Z_GDU *gdu)
75 if (gdu->which == Z_GDU_Z3950 &&
76 gdu->u.z3950 && gdu->u.z3950->which == Z_APDU_initResponse)
78 Z_InitResponse *init = gdu->u.z3950->u.initResponse;
80 if (ODR_MASK_GET(init->options, Z_Options_negotiationModel))
82 Z_CharSetandLanguageNegotiation *p =
83 yaz_get_charneg_record(init->otherInfo);
87 char *charset=NULL, *lang=NULL;
89 NMEM m = nmem_create();
91 yaz_get_response_charneg(m, p, &charset, &lang,
94 z->msg_check_info("Accepted character set : %s", charset);
95 z->msg_check_info("Accepted code language : %s", lang ? lang : "none");
96 z->msg_check_info("Accepted records in ...: %d", selected );
101 z->msg_check_notapp();
104 z->msg_check_fail("did not receive init response as expected");
105 return TEST_FINISHED;
112 * c-file-style: "Stroustrup"
113 * indent-tabs-mode: nil
115 * vim: shiftwidth=4 tabstop=8 expandtab