1 /* This file is part of the Zebra server.
2 Copyright (C) 1994-2010 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
25 #include <yaz/xmalloc.h>
28 int key_SU_encode (int ch, char *out)
34 /* unique value .. which is different from ch >= 0 case */
35 /* is used to generate queries with "null" hits, bug #1142 */
42 out[i] = 65 + (ch & 63);
61 int key_SU_decode (int *ch, const unsigned char *out)
66 for (len = 1; *out >= 65; len++, out++)
68 *ch += (*out - 65) * fact;
71 *ch += (*out - 1) * fact;
78 * c-file-style: "Stroustrup"
79 * indent-tabs-mode: nil
81 * vim: shiftwidth=4 tabstop=8 expandtab