From cf67c29bd1e60408d3e72e07e4edd9e2ef3c876b Mon Sep 17 00:00:00 2001 From: Ganesh Murthy Date: Fri, 23 Sep 2016 10:15:58 -0400 Subject: [PATCH] DISPATCH-521 - Added a version command line option that will display the version of the dispatch router --- CMakeLists.txt | 4 ++++ router/CMakeLists.txt | 1 + router/src/main.c | 8 +++++++- router/src/version.h.in | 23 +++++++++++++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 router/src/version.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b2069d603..f35e3efa88 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,6 +51,10 @@ set (SO_VERSION_MAJOR 2) set (SO_VERSION_MINOR 0) set (SO_VERSION "${SO_VERSION_MAJOR}.${SO_VERSION_MINOR}") +set (QPID_DISPATCH_VERSION_MAJOR 0) +set (QPID_DISPATCH_VERSION_MINOR 7) +set (QPID_DISPATCH_VERSION_PATCH 0) + if (NOT DEFINED LIB_SUFFIX) get_property(LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS) if ("${LIB64}" STREQUAL "TRUE" AND ${CMAKE_SIZEOF_VOID_P} STREQUAL "8") diff --git a/router/CMakeLists.txt b/router/CMakeLists.txt index 5681e00244..275065bae2 100644 --- a/router/CMakeLists.txt +++ b/router/CMakeLists.txt @@ -22,6 +22,7 @@ set(DEFAULT_CONFIG_PATH "${QPID_DISPATCH_CONFDIR}/qdrouterd.conf" CACHE string " set(DEFAULT_DISPATCH_PYTHON_DIR ${QPID_DISPATCH_PYTHON_DIR}) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h) include_directories(${CMAKE_CURRENT_BINARY_DIR}) diff --git a/router/src/main.c b/router/src/main.c index fa895d4986..f922052770 100644 --- a/router/src/main.c +++ b/router/src/main.c @@ -29,6 +29,7 @@ #include #include #include "config.h" +#include "version.h" static int exit_with_sigint = 0; static qd_dispatch_t *dispatch = 0; @@ -293,11 +294,12 @@ int main(int argc, char **argv) {"pidfile", required_argument, 0, 'P'}, {"user", required_argument, 0, 'U'}, {"help", no_argument, 0, 'h'}, + {"version", no_argument, 0, 'v'}, {0, 0, 0, 0} }; while (1) { - int c = getopt_long(argc, argv, "c:I:dP:U:h", long_options, 0); + int c = getopt_long(argc, argv, "c:I:dP:U:h:v", long_options, 0); if (c == -1) break; @@ -326,6 +328,10 @@ int main(int argc, char **argv) usage(argv); exit(0); + case 'v' : + fprintf(stdout, "Qpid Dispatch Router %i.%i.%i\n", QPID_DISPATCH_VERSION_MAJOR, QPID_DISPATCH_VERSION_MINOR, QPID_DISPATCH_VERSION_PATCH); + exit(0); + case '?' : usage(argv); exit(1); diff --git a/router/src/version.h.in b/router/src/version.h.in new file mode 100644 index 0000000000..ffc743f449 --- /dev/null +++ b/router/src/version.h.in @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#define QPID_DISPATCH_VERSION_MAJOR @QPID_DISPATCH_VERSION_MAJOR@ +#define QPID_DISPATCH_VERSION_MINOR @QPID_DISPATCH_VERSION_MINOR@ +#define QPID_DISPATCH_VERSION_PATCH @QPID_DISPATCH_VERSION_PATCH@ +