1 /* $Id: zaptterm.c,v 1.1 2006-09-21 08:39:14 adam Exp $
2 Copyright (C) 1995-2006
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 /* convert APT search term to UTF8 */
32 ZEBRA_RES zapt_term_to_utf8(ZebraHandle zh, Z_AttributesPlusTerm *zapt,
36 Z_Term *term = zapt->term;
41 if (zh->iconv_to_utf8 != 0)
43 char *inbuf = (char *) term->u.general->buf;
44 size_t inleft = term->u.general->len;
46 size_t outleft = IT_MAX_WORD-1;
49 ret = yaz_iconv(zh->iconv_to_utf8, &inbuf, &inleft,
51 if (ret == (size_t)(-1))
53 ret = yaz_iconv(zh->iconv_to_utf8, 0, 0, 0, 0);
56 YAZ_BIB1_QUERY_TERM_INCLUDES_CHARS_THAT_DO_NOT_TRANSLATE_INTO_,
64 sizez = term->u.general->len;
65 if (sizez > IT_MAX_WORD-1)
66 sizez = IT_MAX_WORD-1;
67 memcpy (termz, term->u.general->buf, sizez);
71 case Z_Term_characterString:
72 sizez = strlen(term->u.characterString);
73 if (sizez > IT_MAX_WORD-1)
74 sizez = IT_MAX_WORD-1;
75 memcpy (termz, term->u.characterString, sizez);
79 zebra_setError(zh, YAZ_BIB1_UNSUPP_CODED_VALUE_FOR_TERM, 0);
87 * indent-tabs-mode: nil
89 * vim: shiftwidth=4 tabstop=8 expandtab