From: Adam Dickmeiss Date: Wed, 28 Aug 2002 07:53:51 +0000 (+0000) Subject: ODR uses yaz_iconv X-Git-Tag: YAZ.1.9~34 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=cf9f213fff1ae6b2471f8367114b93ae45ed8b75;p=yaz-moved-to-github.git ODR uses yaz_iconv --- diff --git a/odr/odr-priv.h b/odr/odr-priv.h index 5a5ca1a..d8ad03c 100644 --- a/odr/odr-priv.h +++ b/odr/odr-priv.h @@ -23,18 +23,15 @@ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. * - * $Id: odr-priv.h,v 1.1 2002-07-25 13:20:20 adam Exp $ + * $Id: odr-priv.h,v 1.2 2002-08-28 07:53:51 adam Exp $ */ #ifndef ODR_PRIV_H #define ODR_PRIV_H -#if HAVE_ICONV_H -#include -#endif - #include +#include struct Odr_ber_tag { /* used to be statics in ber_tag... */ int lclass; @@ -50,9 +47,7 @@ struct Odr_private { odr_constack stack[ODR_MAX_STACK]; struct Odr_ber_tag odr_ber_tag; -#if HAVE_ICONV_H - iconv_t iconv_handle; -#endif + yaz_iconv_t iconv_handle; }; /* Private macro. diff --git a/odr/odr.c b/odr/odr.c index 15c6e67..084b632 100644 --- a/odr/odr.c +++ b/odr/odr.c @@ -2,7 +2,7 @@ * Copyright (c) 1995-2002, Index Data * See the file LICENSE for details. * - * $Id: odr.c,v 1.35 2002-07-25 12:51:08 adam Exp $ + * $Id: odr.c,v 1.36 2002-08-28 07:53:51 adam Exp $ * */ #if HAVE_CONFIG_H @@ -60,17 +60,13 @@ void odr_setprint(ODR o, FILE *file) int odr_set_charset(ODR o, const char *to, const char *from) { -#if HAVE_ICONV_H - if (o->op->iconv_handle != (iconv_t)(-1)) - iconv_close (o->op->iconv_handle); + if (o->op->iconv_handle) + yaz_iconv_close (o->op->iconv_handle); o->op->iconv_handle = iconv_open (to, from); - if (o->op->iconv_handle == (iconv_t)(-1)) + if (o->op->iconv_handle == 0) return -1; return 0; -#else - return -1; -#endif } #include @@ -90,9 +86,7 @@ ODR odr_createmem(int direction) r->enable_bias = 1; r->op = xmalloc (sizeof(*r->op)); r->op->odr_ber_tag.lclass = -1; -#if HAVE_ICONV_H - r->op->iconv_handle = (iconv_t)(-1); -#endif + r->op->iconv_handle = 0; odr_reset(r); yaz_log (LOG_DEBUG, "odr_createmem dir=%d o=%p", direction, r); return r; @@ -111,10 +105,8 @@ void odr_reset(ODR o) nmem_reset(o->mem); o->choice_bias = -1; o->lenlen = 1; -#if HAVE_ICONV_H - if (o->op->iconv_handle != (iconv_t)(-1)) - iconv(o->op->iconv_handle, 0, 0, 0, 0); -#endif + if (o->op->iconv_handle != 0) + yaz_iconv(o->op->iconv_handle, 0, 0, 0, 0); yaz_log (LOG_DEBUG, "odr_reset o=%p", o); } @@ -125,10 +117,8 @@ void odr_destroy(ODR o) xfree(o->buf); if (o->print && o->print != stderr) fclose(o->print); -#if HAVE_ICONV_H - if (o->op->iconv_handle != (iconv_t)(-1)) - iconv_close (o->op->iconv_handle); -#endif + if (o->op->iconv_handle != 0) + yaz_iconv_close (o->op->iconv_handle); xfree(o->op); xfree(o); yaz_log (LOG_DEBUG, "odr_destroy o=%p", o); diff --git a/odr/odr_oct.c b/odr/odr_oct.c index 008aaa1..204648c 100644 --- a/odr/odr_oct.c +++ b/odr/odr_oct.c @@ -3,7 +3,7 @@ * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * - * $Id: odr_oct.c,v 1.17 2002-07-25 12:51:08 adam Exp $ + * $Id: odr_oct.c,v 1.18 2002-08-28 07:53:51 adam Exp $ */ #if HAVE_CONFIG_H #include @@ -137,8 +137,8 @@ int odr_iconv_string(ODR o, char **p, int opt, const char *name) if (o->direction == ODR_ENCODE) { t->buf = 0; -#if HAVE_ICONV_H - if (o->op->iconv_handle != (iconv_t)(-1)) + + if (o->op->iconv_handle != 0) { size_t inleft = strlen(*p); char *inbuf = *p; @@ -148,8 +148,8 @@ int odr_iconv_string(ODR o, char **p, int opt, const char *name) t->buf = outbuf; - ret = iconv (o->op->iconv_handle, &inbuf, &inleft, - &outbuf, &outleft); + ret = yaz_iconv (o->op->iconv_handle, &inbuf, &inleft, + &outbuf, &outleft); if (ret == (size_t)(-1)) { o->error = ODATA; @@ -157,7 +157,6 @@ int odr_iconv_string(ODR o, char **p, int opt, const char *name) } t->size = t->len = outbuf - (char*) t->buf; } -#endif if (!t->buf) { t->buf = (unsigned char *) *p; @@ -175,8 +174,8 @@ int odr_iconv_string(ODR o, char **p, int opt, const char *name) if (o->direction == ODR_DECODE) { *p = 0; -#if HAVE_ICONV_H - if (o->op->iconv_handle != (iconv_t)(-1)) + + if (o->op->iconv_handle != 0) { size_t inleft = t->len; char *inbuf = t->buf; @@ -186,8 +185,8 @@ int odr_iconv_string(ODR o, char **p, int opt, const char *name) *p = outbuf; - ret = iconv (o->op->iconv_handle, &inbuf, &inleft, - &outbuf, &outleft); + ret = yaz_iconv (o->op->iconv_handle, &inbuf, &inleft, + &outbuf, &outleft); if (ret == (size_t)(-1)) { o->error = ODATA; @@ -197,7 +196,6 @@ int odr_iconv_string(ODR o, char **p, int opt, const char *name) (*p)[inleft] = '\0'; /* null terminate it */ } -#endif if (!*p) { *p = (char *) t->buf;