From e9f83a80414a92234dfe07baeae336ad8020fdde Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 23 Feb 2018 16:41:47 +0100 Subject: [PATCH] Add a -V flag, which prints the TLSPool version string. The string is the same as the git version information, so could be '0.20.local-20180223-163246'. Fixes #44 --- src/CMakeLists.txt | 1 + src/daemon.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 53511d8..7075bb2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -35,6 +35,7 @@ set(tlspool_SRC ) add_executable(tlspool ${tlspool_SRC}) +target_compile_definitions(tlspool PRIVATE -DTLSPOOL_VERSION="${TLSPool_VERSION}") target_link_libraries(tlspool ${BDB_LIBRARY} ${GNUTLS_LIBRARY} diff --git a/src/daemon.c b/src/daemon.c index 6fd4692..2cfd4aa 100644 --- a/src/daemon.c +++ b/src/daemon.c @@ -14,6 +14,7 @@ #include "manage.h" +static const char version_string[] = TLSPOOL_VERSION; /* defined as compile-time argument */ void process_hangup (int hangupsignal) { tlog (TLOG_DAEMON, LOG_NOTICE, "Received signal %d as a hangup request"); @@ -75,8 +76,13 @@ int main (int argc, char *argv []) { * Cmdline argument parsing */ while (parsing) { - int opt = getopt (argc, argv, "kc:"); + int opt = getopt (argc, argv, "Vkc:"); switch (opt) { + case 'V': + fputs (version_string, stdout); + fputc ('\n', stdout); + exit (0); + break; case 'k': if (kill_competition) { fprintf (stderr, "You can only flag kill-the-competition once\n");