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.
7 #include <yaz/charneg.h>
8 #include <yaz/otherinfo.h>
12 Zlint_test_init_07::Zlint_test_init_07()
16 Zlint_test_init_07::~Zlint_test_init_07()
20 Zlint_code Zlint_test_init_07::init(Zlint *z)
23 Z_APDU *apdu = z->create_Z_PDU(Z_APDU_initRequest);
24 Z_InitRequest *init = apdu->u.initRequest;
25 Z_OtherInformation **oi;
27 z->msg_check_for("for character set negotiation");
29 /* set all options.. see what target really supports .. */
30 ODR_MASK_SET(init->protocolVersion, Z_ProtocolVersion_3);
31 yaz_oi_APDU(apdu, &oi);
34 z->msg_check_fail("encoding failure");
39 Z_OtherInformationUnit *p0;
40 const char *negotiationCharset[] = {
49 if ((p0=yaz_oi_update(oi, z->odr_encode(), NULL, 0, 0))) {
50 ODR_MASK_SET(init->options, Z_Options_negotiationModel);
52 p0->which = Z_OtherInfo_externallyDefinedInfo;
53 p0->information.externallyDefinedInfo =
55 yaz_set_proposal_charneg(
57 negotiationCharset, 5,
58 (const char**)&yazLang, yazLang ? 1 : 0, 1);
61 int r = z->send_Z_PDU(apdu, &len);
64 z->msg_check_fail("unable to send init request");
70 Zlint_code Zlint_test_init_07::recv_gdu(Zlint *z, Z_GDU *gdu)
72 if (gdu->which == Z_GDU_Z3950 &&
73 gdu->u.z3950 && gdu->u.z3950->which == Z_APDU_initResponse)
75 Z_InitResponse *init = gdu->u.z3950->u.initResponse;
77 if (ODR_MASK_GET(init->options, Z_Options_negotiationModel))
79 Z_CharSetandLanguageNegotiation *p =
80 yaz_get_charneg_record(init->otherInfo);
84 char *charset=NULL, *lang=NULL;
86 NMEM m = nmem_create();
88 yaz_get_response_charneg(m, p, &charset, &lang,
91 z->msg_check_info("Accepted character set : %s", charset);
92 z->msg_check_info("Accepted code language : %s", lang ? lang : "none");
93 z->msg_check_info("Accepted records in ...: %d", selected );
98 z->msg_check_notapp();
101 z->msg_check_fail("did not receive init response as expected");
102 return TEST_FINISHED;
109 * indent-tabs-mode: nil
111 * vim: shiftwidth=4 tabstop=8 expandtab