X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Ficonv_encode_iso_8859_1.c;h=2f198864f09931790c82e51b704978ad1bfb7356;hp=f8471863105fc2e31e0ecbcddfa5ee0335143745;hb=55b4bc7eb9295ce335fad273d08d82d62ce4b7ea;hpb=65f1b9fce2d1d86df7d75645fb46fbba32dd01e3 diff --git a/src/iconv_encode_iso_8859_1.c b/src/iconv_encode_iso_8859_1.c index f847186..2f19886 100644 --- a/src/iconv_encode_iso_8859_1.c +++ b/src/iconv_encode_iso_8859_1.c @@ -1,7 +1,6 @@ -/* - * Copyright (C) 1995-2008, Index Data ApS +/* This file is part of the YAZ toolkit. + * Copyright (C) Index Data * See the file LICENSE for details. - * */ /** * \file @@ -16,14 +15,8 @@ #include #include #include -#include - -#if HAVE_ICONV_H -#include -#endif #include -#include #include "iconv-p.h" struct encoder_data @@ -100,7 +93,7 @@ static struct { { 'y', 0x0301, 0xfd}, /* LATIN SMALL LETTER Y WITH ACUTE */ /* omitted: 0xfe LATIN SMALL LETTER THORN */ { 'y', 0x0308, 0xff}, /* LATIN SMALL LETTER Y WITH DIAERESIS */ - + { 0, 0, 0} }; @@ -141,7 +134,7 @@ static size_t write_iso_8859_1(yaz_iconv_t cd, yaz_iconv_encoder_t e, unsigned long x, char **outbuf, size_t *outbytesleft) { - struct encoder_data *w = e->data; + struct encoder_data *w = (struct encoder_data *) e->data; /* list of two char unicode sequence that, when combined, are equivalent to single unicode chars that can be represented in ISO-8859-1/Latin-1. @@ -165,7 +158,7 @@ static size_t write_iso_8859_1(yaz_iconv_t cd, yaz_iconv_encoder_t e, yaz_iconv_set_errno(cd, YAZ_ICONV_E2BIG); return (size_t)(-1); } - if (!latin1_comb[i].x1) + if (!latin1_comb[i].x1) { /* not found. Just write compose_char */ *outp++ = (unsigned char) w->compose_char; (*outbytesleft)--; @@ -199,7 +192,7 @@ static size_t write_iso_8859_1(yaz_iconv_t cd, yaz_iconv_encoder_t e, static size_t flush_iso_8859_1(yaz_iconv_t cd, yaz_iconv_encoder_t e, char **outbuf, size_t *outbytesleft) { - struct encoder_data *w = e->data; + struct encoder_data *w = (struct encoder_data *) e->data; if (w->compose_char) { unsigned char *outp = (unsigned char *) *outbuf; @@ -219,7 +212,7 @@ static size_t flush_iso_8859_1(yaz_iconv_t cd, yaz_iconv_encoder_t e, void init_iso_8859_1(yaz_iconv_encoder_t e) { - struct encoder_data *w = e->data; + struct encoder_data *w = (struct encoder_data *) e->data; w->compose_char = 0; } @@ -230,11 +223,12 @@ void destroy_iso_8859_1(yaz_iconv_encoder_t e) yaz_iconv_encoder_t yaz_iso_8859_1_encoder(const char *tocode, yaz_iconv_encoder_t e) - + { if (!yaz_matchstr(tocode, "iso88591")) { - struct encoder_data *data = xmalloc(sizeof(*data)); + struct encoder_data *data = (struct encoder_data *) + xmalloc(sizeof(*data)); e->data = data; e->write_handle = write_iso_8859_1; e->flush_handle = flush_iso_8859_1; @@ -245,11 +239,35 @@ yaz_iconv_encoder_t yaz_iso_8859_1_encoder(const char *tocode, return 0; } +static unsigned long read_ISO8859_1(yaz_iconv_t cd, + yaz_iconv_decoder_t d, + unsigned char *inp, + size_t inbytesleft, size_t *no_read) +{ + unsigned long x = inp[0]; + *no_read = 1; + return x; +} + +yaz_iconv_decoder_t yaz_iso_8859_1_decoder(const char *fromcode, + yaz_iconv_decoder_t d) + +{ + if (!yaz_matchstr(fromcode, "iso88591")) + { + d->read_handle = read_ISO8859_1; + return d; + } + return 0; +} + /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab */ +