X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=blobdiff_plain;f=include%2Fidzebra%2Futil.h;h=f53a48a7d8339c5ffee0d729d35cc8ef2982c9e5;hp=41f356ece1467b3d96eceb20c3a5552ba2d6121b;hb=4f71537a478fc551989245f0dde38997714eedc1;hpb=deff57cfa9d9b39c4a4f1c9b82a64c6e61d821a4 diff --git a/include/idzebra/util.h b/include/idzebra/util.h index 41f356e..f53a48a 100644 --- a/include/idzebra/util.h +++ b/include/idzebra/util.h @@ -1,8 +1,5 @@ -/* $Id: util.h,v 1.1 2005-03-30 09:25:23 adam Exp $ - Copyright (C) 1995-2005 - Index Data ApS - -This file is part of the Zebra server. +/* This file is part of the Zebra server. + Copyright (C) 1994-2011 Index Data Zebra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -15,51 +12,84 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with Zebra; see the file LICENSE.zebra. If not, write to the -Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA -02111-1307, USA. +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ #ifndef ZEBRA_UTIL_H #define ZEBRA_UTIL_H -#include +#include +#include + +/** + expand GCC_ATTRIBUTE if GCC is in use. See : + http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html -#include + To see gcc pre-defines for c: + gcc -E -dM -x c /dev/null +*/ + +#ifdef __GNUC__ +#if __GNUC__ >= 4 +#define ZEBRA_GCC_ATTR(x) __attribute__ (x) +#endif +#endif -/* check that we don't have all too old yaz */ -#ifndef YLOG_ERRNO -#error Need a modern yaz with YLOG_ defines +#ifndef ZEBRA_GCC_ATTR +#define ZEBRA_GCC_ATTR(x) #endif YAZ_BEGIN_CDECL -#ifdef __GNUC__ -typedef long long int zint; -#define ZINT_FORMAT "%lld" -#define ZINT_FORMAT0 "lld" -#else +/** \var zint + * \brief Zebra integer + * + * This integer is used in various Zebra APIs to specify record identifires, + * number of occurrences etc. It is a "large" integer and is usually + * 64-bit on newer architectures. + */ #ifdef WIN32 typedef __int64 zint; -#define ZINT_FORMAT "%I64d" #define ZINT_FORMAT0 "I64d" #else + +#ifndef ZEBRA_ZINT +#error ZEBRA_ZINT undefined. idzebra-config not in use? +#endif + +#if ZEBRA_ZINT > 0 +typedef long long int zint; +#define ZINT_FORMAT0 "lld" +#else typedef long zint; -#define ZINT_FORMAT "%ld" #define ZINT_FORMAT0 "ld" #endif + #endif -typedef zint SYSNO; +#define ZINT_FORMAT "%" ZINT_FORMAT0 + +/** \var typedef ZEBRA_RES + * \brief Common return type for Zebra API + * + * This return code indicates success with code ZEBRA_OK and failure + * with ZEBRA_FAIL + */ +typedef short ZEBRA_RES; +#define ZEBRA_FAIL -1 +#define ZEBRA_OK 0 + +YAZ_EXPORT zint atoi_zn(const char *buf, zint len); -YAZ_EXPORT -zint atoi_zn (const char *buf, zint len); +YAZ_EXPORT void zebra_zint_encode(char **dst, zint pos); -YAZ_EXPORT -void zebra_zint_encode(char **dst, zint pos); +YAZ_EXPORT void zebra_zint_decode(const char **src, zint *pos); -YAZ_EXPORT -void zebra_zint_decode(const char **src, zint *pos); +YAZ_EXPORT void zebra_exit(const char *msg); + +YAZ_EXPORT zint atozint(const char *src); YAZ_END_CDECL @@ -67,3 +97,12 @@ YAZ_END_CDECL #define CAST_ZINT_TO_DOUBLE(x) (double)(x) #endif +/* + * Local variables: + * c-basic-offset: 4 + * c-file-style: "Stroustrup" + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ +