From aa02c3dfe7142904ddec12dbc55a9c7b55f1a4f9 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Wed, 25 Nov 2009 17:25:10 +0100 Subject: [PATCH] Add compiletime and runtime versioning information. --- configure.ac | 2 +- src/Makefile.am | 4 ++-- src/main.c | 10 ++++++++++ src/routeros_api.h | 2 ++ src/routeros_version.h.in | 27 +++++++++++++++++++++++++++ 5 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 src/routeros_version.h.in diff --git a/configure.ac b/configure.ac index 71e4139..eb8f889 100644 --- a/configure.ac +++ b/configure.ac @@ -65,4 +65,4 @@ AC_ARG_ENABLE(debug, [AS_HELP_STRING([--enable-debug], [Enable extensive debuggi ], []) AM_CONDITIONAL(BUILD_WITH_DEBUG, test "x$enable_debug" = "xyes") -AC_OUTPUT(Makefile src/Makefile) +AC_OUTPUT(Makefile src/Makefile src/routeros_version.h) diff --git a/src/Makefile.am b/src/Makefile.am index 0a3925c..db3f30b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,7 +4,7 @@ if COMPILER_IS_GCC AM_CFLAGS = -Wall -Werror endif -include_HEADERS = routeros_api.h +include_HEADERS = routeros_api.h routeros_version.h lib_LTLIBRARIES = librouteros.la librouteros_la_LDFLAGS = -version-info @LIBROUTEROS_CURRENT@:@LIBROUTEROS_REVISION@:@LIBROUTEROS_AGE@ @@ -12,4 +12,4 @@ librouteros_la_LIBADD = -lgcrypt if BUILD_WITH_LIBSOCKET librouteros_la_LIBADD += -lsocket endif -librouteros_la_SOURCES = main.c routeros_api.h +librouteros_la_SOURCES = main.c routeros_api.h routeros_version.h diff --git a/src/main.c b/src/main.c index 5f77a5d..53e96c2 100644 --- a/src/main.c +++ b/src/main.c @@ -908,4 +908,14 @@ const char *ros_reply_param_val_by_key (const ros_reply_t *r, /* {{{ */ return (NULL); } /* }}} char *ros_reply_param_val_by_key */ +int ros_version (void) /* {{{ */ +{ + return (ROS_VERSION); +} /* }}} int ros_version */ + +const char *ros_version_string (void) /* {{{ */ +{ + return (ROS_VERSION_STRING); +} /* }}} char *ros_version_string */ + /* vim: set ts=2 sw=2 noet fdm=marker : */ diff --git a/src/routeros_api.h b/src/routeros_api.h index 84e5600..7f6956c 100644 --- a/src/routeros_api.h +++ b/src/routeros_api.h @@ -22,6 +22,8 @@ #ifndef ROUTEROS_API_H #define ROUTEROS_API_H 1 +#include + #define ROUTEROS_API_PORT "8728" #ifdef __cplusplus diff --git a/src/routeros_version.h.in b/src/routeros_version.h.in new file mode 100644 index 0000000..af9d025 --- /dev/null +++ b/src/routeros_version.h.in @@ -0,0 +1,27 @@ +#ifndef ROUTEROS_VERSION_H +#define ROUTEROS_VERSION_H 1 + +#ifdef __cplusplus +extern "C" { +#endif + +#define ROS_VERSION_MAJOR @LIBROUTEROS_MAJOR@ +#define ROS_VERSION_MINOR @LIBROUTEROS_MINOR@ +#define ROS_VERSION_PATCH @LIBROUTEROS_PATCH@ + +#define ROS_VERSION_STRING "@LIBROUTEROS_MAJOR@.@LIBROUTEROS_MINOR@.@LIBROUTEROS_PATCH@" + +#define ROS_VERSION_ENCODE(major, minor, patch) \ + ((major) * 10000 + (minor) * 100 + (patch)) + +#define ROS_VERSION \ + ROS_VERSION_ENCODE(ROS_VERSION_MAJOR, ROS_VERSION_MINOR, ROS_VERSION_PATCH) + +int ros_version (void); +const char *ros_version_string (void); + +#ifdef __cplusplus +} +#endif + +#endif /* ROUTEROS_VERSION_H */ -- 2.11.0