+ yaz_log(LOG_LOG, "Version: %s", req->implementationVersion);
+
+ assoc->init->stream = assoc->encode;
+ assoc->init->print = assoc->print;
+ assoc->init->auth = req->idAuthentication;
+ assoc->init->referenceId = req->referenceId;
+ assoc->init->implementation_version = 0;
+ assoc->init->implementation_id = 0;
+ assoc->init->implementation_name = 0;
+ assoc->init->bend_sort = NULL;
+ assoc->init->bend_search = NULL;
+ assoc->init->bend_present = NULL;
+ assoc->init->bend_esrequest = NULL;
+ assoc->init->bend_delete = NULL;
+ assoc->init->bend_scan = NULL;
+ assoc->init->bend_segment = NULL;
+ assoc->init->bend_fetch = NULL;
+ assoc->init->charneg_request = NULL;
+ assoc->init->charneg_response = NULL;
+ assoc->init->decode = assoc->decode;
+
+ if (ODR_MASK_GET(req->options, Z_Options_negotiationModel))
+ {
+ Z_CharSetandLanguageNegotiation *negotiation =
+ yaz_get_charneg_record (req->otherInfo);
+ if (negotiation->which == Z_CharSetandLanguageNegotiation_proposal)
+ assoc->init->charneg_request = negotiation;
+ }
+
+ assoc->init->peer_name =
+ odr_strdup (assoc->encode, cs_addrstr(assoc->client_link));
+ if (!(binitres = (*cb->bend_init)(assoc->init)))
+ {
+ yaz_log(LOG_WARN, "Bad response from backend.");
+ return 0;
+ }
+
+ assoc->backend = binitres->handle;
+ if ((assoc->init->bend_sort))
+ yaz_log (LOG_DEBUG, "Sort handler installed");
+ if ((assoc->init->bend_search))
+ yaz_log (LOG_DEBUG, "Search handler installed");
+ if ((assoc->init->bend_present))
+ yaz_log (LOG_DEBUG, "Present handler installed");
+ if ((assoc->init->bend_esrequest))
+ yaz_log (LOG_DEBUG, "ESRequest handler installed");
+ if ((assoc->init->bend_delete))
+ yaz_log (LOG_DEBUG, "Delete handler installed");
+ if ((assoc->init->bend_scan))
+ yaz_log (LOG_DEBUG, "Scan handler installed");
+ if ((assoc->init->bend_segment))
+ yaz_log (LOG_DEBUG, "Segment handler installed");
+
+ resp->referenceId = req->referenceId;
+ *options = '\0';
+ /* let's tell the client what we can do */
+ if (ODR_MASK_GET(req->options, Z_Options_search))
+ {
+ ODR_MASK_SET(resp->options, Z_Options_search);
+ strcat(options, "srch");
+ }
+ if (ODR_MASK_GET(req->options, Z_Options_present))
+ {
+ ODR_MASK_SET(resp->options, Z_Options_present);
+ strcat(options, " prst");
+ }
+ if (ODR_MASK_GET(req->options, Z_Options_delSet) &&
+ assoc->init->bend_delete)
+ {
+ ODR_MASK_SET(resp->options, Z_Options_delSet);
+ strcat(options, " del");
+ }
+ if (ODR_MASK_GET(req->options, Z_Options_extendedServices) &&
+ assoc->init->bend_esrequest)
+ {
+ ODR_MASK_SET(resp->options, Z_Options_extendedServices);
+ strcat (options, " extendedServices");
+ }
+ if (ODR_MASK_GET(req->options, Z_Options_namedResultSets))
+ {
+ ODR_MASK_SET(resp->options, Z_Options_namedResultSets);
+ strcat(options, " namedresults");
+ }
+ if (ODR_MASK_GET(req->options, Z_Options_scan) && assoc->init->bend_scan)
+ {
+ ODR_MASK_SET(resp->options, Z_Options_scan);
+ strcat(options, " scan");
+ }
+ if (ODR_MASK_GET(req->options, Z_Options_concurrentOperations))
+ {
+ ODR_MASK_SET(resp->options, Z_Options_concurrentOperations);
+ strcat(options, " concurrop");
+ }
+ if (ODR_MASK_GET(req->options, Z_Options_sort) && assoc->init->bend_sort)
+ {
+ ODR_MASK_SET(resp->options, Z_Options_sort);
+ strcat(options, " sort");
+ }
+
+ if (ODR_MASK_GET(req->options, Z_Options_negotiationModel)
+ && assoc->init->charneg_response)
+ {
+ Z_OtherInformation **p;
+ Z_OtherInformationUnit *p0;
+
+ yaz_oi_APDU(apdu, &p);
+
+ if ((p0=yaz_oi_update(p, assoc->encode, NULL, 0, 0))) {
+ ODR_MASK_SET(resp->options, Z_Options_negotiationModel);
+
+ p0->which = Z_OtherInfo_externallyDefinedInfo;
+ p0->information.externallyDefinedInfo =
+ assoc->init->charneg_response;
+ }
+ ODR_MASK_SET(resp->options, Z_Options_negotiationModel);
+ strcat(options, " negotiation");
+ }