From 582a32433ca03dd2ca78dc485329cb81d391a192 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=BE=D1=80=D0=B5=D0=BD=D0=B1=D0=B5=D1=80=D0=B3=20?= =?UTF-8?q?=D0=9C=D0=B0=D1=80=D0=BA=20=28=D0=B4=D0=BE=D0=BC=D0=B0=29?= Date: Wed, 29 Aug 2012 22:55:14 +0600 Subject: [PATCH] Run-time version information is now available Run-time version information is available as exported four integers: - const int nl_ver_num = LIBNL_VER_NUM; - const int nl_ver_maj = LIBNL_VER_MAJ; - const int nl_ver_min = LIBNL_VER_MIN; - const int nl_ver_mic = LIBNL_VER_MIC; The purpose of this is to get version of compiled library as run time. Use cases: - To know exact version of the library in Python's ctypes module, Say, to find out if nl_cache_mngr_alloc() allow sk=NULL - To make sure that the version of the loaded library corresponds to the version of headers (for the paranoid). Say, to check: if (LIBNL_VER_NUM != nl_ver_num) exit(1); --- include/netlink/version.h.in | 11 ++++++++++- lib/Makefile.am | 3 ++- lib/version.c | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 lib/version.c diff --git a/include/netlink/version.h.in b/include/netlink/version.h.in index ac56799..35bf2aa 100644 --- a/include/netlink/version.h.in +++ b/include/netlink/version.h.in @@ -1,5 +1,5 @@ /* - * netlink/version.h Compile Time Versioning Information + * netlink/version.h Versioning Information * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -12,6 +12,8 @@ #ifndef NETLINK_VERSION_H_ #define NETLINK_VERSION_H_ +/* Compile Time Versioning Information */ + #define LIBNL_STRING "@PACKAGE_STRING@" #define LIBNL_VERSION "@PACKAGE_VERSION@" @@ -25,4 +27,11 @@ #define LIBNL_REVISION @LT_REVISION@ #define LIBNL_AGE @LT_AGE@ +/* Run-time version information */ + +extern const int nl_ver_num; +extern const int nl_ver_maj; +extern const int nl_ver_min; +extern const int nl_ver_mic; + #endif diff --git a/lib/Makefile.am b/lib/Makefile.am index aee8d0f..9e5efd8 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -17,7 +17,8 @@ lib_LTLIBRARIES = \ libnl_3_la_SOURCES = \ addr.c attr.c cache.c cache_mngr.c cache_mngt.c data.c \ - error.c handlers.c msg.c nl.c object.c socket.c utils.c + error.c handlers.c msg.c nl.c object.c socket.c utils.c \ + version.c libnl_genl_3_la_LIBADD = libnl-3.la libnl_genl_3_la_SOURCES = \ diff --git a/lib/version.c b/lib/version.c new file mode 100644 index 0000000..0dcafa0 --- /dev/null +++ b/lib/version.c @@ -0,0 +1,36 @@ +/* + * lib/version.c Run-time version information + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * Copyright (c) 2003-2012 Thomas Graf + */ + +/** + * @ingroup core + * @defgroup utils Utilities + * + * Run-time version information + * + * @{ + */ + + +/** + * @name Run-time version information + * @{ + */ + +#include + +const int nl_ver_num = LIBNL_VER_NUM; +const int nl_ver_maj = LIBNL_VER_MAJ; +const int nl_ver_min = LIBNL_VER_MIN; +const int nl_ver_mic = LIBNL_VER_MIC; + +/** @} */ + +/** @} */