From b6201496ae109d698cc7b4586934db460599201c Mon Sep 17 00:00:00 2001
From: BenceJanosSzabo <bence.janos.szabo@ericsson.com>
Date: Wed, 8 Feb 2017 13:02:08 +0100
Subject: [PATCH] Corrected the openssl version printouts

Change-Id: Ib65527799e506082717fcf2cfb14630c0284341a
Signed-off-by: BenceJanosSzabo <bence.janos.szabo@ericsson.com>
---
 common/Makefile          |  2 +-
 common/license.c         |  4 ----
 common/license.h         |  2 --
 common/openssl_version.c | 18 ++++++++++++++++++
 common/openssl_version.h | 25 +++++++++++++++++++++++++
 compiler2/Makefile       |  8 +++++---
 compiler2/main.cc        |  7 ++++---
 mctr2/mctr/Makefile      |  2 +-
 mctr2/mctr/main.cc       | 10 ++++++----
 9 files changed, 60 insertions(+), 18 deletions(-)
 create mode 100644 common/openssl_version.c
 create mode 100644 common/openssl_version.h

diff --git a/common/Makefile b/common/Makefile
index a590616ea..663d21283 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -36,7 +36,7 @@ GENERATED_SOURCES := pattern_la.cc pattern_p.cc pattern_uni.cc config_preproc_la
 # Sources in the CVS
 
 STATIC_SOURCES := memory.c new.cc userinfo.c path.c config_preproc.cc Quadruple.cc \
-		  Path2.cc ModuleVersion.cc JSON_Tokenizer.cc UnicharPattern.cc
+		  Path2.cc ModuleVersion.cc JSON_Tokenizer.cc UnicharPattern.cc openssl_version.c
 
 ifndef MINGW
 STATIC_SOURCES += NetworkHandler.cc
diff --git a/common/license.c b/common/license.c
index eb476e9a9..7aa9efb2c 100644
--- a/common/license.c
+++ b/common/license.c
@@ -489,10 +489,6 @@ void free_openssl()
     ERR_free_strings();
 }
 
-const char * openssl_version_str(void) {
-  return SSLeay_version(SSLEAY_VERSION);
-}
-
 #if defined(WIN32) || defined(INTERIX)
 
 #ifdef INTERIX
diff --git a/common/license.h b/common/license.h
index 32d015199..13d648f5d 100644
--- a/common/license.h
+++ b/common/license.h
@@ -150,8 +150,6 @@ void print_license_info(void);
 void init_openssl(void);
 void free_openssl(void);
 
-const char * openssl_version_str(void);
-
 #if defined(WIN32) || defined(INTERIX)
 long gethostid(void);
 #endif
diff --git a/common/openssl_version.c b/common/openssl_version.c
new file mode 100644
index 000000000..7542c0fe0
--- /dev/null
+++ b/common/openssl_version.c
@@ -0,0 +1,18 @@
+/******************************************************************************
+ * Copyright (c) 2000-2016 Ericsson Telecom AB
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Szabo, Bence Janos
+ *
+ ******************************************************************************/
+
+#include "openssl_version.h"
+#include <openssl/crypto.h>
+
+const char * openssl_version_str(void) {
+  return SSLeay_version(SSLEAY_VERSION);
+}
diff --git a/common/openssl_version.h b/common/openssl_version.h
new file mode 100644
index 000000000..9a98a573a
--- /dev/null
+++ b/common/openssl_version.h
@@ -0,0 +1,25 @@
+/******************************************************************************
+ * Copyright (c) 2000-2016 Ericsson Telecom AB
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Szabo, Bence Janos
+ *
+ ******************************************************************************/
+#ifndef OPENSSL_VERSION_H
+#define OPENSSL_VERSION_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+const char * openssl_version_str(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // OPENSSL_VERSION_H
diff --git a/compiler2/Makefile b/compiler2/Makefile
index 28190b3d3..dcf2ca5f8 100644
--- a/compiler2/Makefile
+++ b/compiler2/Makefile
@@ -111,8 +111,10 @@ COMMON_OBJECTS := $(addprefix ../common/, memory.o path.o userinfo.o)
 
 TCOV2LCOV_COMMON_OBJECTS := ../common/memory.o
 
-COMMON_OBJECTS += ../common/license.o
-TCOV2LCOV_COMMON_OBJECTS += ../common/license.o
+ifeq ($(LICENSING), yes)
+	COMMON_OBJECTS += ../common/license.o
+	TCOV2LCOV_COMMON_OBJECTS += ../common/license.o
+endif
 
 ifdef REGEX_DIR
   COMMON_OBJECTS += $(REGEX_DIR)/lib/regex.o
@@ -120,7 +122,7 @@ endif
 
 COMPILER_COMMON_OBJECTS := $(COMMON_OBJECTS) \
 $(addprefix ../common/, new.o pattern_la.o pattern_p.o pattern_uni.o Quadruple.o \
-ModuleVersion.o JSON_Tokenizer.o UnicharPattern.o)
+ModuleVersion.o JSON_Tokenizer.o UnicharPattern.o openssl_version.o)
 
 ifeq ($(USAGE_STATS), yes)
 COMPILER_COMMON_OBJECTS += ../common/usage_stats.o
diff --git a/compiler2/main.cc b/compiler2/main.cc
index 93d7c465e..c7eaa508a 100644
--- a/compiler2/main.cc
+++ b/compiler2/main.cc
@@ -69,9 +69,11 @@
 
 #include "ttcn3/profiler.h"
 
+#include "../common/openssl_version.h"
 
+#ifdef LICENSE
 #include "../common/license.h"
-
+#endif
 
 using namespace Common;
 
@@ -922,8 +924,7 @@ int main(int argc, char *argv[])
 	  "Compiled with: " C_COMPILER_VERSION "\n", stderr);
 	  fputs("Using ", stderr);
 	  fputs(openssl_version_str(), stderr);
-	  fputs("\n\n", stderr);
-	  fputs(COPYRIGHT_STRING "\n\n", stderr);
+	  fputs("\n\n" COPYRIGHT_STRING "\n\n", stderr);
 #ifdef LICENSE
     print_license_info();
     fputs("\n\n", stderr);
diff --git a/mctr2/mctr/Makefile b/mctr2/mctr/Makefile
index e49f8be38..4de56af22 100644
--- a/mctr2/mctr/Makefile
+++ b/mctr2/mctr/Makefile
@@ -55,7 +55,7 @@ OBJECTS_NOMAIN := $(filter-out Cli_main.o, $(OBJECTS))
 
 COMMON_OBJECTS := $(addprefix ../../common/, memory.o config_preproc.o \
 config_preproc_la.o config_preproc_p.tab.o path.o NetworkHandler.o \
-Path2.o) ../../core/RInt.o ../../core/Textbuf.o
+Path2.o openssl_version.o) ../../core/RInt.o ../../core/Textbuf.o
 
 ifeq ($(LICENSING), yes)
     COMMON_OBJECTS += ../../common/license.o
diff --git a/mctr2/mctr/main.cc b/mctr2/mctr/main.cc
index 83a9e1dd1..5cfe7d910 100644
--- a/mctr2/mctr/main.cc
+++ b/mctr2/mctr/main.cc
@@ -49,6 +49,8 @@
 #include "../../common/license.h"
 #endif
 
+#include "../../common/openssl_version.h"
+
 #include "MainController.h"
 
 #if defined CLI
@@ -273,12 +275,12 @@ int main(int argc, char *argv[])
       " for the TTCN-3 Test Executor\n"
       "Product number: " PRODUCT_NUMBER "\n"
       "Build date: " __DATE__ " " __TIME__ "\n"
-      "Compiled with: " C_COMPILER_VERSION "\n\n"
-      COPYRIGHT_STRING "\n\n", stderr);
+      "Compiled with: " C_COMPILER_VERSION "\n", stderr);
+    fputs("Using ", stderr);
+    fputs(openssl_version_str(), stderr);
+    fputs("\n\n" COPYRIGHT_STRING "\n\n", stderr);
 #ifdef LICENSE
     print_license_info();
-    fputs("\nUsing ", stderr);
-    fputs(openssl_version_str(), stderr);
     fputs("\n\n", stderr);
 #endif
     return 0;
-- 
GitLab