X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Fyaz-proxy.cpp;h=e7783f95953a954f44765108eae102ed2a6093a2;hb=779c379c70bf479073cc4968f6bf5ad35ffe6eec;hp=f2e5f25d980fc6943d865f41ea0bb409bf3edbd1;hpb=f8f641aaf624ab2d522fba4f90f6180b0fc0a681;p=yazpp-moved-to-github.git diff --git a/src/yaz-proxy.cpp b/src/yaz-proxy.cpp index f2e5f25..e7783f9 100644 --- a/src/yaz-proxy.cpp +++ b/src/yaz-proxy.cpp @@ -2,7 +2,7 @@ * Copyright (c) 1998-2004, Index Data. * See the file LICENSE for details. * - * $Id: yaz-proxy.cpp,v 1.107 2004-03-01 17:18:39 adam Exp $ + * $Id: yaz-proxy.cpp,v 1.110 2004-03-17 10:49:22 adam Exp $ */ #include @@ -639,9 +639,13 @@ void Yaz_Proxy::convert_xsl_delay() Z_External *r = npr->u.databaseRecord; if (r->which == Z_External_octet) { +#if 0 + fwrite((char*) r->u.octet_aligned->buf, 1, r->u.octet_aligned->len, stdout); +#endif xmlDocPtr res, doc = xmlParseMemory( (char*) r->u.octet_aligned->buf, r->u.octet_aligned->len); + yaz_log(LOG_LOG, "%sXSLT convert %d", m_session_str, m_stylesheet_offset); @@ -682,8 +686,10 @@ void Yaz_Proxy::convert_to_marcxml(Z_NamePlusRecordList *p) { int i; + yaz_iconv_t cd = yaz_iconv_open("UTF-8", "MARC-8"); yaz_marc_t mt = yaz_marc_create(); yaz_marc_xml(mt, YAZ_MARC_MARCXML); + yaz_marc_iconv(mt, cd); for (i = 0; i < p->num_records; i++) { Z_NamePlusRecord *npr = p->records[i]; @@ -698,44 +704,15 @@ void Yaz_Proxy::convert_to_marcxml(Z_NamePlusRecordList *p) r->u.octet_aligned->len, &result, &rlen)) { - yaz_iconv_t cd = yaz_iconv_open("UTF-8", "MARC-8"); - WRBUF wrbuf = wrbuf_alloc(); - - char outbuf[120]; - size_t inbytesleft = rlen; - const char *inp = result; - while (cd && inbytesleft) - { - size_t outbytesleft = sizeof(outbuf); - char *outp = outbuf; - size_t r; - - r = yaz_iconv (cd, (char**) &inp, - &inbytesleft, - &outp, &outbytesleft); - if (r == (size_t) (-1)) - { - int e = yaz_iconv_error(cd); - if (e != YAZ_ICONV_E2BIG) - { - yaz_log(LOG_WARN, "conversion failure"); - break; - } - } - wrbuf_write(wrbuf, outbuf, outp - outbuf); - } - if (cd) - yaz_iconv_close(cd); - npr->u.databaseRecord = z_ext_record(odr_encode(), VAL_TEXT_XML, - wrbuf_buf(wrbuf), - wrbuf_len(wrbuf)); - wrbuf_free(wrbuf, 1); + result, rlen); } } } } + if (cd) + yaz_iconv_close(cd); yaz_marc_destroy(mt); } @@ -1019,7 +996,7 @@ int Yaz_Proxy::send_to_client(Z_APDU *apdu) int kill_session = 0; Z_ReferenceId **new_id = get_referenceIdP(apdu); - if (new_id && m_referenceId) + if (new_id) *new_id = m_referenceId; if (apdu->which == Z_APDU_searchResponse) @@ -1393,8 +1370,8 @@ void Yaz_Proxy::recv_GDU(Z_GDU *apdu, int len) m_bytes_recv += len; - if (m_log_mask & PROXY_LOG_APDU_CLIENT) - yaz_log (LOG_DEBUG, "%sReceiving %s from client %d bytes", + if (m_log_mask & PROXY_LOG_REQ_CLIENT) + yaz_log (LOG_LOG, "%sReceiving %s from client %d bytes", m_session_str, gdu_name(apdu), len); if (m_bw_hold_PDU) // double incoming PDU. shutdown now.