+ int i;
+ Z_OtherInformation *otherInformation = *otherInformationP;
+ if (!otherInformation)
+ {
+ otherInformation = *otherInformationP = (Z_OtherInformation *)
+ odr_malloc (odr_encode(), sizeof(*otherInformation));
+ otherInformation->num_elements = 0;
+ otherInformation->list = (Z_OtherInformationUnit **)
+ odr_malloc (odr_encode(), 8*sizeof(*otherInformation));
+ for (i = 0; i<8; i++)
+ otherInformation->list[i] = 0;
+ }
+ for (i = 0; i<otherInformation->num_elements; i++)
+ {
+ assert (otherInformation->list[i]);
+ if (!oid)
+ {
+ if (!otherInformation->list[i]->category)
+ return otherInformation->list[i];
+ }
+ else
+ {
+ if (otherInformation->list[i]->category &&
+ categoryValue ==
+ *otherInformation->list[i]->category->categoryValue &&
+ !oid_oidcmp (oid, otherInformation->list[i]->category->
+ categoryTypeId))
+ return otherInformation->list[i];
+ }
+ }
+ otherInformation->list[i] = (Z_OtherInformationUnit*)
+ odr_malloc (odr_encode(), sizeof(Z_OtherInformationUnit));
+ if (oid)
+ {
+ otherInformation->list[i]->category = (Z_InfoCategory*)
+ odr_malloc (odr_encode(), sizeof(Z_InfoCategory));
+ otherInformation->list[i]->category->categoryTypeId = (int*)
+ odr_oiddup (odr_encode(), oid);
+ otherInformation->list[i]->category->categoryValue = (int*)
+ odr_malloc (odr_encode(), sizeof(int));
+ *otherInformation->list[i]->category->categoryValue =
+ categoryValue;
+ }
+ else
+ otherInformation->list[i]->category = 0;
+ otherInformation->list[i]->which = Z_OtherInfo_characterInfo;
+ otherInformation->list[i]->information.characterInfo = 0;
+
+ otherInformation->num_elements = i+1;
+ return otherInformation->list[i];
+}
+
+void Yaz_IR_Assoc::recv_Z_PDU(Z_APDU *apdu)
+{
+ logf (LOG_LOG, "recv_Z_PDU");
+ m_lastReceived = apdu->which;
+ switch (apdu->which)
+ {
+ case Z_APDU_initResponse:
+ logf (LOG_LOG, "recv InitResponse");
+ recv_initResponse(apdu->u.initResponse);
+ break;
+ case Z_APDU_initRequest:
+ logf (LOG_LOG, "recv InitRequest");
+ recv_initRequest(apdu->u.initRequest);
+ break;
+ case Z_APDU_searchRequest:
+ logf (LOG_LOG, "recv searchRequest");
+ recv_searchRequest(apdu->u.searchRequest);
+ break;
+ case Z_APDU_searchResponse:
+ logf (LOG_LOG, "recv searchResponse");
+ recv_searchResponse(apdu->u.searchResponse);
+ break;
+ case Z_APDU_presentRequest:
+ logf (LOG_LOG, "recv presentRequest");
+ recv_presentRequest(apdu->u.presentRequest);
+ break;
+ case Z_APDU_presentResponse:
+ logf (LOG_LOG, "recv presentResponse");
+ recv_presentResponse(apdu->u.presentResponse);
+ break;
+ }
+}
+
+int Yaz_IR_Assoc::send_searchRequest(Yaz_Z_Query *query)
+{
+ Z_APDU *apdu = create_Z_PDU(Z_APDU_searchRequest);
+ Z_SearchRequest *req = apdu->u.searchRequest;
+ int recordSyntax;
+
+ req->query = query->get_Z_Query();
+ if (!req->query)
+ return -1;
+ get_databaseNames (&req->num_databaseNames, &req->databaseNames);
+ for (int i = 0; i<req->num_databaseNames; i++)
+ logf (LOG_LOG, "Database %s", req->databaseNames[i]);
+ int oid_syntax[OID_SIZE];
+ oident prefsyn;
+ get_preferredRecordSyntax(&recordSyntax);
+ if (recordSyntax != VAL_NONE)
+ {
+ prefsyn.proto = PROTO_Z3950;
+ prefsyn.oclass = CLASS_RECSYN;
+ prefsyn.value = (enum oid_value) recordSyntax;
+ oid_ent_to_oid(&prefsyn, oid_syntax);
+ req->preferredRecordSyntax = oid_syntax;
+ }
+ logf (LOG_LOG, "send_searchRequest");
+ return send_Z_PDU(apdu);