From 3fcc65de3bb8ac7af03900dccf23a5b1219b2e8e Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 27 Aug 2007 17:22:22 +0000 Subject: [PATCH] Added zebra_get_version --- configure.ac | 3 ++- include/idzebra/version.h | 22 ++++++++++++++--- index/zebraapi.c | 8 ++++-- index/zebraidx.c | 26 ++++++++++---------- index/zebrasrv.c | 7 ++++-- util/Makefile.am | 8 +++--- util/version.c | 60 +++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 109 insertions(+), 25 deletions(-) create mode 100644 util/version.c diff --git a/configure.ac b/configure.ac index d07e327..cce7a19 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ dnl Zebra, Index Data ApS, 1995-2007 -dnl $Id: configure.ac,v 1.59 2007-05-16 10:50:03 adam Exp $ +dnl $Id: configure.ac,v 1.60 2007-08-27 17:22:22 adam Exp $ dnl AC_PREREQ(2.59) AC_INIT([idzebra],[2.0.15],[zebra-help@indexdata.dk]) @@ -23,6 +23,7 @@ dnl ------ Checking programs AC_PROG_CC AC_PROG_CPP AM_PROG_LIBTOOL +AC_DEFINE_UNQUOTED(HOST_TRIPLET,"${host}") dnl dnl ------ headers AC_CHECK_HEADERS([sys/resource.h sys/time.h sys/wait.h sys/utsname.h unistd.h]) diff --git a/include/idzebra/version.h b/include/idzebra/version.h index aad29a8..491b949 100644 --- a/include/idzebra/version.h +++ b/include/idzebra/version.h @@ -1,4 +1,4 @@ -/* $Id: version.h,v 1.22 2007-05-16 10:50:03 adam Exp $ +/* $Id: version.h,v 1.23 2007-08-27 17:22:22 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -20,11 +20,27 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef ZEBRAVER +#ifndef IDZEBRA_VERSION_H +#define IDZEBRA_VERSION_H + +#include + +YAZ_BEGIN_CDECL + #define ZEBRAVER "2.0.15" -#define ZEBRADATE "$Date: 2007-05-16 10:50:03 $" +#define ZEBRADATE "$Date: 2007-08-27 17:22:22 $" + +/** \brief Returns Zebra version and system info. + \param version_str buffer for version (at least 16 bytes) + \param sys_str buffer for system info (at least 80 bytes) + \returns version as integer +*/ +YAZ_EXPORT +void zebra_get_version(char *version_str, char *sys_str); + +YAZ_END_CDECL #endif /* diff --git a/index/zebraapi.c b/index/zebraapi.c index 93c9ad9..6fefbb2 100644 --- a/index/zebraapi.c +++ b/index/zebraapi.c @@ -1,4 +1,4 @@ -/* $Id: zebraapi.c,v 1.257 2007-08-21 11:06:47 adam Exp $ +/* $Id: zebraapi.c,v 1.258 2007-08-27 17:22:22 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -192,6 +192,8 @@ ZebraService zebra_start(const char *configName) ZebraService zebra_start_res(const char *configName, Res def_res, Res over_res) { Res res; + char version_str[16]; + char system_str[80]; zebra_flock_init(); @@ -201,7 +203,9 @@ ZebraService zebra_start_res(const char *configName, Res def_res, Res over_res) log_level_initialized = 1; } - yaz_log(YLOG_LOG, "zebra_start %s %s", ZEBRAVER, + zebra_get_version(version_str, system_str); + + yaz_log(YLOG_LOG, "zebra_start %s %s", version_str, configName ? configName : ""); if ((res = res_open(def_res, over_res))) diff --git a/index/zebraidx.c b/index/zebraidx.c index fd6d26a..9b2046e 100644 --- a/index/zebraidx.c +++ b/index/zebraidx.c @@ -1,4 +1,4 @@ -/* $Id: zebraidx.c,v 1.5 2007-04-17 20:27:14 adam Exp $ +/* $Id: zebraidx.c,v 1.6 2007-08-27 17:22:22 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -33,6 +33,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include +#include #include char *prog; @@ -230,18 +231,17 @@ int main (int argc, char **argv) } else if (ret == 'V') { - printf("Zebra %s %s\n", ZEBRAVER, ZEBRADATE); - printf(" (C) 1994-2007, Index Data ApS\n"); -#ifdef WIN32 -#ifdef _DEBUG - printf(" WIN32 Debug\n"); -#else - printf(" WIN32 Release\n"); -#endif -#endif -#if HAVE_BZLIB_H - printf("Using: libbzip2, (C) 1996-1999 Julian R Seward. All rights reserved.\n"); -#endif + char version_str[20]; + char sys_str[80]; + zebra_get_version(version_str, sys_str); + + printf("Zebra %s\n", version_str); + printf("(C) 1994-2007, Index Data ApS\n"); + printf("Zebra is free software, covered by the GNU General Public License, and you are\n"); + printf("welcome to change it and/or distribute copies of it under certain conditions.\n"); + printf("Configured as: %s\n", sys_str); + if (strcmp(version_str, ZEBRAVER)) + printf("zebraidx compiled version %s\n", ZEBRAVER); } else if (ret == 'v') yaz_log_init_level (yaz_log_mask_str(arg)); diff --git a/index/zebrasrv.c b/index/zebrasrv.c index 29b19aa..f35c051 100644 --- a/index/zebrasrv.c +++ b/index/zebrasrv.c @@ -1,4 +1,4 @@ -/* $Id: zebrasrv.c,v 1.18 2007-08-22 08:13:00 adam Exp $ +/* $Id: zebrasrv.c,v 1.19 2007-08-27 17:22:22 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -61,6 +61,7 @@ bend_initresult *bend_init (bend_initrequest *q) struct statserv_options_block *sob; char *user = NULL; char *passwd = NULL; + char version_str[16]; r->errcode = 0; r->errstring = 0; @@ -72,8 +73,10 @@ bend_initresult *bend_init (bend_initrequest *q) q->bend_fetch = bend_fetch; q->bend_scan = bend_scan; + zebra_get_version(version_str, 0); + q->implementation_name = "Zebra Information Server"; - q->implementation_version = "Zebra " ZEBRAVER; + q->implementation_version = odr_strdup(q->stream, version_str); yaz_log (YLOG_DEBUG, "bend_init"); diff --git a/util/Makefile.am b/util/Makefile.am index dc83e27..617216f 100644 --- a/util/Makefile.am +++ b/util/Makefile.am @@ -1,4 +1,4 @@ -## $Id: Makefile.am,v 1.32 2007-05-16 10:57:06 adam Exp $ +## $Id: Makefile.am,v 1.33 2007-08-27 17:22:22 adam Exp $ noinst_LTLIBRARIES = libidzebra-util.la @@ -15,9 +15,9 @@ DISTCLEANFILES = idzebra-config-2.0 AM_CPPFLAGS = -I$(srcdir)/../include $(YAZINC) -DDEFAULT_PROFILE_PATH=\"$(pkgdatadir)/tab\" LDADD = libidzebra-util.la $(YAZLALIB) -libidzebra_util_la_SOURCES = zint.c res.c charmap.c zebramap.c passwddb.c \ - zebra-lock.c dirent.c xpath.c atoi_zn.c snippet.c flock.c attrfind.c \ - exit.c it_key.c su_codec.c +libidzebra_util_la_SOURCES = version.c zint.c res.c charmap.c zebramap.c \ + passwddb.c zebra-lock.c dirent.c xpath.c atoi_zn.c snippet.c flock.c \ + attrfind.c exit.c it_key.c su_codec.c tstpass_SOURCES = tstpass.c diff --git a/util/version.c b/util/version.c new file mode 100644 index 0000000..edae783 --- /dev/null +++ b/util/version.c @@ -0,0 +1,60 @@ +/* $Id: version.c,v 1.1 2007-08-27 17:22:22 adam Exp $ + Copyright (C) 1995-2007 + Index Data ApS + +This file is part of the Zebra server. + +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 +Software Foundation; either version 2, or (at your option) any later +version. + +Zebra is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +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 this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + +/** + * \file version.c + * \brief Implements Zebra version utilities. + */ + +#if HAVE_CONFIG_H +#include +#endif + +#include +#include + +void zebra_get_version(char *version_str, char *sys_str) +{ + if (version_str) + strcpy(version_str, ZEBRAVER); + if (sys_str) + { + strcpy(sys_str, "unknown"); + +#ifdef WIN32 + strcpy(sys_str, "win32"); +#endif + +#ifdef HOST_TRIPLET + strcpy(sys_str, HOST_TRIPLET); +#endif + } +} + +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ + -- 1.7.10.4