X-Git-Url: http://git.indexdata.com/?p=yazproxy-moved-to-github.git;a=blobdiff_plain;f=src%2Fcharset-converter.cpp;h=5bb4e030003fc9a3615c2403dec60b8bbc4b6475;hp=4a9b8c3fe1a57d4a4480c8d8dc1e04d02bb64aa1;hb=e0c91845b81ed75c36af0fef3306760facf61725;hpb=e1e297959681cde585d782c49db6daf66675abb0 diff --git a/src/charset-converter.cpp b/src/charset-converter.cpp index 4a9b8c3..5bb4e03 100644 --- a/src/charset-converter.cpp +++ b/src/charset-converter.cpp @@ -1,4 +1,4 @@ -/* $Id: charset-converter.cpp,v 1.1 2005-05-04 08:35:03 adam Exp $ +/* $Id: charset-converter.cpp,v 1.3 2005-05-18 20:15:22 adam Exp $ Copyright (c) 1998-2005, Index Data. This file is part of the yaz-proxy. @@ -19,6 +19,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include #include #include "proxyp.h" @@ -27,6 +28,7 @@ Yaz_CharsetConverter::Yaz_CharsetConverter() m_wrbuf = wrbuf_alloc(); m_target_query_charset = 0; m_client_query_charset = 0; + m_client_charset_selected = 0; } Yaz_CharsetConverter::~Yaz_CharsetConverter() @@ -36,6 +38,11 @@ Yaz_CharsetConverter::~Yaz_CharsetConverter() xfree(m_client_query_charset); } +const char *Yaz_CharsetConverter::get_target_query_charset() +{ + return m_target_query_charset; +} + void Yaz_CharsetConverter::set_target_query_charset(const char *s) { xfree(m_target_query_charset); @@ -52,16 +59,39 @@ void Yaz_CharsetConverter::set_client_query_charset(const char *s) m_client_query_charset = xstrdup(s); } +const char *Yaz_CharsetConverter::get_client_query_charset() +{ + return m_client_query_charset; +} + +void Yaz_CharsetConverter::set_client_charset_selected(int sel) +{ + m_client_charset_selected = sel; +} + +int Yaz_CharsetConverter::get_client_charset_selected() +{ + return m_client_charset_selected; +} + void Yaz_CharsetConverter::convert_type_1(char *buf_in, int len_in, char **buf_out, int *len_out, ODR o) { wrbuf_rewind(m_wrbuf); wrbuf_iconv_write(m_wrbuf, m_ct, buf_in, len_in); - + *len_out = wrbuf_len(m_wrbuf); - *buf_out = (char*) odr_malloc(o, *len_out); - memcpy(*buf_out, wrbuf_buf(m_wrbuf), *len_out); + if (*len_out == 0) + { // we assume conversion failed + *buf_out = buf_in; + *len_out = len_in; + } + else + { + *buf_out = (char*) odr_malloc(o, *len_out); + memcpy(*buf_out, wrbuf_buf(m_wrbuf), *len_out); + } } void Yaz_CharsetConverter::convert_type_1(Z_Term *q, ODR o) @@ -102,6 +132,7 @@ void Yaz_CharsetConverter::convert_type_1(Z_RPNStructure *q, ODR o) break; } } + void Yaz_CharsetConverter::convert_type_1(Z_RPNQuery *q, ODR o) { if (m_target_query_charset && m_client_query_charset)