X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fsiconv.c;h=596fe25daaa81d0d2086431453c9efc4fb705afd;hp=36dc4b263f0caea687922b6dc616eb9b25960ebd;hb=b06636208651777c08e2456bf3b5953fc3c0f2c2;hpb=96c6e58f286787106e4a7b3bb3900a36051968d6 diff --git a/src/siconv.c b/src/siconv.c index 36dc4b2..596fe25 100644 --- a/src/siconv.c +++ b/src/siconv.c @@ -1,5 +1,5 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2008 Index Data + * Copyright (C) 1995-2013 Index Data * See the file LICENSE for details. */ /** @@ -20,14 +20,13 @@ #include #include #include -#include #if HAVE_ICONV_H #include #endif #include -#include +#include #include "iconv-p.h" struct yaz_iconv_struct { @@ -78,6 +77,8 @@ static int prepare_decoders(yaz_iconv_t cd, const char *tocode) { if (yaz_marc8_decoder(tocode, &cd->decoder)) return 1; + if (yaz_iso5426_decoder(tocode, &cd->decoder)) + return 1; if (yaz_utf8_decoder(tocode, &cd->decoder)) return 1; if (yaz_ucs4_decoder(tocode, &cd->decoder)) @@ -90,12 +91,14 @@ static int prepare_decoders(yaz_iconv_t cd, const char *tocode) return 1; if (yaz_wchar_decoder(tocode, &cd->decoder)) return 1; + if (yaz_danmarc_decoder(tocode, &cd->decoder)) + return 1; return 0; } yaz_iconv_t yaz_iconv_open(const char *tocode, const char *fromcode) { - yaz_iconv_t cd = (yaz_iconv_t) xmalloc (sizeof(*cd)); + yaz_iconv_t cd = (yaz_iconv_t) xmalloc(sizeof(*cd)); cd->encoder.data = 0; cd->encoder.write_handle = 0; @@ -182,10 +185,10 @@ size_t yaz_iconv(yaz_iconv_t cd, char **inbuf, size_t *inbytesleft, if (cd->init_flag) { cd->my_errno = YAZ_ICONV_UNKNOWN; - + if (cd->encoder.init_handle) (*cd->encoder.init_handle)(&cd->encoder); - + cd->unget_x = 0; cd->no_read_x = 0; @@ -195,7 +198,7 @@ size_t yaz_iconv(yaz_iconv_t cd, char **inbuf, size_t *inbytesleft, size_t r = (cd->decoder.init_handle)( cd, &cd->decoder, inbuf ? (unsigned char *) *inbuf : 0, - inbytesleft ? *inbytesleft : 0, + inbytesleft ? *inbytesleft : 0, &no_read); if (r) { @@ -246,7 +249,7 @@ size_t yaz_iconv(yaz_iconv_t cd, char **inbuf, size_t *inbytesleft, break; } x = (*cd->decoder.read_handle)( - cd, &cd->decoder, + cd, &cd->decoder, (unsigned char *) *inbuf, *inbytesleft, &no_read); if (no_read == 0) { @@ -304,7 +307,9 @@ void yaz_iconv_set_errno(yaz_iconv_t cd, int no) /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab */ +