X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmarcdisp.c;h=1680ea50041ebae881550ae1da7111e656df842c;hb=461dbf959bb1d556261c66300d6b0eabb0ae0909;hp=e7df01ec1aa2cbd13a54dabfac6662ae32522e15;hpb=a1adc770bc8b74097e1d4388d16b1246063da7e7;p=yaz-moved-to-github.git diff --git a/src/marcdisp.c b/src/marcdisp.c index e7df01e..1680ea5 100644 --- a/src/marcdisp.c +++ b/src/marcdisp.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2006, Index Data ApS * See the file LICENSE for details. * - * $Id: marcdisp.c,v 1.30 2006-05-23 13:17:30 adam Exp $ + * $Id: marcdisp.c,v 1.32 2006-08-01 09:28:04 adam Exp $ */ /** @@ -26,7 +26,7 @@ #include #include -#if HAVE_XML2 +#if YAZ_HAVE_XML2 #include #include #endif @@ -181,7 +181,7 @@ void yaz_marc_add_controlfield(yaz_marc_t mt, const char *tag, } } -#if HAVE_XML2 +#if YAZ_HAVE_XML2 void yaz_marc_add_controlfield_xml(yaz_marc_t mt, const xmlNode *ptr_tag, const xmlNode *ptr_data) { @@ -206,7 +206,7 @@ void yaz_marc_add_datafield(yaz_marc_t mt, const char *tag, mt->subfield_pp = &n->u.datafield.subfields; } -#if HAVE_XML2 +#if YAZ_HAVE_XML2 void yaz_marc_add_datafield_xml(yaz_marc_t mt, const xmlNode *ptr_tag, const char *indicator, size_t indicator_len) { @@ -590,7 +590,7 @@ int yaz_marc_write_iso2709(yaz_marc_t mt, WRBUF wr) int length_implementation; int data_offset = 0; const char *leader = 0; - WRBUF wr_dir, wr_head; + WRBUF wr_dir, wr_head, wr_data_tmp; int base_address; for (n = mt->nodes; n; n = n->next) @@ -610,6 +610,7 @@ int yaz_marc_write_iso2709(yaz_marc_t mt, WRBUF wr) if (!atoi_n_check(leader+22, 1, &length_implementation)) return -1; + wr_data_tmp = wrbuf_alloc(); wr_dir = wrbuf_alloc(); for (n = mt->nodes; n; n = n->next) { @@ -621,12 +622,20 @@ int yaz_marc_write_iso2709(yaz_marc_t mt, WRBUF wr) wrbuf_printf(wr_dir, "%.3s", n->u.datafield.tag); data_length += indicator_length; for (s = n->u.datafield.subfields; s; s = s->next) - data_length += 1+strlen(s->code_data); + { + wrbuf_rewind(wr_data_tmp); + wrbuf_iconv_puts(wr_data_tmp, mt->iconv_cd, s->code_data); + data_length += 1+wrbuf_len(wr_data_tmp); + } data_length++; break; case YAZ_MARC_CONTROLFIELD: wrbuf_printf(wr_dir, "%.3s", n->u.controlfield.tag); - data_length += strlen(n->u.controlfield.data); + + wrbuf_rewind(wr_data_tmp); + wrbuf_iconv_puts(wr_data_tmp, mt->iconv_cd, + n->u.controlfield.data); + data_length += wrbuf_len(wr_data_tmp); data_length++; break; case YAZ_MARC_COMMENT: @@ -662,6 +671,7 @@ int yaz_marc_write_iso2709(yaz_marc_t mt, WRBUF wr) wrbuf_write(wr, wrbuf_buf(wr_dir), wrbuf_len(wr_dir)); wrbuf_free(wr_head, 1); wrbuf_free(wr_dir, 1); + wrbuf_free(wr_data_tmp, 1); for (n = mt->nodes; n; n = n->next) { @@ -674,12 +684,12 @@ int yaz_marc_write_iso2709(yaz_marc_t mt, WRBUF wr) for (s = n->u.datafield.subfields; s; s = s->next) { wrbuf_printf(wr, "%c", ISO2709_IDFS); - wrbuf_puts(wr, s->code_data); + wrbuf_iconv_puts(wr, mt->iconv_cd, s->code_data); } wrbuf_printf(wr, "%c", ISO2709_FS); break; case YAZ_MARC_CONTROLFIELD: - wrbuf_puts(wr, n->u.controlfield.data); + wrbuf_iconv_puts(wr, mt->iconv_cd, n->u.controlfield.data); wrbuf_printf(wr, "%c", ISO2709_FS); break; case YAZ_MARC_COMMENT: @@ -692,7 +702,7 @@ int yaz_marc_write_iso2709(yaz_marc_t mt, WRBUF wr) return 0; } -#if HAVE_XML2 +#if YAZ_HAVE_XML2 int yaz_marc_read_xml_subfields(yaz_marc_t mt, const xmlNode *ptr) { for (; ptr; ptr = ptr->next)