2abf9cf4b932671ae0c5210386d46dd0bbd545a6
[idzebra-moved-to-github.git] / include / idzebra / util.h
1 /* $Id: util.h,v 1.9 2006-10-10 14:45:42 adam Exp $
2    Copyright (C) 1995-2006
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 this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20
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 WIN32
46 typedef __int64 zint;
47 #define ZINT_FORMAT0 "I64d"
48 #else
49
50 #ifndef ZEBRA_ZINT
51 #error ZEBRA_ZINT undefined. idzebra-config not in use?
52 #endif
53
54 #if ZEBRA_ZINT > 0
55 typedef long long int zint;
56 #define ZINT_FORMAT0 "lld"
57 #else
58 typedef long zint;
59 #define ZINT_FORMAT0 "ld"
60 #endif
61
62 #endif
63
64 #define ZINT_FORMAT "%" ZINT_FORMAT0
65
66 /** \var typedef ZEBRA_RES
67  * \brief Common return type for Zebra API
68  *
69  * This return code indicates success with code ZEBRA_OK and failure
70  * with ZEBRA_FAIL
71  */
72 typedef short ZEBRA_RES;
73 #define ZEBRA_FAIL -1
74 #define ZEBRA_OK   0
75
76 typedef zint SYSNO;
77
78 YAZ_EXPORT
79 zint atoi_zn (const char *buf, zint len);
80
81 YAZ_EXPORT
82 void zebra_zint_encode(char **dst, zint pos);
83
84 YAZ_EXPORT
85 void zebra_zint_decode(const char **src, zint *pos);
86
87 YAZ_END_CDECL
88
89 #define CAST_ZINT_TO_INT(x) (int)(x)
90 #define CAST_ZINT_TO_DOUBLE(x) (double)(x)
91
92 #endif
93 /*
94  * Local variables:
95  * c-basic-offset: 4
96  * indent-tabs-mode: nil
97  * End:
98  * vim: shiftwidth=4 tabstop=8 expandtab
99  */
100