From a3eab24c360b39ed066ee67ce389e11e25651d53 Mon Sep 17 00:00:00 2001 From: Dirk Grunwald Date: Wed, 30 Nov 2022 11:27:57 -0700 Subject: [PATCH 01/17] Remove backslash in includes --- include/itm.h | 6 +++++- src/ComputeDeltaH.cpp | 2 +- src/DiffractionLoss.cpp | 2 +- src/FindHorizons.cpp | 2 +- src/FreeSpaceLoss.cpp | 2 +- src/FresnelIntegral.cpp | 2 +- src/H0Function.cpp | 2 +- src/InitializeArea.cpp | 4 ++-- src/InitializePointToPoint.cpp | 4 ++-- ...InverseComplementaryCumulativeDistributionFunction.cpp | 2 +- src/KnifeEdgeDiffraction.cpp | 2 +- src/LineOfSightLoss.cpp | 2 +- src/LinearLeastSquaresFit.cpp | 2 +- src/LongleyRice.cpp | 8 ++++---- src/QuickPfl.cpp | 2 +- src/SigmaHFunction.cpp | 2 +- src/SmoothEarthDiffraction.cpp | 2 +- src/TerrainRoughness.cpp | 2 +- src/TroposcatterLoss.cpp | 2 +- src/ValidateInputs.cpp | 8 ++++---- src/Variability.cpp | 6 +++--- src/itm_area.cpp | 6 +++--- src/itm_p2p.cpp | 6 +++--- 23 files changed, 41 insertions(+), 37 deletions(-) diff --git a/include/itm.h b/include/itm.h index 7ad1fbc..5887e22 100644 --- a/include/itm.h +++ b/include/itm.h @@ -7,7 +7,11 @@ using namespace std; // Export the DLL functions as "C" and not C++ -#define DLLEXPORT extern "C" __declspec(dllexport) +#ifdef _WIN32 +# define DLLEXPORT extern "C" __declspec(dllexport) +#else +# define DLLEXPORT extern "C" +#endif #define MAX(x, y) (((x) > (y)) ? (x) : (y)) #define MIN(x, y) (((x) < (y)) ? (x) : (y)) #define DIM(x, y) (((x) > (y)) ? (x - y) : (0)) diff --git a/src/ComputeDeltaH.cpp b/src/ComputeDeltaH.cpp index 0f4aae4..20f4b3a 100644 --- a/src/ComputeDeltaH.cpp +++ b/src/ComputeDeltaH.cpp @@ -1,4 +1,4 @@ -#include "..\include\itm.h" +#include "itm.h" /*============================================================================= | diff --git a/src/DiffractionLoss.cpp b/src/DiffractionLoss.cpp index dc3a669..ccfac0b 100644 --- a/src/DiffractionLoss.cpp +++ b/src/DiffractionLoss.cpp @@ -1,4 +1,4 @@ -#include "..\include\itm.h" +#include "itm.h" /*============================================================================= | diff --git a/src/FindHorizons.cpp b/src/FindHorizons.cpp index 7beb29a..8b28df5 100644 --- a/src/FindHorizons.cpp +++ b/src/FindHorizons.cpp @@ -1,4 +1,4 @@ -#include "..\include\itm.h" +#include "itm.h" /*============================================================================= | diff --git a/src/FreeSpaceLoss.cpp b/src/FreeSpaceLoss.cpp index 0981ec7..c92fed1 100644 --- a/src/FreeSpaceLoss.cpp +++ b/src/FreeSpaceLoss.cpp @@ -1,4 +1,4 @@ -#include "..\include\itm.h" +#include "itm.h" /*============================================================================= | diff --git a/src/FresnelIntegral.cpp b/src/FresnelIntegral.cpp index 0726d1b..57760f3 100644 --- a/src/FresnelIntegral.cpp +++ b/src/FresnelIntegral.cpp @@ -1,4 +1,4 @@ -#include "..\include\itm.h" +#include "itm.h" /*============================================================================= | diff --git a/src/H0Function.cpp b/src/H0Function.cpp index b1ae842..b9efda7 100644 --- a/src/H0Function.cpp +++ b/src/H0Function.cpp @@ -1,4 +1,4 @@ -#include "..\include\itm.h" +#include "itm.h" /*============================================================================= | diff --git a/src/InitializeArea.cpp b/src/InitializeArea.cpp index 8d1ffc8..e70d189 100644 --- a/src/InitializeArea.cpp +++ b/src/InitializeArea.cpp @@ -1,5 +1,5 @@ -#include "..\include\itm.h" -#include "..\include\Enums.h" +#include "itm.h" +#include "Enums.h" /*============================================================================= | diff --git a/src/InitializePointToPoint.cpp b/src/InitializePointToPoint.cpp index b001477..4fd5400 100644 --- a/src/InitializePointToPoint.cpp +++ b/src/InitializePointToPoint.cpp @@ -1,5 +1,5 @@ -#include "..\include\itm.h" -#include "..\include\Enums.h" +#include "itm.h" +#include "Enums.h" /*============================================================================= | diff --git a/src/InverseComplementaryCumulativeDistributionFunction.cpp b/src/InverseComplementaryCumulativeDistributionFunction.cpp index 68b0436..db8011d 100644 --- a/src/InverseComplementaryCumulativeDistributionFunction.cpp +++ b/src/InverseComplementaryCumulativeDistributionFunction.cpp @@ -1,4 +1,4 @@ -#include "..\include\itm.h" +#include "itm.h" /*============================================================================= | diff --git a/src/KnifeEdgeDiffraction.cpp b/src/KnifeEdgeDiffraction.cpp index 4cec35c..061ce4a 100644 --- a/src/KnifeEdgeDiffraction.cpp +++ b/src/KnifeEdgeDiffraction.cpp @@ -1,4 +1,4 @@ -#include "..\include\itm.h" +#include "itm.h" /*============================================================================= | diff --git a/src/LineOfSightLoss.cpp b/src/LineOfSightLoss.cpp index e8c7a73..23b9553 100644 --- a/src/LineOfSightLoss.cpp +++ b/src/LineOfSightLoss.cpp @@ -1,4 +1,4 @@ -#include "..\include\itm.h" +#include "itm.h" /*============================================================================= | diff --git a/src/LinearLeastSquaresFit.cpp b/src/LinearLeastSquaresFit.cpp index 65f2829..076a58c 100644 --- a/src/LinearLeastSquaresFit.cpp +++ b/src/LinearLeastSquaresFit.cpp @@ -1,4 +1,4 @@ -#include "..\include\itm.h" +#include "itm.h" /*============================================================================= | diff --git a/src/LongleyRice.cpp b/src/LongleyRice.cpp index 6de72ab..181112d 100644 --- a/src/LongleyRice.cpp +++ b/src/LongleyRice.cpp @@ -1,7 +1,7 @@ -#include "..\include\itm.h" -#include "..\include\Enums.h" -#include "..\include\Errors.h" -#include "..\include\Warnings.h" +#include "itm.h" +#include "Enums.h" +#include "Errors.h" +#include "Warnings.h" /*============================================================================= | diff --git a/src/QuickPfl.cpp b/src/QuickPfl.cpp index 6f4c942..104130c 100644 --- a/src/QuickPfl.cpp +++ b/src/QuickPfl.cpp @@ -1,4 +1,4 @@ -#include "..\include\itm.h" +#include "itm.h" /*============================================================================= | diff --git a/src/SigmaHFunction.cpp b/src/SigmaHFunction.cpp index 066b4ea..4b309ef 100644 --- a/src/SigmaHFunction.cpp +++ b/src/SigmaHFunction.cpp @@ -1,4 +1,4 @@ -#include "..\include\itm.h" +#include "itm.h" /*============================================================================= | diff --git a/src/SmoothEarthDiffraction.cpp b/src/SmoothEarthDiffraction.cpp index 25b480e..6327c24 100644 --- a/src/SmoothEarthDiffraction.cpp +++ b/src/SmoothEarthDiffraction.cpp @@ -1,4 +1,4 @@ -#include "..\include\itm.h" +#include "itm.h" /*============================================================================= | diff --git a/src/TerrainRoughness.cpp b/src/TerrainRoughness.cpp index d4acc35..36c0570 100644 --- a/src/TerrainRoughness.cpp +++ b/src/TerrainRoughness.cpp @@ -1,4 +1,4 @@ -#include "..\include\itm.h" +#include "itm.h" /*============================================================================= | diff --git a/src/TroposcatterLoss.cpp b/src/TroposcatterLoss.cpp index b2e4fd0..d6ce298 100644 --- a/src/TroposcatterLoss.cpp +++ b/src/TroposcatterLoss.cpp @@ -1,4 +1,4 @@ -#include "..\include\itm.h" +#include "itm.h" /*============================================================================= | diff --git a/src/ValidateInputs.cpp b/src/ValidateInputs.cpp index c300fb7..1510bc4 100644 --- a/src/ValidateInputs.cpp +++ b/src/ValidateInputs.cpp @@ -1,7 +1,7 @@ -#include "..\include\itm.h" -#include "..\include\Enums.h" -#include "..\include\Errors.h" -#include "..\include\Warnings.h" +#include "itm.h" +#include "Enums.h" +#include "Errors.h" +#include "Warnings.h" /*============================================================================= | diff --git a/src/Variability.cpp b/src/Variability.cpp index fa1d699..ccd51d4 100644 --- a/src/Variability.cpp +++ b/src/Variability.cpp @@ -1,6 +1,6 @@ -#include "..\include\itm.h" -#include "..\include\Enums.h" -#include "..\include\Warnings.h" +#include "itm.h" +#include "Enums.h" +#include "Warnings.h" /*============================================================================= | diff --git a/src/itm_area.cpp b/src/itm_area.cpp index 756ece7..5733806 100644 --- a/src/itm_area.cpp +++ b/src/itm_area.cpp @@ -1,6 +1,6 @@ -#include "..\include\itm.h" -#include "..\include\Enums.h" -#include "..\include\Errors.h" +#include "itm.h" +#include "Enums.h" +#include "Errors.h" /*============================================================================= | diff --git a/src/itm_p2p.cpp b/src/itm_p2p.cpp index 41becdc..d296016 100644 --- a/src/itm_p2p.cpp +++ b/src/itm_p2p.cpp @@ -1,6 +1,6 @@ -#include "..\include\itm.h" -#include "..\include\Enums.h" -#include "..\include\Errors.h" +#include "itm.h" +#include "Enums.h" +#include "Errors.h" /*============================================================================= | From 45bcd28ac932ff75b2173b92f31202b5acc2a607 Mon Sep 17 00:00:00 2001 From: Dirk Grunwald Date: Wed, 30 Nov 2022 11:28:19 -0700 Subject: [PATCH 02/17] cmake build --- CMakeLists.txt | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ itmlib.pc.in | 12 +++++++++ 2 files changed, 78 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 itmlib.pc.in diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..4c0e48d --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,66 @@ +# +# Cmake for a shared library using directions at https://stackoverflow.com/questions/17511496/how-to-create-a-shared-library-with-cmake +# +cmake_minimum_required(VERSION 3.9) + +project(itmlib VERSION 1.0.1 DESCRIPTION "NTIA Irregular Terrain Model library") + +SET(itmlib_SRC + src/ComputeDeltaH.cpp + src/DiffractionLoss.cpp + src/FindHorizons.cpp + src/FreeSpaceLoss.cpp + src/FresnelIntegral.cpp + src/H0Function.cpp + src/InitializeArea.cpp + src/InitializePointToPoint.cpp + src/InverseComplementaryCumulativeDistributionFunction.cpp + src/itm_area.cpp + src/itm_p2p.cpp + src/KnifeEdgeDiffraction.cpp + src/LinearLeastSquaresFit.cpp + src/LineOfSightLoss.cpp + src/LongleyRice.cpp + src/QuickPfl.cpp + src/SigmaHFunction.cpp + src/SmoothEarthDiffraction.cpp + src/TerrainRoughness.cpp + src/TroposcatterLoss.cpp + src/ValidateInputs.cpp + src/Variability.cpp +) + +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS YES CACHE BOOL "Export all symbols") + +# +# run cmake -DBUILD_SHARED_LIBS=ON if you want shared libs +# See https://cgold.readthedocs.io/en/latest/tutorials/libraries/static-shared.html +# +add_library(itmlib ${itmlib_SRC}) + +set_target_properties(itmlib PROPERTIES VERSION ${PROJECT_VERSION}) +set_target_properties(itmlib PROPERTIES SOVERSION 1) + + +set_target_properties(itmlib PROPERTIES PUBLIC_HEADER include/itm.h) +set_target_properties(itmlib PROPERTIES PUBLIC_HEADER include/Enums.h) +set_target_properties(itmlib PROPERTIES PUBLIC_HEADER include/Errors.h) +set_target_properties(itmlib PROPERTIES PUBLIC_HEADER include/Warnigns.h) + + +# +# inclue the include directory +# +target_include_directories(itmlib PRIVATE include) + +include(GNUInstallDirs) +install(TARGETS itmlib + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/imtlib + ) + +# pkg_check_modules() + +configure_file(itmlib.pc.in itmlib.pc @ONLY) + +install(FILES ${CMAKE_BINARY_DIR}/itmlib.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig) diff --git a/itmlib.pc.in b/itmlib.pc.in new file mode 100644 index 0000000..ab4f27a --- /dev/null +++ b/itmlib.pc.in @@ -0,0 +1,12 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=@CMAKE_INSTALL_PREFIX@ +libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ +includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ + +Name: @PROJECT_NAME@ +Description: @PROJECT_DESCRIPTION@ +Version: @PROJECT_VERSION@ + +Requires: +Libs: -L${libdir} -litmlib +Cflags: -I${includedir} \ No newline at end of file From 8c4d154f6d74e85dae42d3f3d406dc5c81657cb3 Mon Sep 17 00:00:00 2001 From: Dirk Grunwald Date: Wed, 30 Nov 2022 14:49:09 -0700 Subject: [PATCH 03/17] imt -> itm typo --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c0e48d..ab0082a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,7 +56,7 @@ target_include_directories(itmlib PRIVATE include) include(GNUInstallDirs) install(TARGETS itmlib LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/imtlib + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/itmlib ) # pkg_check_modules() From 26fac01e5af82b086bad0a98bf548bc35e3708c5 Mon Sep 17 00:00:00 2001 From: Dirk Grunwald Date: Wed, 30 Nov 2022 19:04:47 -0700 Subject: [PATCH 04/17] initial CLI for non-WIN22 systems --- CMakeLists.txt | 9 +++++--- win32/ITMDrvr/AreaMode.cpp | 12 ++++++++-- win32/ITMDrvr/AreaMode.h | 5 +++++ win32/ITMDrvr/CMakeLists.txt | 16 +++++++++++++ win32/ITMDrvr/Common.h | 11 +++++++++ win32/ITMDrvr/ITMDrvr.cpp | 36 ++++++++++++++++++++++++------ win32/ITMDrvr/ITMDrvr.h | 14 +++++++++++- win32/ITMDrvr/PointToPointMode.cpp | 13 ++++++++--- win32/ITMDrvr/PointToPointMode.h | 9 +++++++- win32/ITMDrvr/Reporting.cpp | 7 +++--- win32/ITMDrvr/Reporting.h | 6 ++++- 11 files changed, 117 insertions(+), 21 deletions(-) create mode 100644 win32/ITMDrvr/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index ab0082a..7c82488 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ # cmake_minimum_required(VERSION 3.9) -project(itmlib VERSION 1.0.1 DESCRIPTION "NTIA Irregular Terrain Model library") +project(itmlib VERSION 1.3 DESCRIPTION "NTIA Irregular Terrain Model library") SET(itmlib_SRC src/ComputeDeltaH.cpp @@ -40,18 +40,19 @@ add_library(itmlib ${itmlib_SRC}) set_target_properties(itmlib PROPERTIES VERSION ${PROJECT_VERSION}) set_target_properties(itmlib PROPERTIES SOVERSION 1) - +add_compile_definitions(ITMLIB_VERSION=${PROJECT_VERSION}) set_target_properties(itmlib PROPERTIES PUBLIC_HEADER include/itm.h) set_target_properties(itmlib PROPERTIES PUBLIC_HEADER include/Enums.h) set_target_properties(itmlib PROPERTIES PUBLIC_HEADER include/Errors.h) set_target_properties(itmlib PROPERTIES PUBLIC_HEADER include/Warnigns.h) +cmake_path(APPEND itminclude "${CMAKE_SOURCE_DIR}" "include") # # inclue the include directory # -target_include_directories(itmlib PRIVATE include) +target_include_directories(itmlib PRIVATE ${itminclude}) include(GNUInstallDirs) install(TARGETS itmlib @@ -64,3 +65,5 @@ install(TARGETS itmlib configure_file(itmlib.pc.in itmlib.pc @ONLY) install(FILES ${CMAKE_BINARY_DIR}/itmlib.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig) + +add_subdirectory(win32/ITMDrvr) diff --git a/win32/ITMDrvr/AreaMode.cpp b/win32/ITMDrvr/AreaMode.cpp index c5d6400..37d576f 100644 --- a/win32/ITMDrvr/AreaMode.cpp +++ b/win32/ITMDrvr/AreaMode.cpp @@ -5,13 +5,13 @@ #include "Common.h" // ITM DLL Functions -typedef int(__stdcall *itm_area_tls_ex_func)(double h_tx__meter, double h_rx__meter, +typedef int(WIN32_STDCALL *itm_area_tls_ex_func)(double h_tx__meter, double h_rx__meter, int tx_site_criteria, int rx_site_criteria, double d__km, double delta_h__meter, int climate, double N_0, double f__mhz, int pol, double epsilon, double sigma, int mdvar, double time, double location, double situation, double *A__db, long *warnings, struct IntermediateValues *interValues); -typedef int(__stdcall *itm_area_cr_ex_func)(double h_tx__meter, double h_rx__meter, +typedef int(WIN32_STDCALL *itm_area_cr_ex_func)(double h_tx__meter, double h_rx__meter, int tx_site_criteria, int rx_site_criteria, double d__km, double delta_h__meter, int climate, double N_0, double f__mhz, int pol, double epsilon, double sigma, int mdvar, double confidence, double reliability, double *A__db, @@ -130,6 +130,7 @@ int CallAreaMode(DrvrParams* params, AreaParams* area_params, IntermediateValues | Returns: rtn - Return error code | *===========================================================================*/ + #ifdef _WIN32 int LoadAreaFunctions(HINSTANCE hLib) { itm_area_tls_ex = (itm_area_tls_ex_func)GetProcAddress((HMODULE)hLib, "ITM_AREA_TLS_Ex"); if (itm_area_tls_ex == nullptr) @@ -141,6 +142,13 @@ int LoadAreaFunctions(HINSTANCE hLib) { return SUCCESS; } +#else +int LoadAreaFunctions() { + itm_area_tls_ex = (itm_area_tls_ex_func) &ITM_AREA_TLS_Ex; + itm_area_cr_ex = (itm_area_cr_ex_func) &ITM_AREA_CR_Ex; + return SUCCESS; +} +#endif /*============================================================================= | diff --git a/win32/ITMDrvr/AreaMode.h b/win32/ITMDrvr/AreaMode.h index d58c777..6b55c4a 100644 --- a/win32/ITMDrvr/AreaMode.h +++ b/win32/ITMDrvr/AreaMode.h @@ -8,4 +8,9 @@ int ValidateAreaInputs(AreaParams* area_params); int CallAreaMode(DrvrParams* params, AreaParams* area_params, IntermediateValues* inter_vals, vector* A__db, vector* A_fs__db, long* warnings); void WriteAreaInputs(FILE* fp, AreaParams* area_params); + +#ifdef _WIN32 int LoadAreaFunctions(HINSTANCE hLib); +#else +int LoadAreaFunctions(void* hLib); +#endif diff --git a/win32/ITMDrvr/CMakeLists.txt b/win32/ITMDrvr/CMakeLists.txt new file mode 100644 index 0000000..4e21ab4 --- /dev/null +++ b/win32/ITMDrvr/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.9) + +SET(ITMDRVR_SRC + AreaMode.cpp + Common.cpp + ITMDrvr.cpp + PointToPointMode.cpp + Reporting.cpp +) + + +add_executable(itmdrvr ${ITMDRVR_SRC}) +target_include_directories(itmdrvr PRIVATE + ${itminclude} +) +target_link_libraries(itmdrvr itmlib) \ No newline at end of file diff --git a/win32/ITMDrvr/Common.h b/win32/ITMDrvr/Common.h index 53eaa50..906e03c 100644 --- a/win32/ITMDrvr/Common.h +++ b/win32/ITMDrvr/Common.h @@ -3,3 +3,14 @@ int ParseInteger(const char* str, int* value); int ParseDouble(const char* str, double* value); int ParsingErrorHelper(int err, const char* msg); + +#ifdef _WIN32 +# define WIN32_STDCALL __stdcall +#else +# define WIN32_STDCALL +# define fprintf_s fprintf +# define printf_s printf +# define fwprintf_s fwprintf +# define sprintf_s sprintf +# define wprintf_s wprintf +#endif \ No newline at end of file diff --git a/win32/ITMDrvr/ITMDrvr.cpp b/win32/ITMDrvr/ITMDrvr.cpp index 61bedbe..1236b7d 100644 --- a/win32/ITMDrvr/ITMDrvr.cpp +++ b/win32/ITMDrvr/ITMDrvr.cpp @@ -4,9 +4,11 @@ #include "Labels.h" #include "Tags.h" #include "Reporting.h" -#include "..\..\include\Enums.h" -#include "..\..\include\Errors.h" -#include "..\..\include\Warnings.h" +#include "Common.h" + +#include "Enums.h" +#include "Errors.h" +#include "Warnings.h" int dllVerMajor = NOT_SET; int dllVerMinor = NOT_SET; @@ -27,7 +29,11 @@ int main(int argc, char** argv) { // Get the time time_t t = time(NULL); +#ifdef _WIN32 _wctime_s(buf, TIME_SIZE, &t); +#else + strncpy((char*) buf, ctime(&t), TIME_SIZE); +#endif rtn = ParseArguments(argc, argv, ¶ms); if (rtn == DRVR__RETURN_SUCCESS) @@ -70,7 +76,12 @@ int main(int argc, char** argv) { // print results to file FILE* fp; +#ifdef _WIN32 int err = fopen_s(&fp, params.out_file, "w"); +#else + fp = fopen(params.out_file, "w"); + int err = errno; +#endif if (err != 0) { printf_s("Error opening output file. Exiting.\n"); return err; @@ -103,7 +114,7 @@ int main(int argc, char** argv) { } else { fprintf_s(fp, "Results\n"); - fprintf_s(fp, "ITM Warning Flags 0x%.4X ", warnings); + fprintf_s(fp, "ITM Warning Flags 0x%.4X ", (int) warnings); PrintWarningMessages(fp, warnings); fprintf_s(fp, "ITM Return Code %-12i ", rtn); PrintErrorMsgLabel(fp, rtn); @@ -402,6 +413,9 @@ int Validate_RequiredErrMsgHelper(const char* opt, int err) { | *===========================================================================*/ int LoadDLL() { +#ifndef _WIN32 + // empty +#else HINSTANCE hLib = LoadLibrary(TEXT("itm.dll")); if (hLib == NULL) @@ -420,7 +434,7 @@ int LoadDLL() { rtn = LoadAreaFunctions(hLib); if (rtn != SUCCESS) return rtn; - +#endif return SUCCESS; } @@ -434,6 +448,11 @@ int LoadDLL() { | *===========================================================================*/ void GetDLLVersionInfo() { +#ifndef _WIN32 + float version = ITMLIB_VERSION; + dllVerMajor = int(version); + dllVerMinor = ( version - int(version)) * 100; +#else DWORD verHandle = NULL; UINT size = 0; LPBYTE lpBuffer = NULL; @@ -461,7 +480,7 @@ void GetDLLVersionInfo() { delete[] verData; } - +#endif return; } @@ -476,6 +495,9 @@ void GetDLLVersionInfo() { *===========================================================================*/ void GetDrvrVersionInfo() { +#ifndef _WIN32 + // empty +#else DWORD verHandle = NULL; UINT size = 0; LPBYTE lpBuffer = NULL; @@ -507,6 +529,6 @@ void GetDrvrVersionInfo() delete[] verData; } - +#endif return; } \ No newline at end of file diff --git a/win32/ITMDrvr/ITMDrvr.h b/win32/ITMDrvr/ITMDrvr.h index 4f56ea0..06e43ac 100644 --- a/win32/ITMDrvr/ITMDrvr.h +++ b/win32/ITMDrvr/ITMDrvr.h @@ -2,7 +2,11 @@ #include #include #include -#include +#ifdef _WIN32 +# include +#else +# define DLLEXPORT extern "C" +#endif #include #include #include @@ -138,6 +142,11 @@ struct AreaParams { int mode = NOT_SET; }; +#ifdef _WIN32 +// +// Duplicates specification in itm.h +// and that version is used in non-WIN32 builds +// struct IntermediateValues { double theta_hzn[2]; // Terminal horizon angles @@ -150,6 +159,9 @@ struct IntermediateValues double d__km; // Path distance, in km int mode; // Mode of propagation value }; +#else +# include "itm.h" +#endif // // FUNCTIONS diff --git a/win32/ITMDrvr/PointToPointMode.cpp b/win32/ITMDrvr/PointToPointMode.cpp index 632dfc6..a2a6f59 100644 --- a/win32/ITMDrvr/PointToPointMode.cpp +++ b/win32/ITMDrvr/PointToPointMode.cpp @@ -5,12 +5,12 @@ #include "Common.h" // ITM DLL Functions -typedef int(__stdcall *itm_p2p_tls_ex_func)(double h_tx__meter, double h_rx__meter, +typedef int(WIN32_STDCALL *itm_p2p_tls_ex_func)(double h_tx__meter, double h_rx__meter, double pfl[], int climate, double N_0, double f__mhz, int pol, double epsilon, double sigma, int mdvar, double time, double location, double situation, double *A__db, long *warnings, struct IntermediateValues *interValues); -typedef int(__stdcall *itm_p2p_cr_ex_func)(double h_tx__meter, double h_rx__meter, +typedef int(WIN32_STDCALL *itm_p2p_cr_ex_func)(double h_tx__meter, double h_rx__meter, double pfl[], int climate, double N_0, double f__mhz, int pol, double epsilon, double sigma, int mdvar, double confidence, double reliability, double *A__db, long *warnings, struct IntermediateValues *interValues); @@ -111,6 +111,7 @@ int CallP2PMode(DrvrParams* params, P2PParams* p2p_params, IntermediateValues* i | Returns: rtn - Return error code | *===========================================================================*/ + #ifdef _WIN32 int LoadP2PFunctions(HINSTANCE hLib) { itm_p2p_tls_ex = (itm_p2p_tls_ex_func)GetProcAddress((HMODULE)hLib, "ITM_P2P_TLS_Ex"); if (itm_p2p_tls_ex == nullptr) @@ -119,9 +120,15 @@ int LoadP2PFunctions(HINSTANCE hLib) { itm_p2p_cr_ex = (itm_p2p_cr_ex_func)GetProcAddress((HMODULE)hLib, "ITM_P2P_CR_Ex"); if (itm_p2p_cr_ex == nullptr) return DRVRERR__GET_P2P_CR_FUNC_LOADING; - return SUCCESS; } +#else +int LoadP2PFunctions() { + itm_p2p_tls_ex = (itm_p2p_tls_ex_func) &ITM_P2P_TLS_Ex; + itm_p2p_cr_ex = (itm_p2p_cr_ex_func) &ITM_P2P_CR_Ex; + return SUCCESS; +} +#endif /*============================================================================= | diff --git a/win32/ITMDrvr/PointToPointMode.h b/win32/ITMDrvr/PointToPointMode.h index 574d486..cd7b9c8 100644 --- a/win32/ITMDrvr/PointToPointMode.h +++ b/win32/ITMDrvr/PointToPointMode.h @@ -7,5 +7,12 @@ int ParseP2PInputFile(const char* in_file, P2PParams *p2p_params); int ValidateP2PInputs(P2PParams* p2p_params); int CallP2PMode(DrvrParams* params, P2PParams* p2p_params, IntermediateValues* inter_vals, vector* A__db, long* warnings); void WriteP2PInputs(FILE* fp, P2PParams* p2p_params); -int LoadP2PFunctions(HINSTANCE hLib); void ParseTerrainFile(const char* terrain_file, vector* pfl); + + +#ifdef _WIN32 +int LoadP2PFunctions(HINSTANCE hLib); +#else +int LoadP2PFunctions(void* hLib); +#endif + diff --git a/win32/ITMDrvr/Reporting.cpp b/win32/ITMDrvr/Reporting.cpp index e411a9c..1e51282 100644 --- a/win32/ITMDrvr/Reporting.cpp +++ b/win32/ITMDrvr/Reporting.cpp @@ -1,8 +1,9 @@ #include "Reporting.h" +#include "Common.h" #include "Labels.h" -#include "..\..\include\Enums.h" -#include "..\..\include\Errors.h" -#include "..\..\include\Warnings.h" +#include "Enums.h" +#include "Errors.h" +#include "Warnings.h" bool need_buffer = false; diff --git a/win32/ITMDrvr/Reporting.h b/win32/ITMDrvr/Reporting.h index 74255f2..8eb6c2e 100644 --- a/win32/ITMDrvr/Reporting.h +++ b/win32/ITMDrvr/Reporting.h @@ -2,7 +2,11 @@ #include #include #include -#include +#ifdef _WIN32 +# include +#else +# define DLLEXPORT extern "C" +#endif #include #include #include From 52191f0585a523307d0814a1fd3743c5eba0829e Mon Sep 17 00:00:00 2001 From: Dirk Grunwald Date: Thu, 1 Dec 2022 09:16:09 -0700 Subject: [PATCH 05/17] Make DLL load functions more similar --- win32/ITMDrvr/AreaMode.cpp | 2 +- win32/ITMDrvr/AreaMode.h | 2 +- win32/ITMDrvr/PointToPointMode.cpp | 2 +- win32/ITMDrvr/PointToPointMode.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/win32/ITMDrvr/AreaMode.cpp b/win32/ITMDrvr/AreaMode.cpp index 37d576f..b742c53 100644 --- a/win32/ITMDrvr/AreaMode.cpp +++ b/win32/ITMDrvr/AreaMode.cpp @@ -143,7 +143,7 @@ int LoadAreaFunctions(HINSTANCE hLib) { return SUCCESS; } #else -int LoadAreaFunctions() { +int LoadAreaFunctions(void *) { itm_area_tls_ex = (itm_area_tls_ex_func) &ITM_AREA_TLS_Ex; itm_area_cr_ex = (itm_area_cr_ex_func) &ITM_AREA_CR_Ex; return SUCCESS; diff --git a/win32/ITMDrvr/AreaMode.h b/win32/ITMDrvr/AreaMode.h index 6b55c4a..1b0a9a6 100644 --- a/win32/ITMDrvr/AreaMode.h +++ b/win32/ITMDrvr/AreaMode.h @@ -12,5 +12,5 @@ void WriteAreaInputs(FILE* fp, AreaParams* area_params); #ifdef _WIN32 int LoadAreaFunctions(HINSTANCE hLib); #else -int LoadAreaFunctions(void* hLib); +int LoadAreaFunctions(void *); #endif diff --git a/win32/ITMDrvr/PointToPointMode.cpp b/win32/ITMDrvr/PointToPointMode.cpp index a2a6f59..61bb773 100644 --- a/win32/ITMDrvr/PointToPointMode.cpp +++ b/win32/ITMDrvr/PointToPointMode.cpp @@ -123,7 +123,7 @@ int LoadP2PFunctions(HINSTANCE hLib) { return SUCCESS; } #else -int LoadP2PFunctions() { +int LoadP2PFunctions(void *) { itm_p2p_tls_ex = (itm_p2p_tls_ex_func) &ITM_P2P_TLS_Ex; itm_p2p_cr_ex = (itm_p2p_cr_ex_func) &ITM_P2P_CR_Ex; return SUCCESS; diff --git a/win32/ITMDrvr/PointToPointMode.h b/win32/ITMDrvr/PointToPointMode.h index cd7b9c8..a0d668e 100644 --- a/win32/ITMDrvr/PointToPointMode.h +++ b/win32/ITMDrvr/PointToPointMode.h @@ -13,6 +13,6 @@ void ParseTerrainFile(const char* terrain_file, vector* pfl); #ifdef _WIN32 int LoadP2PFunctions(HINSTANCE hLib); #else -int LoadP2PFunctions(void* hLib); +int LoadP2PFunctions(void *); #endif From 97b2fcaea6a8fe127e5a3ffbe7fa2b55064710be Mon Sep 17 00:00:00 2001 From: Dirk Grunwald Date: Thu, 1 Dec 2022 09:16:36 -0700 Subject: [PATCH 06/17] fix version and date printing. Output now identical --- CMakeLists.txt | 5 +++-- win32/ITMDrvr/ITMDrvr.cpp | 36 ++++++++++++++++++++++++------------ 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c82488..8052b9f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,8 +39,9 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS YES CACHE BOOL "Export all symbols") add_library(itmlib ${itmlib_SRC}) set_target_properties(itmlib PROPERTIES VERSION ${PROJECT_VERSION}) -set_target_properties(itmlib PROPERTIES SOVERSION 1) -add_compile_definitions(ITMLIB_VERSION=${PROJECT_VERSION}) +set_target_properties(itmlib PROPERTIES SOVERSION 0) +add_compile_definitions( + ITMLIB_VERSION="${PROJECT_VERSION}.0") set_target_properties(itmlib PROPERTIES PUBLIC_HEADER include/itm.h) set_target_properties(itmlib PROPERTIES PUBLIC_HEADER include/Enums.h) diff --git a/win32/ITMDrvr/ITMDrvr.cpp b/win32/ITMDrvr/ITMDrvr.cpp index 1236b7d..d2eff56 100644 --- a/win32/ITMDrvr/ITMDrvr.cpp +++ b/win32/ITMDrvr/ITMDrvr.cpp @@ -16,8 +16,7 @@ int drvrVerMajor = NOT_SET; int drvrVerMinor = NOT_SET; int drvrVerDrvr = NOT_SET; -wchar_t buf[TIME_SIZE]; - +char timebuf[TIME_SIZE]; /*============================================================================= | | Description: Main function of the ITM driver executable @@ -29,10 +28,21 @@ int main(int argc, char** argv) { // Get the time time_t t = time(NULL); + #ifdef _WIN32 + // + // According to https://stackoverflow.com/questions/34343181/no-output-when-using-fprintf-after-fwprintf + // you can not mix wide/narrow output in the same file. + // Because of this, on Linux/MacOS a fwprintf produces + // no output. Thus, we convert to narrow for both platforms. + // + wchar_t buf[TIME_SIZE]; _wctime_s(buf, TIME_SIZE, &t); -#else - strncpy((char*) buf, ctime(&t), TIME_SIZE); + std::mbstate_t state = std::mbstate_t(); + const wchar_t *bufptr = buf; + wcsrtombs(timebuf, &bufptr, TIME_SIZE, &state); +#else + strncpy(timebuf, ctime(&t), TIME_SIZE); #endif rtn = ParseArguments(argc, argv, ¶ms); @@ -89,7 +99,8 @@ int main(int argc, char** argv) { else { fprintf_s(fp, "itm.dll Version v%i.%i\n", dllVerMajor, dllVerMinor); fprintf_s(fp, "ITMDrvr.exe Version v%i.%i.%i\n", drvrVerMajor, drvrVerMinor, drvrVerDrvr); - fwprintf_s(fp, L"Date Generated %s", buf); + fprintf(fp, "Date Generated %s", timebuf); + fprintf_s(fp, "Input Arguments "); for (int i = 1; i < argc; i++) { fprintf_s(fp, "%s ", argv[i]); @@ -321,7 +332,7 @@ void Version() { printf_s("Institute for Telecommunications Sciences - Boulder, CO\n"); printf_s("\tITM Driver Version: %i.%i\n", drvrVerMajor, drvrVerMinor); printf_s("\tITM DLL Version: %i.%i\n", dllVerMajor, dllVerMinor); - wprintf_s(L"Time: %s", buf); + printf_s("Time: %s", timebuf); printf_s("*******************************************************\n"); } @@ -414,12 +425,13 @@ int Validate_RequiredErrMsgHelper(const char* opt, int err) { *===========================================================================*/ int LoadDLL() { #ifndef _WIN32 - // empty + void *hLib = NULL; #else HINSTANCE hLib = LoadLibrary(TEXT("itm.dll")); if (hLib == NULL) return DRVRERR__DLL_LOADING; +#endif GetDLLVersionInfo(); GetDrvrVersionInfo(); @@ -434,7 +446,7 @@ int LoadDLL() { rtn = LoadAreaFunctions(hLib); if (rtn != SUCCESS) return rtn; -#endif + return SUCCESS; } @@ -449,9 +461,8 @@ int LoadDLL() { *===========================================================================*/ void GetDLLVersionInfo() { #ifndef _WIN32 - float version = ITMLIB_VERSION; - dllVerMajor = int(version); - dllVerMinor = ( version - int(version)) * 100; + sscanf(ITMLIB_VERSION, "%d.%d", + &dllVerMajor, &dllVerMinor); #else DWORD verHandle = NULL; UINT size = 0; @@ -496,7 +507,8 @@ void GetDLLVersionInfo() { void GetDrvrVersionInfo() { #ifndef _WIN32 - // empty + sscanf(ITMLIB_VERSION, "%d.%d.%d", + &drvrVerMajor, &drvrVerMinor, &drvrVerDrvr); #else DWORD verHandle = NULL; UINT size = 0; From 3697f2c9e79d4607246c0ef918ded9209f697a16 Mon Sep 17 00:00:00 2001 From: Dirk Grunwald Date: Thu, 1 Dec 2022 09:45:40 -0700 Subject: [PATCH 07/17] force c++14 builds, convert sprintf to snprintf --- CMakeLists.txt | 3 +++ win32/ITMDrvr/CMakeLists.txt | 6 +++++- win32/ITMDrvr/Common.h | 4 ++-- win32/ITMDrvr/ITMDrvr.cpp | 8 ++++---- win32/ITMDrvr/ITMDrvr.h | 7 ++++--- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8052b9f..cc493bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,6 +43,9 @@ set_target_properties(itmlib PROPERTIES SOVERSION 0) add_compile_definitions( ITMLIB_VERSION="${PROJECT_VERSION}.0") +# Use C++14 -- needed because of initializers +set_property(TARGET itmlib PROPERTY CXX_STANDARD 14) + set_target_properties(itmlib PROPERTIES PUBLIC_HEADER include/itm.h) set_target_properties(itmlib PROPERTIES PUBLIC_HEADER include/Enums.h) set_target_properties(itmlib PROPERTIES PUBLIC_HEADER include/Errors.h) diff --git a/win32/ITMDrvr/CMakeLists.txt b/win32/ITMDrvr/CMakeLists.txt index 4e21ab4..fa8ac86 100644 --- a/win32/ITMDrvr/CMakeLists.txt +++ b/win32/ITMDrvr/CMakeLists.txt @@ -13,4 +13,8 @@ add_executable(itmdrvr ${ITMDRVR_SRC}) target_include_directories(itmdrvr PRIVATE ${itminclude} ) -target_link_libraries(itmdrvr itmlib) \ No newline at end of file + +# Use C++14 +set_property(TARGET itmdrvr PROPERTY CXX_STANDARD 14) + +target_link_libraries(itmdrvr itmlib) diff --git a/win32/ITMDrvr/Common.h b/win32/ITMDrvr/Common.h index 906e03c..3e5193c 100644 --- a/win32/ITMDrvr/Common.h +++ b/win32/ITMDrvr/Common.h @@ -11,6 +11,6 @@ int ParsingErrorHelper(int err, const char* msg); # define fprintf_s fprintf # define printf_s printf # define fwprintf_s fwprintf -# define sprintf_s sprintf +# define snprintf_s snprintf # define wprintf_s wprintf -#endif \ No newline at end of file +#endif diff --git a/win32/ITMDrvr/ITMDrvr.cpp b/win32/ITMDrvr/ITMDrvr.cpp index d2eff56..4d6995e 100644 --- a/win32/ITMDrvr/ITMDrvr.cpp +++ b/win32/ITMDrvr/ITMDrvr.cpp @@ -220,15 +220,15 @@ int ParseArguments(int argc, char** argv, DrvrParams* params) { Lowercase(argv[i]); if (Match("-i", argv[i])) { - sprintf_s(params->in_file, "%s", argv[i + 1]); + snprintf_s(params->in_file, DRVR_PARAMS_SIZE, "%s", argv[i + 1]); i++; } else if (Match("-o", argv[i])) { - sprintf_s(params->out_file, "%s", argv[i + 1]); + snprintf_s(params->out_file, DRVR_PARAMS_SIZE, "%s", argv[i + 1]); i++; } else if (Match("-t", argv[i])) { - sprintf_s(params->terrain_file, "%s", argv[i + 1]); + snprintf_s(params->terrain_file, DRVR_PARAMS_SIZE, "%s", argv[i + 1]); i++; } else if (Match("-mode", argv[i])) @@ -543,4 +543,4 @@ void GetDrvrVersionInfo() } #endif return; -} \ No newline at end of file +} diff --git a/win32/ITMDrvr/ITMDrvr.h b/win32/ITMDrvr/ITMDrvr.h index 06e43ac..a32b73e 100644 --- a/win32/ITMDrvr/ITMDrvr.h +++ b/win32/ITMDrvr/ITMDrvr.h @@ -87,10 +87,11 @@ using namespace std; // DATA STRUCTURES /////////////////////////////////////////////// +#define DRVR_PARAMS_SIZE 256 struct DrvrParams { - char terrain_file[256] = { 0 }; // Terrain file - char in_file[256] = { 0 }; // Input file - char out_file[256] = { 0 }; // Output file + char terrain_file[DRVR_PARAMS_SIZE] = { 0 }; // Terrain file + char in_file[DRVR_PARAMS_SIZE] = { 0 }; // Input file + char out_file[DRVR_PARAMS_SIZE] = { 0 }; // Output file int mode = NOT_SET; // Mode (P2P, AREA) bool DBG = false; // Dump intermediate values to file? From 8e5eb7887a78087721b4f3a7446de2655dce75c8 Mon Sep 17 00:00:00 2001 From: Dirk Grunwald Date: Thu, 1 Dec 2022 17:01:02 +0000 Subject: [PATCH 08/17] make cmake backward compatible --- CMakeLists.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cc493bd..5ecdadb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # # Cmake for a shared library using directions at https://stackoverflow.com/questions/17511496/how-to-create-a-shared-library-with-cmake # -cmake_minimum_required(VERSION 3.9) +cmake_minimum_required(VERSION 3.16) project(itmlib VERSION 1.3 DESCRIPTION "NTIA Irregular Terrain Model library") @@ -51,7 +51,12 @@ set_target_properties(itmlib PROPERTIES PUBLIC_HEADER include/Enums.h) set_target_properties(itmlib PROPERTIES PUBLIC_HEADER include/Errors.h) set_target_properties(itmlib PROPERTIES PUBLIC_HEADER include/Warnigns.h) -cmake_path(APPEND itminclude "${CMAKE_SOURCE_DIR}" "include") +# Only Cmake 3.20+ provides platform independent way to construct paths +IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER_EQUAL 3.20) + cmake_path(APPEND itminclude "${CMAKE_SOURCE_DIR}" "include") +ELSE (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER_EQUAL 3.20) + set(itminclude "${CMAKE_SOURCE_DIR}/include") +ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER_EQUAL 3.20) # # inclue the include directory From 937f1bb9ea65f023ea0abae781394df2cbdfd30c Mon Sep 17 00:00:00 2001 From: Dirk Grunwald Date: Thu, 1 Dec 2022 17:43:43 -0700 Subject: [PATCH 09/17] add build actions for windows and linux --- .github/workflows/compile-and-test.yml | 60 ++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/compile-and-test.yml diff --git a/.github/workflows/compile-and-test.yml b/.github/workflows/compile-and-test.yml new file mode 100644 index 0000000..7a0f2bc --- /dev/null +++ b/.github/workflows/compile-and-test.yml @@ -0,0 +1,60 @@ +name: Compile and test Release & Debug builds +# using https://levelup.gitconnected.com/utilizing-github-actions-to-build-and-test-on-multiple-platforms-a7fe3aa6ce2a + +on: + push: + branches: [ PR_cmake ] + + pull_request: + branches: [ PR_cmake ] + + workflow_dispatch: + +defaults: + run: + shell: bash + +jobs: + build_and_test: + name: > + Build and test a ${{ matrix.build }} version of Lamscript on + ${{ matrix.os }} with ${{ matrix.compiler }}. + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + compiler: [ g++-10 ] + build: [Release, Debug] + include: + - os: ubuntu-latest + target: Linux + # - os: macos-latest + # target: Macos + - os: windows-latest + compiler: cl + target: Windows + build: Release + # - os: windows-latest + # compiler: cl + # target: Windows + # build: Debug + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Linux/MacOS compile + if: ${{ matrix.os != 'windows-latest' }} + run: mkdir -p build ; cd build ; \ + cmake .. ; \ + make + + - name: Add msbuild to PATH + if: ${{ matrix.os == 'windows-latest' }} + uses: microsoft/setup-msbuild@v1.0.2 + + - name: Compile for Windows + if: ${{ matrix.os == 'windows-latest' }} + run: mkdir -p build ; cd build ; \ + cmake -G "Visual Studio 16 2019" .. ; \ + MSBuild.exe ../win32/lamscript.sln //t:Rebuild //p:Configuration=Release \ No newline at end of file From 71665aaad4ff0d5c1063b8867e4f46246e9fb12d Mon Sep 17 00:00:00 2001 From: Dirk Grunwald Date: Thu, 1 Dec 2022 18:05:10 -0700 Subject: [PATCH 10/17] add cmake rule to actions --- .github/workflows/compile-and-test.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/compile-and-test.yml b/.github/workflows/compile-and-test.yml index 7a0f2bc..50cf16d 100644 --- a/.github/workflows/compile-and-test.yml +++ b/.github/workflows/compile-and-test.yml @@ -17,14 +17,14 @@ defaults: jobs: build_and_test: name: > - Build and test a ${{ matrix.build }} version of Lamscript on + Build and test a ${{ matrix.build }} version of ITM on ${{ matrix.os }} with ${{ matrix.compiler }}. runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest, macos-latest] compiler: [ g++-10 ] - build: [Release, Debug] + build: [Release] include: - os: ubuntu-latest target: Linux @@ -43,6 +43,9 @@ jobs: - name: Checkout Repository uses: actions/checkout@v2 + - name: Setup cmake + uses: lukka/get-cmake@latest + - name: Linux/MacOS compile if: ${{ matrix.os != 'windows-latest' }} run: mkdir -p build ; cd build ; \ From 01003c11b25aab4d39f96e5a3df9c181e65e1704 Mon Sep 17 00:00:00 2001 From: Dirk Grunwald Date: Thu, 1 Dec 2022 18:12:07 -0700 Subject: [PATCH 11/17] attempt to clean cmake action --- .github/workflows/compile-and-test.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/compile-and-test.yml b/.github/workflows/compile-and-test.yml index 50cf16d..db27db9 100644 --- a/.github/workflows/compile-and-test.yml +++ b/.github/workflows/compile-and-test.yml @@ -22,7 +22,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest] compiler: [ g++-10 ] build: [Release] include: @@ -44,9 +44,9 @@ jobs: uses: actions/checkout@v2 - name: Setup cmake - uses: lukka/get-cmake@latest - name: Linux/MacOS compile + uses: lukka/get-cmake@latest if: ${{ matrix.os != 'windows-latest' }} run: mkdir -p build ; cd build ; \ cmake .. ; \ @@ -57,6 +57,7 @@ jobs: uses: microsoft/setup-msbuild@v1.0.2 - name: Compile for Windows + uses: lukka/get-cmake@latest if: ${{ matrix.os == 'windows-latest' }} run: mkdir -p build ; cd build ; \ cmake -G "Visual Studio 16 2019" .. ; \ From 7025b2ecb391b9bc6b43632b105d9a2eac1add0b Mon Sep 17 00:00:00 2001 From: Dirk Grunwald Date: Thu, 1 Dec 2022 18:33:40 -0700 Subject: [PATCH 12/17] try linux only cmake --- .github/workflows/compile-and-test.yml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/compile-and-test.yml b/.github/workflows/compile-and-test.yml index db27db9..5a718b2 100644 --- a/.github/workflows/compile-and-test.yml +++ b/.github/workflows/compile-and-test.yml @@ -30,23 +30,20 @@ jobs: target: Linux # - os: macos-latest # target: Macos - - os: windows-latest - compiler: cl - target: Windows - build: Release # - os: windows-latest # compiler: cl # target: Windows + # build: Release + # # - os: windows-latest + # compiler: cl + # target: Windows # build: Debug steps: - name: Checkout Repository - uses: actions/checkout@v2 - - - name: Setup cmake + uses: actions/checkout@v3 - name: Linux/MacOS compile - uses: lukka/get-cmake@latest if: ${{ matrix.os != 'windows-latest' }} run: mkdir -p build ; cd build ; \ cmake .. ; \ From f36d8d366042c874fa5c18df8452393e3642fd31 Mon Sep 17 00:00:00 2001 From: Dirk Grunwald Date: Thu, 1 Dec 2022 18:41:33 -0700 Subject: [PATCH 13/17] clean workflow --- .github/workflows/compile-and-test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/compile-and-test.yml b/.github/workflows/compile-and-test.yml index 5a718b2..28dbd94 100644 --- a/.github/workflows/compile-and-test.yml +++ b/.github/workflows/compile-and-test.yml @@ -54,7 +54,6 @@ jobs: uses: microsoft/setup-msbuild@v1.0.2 - name: Compile for Windows - uses: lukka/get-cmake@latest if: ${{ matrix.os == 'windows-latest' }} run: mkdir -p build ; cd build ; \ cmake -G "Visual Studio 16 2019" .. ; \ From 78b908af5b41a8ba4a608788aeafc2b1ecb1c946 Mon Sep 17 00:00:00 2001 From: Dirk Grunwald Date: Fri, 2 Dec 2022 15:03:48 -0700 Subject: [PATCH 14/17] try with run-cmake --- .github/workflows/compile-and-test.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/compile-and-test.yml b/.github/workflows/compile-and-test.yml index 28dbd94..312ef84 100644 --- a/.github/workflows/compile-and-test.yml +++ b/.github/workflows/compile-and-test.yml @@ -45,9 +45,11 @@ jobs: - name: Linux/MacOS compile if: ${{ matrix.os != 'windows-latest' }} - run: mkdir -p build ; cd build ; \ - cmake .. ; \ - make + uses: lukka/run-cmake@v3 + with: + cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt' + buildDirectory: "${{ github.workspace }}/build" + buildWithCMake: true - name: Add msbuild to PATH if: ${{ matrix.os == 'windows-latest' }} From 64100c20a3e6749e58fed47d66b3609febfab306 Mon Sep 17 00:00:00 2001 From: Dirk Grunwald Date: Fri, 2 Dec 2022 17:19:18 -0700 Subject: [PATCH 15/17] try with windows run-cmake --- .github/workflows/compile-and-test.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/compile-and-test.yml b/.github/workflows/compile-and-test.yml index 312ef84..1b5860a 100644 --- a/.github/workflows/compile-and-test.yml +++ b/.github/workflows/compile-and-test.yml @@ -57,6 +57,8 @@ jobs: - name: Compile for Windows if: ${{ matrix.os == 'windows-latest' }} - run: mkdir -p build ; cd build ; \ - cmake -G "Visual Studio 16 2019" .. ; \ - MSBuild.exe ../win32/lamscript.sln //t:Rebuild //p:Configuration=Release \ No newline at end of file + uses: lukka/run-cmake@v3 + with: + cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt' + buildDirectory: "${{ github.workspace }}/build" + buildWithCMake: true \ No newline at end of file From c7a47889bd2336ac71acdb56f4869ac91e074ede Mon Sep 17 00:00:00 2001 From: Dirk Grunwald Date: Fri, 2 Dec 2022 17:19:43 -0700 Subject: [PATCH 16/17] try with windows run-cmake --- .github/workflows/compile-and-test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/compile-and-test.yml b/.github/workflows/compile-and-test.yml index 1b5860a..8b9525c 100644 --- a/.github/workflows/compile-and-test.yml +++ b/.github/workflows/compile-and-test.yml @@ -30,10 +30,10 @@ jobs: target: Linux # - os: macos-latest # target: Macos - # - os: windows-latest - # compiler: cl - # target: Windows - # build: Release + - os: windows-latest + compiler: cl + target: Windows + build: Release # # - os: windows-latest # compiler: cl # target: Windows From 31d068635380f61211e4ba43d50b03f0711b758e Mon Sep 17 00:00:00 2001 From: Dirk Grunwald Date: Fri, 2 Dec 2022 17:41:40 -0700 Subject: [PATCH 17/17] Changes to compile WIN32 with github actions --- win32/ITMDrvr/AreaMode.cpp | 36 +++++++++++++++--------------- win32/ITMDrvr/CMakeLists.txt | 11 +++++++++ win32/ITMDrvr/Common.cpp | 6 ++--- win32/ITMDrvr/Common.h | 1 - win32/ITMDrvr/ITMDrvr.cpp | 13 +++++++---- win32/ITMDrvr/ITMDrvr.h | 5 ++++- win32/ITMDrvr/PointToPointMode.cpp | 28 +++++++++++------------ 7 files changed, 59 insertions(+), 41 deletions(-) diff --git a/win32/ITMDrvr/AreaMode.cpp b/win32/ITMDrvr/AreaMode.cpp index b742c53..f2f9366 100644 --- a/win32/ITMDrvr/AreaMode.cpp +++ b/win32/ITMDrvr/AreaMode.cpp @@ -175,22 +175,22 @@ int ParseAreaInputFile(const char* in_file, AreaParams* area_params) { transform(key.begin(), key.end(), key.begin(), ::tolower); if (key.compare(TAG__HTX) == 0) { - if (ParseDouble(value.c_str(), &area_params->h_tx__meter) == ERROR) { + if (ParseDouble(value.c_str(), &area_params->h_tx__meter) == ITM_ERROR) { return ParsingErrorHelper(DRVRERR__PARSE_HTX, TAG__HTX); } } else if (key.compare(TAG__HRX) == 0) { - if (ParseDouble(value.c_str(), &area_params->h_rx__meter) == ERROR) { + if (ParseDouble(value.c_str(), &area_params->h_rx__meter) == ITM_ERROR) { return ParsingErrorHelper(DRVRERR__PARSE_HRX, TAG__HRX); } } else if (key.compare(TAG__TX_SITE) == 0) { - if (ParseInteger(value.c_str(), &area_params->tx_site_criteria) == ERROR) { + if (ParseInteger(value.c_str(), &area_params->tx_site_criteria) == ITM_ERROR) { return ParsingErrorHelper(DRVRERR__PARSE_TX_SITE, TAG__TX_SITE); } } else if (key.compare(TAG__RX_SITE) == 0) { - if (ParseInteger(value.c_str(), &area_params->rx_site_criteria) == ERROR) { + if (ParseInteger(value.c_str(), &area_params->rx_site_criteria) == ITM_ERROR) { return ParsingErrorHelper(DRVRERR__PARSE_RX_SITE, TAG__RX_SITE); } } @@ -201,7 +201,7 @@ int ParseAreaInputFile(const char* in_file, AreaParams* area_params) { string str = value.substr(s, e); double p; - if (ParseDouble(str.c_str(), &p) == ERROR) { + if (ParseDouble(str.c_str(), &p) == ITM_ERROR) { return ParsingErrorHelper(DRVRERR__PARSE_DKM, TAG__DKM); } @@ -244,52 +244,52 @@ int ParseAreaInputFile(const char* in_file, AreaParams* area_params) { } } else if (key.compare(TAG__DELTAH) == 0) { - if (ParseDouble(value.c_str(), &area_params->delta_h__meter) == ERROR) { + if (ParseDouble(value.c_str(), &area_params->delta_h__meter) == ITM_ERROR) { return ParsingErrorHelper(DRVRERR__PARSE_DELTAH, TAG__DELTAH); } } else if (key.compare(TAG__CLIMATE) == 0) { - if (ParseInteger(value.c_str(), &area_params->climate) == ERROR) { + if (ParseInteger(value.c_str(), &area_params->climate) == ITM_ERROR) { return ParsingErrorHelper(DRVRERR__PARSE_CLIMATE, TAG__CLIMATE); } } else if (key.compare("n_0") == 0) { - if (ParseDouble(value.c_str(), &area_params->N_0) == ERROR) { + if (ParseDouble(value.c_str(), &area_params->N_0) == ITM_ERROR) { return ParsingErrorHelper(DRVRERR__PARSE_N0, TAG__N0); } } else if (key.compare(TAG__FREQ) == 0) { - if (ParseDouble(value.c_str(), &area_params->f__mhz) == ERROR) { + if (ParseDouble(value.c_str(), &area_params->f__mhz) == ITM_ERROR) { return ParsingErrorHelper(DRVRERR__PARSE_FREQ, TAG__FREQ); } } else if (key.compare(TAG__POL) == 0) { - if (ParseInteger(value.c_str(), &area_params->pol) == ERROR) { + if (ParseInteger(value.c_str(), &area_params->pol) == ITM_ERROR) { return ParsingErrorHelper(DRVRERR__PARSE_POL, TAG__POL); } } else if (key.compare(TAG__EPSILON) == 0) { - if (ParseDouble(value.c_str(), &area_params->epsilon) == ERROR) { + if (ParseDouble(value.c_str(), &area_params->epsilon) == ITM_ERROR) { return ParsingErrorHelper(DRVRERR__PARSE_EPSILON, TAG__EPSILON); } } else if (key.compare(TAG__SIGMA) == 0) { - if (ParseDouble(value.c_str(), &area_params->sigma) == ERROR) { + if (ParseDouble(value.c_str(), &area_params->sigma) == ITM_ERROR) { return ParsingErrorHelper(DRVRERR__PARSE_SIGMA, TAG__SIGMA); } } else if (key.compare(TAG__MDVAR) == 0) { - if (ParseInteger(value.c_str(), &area_params->mdvar) == ERROR) { + if (ParseInteger(value.c_str(), &area_params->mdvar) == ITM_ERROR) { return ParsingErrorHelper(DRVRERR__PARSE_MDVAR, TAG__MDVAR); } } else if (key.compare(TAG__TIME) == 0) { - if (ParseDouble(value.c_str(), &area_params->time) == ERROR) { + if (ParseDouble(value.c_str(), &area_params->time) == ITM_ERROR) { return ParsingErrorHelper(DRVRERR__PARSE_TIME, TAG__TIME); } } else if (key.compare(TAG__LOCATION) == 0) { - if (ParseDouble(value.c_str(), &area_params->location) == ERROR) { + if (ParseDouble(value.c_str(), &area_params->location) == ITM_ERROR) { return ParsingErrorHelper(DRVRERR__PARSE_LOCATION, TAG__LOCATION); } } @@ -300,7 +300,7 @@ int ParseAreaInputFile(const char* in_file, AreaParams* area_params) { string str = value.substr(s, e); double situation; - if (ParseDouble(str.c_str(), &situation) == ERROR) { + if (ParseDouble(str.c_str(), &situation) == ITM_ERROR) { return ParsingErrorHelper(DRVRERR__PARSE_SITUATION, TAG__SITUATION); } @@ -315,7 +315,7 @@ int ParseAreaInputFile(const char* in_file, AreaParams* area_params) { string str = value.substr(s, e); double confidence; - if (ParseDouble(str.c_str(), &confidence) == ERROR) { + if (ParseDouble(str.c_str(), &confidence) == ITM_ERROR) { return ParsingErrorHelper(DRVRERR__PARSE_CONFIDENCE, TAG__CONFIDENCE); } @@ -324,7 +324,7 @@ int ParseAreaInputFile(const char* in_file, AreaParams* area_params) { } while (e != value.npos); } else if (key.compare(TAG__RELIABILITY) == 0) { - if (ParseDouble(value.c_str(), &area_params->reliability) == ERROR) { + if (ParseDouble(value.c_str(), &area_params->reliability) == ITM_ERROR) { return ParsingErrorHelper(DRVRERR__PARSE_RELIABILITY, TAG__RELIABILITY); } } diff --git a/win32/ITMDrvr/CMakeLists.txt b/win32/ITMDrvr/CMakeLists.txt index fa8ac86..44ab382 100644 --- a/win32/ITMDrvr/CMakeLists.txt +++ b/win32/ITMDrvr/CMakeLists.txt @@ -18,3 +18,14 @@ target_include_directories(itmdrvr PRIVATE set_property(TARGET itmdrvr PROPERTY CXX_STANDARD 14) target_link_libraries(itmdrvr itmlib) + +# +# Use UNICODE in windows +# + +if (WIN32) + ADD_DEFINITIONS(-DUNICODE) + ADD_DEFINITIONS(-D_UNICODE) + target_link_libraries(itmdrvr version) +endif (WIN32) + diff --git a/win32/ITMDrvr/Common.cpp b/win32/ITMDrvr/Common.cpp index 5055779..25b758e 100644 --- a/win32/ITMDrvr/Common.cpp +++ b/win32/ITMDrvr/Common.cpp @@ -19,12 +19,12 @@ int ParseInteger(const char* str, int* value) { *value = ::stoi(str, &t, 10); } catch (...) { // error parsing the input string value - return ERROR; + return ITM_ERROR; } // verify the entire string was parsed, and a trailing char wasn't omitted if (strlen(str) != t) - return ERROR; + return ITM_ERROR; return SUCCESS; } @@ -46,7 +46,7 @@ int ParseDouble(const char* str, double* value) { } catch (...) { // error parsing the input string value - return ERROR; + return ITM_ERROR; } return SUCCESS; diff --git a/win32/ITMDrvr/Common.h b/win32/ITMDrvr/Common.h index 3e5193c..270f07b 100644 --- a/win32/ITMDrvr/Common.h +++ b/win32/ITMDrvr/Common.h @@ -11,6 +11,5 @@ int ParsingErrorHelper(int err, const char* msg); # define fprintf_s fprintf # define printf_s printf # define fwprintf_s fwprintf -# define snprintf_s snprintf # define wprintf_s wprintf #endif diff --git a/win32/ITMDrvr/ITMDrvr.cpp b/win32/ITMDrvr/ITMDrvr.cpp index 4d6995e..72a50c0 100644 --- a/win32/ITMDrvr/ITMDrvr.cpp +++ b/win32/ITMDrvr/ITMDrvr.cpp @@ -30,14 +30,19 @@ int main(int argc, char** argv) { time_t t = time(NULL); #ifdef _WIN32 + // + // Originally, this code use _wctime_s to get the time in a wchar + // format. There are two problems: // // According to https://stackoverflow.com/questions/34343181/no-output-when-using-fprintf-after-fwprintf // you can not mix wide/narrow output in the same file. // Because of this, on Linux/MacOS a fwprintf produces // no output. Thus, we convert to narrow for both platforms. // + // second, _wctime_s is are wrappers for + // wchar_t buf[TIME_SIZE]; - _wctime_s(buf, TIME_SIZE, &t); + _wctime64_s(buf, TIME_SIZE, &t); std::mbstate_t state = std::mbstate_t(); const wchar_t *bufptr = buf; wcsrtombs(timebuf, &bufptr, TIME_SIZE, &state); @@ -220,15 +225,15 @@ int ParseArguments(int argc, char** argv, DrvrParams* params) { Lowercase(argv[i]); if (Match("-i", argv[i])) { - snprintf_s(params->in_file, DRVR_PARAMS_SIZE, "%s", argv[i + 1]); + snprintf(params->in_file, DRVR_PARAMS_SIZE, "%s", argv[i + 1]); i++; } else if (Match("-o", argv[i])) { - snprintf_s(params->out_file, DRVR_PARAMS_SIZE, "%s", argv[i + 1]); + snprintf(params->out_file, DRVR_PARAMS_SIZE, "%s", argv[i + 1]); i++; } else if (Match("-t", argv[i])) { - snprintf_s(params->terrain_file, DRVR_PARAMS_SIZE, "%s", argv[i + 1]); + snprintf(params->terrain_file, DRVR_PARAMS_SIZE, "%s", argv[i + 1]); i++; } else if (Match("-mode", argv[i])) diff --git a/win32/ITMDrvr/ITMDrvr.h b/win32/ITMDrvr/ITMDrvr.h index a32b73e..223fb8a 100644 --- a/win32/ITMDrvr/ITMDrvr.h +++ b/win32/ITMDrvr/ITMDrvr.h @@ -10,6 +10,9 @@ #include #include #include +#include // snprintf in Windows +#include // _wctime_s in Windows +#include // for _wctime_s in Windows using namespace std; @@ -29,7 +32,7 @@ using namespace std; /////////////////////////////////////////////// #define NOT_SET -1 -#define ERROR -1 +#define ITM_ERROR -1 // disambiguage for windows wingdi.h #define SUCCESS 0 #define SUCCESS_WITH_WARNINGS 1 #define DRVR__RETURN_SUCCESS 1000 diff --git a/win32/ITMDrvr/PointToPointMode.cpp b/win32/ITMDrvr/PointToPointMode.cpp index 61bb773..63939ee 100644 --- a/win32/ITMDrvr/PointToPointMode.cpp +++ b/win32/ITMDrvr/PointToPointMode.cpp @@ -155,62 +155,62 @@ int ParseP2PInputFile(const char* in_file, P2PParams *p2p_params) { transform(key.begin(), key.end(), key.begin(), ::tolower); if (key.compare(TAG__HTX) == 0) { - if (ParseDouble(value.c_str(), &p2p_params->h_tx__meter) == ERROR) { + if (ParseDouble(value.c_str(), &p2p_params->h_tx__meter) == ITM_ERROR) { return ParsingErrorHelper(DRVRERR__PARSE_HTX, TAG__HTX); } } else if (key.compare(TAG__HRX) == 0) { - if (ParseDouble(value.c_str(), &p2p_params->h_rx__meter) == ERROR) { + if (ParseDouble(value.c_str(), &p2p_params->h_rx__meter) == ITM_ERROR) { return ParsingErrorHelper(DRVRERR__PARSE_HRX, TAG__HRX); } } else if (key.compare(TAG__CLIMATE) == 0) { - if (ParseInteger(value.c_str(), &p2p_params->climate) == ERROR) { + if (ParseInteger(value.c_str(), &p2p_params->climate) == ITM_ERROR) { return ParsingErrorHelper(DRVRERR__PARSE_CLIMATE, TAG__CLIMATE); } } else if (key.compare("n_0") == 0) { - if (ParseDouble(value.c_str(), &p2p_params->N_0) == ERROR) { + if (ParseDouble(value.c_str(), &p2p_params->N_0) == ITM_ERROR) { return ParsingErrorHelper(DRVRERR__PARSE_N0, TAG__N0); } } else if (key.compare(TAG__FREQ) == 0) { - if (ParseDouble(value.c_str(), &p2p_params->f__mhz) == ERROR) { + if (ParseDouble(value.c_str(), &p2p_params->f__mhz) == ITM_ERROR) { return ParsingErrorHelper(DRVRERR__PARSE_FREQ, TAG__FREQ); } } else if (key.compare(TAG__POL) == 0) { - if (ParseInteger(value.c_str(), &p2p_params->pol) == ERROR) { + if (ParseInteger(value.c_str(), &p2p_params->pol) == ITM_ERROR) { return ParsingErrorHelper(DRVRERR__PARSE_POL, TAG__POL); } } else if (key.compare(TAG__EPSILON) == 0) { - if (ParseDouble(value.c_str(), &p2p_params->epsilon) == ERROR) { + if (ParseDouble(value.c_str(), &p2p_params->epsilon) == ITM_ERROR) { return ParsingErrorHelper(DRVRERR__PARSE_EPSILON, TAG__EPSILON); } } else if (key.compare(TAG__SIGMA) == 0) { - if (ParseDouble(value.c_str(), &p2p_params->sigma) == ERROR) { + if (ParseDouble(value.c_str(), &p2p_params->sigma) == ITM_ERROR) { return ParsingErrorHelper(DRVRERR__PARSE_SIGMA, TAG__SIGMA); } } else if (key.compare(TAG__MDVAR) == 0) { - if (ParseInteger(value.c_str(), &p2p_params->mdvar) == ERROR) { + if (ParseInteger(value.c_str(), &p2p_params->mdvar) == ITM_ERROR) { return ParsingErrorHelper(DRVRERR__PARSE_MDVAR, TAG__MDVAR); } } else if (key.compare(TAG__TIME) == 0) { - if (ParseDouble(value.c_str(), &p2p_params->time) == ERROR) { + if (ParseDouble(value.c_str(), &p2p_params->time) == ITM_ERROR) { return ParsingErrorHelper(DRVRERR__PARSE_TIME, TAG__TIME); } } else if (key.compare(TAG__LOCATION) == 0) { - if (ParseDouble(value.c_str(), &p2p_params->location) == ERROR) { + if (ParseDouble(value.c_str(), &p2p_params->location) == ITM_ERROR) { return ParsingErrorHelper(DRVRERR__PARSE_LOCATION, TAG__LOCATION); } } else if (key.compare(TAG__SITUATION) == 0) { - if (ParseDouble(value.c_str(), &p2p_params->situation) == ERROR) { + if (ParseDouble(value.c_str(), &p2p_params->situation) == ITM_ERROR) { return ParsingErrorHelper(DRVRERR__PARSE_SITUATION, TAG__SITUATION); } } @@ -221,7 +221,7 @@ int ParseP2PInputFile(const char* in_file, P2PParams *p2p_params) { string str = value.substr(s, e); double confidence; - if (ParseDouble(str.c_str(), &confidence) == ERROR) { + if (ParseDouble(str.c_str(), &confidence) == ITM_ERROR) { return ParsingErrorHelper(DRVRERR__PARSE_CONFIDENCE, TAG__CONFIDENCE); } @@ -236,7 +236,7 @@ int ParseP2PInputFile(const char* in_file, P2PParams *p2p_params) { string str = value.substr(s, e); double reliability; - if (ParseDouble(str.c_str(), &reliability) == ERROR) { + if (ParseDouble(str.c_str(), &reliability) == ITM_ERROR) { return ParsingErrorHelper(DRVRERR__PARSE_RELIABILITY, TAG__RELIABILITY); }