1 /* $Id: untrans.c,v 1.4 2007-10-30 19:17:15 adam Exp $
2 Copyright (C) 1995-2007
5 This file is part of the Zebra server.
7 Zebra is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 #include <yaz/diagbib1.h>
31 void zebra_term_untrans(ZebraHandle zh, int reg_type,
32 char *dst, const char *src)
34 zebra_map_t zm = zebra_map_get(zh->reg->zebra_maps, reg_type);
38 const char *cp = zebra_maps_output(zm, &src);
41 if (len < IT_MAX_WORD-1)
46 while (*cp && len < IT_MAX_WORD-1)
52 void zebra_term_untrans_iconv(ZebraHandle zh, NMEM stream, int reg_type,
53 char **dst, const char *src)
55 char term_src[IT_MAX_WORD];
56 char term_dst[IT_MAX_WORD];
58 zebra_term_untrans (zh, reg_type, term_src, src);
60 if (zh->iconv_from_utf8 != 0)
63 char *inbuf = term_src;
64 size_t inleft = strlen(term_src);
65 char *outbuf = term_dst;
66 size_t outleft = sizeof(term_dst)-1;
69 ret = yaz_iconv (zh->iconv_from_utf8, &inbuf, &inleft,
71 if (ret == (size_t)(-1))
75 yaz_iconv (zh->iconv_from_utf8, 0, 0, &outbuf, &outleft);
76 len = outbuf - term_dst;
78 *dst = nmem_malloc(stream, len + 1);
80 memcpy (*dst, term_dst, len);
84 *dst = nmem_strdup(stream, term_src);
92 * indent-tabs-mode: nil
94 * vim: shiftwidth=4 tabstop=8 expandtab