- {
- if (apdu->u.initRequest->implementationId)
- yaz_log(YLOG_LOG, "%simplementationId: %s",
- m_session_str, apdu->u.initRequest->implementationId);
- if (apdu->u.initRequest->implementationName)
- yaz_log(YLOG_LOG, "%simplementationName: %s",
- m_session_str, apdu->u.initRequest->implementationName);
- if (apdu->u.initRequest->implementationVersion)
- yaz_log(YLOG_LOG, "%simplementationVersion: %s",
- m_session_str, apdu->u.initRequest->implementationVersion);
- if (m_initRequest_apdu == 0)
- {
- if (m_initRequest_mem)
- nmem_destroy(m_initRequest_mem);
-
- m_initRequest_apdu = apdu;
- m_initRequest_mem = odr_extract_mem(odr_decode());
-
- m_initRequest_preferredMessageSize = *apdu->u.initRequest->
- preferredMessageSize;
- *apdu->u.initRequest->preferredMessageSize = 1024*1024;
- m_initRequest_maximumRecordSize = *apdu->u.initRequest->
- maximumRecordSize;
- *apdu->u.initRequest->maximumRecordSize = 1024*1024;
-
- // Save proposal charsets and langs.
- if (ODR_MASK_GET(apdu->u.initRequest->options,
- Z_Options_negotiationModel))
- {
- Z_CharSetandLanguageNegotiation *charSetandLangRecord =
- yaz_get_charneg_record(*oi);
-
- yaz_get_proposal_charneg(m_referenceId_mem,
- charSetandLangRecord,
- &m_initRequest_oi_negotiation_charsets,
- &m_initRequest_oi_negotiation_num_charsets,
- &m_initRequest_oi_negotiation_langs,
- &m_initRequest_oi_negotiation_num_langs,
- &m_initRequest_oi_negotiation_selected);
-
- for (int i=0; i<m_initRequest_oi_negotiation_num_charsets; i++)
- {
- yaz_log(YLOG_LOG, "%scharacters set proposal: %s",
- m_session_str,(m_initRequest_oi_negotiation_charsets[i])?
- m_initRequest_oi_negotiation_charsets[i]:"none");
- }
- for (int i=0; i<m_initRequest_oi_negotiation_num_langs; i++)
- {
- yaz_log(YLOG_LOG, "%slanguages proposal: %s",
- m_session_str, (m_initRequest_oi_negotiation_langs[i])?
- m_initRequest_oi_negotiation_langs[i]:"none");
- }
- yaz_log(YLOG_LOG, "%sselected proposal: %d (boolean)",
- m_session_str, m_initRequest_oi_negotiation_selected);
- }
- // save init options for the response..
- m_initRequest_options = apdu->u.initRequest->options;
-
- apdu->u.initRequest->options =
- (Odr_bitmask *)nmem_malloc(m_initRequest_mem,
- sizeof(Odr_bitmask));
- ODR_MASK_ZERO(apdu->u.initRequest->options);
- int i;
- for (i = 0; i<= 24; i++)
- ODR_MASK_SET(apdu->u.initRequest->options, i);
- // check negotiation option
- if (!ODR_MASK_GET(m_initRequest_options,
- Z_Options_negotiationModel))
- {
- ODR_MASK_CLEAR(apdu->u.initRequest->options,
- Z_Options_negotiationModel);
- }
- ODR_MASK_CLEAR(apdu->u.initRequest->options,
- Z_Options_concurrentOperations);
- // make new version
- m_initRequest_version = apdu->u.initRequest->protocolVersion;
- apdu->u.initRequest->protocolVersion =
- (Odr_bitmask *)nmem_malloc(m_initRequest_mem,
- sizeof(Odr_bitmask));
- ODR_MASK_ZERO(apdu->u.initRequest->protocolVersion);
-
- for (i = 0; i<= 8; i++)
- ODR_MASK_SET(apdu->u.initRequest->protocolVersion, i);
- }
- if (m_client->m_init_flag)
- {
- if (handle_init_response_for_invalid_session(apdu))
- return;
- if (m_client->m_initResponse)
- {
- Z_APDU *apdu2 = m_client->m_initResponse;
- apdu2->u.initResponse->otherInfo = 0;
- if (m_client->m_cookie && *m_client->m_cookie)
- set_otherInformationString(apdu2, VAL_COOKIE, 1,
- m_client->m_cookie);
- apdu2->u.initResponse->referenceId =
- apdu->u.initRequest->referenceId;
- apdu2->u.initResponse->options = m_client->m_initResponse_options;
- apdu2->u.initResponse->protocolVersion =
- m_client->m_initResponse_version;
-
- send_to_client(apdu2);
- return;
- }
- }
- m_client->m_init_flag = 1;
- }
-
- if (!handle_authentication(apdu))
- {
- Z_APDU *apdu_reject = zget_APDU(odr_encode(), Z_APDU_initResponse);
- *apdu_reject->u.initResponse->result = 0;
- send_to_client(apdu_reject);
-
- shutdown();
- return;
- }