Remove unused directories and files in video_in_hal
[staging/basesystem.git] / service / native / framework_unified / client / NS_Utility / buildversioncheck / library / src / NS_BuildVersionCheck.cpp
1 /*
2  * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 ///////////////////////////////////////////////////////////////////////////////
18 /// \ingroup  tag_NSFramework
19 /// \brief
20 ///
21 ///
22 ///
23 ///////////////////////////////////////////////////////////////////////////////
24
25 ///////////////////////////////////////////////////////////////////////////////
26 // Interfaces
27 ///////////////////////////////////////////////////////////////////////////////
28 #include <native_service/ns_buildversioncheck.hpp>
29 #include <cstdlib>
30 #include <cstring>
31
32 namespace {
33
34 namespace frameworkunified_ns_bvc {
35
36 const UI_32 kMaxBuildVersionLength = 32;
37 PCSTR g_build_version_env_var_name = "BUILD_VERSION";
38 PCSTR g_build_version = _BUILD_VERSION;  // Should be defined when library is built
39
40 bool isEmptyString(PCSTR str) {  // NOLINT (readability/nolint)
41   return 0 == std::strncmp("", str, 1);
42 }
43
44 }  // namespace frameworkunified_ns_bvc
45
46 }  // namespace
47
48 namespace frameworkunified {
49
50 namespace ns {
51
52 namespace utility {
53
54 BOOL buildVersionsMatch(PCSTR build_version) {  // NOLINT (readability/nolint)
55   PCSTR env_build_version = getEnvironmentBuildVersion();
56   PCSTR lib_build_version = getLibraryBuildVersion();
57   return 0 == std::strncmp(env_build_version, build_version, frameworkunified_ns_bvc::kMaxBuildVersionLength) &&
58          0 == std::strncmp(lib_build_version, build_version, frameworkunified_ns_bvc::kMaxBuildVersionLength) &&
59          !frameworkunified_ns_bvc::isEmptyString(build_version) &&
60          !frameworkunified_ns_bvc::isEmptyString(env_build_version) &&
61          !frameworkunified_ns_bvc::isEmptyString(lib_build_version);
62 }
63
64 PCSTR getEnvironmentBuildVersion() {  // NOLINT (readability/nolint)
65   static PCSTR env_version = std::getenv(frameworkunified_ns_bvc::g_build_version_env_var_name);
66   return env_version != NULL ? env_version : "";
67 }
68
69 PCSTR getLibraryBuildVersion() {  // NOLINT (readability/nolint)
70   return frameworkunified_ns_bvc::g_build_version;
71 }
72
73 namespace utility_private {
74
75 PCSTR niceBuildVersion(PCSTR build_version) {  // NOLINT (readability/nolint)
76   return frameworkunified_ns_bvc::isEmptyString(build_version) ?  "<Not defined>" : build_version;
77 }
78
79 }  // namespace utility_private
80
81 }  // namespace utility
82
83 }  // namespace ns
84
85 }  // namespace frameworkunified