From: Adam Dickmeiss Date: Tue, 15 Mar 2011 08:44:26 +0000 (+0100) Subject: Multi iconv conversions for yaz_opac_decode_wrbuf2 X-Git-Tag: v4.1.7~4 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=a02076d5c1a2ee1e080ea32b3e76c7af751b88b7;p=yaz-moved-to-github.git Multi iconv conversions for yaz_opac_decode_wrbuf2 This function uses iconv handle for MARC first; failing that uses iconv handle supplied to function yaz_opac_decode_wrbuf. Bug #4048. --- diff --git a/src/opacdisp.c b/src/opacdisp.c index 807ca2b..735d969 100644 --- a/src/opacdisp.c +++ b/src/opacdisp.c @@ -18,18 +18,25 @@ #include #include -static void opac_element_str(WRBUF wrbuf, yaz_iconv_t cd, +static void opac_element_str(WRBUF wrbuf, yaz_iconv_t cd1, yaz_iconv_t cd2, int l, const char *elem, const char *data) { if (data) { + size_t pos; while (--l >= 0) wrbuf_puts(wrbuf, " "); wrbuf_puts(wrbuf, "<"); wrbuf_puts(wrbuf, elem); wrbuf_puts(wrbuf, ">"); - wrbuf_iconv_puts_cdata(wrbuf, cd, data); + + pos = wrbuf->pos; /* save position */ + if (wrbuf_iconv_write_x(wrbuf, cd1, data, strlen(data), 1) && cd2) + { + wrbuf->pos = pos; /* rewind to pos */ + wrbuf_iconv_write_x(wrbuf, cd2, data, strlen(data), 1); + } wrbuf_puts(wrbuf, "\n"); @@ -53,9 +60,10 @@ static void opac_element_bool(WRBUF wrbuf, int l, const char *elem, int *data) } void yaz_opac_decode_wrbuf2(yaz_marc_t mt, Z_OPACRecord *r, WRBUF wrbuf, - yaz_iconv_t cd) + yaz_iconv_t cd2) { int i; + yaz_iconv_t cd1 = yaz_marc_get_iconv(mt); wrbuf_puts(wrbuf, "\n"); if (r->bibliographicRecord) @@ -92,35 +100,50 @@ void yaz_opac_decode_wrbuf2(yaz_marc_t mt, Z_OPACRecord *r, WRBUF wrbuf, Z_HoldingsAndCircData *d = h->u.holdingsAndCirc; - opac_element_str(wrbuf, cd, 2, "typeOfRecord", d->typeOfRecord); - opac_element_str(wrbuf, cd, 2, "encodingLevel", d->encodingLevel); - opac_element_str(wrbuf, cd, 2, "format", d->format); - opac_element_str(wrbuf, cd, 2, "receiptAcqStatus", d->receiptAcqStatus); - opac_element_str(wrbuf, cd, 2, "generalRetention", d->generalRetention); - opac_element_str(wrbuf, cd, 2, "completeness", d->completeness); - opac_element_str(wrbuf, cd, 2, "dateOfReport", d->dateOfReport); - opac_element_str(wrbuf, cd, 2, "nucCode", d->nucCode); - opac_element_str(wrbuf, cd, 2, "localLocation", d->localLocation); - opac_element_str(wrbuf, cd, 2, "shelvingLocation", d->shelvingLocation); - opac_element_str(wrbuf, cd, 2, "callNumber", d->callNumber); - opac_element_str(wrbuf, cd, 2, "shelvingData", d->shelvingData); - - opac_element_str(wrbuf, cd, 2, "copyNumber", d->copyNumber); - opac_element_str(wrbuf, cd, 2, "publicNote", d->publicNote); - opac_element_str(wrbuf, cd, 2, "reproductionNote", d->reproductionNote); - opac_element_str(wrbuf, cd, 2, "termsUseRepro", d->termsUseRepro); - opac_element_str(wrbuf, cd, 2, "enumAndChron", d->enumAndChron); + opac_element_str(wrbuf, cd1, cd2, 2, "typeOfRecord", + d->typeOfRecord); + opac_element_str(wrbuf, cd1, cd2, 2, "encodingLevel", + d->encodingLevel); + opac_element_str(wrbuf, cd1, cd2, 2, "format", + d->format); + opac_element_str(wrbuf, cd1, cd2, 2, "receiptAcqStatus", + d->receiptAcqStatus); + opac_element_str(wrbuf, cd1, cd2, 2, "generalRetention", + d->generalRetention); + opac_element_str(wrbuf, cd1, cd2, 2, "completeness", + d->completeness); + opac_element_str(wrbuf, cd1, cd2, 2, "dateOfReport", + d->dateOfReport); + opac_element_str(wrbuf, cd1, cd2, 2, "nucCode", d->nucCode); + opac_element_str(wrbuf, cd1, cd2, 2, "localLocation", + d->localLocation); + opac_element_str(wrbuf, cd1, cd2, 2, "shelvingLocation", + d->shelvingLocation); + opac_element_str(wrbuf, cd1, cd2, 2, "callNumber", + d->callNumber); + opac_element_str(wrbuf, cd1, cd2, 2, "shelvingData", + d->shelvingData); + opac_element_str(wrbuf, cd1, cd2, 2, "copyNumber", + d->copyNumber); + opac_element_str(wrbuf, cd1, cd2, 2, "publicNote", + d->publicNote); + opac_element_str(wrbuf, cd1, cd2, 2, "reproductionNote", + d->reproductionNote); + opac_element_str(wrbuf, cd1, cd2, 2, "termsUseRepro", + d->termsUseRepro); + opac_element_str(wrbuf, cd1, cd2, 2, "enumAndChron", + d->enumAndChron); if (d->num_volumes) { wrbuf_puts (wrbuf, " \n"); for (j = 0; jnum_volumes; j++) { wrbuf_puts (wrbuf, " \n"); - opac_element_str(wrbuf, cd, 4, "enumeration", + opac_element_str(wrbuf, cd1, cd2, 4, "enumeration", d->volumes[j]->enumeration); - opac_element_str(wrbuf, cd, 4, "chronology", + opac_element_str(wrbuf, cd1, cd2, 4, "chronology", d->volumes[j]->chronology); - opac_element_str(wrbuf, cd, 4, "enumAndChron", + opac_element_str(wrbuf, cd1, cd2, 4, "enumAndChron", d->volumes[j]->enumAndChron); wrbuf_puts(wrbuf, " \n"); } @@ -134,23 +157,23 @@ void yaz_opac_decode_wrbuf2(yaz_marc_t mt, Z_OPACRecord *r, WRBUF wrbuf, wrbuf_puts(wrbuf," \n"); opac_element_bool(wrbuf, 4, "availableNow", d->circulationData[j]->availableNow); - opac_element_str(wrbuf, cd, 4, "availabiltyDate", + opac_element_str(wrbuf, cd1, cd2, 4, "availabiltyDate", d->circulationData[j]->availablityDate); - opac_element_str(wrbuf, cd, 4, "availableThru", + opac_element_str(wrbuf, cd1, cd2, 4, "availableThru", d->circulationData[j]->availableThru); - opac_element_str(wrbuf, cd, 4, "restrictions", + opac_element_str(wrbuf, cd1, cd2, 4, "restrictions", d->circulationData[j]->restrictions); - opac_element_str(wrbuf, cd, 4, "itemId", + opac_element_str(wrbuf, cd1, cd2, 4, "itemId", d->circulationData[j]->itemId); opac_element_bool(wrbuf, 4, "renewable", d->circulationData[j]->renewable); opac_element_bool(wrbuf, 4, "onHold", d->circulationData[j]->onHold); - opac_element_str(wrbuf, cd, 4, "enumAndChron", + opac_element_str(wrbuf, cd1, cd2, 4, "enumAndChron", d->circulationData[j]->enumAndChron); - opac_element_str(wrbuf, cd, 4, "midspine", + opac_element_str(wrbuf, cd1, cd2, 4, "midspine", d->circulationData[j]->midspine); - opac_element_str(wrbuf, cd, 4, "temporaryLocation", + opac_element_str(wrbuf, cd1, cd2, 4, "temporaryLocation", d->circulationData[j]->temporaryLocation); wrbuf_puts(wrbuf, " \n"); } @@ -165,7 +188,7 @@ void yaz_opac_decode_wrbuf2(yaz_marc_t mt, Z_OPACRecord *r, WRBUF wrbuf, void yaz_opac_decode_wrbuf(yaz_marc_t mt, Z_OPACRecord *r, WRBUF wrbuf) { - yaz_opac_decode_wrbuf2(mt, r, wrbuf, yaz_marc_get_iconv(mt)); + yaz_opac_decode_wrbuf2(mt, r, wrbuf, 0); } /*