1 /* This file is part of the Zebra server.
2 Copyright (C) 1994-2009 Index Data
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #include <yaz/diagbib1.h>
28 int zebra_term_untrans(ZebraHandle zh, const char *index_type,
29 char *dst, const char *src)
31 zebra_map_t zm = zebra_map_get(zh->reg->zebra_maps, index_type);
36 if (zebra_maps_is_icu(zm))
45 const char *cp = zebra_maps_output(zm, &src);
48 if (len < IT_MAX_WORD-1)
53 while (*cp && len < IT_MAX_WORD-1)
61 int zebra_term_untrans_iconv(ZebraHandle zh, NMEM stream,
62 const char *index_type,
63 char **dst, const char *src)
65 char term_src[IT_MAX_WORD];
66 char term_dst[IT_MAX_WORD];
69 r = zebra_term_untrans (zh, index_type, term_src, src);
73 if (zh->iconv_from_utf8 != 0)
76 char *inbuf = term_src;
77 size_t inleft = strlen(term_src);
78 char *outbuf = term_dst;
79 size_t outleft = sizeof(term_dst)-1;
82 ret = yaz_iconv (zh->iconv_from_utf8, &inbuf, &inleft,
84 if (ret == (size_t)(-1))
88 yaz_iconv (zh->iconv_from_utf8, 0, 0, &outbuf, &outleft);
89 len = outbuf - term_dst;
91 *dst = nmem_malloc(stream, len + 1);
93 memcpy (*dst, term_dst, len);
97 *dst = nmem_strdup(stream, term_src);
106 * indent-tabs-mode: nil
108 * vim: shiftwidth=4 tabstop=8 expandtab