/* This file is part of Metaproxy.
- Copyright (C) 2005-2012 Index Data
+ Copyright (C) 2005-2013 Index Data
Metaproxy is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
}
+Z_RecordComposition *mp_util::piggyback_to_RecordComposition(
+ ODR odr, Odr_int result_set_size, Z_SearchRequest *sreq)
+{
+ Z_RecordComposition *comp = 0;
+ Odr_int present_dummy;
+ const char *element_set_name = 0;
+ mp::util::piggyback_sr(sreq, result_set_size,
+ present_dummy, &element_set_name);
+ if (element_set_name)
+ {
+ comp = (Z_RecordComposition *) odr_malloc(odr, sizeof(*comp));
+ comp->which = Z_RecordComp_simple;
+ comp->u.simple = (Z_ElementSetNames *)
+ odr_malloc(odr, sizeof(Z_ElementSetNames));
+ comp->u.simple->which = Z_ElementSetNames_generic;
+ comp->u.simple->u.generic = odr_strdup(odr, element_set_name);
+ }
+ return comp;
+}
+
void mp_util::piggyback_sr(Z_SearchRequest *sreq,
Odr_int result_set_size,
Odr_int &number_to_present,
void mp_util::get_init_diagnostics(
Z_InitResponse *initrs, int &error_code, std::string &addinfo)
{
- Z_External *uif = initrs->userInformationField;
- if (uif && uif->which == Z_External_userInfo1)
- {
- Z_OtherInformation *ui = uif->u.userInfo1;
- int i;
- for (i = 0; i < ui->num_elements; i++)
- {
- Z_OtherInformationUnit *unit = ui->list[i];
- if (unit->which == Z_OtherInfo_externallyDefinedInfo &&
- unit->information.externallyDefinedInfo &&
- unit->information.externallyDefinedInfo->which ==
- Z_External_diag1)
- {
- Z_DiagnosticFormat *diag =
- unit->information.externallyDefinedInfo->u.diag1;
-
- if (diag->num > 0)
- {
- Z_DiagnosticFormat_s *ds = diag->elements[0];
- if (ds->which == Z_DiagnosticFormat_s_defaultDiagRec)
- mp::util::get_default_diag(ds->u.defaultDiagRec,
- error_code, addinfo);
- }
- }
- }
- }
+ Z_DefaultDiagFormat *df = yaz_decode_init_diag(0, initrs);
+
+ if (df)
+ get_default_diag(df, error_code, addinfo);
}
int mp_util::get_or_remove_vhost_otherinfo(
return apdu;
}
-Z_GDU *mp::odr::create_HTTP_Response(mp::Session &session,
- Z_HTTP_Request *hreq, int code)
+Z_GDU *mp::odr::create_HTTP_Response_details(mp::Session &session,
+ Z_HTTP_Request *hreq, int code,
+ const char *details)
{
const char *response_version = "1.0";
bool keepalive = false;
response_version = "1.1";
}
- Z_GDU *gdu = z_get_HTTP_Response(m_odr, code);
+ Z_GDU *gdu = z_get_HTTP_Response_details(m_odr, code, details);
Z_HTTP_Response *hres = gdu->u.HTTP_Response;
hres->version = odr_strdup(m_odr, response_version);
if (keepalive)
return gdu;
}
+Z_GDU *mp::odr::create_HTTP_Response(mp::Session &session,
+ Z_HTTP_Request *hreq, int code)
+{
+ return create_HTTP_Response_details(session, hreq, code, 0);
+
+}
+
Z_ReferenceId **mp_util::get_referenceId(const Z_APDU *apdu)
{
switch (apdu->which)