1 /* This file is part of the Zebra server. 2 Copyright (C) 2004-2013 Index Data 3 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 7 version. 8 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 12 for more details. 13 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 17 18 */ 19 20 #ifndef ZEBRA_UTIL_H 21 #define ZEBRA_UTIL_H 22 23 #include <yaz/yconfig.h> 24 #include <yaz/log.h> 25 26 /** 27 expand GCC_ATTRIBUTE if GCC is in use. See : 28 http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html 29 30 To see gcc pre-defines for c: 31 gcc -E -dM -x c /dev/null 32 */ 33 34 #ifdef __GNUC__ 35 #if __GNUC__ >= 4 36 #define ZEBRA_GCC_ATTR(x) __attribute__ (x) 37 #endif 38 #endif 39 40 #ifndef ZEBRA_GCC_ATTR 41 #define ZEBRA_GCC_ATTR(x) 42 #endif 43 44 YAZ_BEGIN_CDECL 45 46 /** \var zint 47 * \brief Zebra integer 48 * 49 * This integer is used in various Zebra APIs to specify record identifires, 50 * number of occurrences etc. It is a "large" integer and is usually 51 * 64-bit on newer architectures. 52 */ 53 #ifdef WIN32 54 typedef __int64 zint; 55 #define ZINT_FORMAT0 "I64d" 56 #else 57 58 #ifndef ZEBRA_ZINT 59 #error ZEBRA_ZINT undefined. idzebra-config not in use? 60 #endif 61 62 #if ZEBRA_ZINT > 0 63 typedef long long int zint; 64 #define ZINT_FORMAT0 "lld" 65 #else 66 typedef long zint; 67 #define ZINT_FORMAT0 "ld" 68 #endif 69 70 #endif 71 72 #define ZINT_FORMAT "%" ZINT_FORMAT0 73 74 /** \var typedef ZEBRA_RES 75 * \brief Common return type for Zebra API 76 * 77 * This return code indicates success with code ZEBRA_OK and failure 78 * with ZEBRA_FAIL 79 */ 80 typedef short ZEBRA_RES; 81 #define ZEBRA_FAIL -1 82 #define ZEBRA_OK 0 83 84 YAZ_EXPORT zint atoi_zn(const char *buf, zint len); 85 86 YAZ_EXPORT void zebra_zint_encode(char **dst, zint pos); 87 88 YAZ_EXPORT void zebra_zint_decode(const char **src, zint *pos); 89 90 YAZ_EXPORT void zebra_exit(const char *msg); 91 92 YAZ_EXPORT zint atozint(const char *src); 93 94 YAZ_END_CDECL 95 96 #define CAST_ZINT_TO_INT(x) (int)(x) 97 #define CAST_ZINT_TO_DOUBLE(x) (double)(x) 98 99 #endif 100 /* 101 * Local variables: 102 * c-basic-offset: 4 103 * c-file-style: "Stroustrup" 104 * indent-tabs-mode: nil 105 * End: 106 * vim: shiftwidth=4 tabstop=8 expandtab 107 */ 108 109