Many public functions returns ZEBRA_RES rather than int to avoid
[idzebra-moved-to-github.git] / include / idzebra / util.h
1 /* $Id: util.h,v 1.2 2005-04-15 10:47:48 adam Exp $
2    Copyright (C) 1995-2005
3    Index Data ApS
4
5 This file is part of the Zebra server.
6
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
10 version.
11
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
15 for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Zebra; see the file LICENSE.zebra.  If not, write to the
19 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA.
21 */
22
23 #ifndef ZEBRA_UTIL_H
24 #define ZEBRA_UTIL_H
25
26 #include <yaz/yconfig.h>
27 #include <yaz/log.h>
28
29 #include <idzebra/version.h>
30
31 /* check that we don't have all too old yaz */
32 #ifndef YLOG_ERRNO
33 #error Need a modern yaz with YLOG_ defines
34 #endif
35
36 YAZ_BEGIN_CDECL
37
38 #ifdef __GNUC__
39 typedef long long int zint;
40 #define ZINT_FORMAT "%lld"
41 #define ZINT_FORMAT0 "lld"
42 #else
43 #ifdef WIN32
44 typedef __int64 zint;
45 #define ZINT_FORMAT "%I64d"
46 #define ZINT_FORMAT0 "I64d"
47 #else
48 typedef long zint;
49 #define ZINT_FORMAT "%ld"
50 #define ZINT_FORMAT0 "ld"
51 #endif
52 #endif
53
54 typedef short ZEBRA_RES;
55 #define ZEBRA_FAIL -1
56 #define ZEBRA_OK   0
57
58 typedef zint SYSNO;
59
60 YAZ_EXPORT
61 zint atoi_zn (const char *buf, zint len);
62
63 YAZ_EXPORT
64 void zebra_zint_encode(char **dst, zint pos);
65
66 YAZ_EXPORT
67 void zebra_zint_decode(const char **src, zint *pos);
68
69 YAZ_END_CDECL
70
71 #define CAST_ZINT_TO_INT(x) (int)(x)
72 #define CAST_ZINT_TO_DOUBLE(x) (double)(x)
73
74 #endif