0744feab9bd7eacf2da6cac93e43d9455e6587da
[idzebra-moved-to-github.git] / include / idzebra / util.h
1 /* $Id: util.h,v 1.7 2006-05-19 13:49:34 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 /** \var zint
39  * \brief Zebra integer
40  *
41  * This integer is used in various Zebra APIs to specify record identifires,
42  * number of occurrences etc. It is a "large" integer and is usually
43  * 64-bit on newer architectures.
44  */
45 #ifdef __GNUC__
46 typedef long long int zint;
47 #define ZINT_FORMAT "%lld"
48 #define ZINT_FORMAT0 "lld"
49 #else
50 #ifdef WIN32
51 typedef __int64 zint;
52 #define ZINT_FORMAT "%I64d"
53 #define ZINT_FORMAT0 "I64d"
54 #else
55 typedef long zint;
56 #define ZINT_FORMAT "%ld"
57 #define ZINT_FORMAT0 "ld"
58 #endif
59 #endif
60
61 /** \var typedef ZEBRA_RES
62  * \brief Common return type for Zebra API
63  *
64  * This return code indicates success with code ZEBRA_OK and failure
65  * with ZEBRA_FAIL
66  */
67 typedef short ZEBRA_RES;
68 #define ZEBRA_FAIL -1
69 #define ZEBRA_OK   0
70
71 typedef zint SYSNO;
72
73 YAZ_EXPORT
74 zint atoi_zn (const char *buf, zint len);
75
76 YAZ_EXPORT
77 void zebra_zint_encode(char **dst, zint pos);
78
79 YAZ_EXPORT
80 void zebra_zint_decode(const char **src, zint *pos);
81
82 YAZ_END_CDECL
83
84 #define CAST_ZINT_TO_INT(x) (int)(x)
85 #define CAST_ZINT_TO_DOUBLE(x) (double)(x)
86
87 #endif
88 /*
89  * Local variables:
90  * c-basic-offset: 4
91  * indent-tabs-mode: nil
92  * End:
93  * vim: shiftwidth=4 tabstop=8 expandtab
94  */
95