* Copyright (c) 1998-2004, Index Data.
* See the file LICENSE for details.
*
- * $Id: yaz-proxy-config.cpp,v 1.23 2004-01-07 13:40:06 adam Exp $
+ * $Id: yaz-proxy-config.cpp,v 1.24 2004-01-15 23:44:58 adam Exp $
*/
#include <ctype.h>
if (ptr->type == XML_ELEMENT_NODE &&
!strcmp((const char *) ptr->name, "explain"))
{
+ xmlNodePtr ptr1 = ptr->children;
+ if (db)
+ {
+ for (; ptr1; ptr1 = ptr1->next)
+ if (ptr1->type == XML_ELEMENT_NODE &&
+ !strcmp((const char *) ptr1->name, "serverInfo"))
+ break;
+ if (!ptr1)
+ continue;
+ for (ptr1 = ptr1->children; ptr; ptr1 = ptr1->next)
+ if (ptr1->type == XML_ELEMENT_NODE &&
+ !strcmp((const char *) ptr1->name, "database"))
+ break;
+
+ if (!ptr1)
+ continue;
+ for (ptr1 = ptr1->children; ptr1; ptr1 = ptr1->next)
+ if (ptr1->type == XML_TEXT_NODE &&
+ ptr1->content &&
+ !strcmp((const char *) ptr1->content, db))
+ break;
+ if (!ptr1)
+ continue;
+ }
xmlNodePtr ptr2 = xmlCopyNode(ptr, 1);
xmlDocPtr doc = xmlNewDoc((const xmlChar *) "1.0");
return content;
}
}
- else
- yaz_log(LOG_WARN, "No explain node 1");
-
#endif
yaz_log(LOG_WARN, "No explain node");
return 0;
* Copyright (c) 1998-2004, Index Data.
* See the file LICENSE for details.
*
- * $Id: yaz-proxy.cpp,v 1.90 2004-01-15 15:47:52 adam Exp $
+ * $Id: yaz-proxy.cpp,v 1.91 2004-01-15 23:44:58 adam Exp $
*/
#include <assert.h>
m_marcxml_flag = 0;
m_stylesheet_schema = 0;
m_s2z_stylesheet = 0;
+ m_s2z_database = 0;
m_schema = 0;
m_initRequest_apdu = 0;
m_initRequest_mem = 0;
int Yaz_Proxy::send_srw_explain_response(Z_SRW_diagnostic *diagnostics,
int num_diagnostics)
{
- Z_SRW_PDU *res = yaz_srw_get(odr_encode(), Z_SRW_explain_response);
- Z_SRW_explainResponse *er = res->u.explain_response;
-
Yaz_ProxyConfig *cfg = check_reconfigure();
if (cfg)
{
int len;
char *b = cfg->get_explain(odr_encode(), 0 /* target */,
- 0 /* db */, &len);
+ m_s2z_database, &len);
if (b)
{
+ Z_SRW_PDU *res = yaz_srw_get(odr_encode(), Z_SRW_explain_response);
+ Z_SRW_explainResponse *er = res->u.explain_response;
+
er->record.recordData_buf = b;
er->record.recordData_len = len;
er->record.recordPacking = m_s2z_packing;
+
+ er->diagnostics = diagnostics;
+ er->num_diagnostics = num_diagnostics;
+ return send_srw_response(res);
}
}
- er->diagnostics = diagnostics;
- er->num_diagnostics = num_diagnostics;
- return send_srw_response(res);
+ return send_http_response(404);
}
int Yaz_Proxy::send_PDU_convert(Z_APDU *apdu, int *len)
void Yaz_Proxy::handle_incoming_HTTP(Z_HTTP_Request *hreq)
{
-
if (m_s2z_odr_init)
{
odr_destroy(m_s2z_odr_init);
{
Z_SRW_searchRetrieveRequest *srw_req = srw_pdu->u.request;
+ m_s2z_database = odr_strdup(m_s2z_odr_init, srw_req->database);
// recordXPath unsupported.
if (srw_req->recordXPath)
{
{
Z_SRW_explainRequest *srw_req = srw_pdu->u.explain_request;
+ m_s2z_database = odr_strdup(m_s2z_odr_init, srw_req->database);
+
// save stylesheet
if (srw_req->stylesheet)
m_s2z_stylesheet =
}
else if (srw_pdu->which == Z_SRW_scan_request)
{
+ m_s2z_database = odr_strdup(m_s2z_odr_init,
+ srw_pdu->u.scan_request->database);
+
yaz_add_srw_diagnostic(odr_decode(),
&diagnostic, &num_diagnostic,
4, "scan");
}
else
{
+ m_s2z_database = 0;
+
send_to_srw_client_error(4, 0);
}
}