From 8553a8d63f97cfa8d64b5b2260e81f8c896a8398 Mon Sep 17 00:00:00 2001 From: nancy.liao <huihui.liao@greentest.com.cn> Date: 周五, 23 5月 2025 18:36:03 +0800 Subject: [PATCH] 修改部分因为标准原因的报错 --- src/library/CMakeLists.txt | 11 ++++++++++- src/library/licensecc.cpp | 8 ++++++-- src/library/LicenseReader.cpp | 3 --- test/functional/generate-license.cpp | 3 ++- test/functional/standard-license_test.cpp | 1 + src/CMakeLists.txt | 3 ++- src/inspector/inspector.cpp | 5 +---- src/library/ini/SimpleIni.h | 12 ++++++++---- test/functional/crack_test.cpp | 1 + CMakeLists.txt | 1 - src/library/base/file_utils.cpp | 4 +++- test/functional/generate-license.h | 1 + 12 files changed, 35 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 16e641b..9dc35a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,7 +131,6 @@ message( STATUS "Project base dir : " ${LCC_PROJECTS_BASE_DIR}/${LCC_PROJECT_NAME} ) add_subdirectory(src) - #boost is required only for tests #bug in cmake win32 - can't find boost compiled with mingw if(WIN32 AND "x${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "x") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6c4253f..fcff40d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,4 +7,5 @@ "${LCC_INCLUDE_DIR}/licensecc_properties.h") ENDIF(NOT EXISTS "${LCC_INCLUDE_DIR}/licensecc_properties.h") -add_subdirectory("library") \ No newline at end of file +add_subdirectory("library") + diff --git a/src/inspector/inspector.cpp b/src/inspector/inspector.cpp index 7af061e..03cbfac 100644 --- a/src/inspector/inspector.cpp +++ b/src/inspector/inspector.cpp @@ -12,7 +12,7 @@ #include "../library/os/cpu_info.hpp" #include "../library/os/dmi_info.hpp" #include "../library/os/network.hpp" - +//纭欢鐨勮澶囦俊鎭幏鍙� using namespace std; using namespace license::os; @@ -93,9 +93,6 @@ std::cout << x.second << ": NA" << endl; } } - cout << "Virtualiz. class :" << descByVirt.find(exec_env_info.virtualization)->second << endl; - cout << "Virtualiz. detail:" << descByVirtDetail.find(exec_env_info.virtualization_detail)->second << endl; - cout << "Cloud provider :" << descByCloudProvider.find(exec_env_info.cloud_provider)->second << endl; std::vector<license::os::OsAdapterInfo> adapterInfos; FUNCTION_RETURN ret = license::os::getAdapterInfos(adapterInfos); diff --git a/src/library/CMakeLists.txt b/src/library/CMakeLists.txt index f174976..462686e 100644 --- a/src/library/CMakeLists.txt +++ b/src/library/CMakeLists.txt @@ -4,6 +4,7 @@ add_subdirectory("hw_identifier") ADD_LIBRARY(licensecc_static STATIC + licensecc.cpp LicenseReader.cpp limits/license_verifier.cpp @@ -22,15 +23,23 @@ endif(CODE_COVERAGE AND UNIX) define_property(TARGET PROPERTY WITH_OPENSSL BRIEF_DOCS "need openssl to compile" FULL_DOCS "ff") + IF(UNIX OR OPENSSL_FOUND) target_compile_definitions(licensecc_static PUBLIC HAS_OPENSSL) set_target_properties(licensecc_static PROPERTIES WITH_OPENSSL 1) - target_link_libraries(licensecc_static PUBLIC OpenSSL::Crypto ${EXTERNAL_LIBS} ${CMAKE_DL_LIBS}) + target_link_libraries(licensecc_static PUBLIC + + OpenSSL::Crypto + ${EXTERNAL_LIBS} ${CMAKE_DL_LIBS} + + ) ELSE(UNIX OR OPENSSL_FOUND) set_target_properties(licensecc_static PROPERTIES WITH_OPENSSL 0) target_link_libraries(licensecc_static PUBLIC ${EXTERNAL_LIBS}) ENDIF(UNIX OR OPENSSL_FOUND) + + #set_property(TARGET licensecc_static PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") target_include_directories(licensecc_static diff --git a/src/library/LicenseReader.cpp b/src/library/LicenseReader.cpp index 4d2792c..7c774e8 100644 --- a/src/library/LicenseReader.cpp +++ b/src/library/LicenseReader.cpp @@ -117,9 +117,6 @@ } } -#ifndef NDEBUG - cout << "license to sign [" << oss.str() << "]" << endl; -#endif return oss.str(); } diff --git a/src/library/base/file_utils.cpp b/src/library/base/file_utils.cpp index dba4d22..e5dd5f7 100644 --- a/src/library/base/file_utils.cpp +++ b/src/library/base/file_utils.cpp @@ -13,7 +13,7 @@ #include <errno.h> #include <cstring> #include "file_utils.hpp" - +#include "../test/functional/generate-license.h" namespace license { using namespace std; @@ -69,4 +69,6 @@ return path.substr(0, dotpos); } + } + diff --git a/src/library/ini/SimpleIni.h b/src/library/ini/SimpleIni.h index 7142085..ed43eba 100644 --- a/src/library/ini/SimpleIni.h +++ b/src/library/ini/SimpleIni.h @@ -218,6 +218,7 @@ #include <list> #include <algorithm> #include <stdio.h> +#include <functional> #ifdef SI_SUPPORT_IOSTREAMS # include <iostream> @@ -244,7 +245,7 @@ }; #define SI_UTF8_SIGNATURE "\xEF\xBB\xBF" - +#include <functional> #ifdef _WIN32 # define SI_NEWLINE_A "\r\n" # define SI_NEWLINE_W L"\r\n" @@ -325,8 +326,9 @@ bool operator>(const Entry & rhs) const { return LoadOrder()(rhs, *this); } #endif - /** Strict less ordering by name of key only */ - struct KeyOrder : std::binary_function<Entry, Entry, bool> { + /** Strict less ordering by name of key only */ + + struct KeyOrder /*: std::binary_function<Entry, Entry, bool>*/{ bool operator()(const Entry & lhs, const Entry & rhs) const { const static SI_STRLESS isLess = SI_STRLESS(); return isLess(lhs.pItem, rhs.pItem); @@ -334,7 +336,9 @@ }; /** Strict less ordering by order, and then name of key */ - struct LoadOrder : std::binary_function<Entry, Entry, bool> { + struct LoadOrder /*: std::binary_function<Entry, Entry, bool>*/ + { + bool operator()(const Entry & lhs, const Entry & rhs) const { if (lhs.nOrder != rhs.nOrder) { return lhs.nOrder < rhs.nOrder; diff --git a/src/library/licensecc.cpp b/src/library/licensecc.cpp index af9b171..948603a 100644 --- a/src/library/licensecc.cpp +++ b/src/library/licensecc.cpp @@ -24,7 +24,8 @@ #include "limits/license_verifier.hpp" #include "base/string_utils.h" #include "LicenseReader.hpp" - +#include "../test/functional/generate-license.h" +using namespace license; using namespace std; void print_error(char out_buffer[LCC_API_ERROR_BUFFER_SIZE], LicenseInfo* licenseInfo) {} @@ -56,6 +57,7 @@ } static void mergeLicenses(const vector<LicenseInfo>& licenses, LicenseInfo* license_out) { + if (license_out != nullptr) { int days_left = INT_MIN; for (auto it = licenses.begin(); it != licenses.end(); it++) { @@ -70,7 +72,6 @@ } } } - LCC_EVENT_TYPE acquire_license(const CallerInformations* callerInformation, const LicenseLocation* licenseLocation, LicenseInfo* license_out) { const license::LicenseReader lr = license::LicenseReader(licenseLocation); @@ -131,9 +132,12 @@ if (license_out != nullptr) { er.exportLastEvents(license_out->status, LCC_API_AUDIT_EVENT_NUM); } + return result; } + + LCC_EVENT_TYPE confirm_license(char* product, LicenseLocation licenseLocation) { return LICENSE_OK; } LCC_EVENT_TYPE release_license(char* product, LicenseLocation licenseLocation) { return LICENSE_OK; } diff --git a/test/functional/crack_test.cpp b/test/functional/crack_test.cpp index b427928..31fa782 100644 --- a/test/functional/crack_test.cpp +++ b/test/functional/crack_test.cpp @@ -18,6 +18,7 @@ using namespace license; using namespace std; +//娴嬭瘯涓�涓�氱敤鐨勮鍙瘉 /** * Test a generic license, passing a bad license number trough the api. * see projects/DEFAULT/include/licensecc/DEFAULT/licensecc_properties.h (magic should be 0) diff --git a/test/functional/generate-license.cpp b/test/functional/generate-license.cpp index a1a760a..d9b65f0 100644 --- a/test/functional/generate-license.cpp +++ b/test/functional/generate-license.cpp @@ -15,10 +15,11 @@ #include <licensecc_properties_test.h> #include <licensecc_properties.h> -#include "../../src/library/base/base.h" +#include"licensecc/licensecc.h" #include "../../src/library/ini/SimpleIni.h" #include "generate-license.h" +#include "../src/library/base/file_utils.hpp" namespace fs = boost::filesystem; using namespace std; diff --git a/test/functional/generate-license.h b/test/functional/generate-license.h index 28fba23..9105094 100644 --- a/test/functional/generate-license.h +++ b/test/functional/generate-license.h @@ -6,6 +6,7 @@ std::string generate_license(const std::string& fname, const std::vector<std::string>& other_args); std::string sign_data(const std::string& data, const std::string& test_name); +void tetsMultiple_features(); } // namespace test } // namespace license diff --git a/test/functional/standard-license_test.cpp b/test/functional/standard-license_test.cpp index c163212..eb5a9b8 100644 --- a/test/functional/standard-license_test.cpp +++ b/test/functional/standard-license_test.cpp @@ -99,6 +99,7 @@ } #endif + // // BOOST_AUTO_TEST_CASE( hw_identifier ) { // const string licLocation(PROJECT_TEST_TEMP_DIR "/hw_identifier.lic"); -- Gitblit v1.9.1