From 9188104b0bee4911db76d9030dca5d78580374cf Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Wed, 15 Nov 2023 14:47:22 -0500 Subject: [PATCH] Squashed 'externals/nitro/' changes from c899f14ad..b5612a7df b5612a7df enable "WarningsAsErrors" for DEBUG builds 2f47cc122 Merge commit 'f067a751ac940fc485c06f003e2e2c23071a8766' into cpp17 f067a751a Squashed 'externals/coda-oss/' changes from 5015192abb..1ec9a072c4 50a3500ec Merge branch 'main' into cpp17 de4686af0 improve TRE unitesting (#599) a4d0a5130 remove /Wall from MSVC (#598) b97c4a867 disable pre-loaded TREs (#597) 1075b4ecd be sure the string is properly padded for the field type git-subtree-dir: externals/nitro git-subtree-split: b5612a7dffc1a7340da81f6390fda40e8a59e679 --- UnitTest/UnitTest.cpp | 4 +- UnitTest/UnitTest.vcxproj | 6 +- UnitTest/nitf-c++.cpp | 2 +- externals/coda-oss/modules/c++/CMakeLists.txt | 7 +- .../coda-oss/modules/c++/coda-oss.vcxproj | 4 +- .../modules/c++/str/include/str/Convert.h | 3 +- .../modules/c++/str/source/Convert.cpp | 21 +-- modules/c++/CMakeLists.txt | 9 +- modules/c++/nitf-c++.vcxproj | 4 +- modules/c++/nitf-c++.vcxproj.filters | 3 + .../nitf/apps/show_nitf++/show_nitf++.vcxproj | 3 +- modules/c++/nitf/include/nitf/TRE.hpp | 3 - modules/c++/nitf/include/nitf/TREsTyped.hpp | 120 ++++++++++++++++++ modules/c++/nitf/source/TRE.cpp | 38 +++++- modules/c++/nitf/source/UnitTests.cpp | 2 +- .../c++/nitf/unittests/test_create_nitf++.cpp | 11 +- .../nitf/unittests/test_j2k_compress_tile.cpp | 4 +- .../test_j2k_compressed_byte_provider.cpp | 5 +- .../c++/nitf/unittests/test_load_plugins.cpp | 4 +- .../c++/nitf/unittests/test_tre_create++.cpp | 3 +- .../c++/nitf/unittests/test_tre_mods++.cpp | 54 +++++++- modules/c++/nitf/unittests/test_tre_mods.cpp | 30 +++-- modules/c/CMakeLists.txt | 9 +- modules/c/j2k/J2KCompress.vcxproj | 2 +- modules/c/j2k/J2KDecompress.vcxproj | 2 +- modules/c/nitf-c.vcxproj | 3 +- modules/c/nitf/ACCPOB.vcxproj | 119 ----------------- modules/c/nitf/ACFTA.vcxproj | 119 ----------------- modules/c/nitf/AIMIDB.vcxproj | 119 ----------------- modules/c/nitf/CSCRNA.vcxproj | 119 ----------------- modules/c/nitf/CSEXRB.vcxproj | 119 ----------------- modules/c/nitf/ENGRDA.vcxproj | 119 ----------------- modules/c/nitf/HISTOA.vcxproj | 119 ----------------- modules/c/nitf/JITCID.vcxproj | 119 ----------------- modules/c/nitf/PTPRAA.vcxproj | 119 ----------------- modules/c/nitf/RPFHDR.vcxproj | 119 ----------------- .../nitf/{ACCHZB.vcxproj => TEST_DES.vcxproj} | 4 +- modules/c/nitf/XML_DATA_CONTENT.vcxproj | 2 +- .../c/nitf/include/nitf/PluginIdentifier.h | 1 + modules/c/nitf/include/nitf/PluginRegistry.h | 15 ++- modules/c/nitf/source/PluginRegistry.c | 118 +++++++++++++---- modules/c/nitf/source/TREs.c | 102 ++++++++++++--- modules/c/nrt/source/DLLUnix.c | 2 +- modules/c/nrt/source/DLLWin32.c | 2 +- nitro.sln | 84 +----------- 45 files changed, 483 insertions(+), 1393 deletions(-) create mode 100644 modules/c++/nitf/include/nitf/TREsTyped.hpp delete mode 100644 modules/c/nitf/ACCPOB.vcxproj delete mode 100644 modules/c/nitf/ACFTA.vcxproj delete mode 100644 modules/c/nitf/AIMIDB.vcxproj delete mode 100644 modules/c/nitf/CSCRNA.vcxproj delete mode 100644 modules/c/nitf/CSEXRB.vcxproj delete mode 100644 modules/c/nitf/ENGRDA.vcxproj delete mode 100644 modules/c/nitf/HISTOA.vcxproj delete mode 100644 modules/c/nitf/JITCID.vcxproj delete mode 100644 modules/c/nitf/PTPRAA.vcxproj delete mode 100644 modules/c/nitf/RPFHDR.vcxproj rename modules/c/nitf/{ACCHZB.vcxproj => TEST_DES.vcxproj} (98%) diff --git a/UnitTest/UnitTest.cpp b/UnitTest/UnitTest.cpp index bd3176e4ae..96add941b2 100644 --- a/UnitTest/UnitTest.cpp +++ b/UnitTest/UnitTest.cpp @@ -1,11 +1,13 @@ #include "pch.h" #include "CppUnitTest.h" +#include #include // https://learn.microsoft.com/en-us/visualstudio/test/microsoft-visualstudio-testtools-cppunittestframework-api-reference?view=vs-2022 TEST_MODULE_INITIALIZE(methodName) { // module initialization code - nitf::Test::setNitfPluginPath(); + nitf_PluginRegistry_PreloadedTREHandlersEnable(NRT_TRUE); + nitf::Test::j2kSetNitfPluginPath(); } \ No newline at end of file diff --git a/UnitTest/UnitTest.vcxproj b/UnitTest/UnitTest.vcxproj index 3362ac3c23..386b6ec315 100644 --- a/UnitTest/UnitTest.vcxproj +++ b/UnitTest/UnitTest.vcxproj @@ -55,7 +55,7 @@ Use - Level3 + Level4 true $(ProjectDir);$(SolutionDir)modules\c\nrt\include;$(SolutionDir)modules\c\nitf\include;$(SolutionDir)modules\c++\nitf\include;$(SolutionDir)modules\c\j2k\include;$(SolutionDir)modules\c;$(SolutionDir)modules\c++;$(SolutionDir)externals\coda-oss\modules\c++;$(SolutionDir)externals\coda-oss\out\install\$(Platform)-$(Configuration)\include;$(SolutionDir)out\install\$(Platform)-$(Configuration)\include;$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) _DEBUG;%(PreprocessorDefinitions) @@ -70,6 +70,7 @@ stdcpp17 stdc11 true + true Windows @@ -262,9 +263,6 @@ {f06550ad-cfc7-40b8-8727-6c82c69a8982} - - {53f9f908-c678-4dee-9309-e71c1e03a45f} - {78849481-d356-4cc7-b182-31c21f857ed1} diff --git a/UnitTest/nitf-c++.cpp b/UnitTest/nitf-c++.cpp index 700258d514..92ba3fad2b 100644 --- a/UnitTest/nitf-c++.cpp +++ b/UnitTest/nitf-c++.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include #include diff --git a/externals/coda-oss/modules/c++/CMakeLists.txt b/externals/coda-oss/modules/c++/CMakeLists.txt index d30fb57661..694e037aa9 100644 --- a/externals/coda-oss/modules/c++/CMakeLists.txt +++ b/externals/coda-oss/modules/c++/CMakeLists.txt @@ -3,8 +3,11 @@ set(TARGET_LANGUAGE c++) if (MSVC) # By default, there is a /W3 on the command-line from somewhere (?); adding # /Wn results in a compiler warning. - #add_compile_options(/W4) # /Wall - string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") # /Wall + # + # https://github.com/microsoft/STL/wiki/Changelog#vs-2022-179-preview-1 + # > *Note*: `/Wall` is not intended for regular production use, as it contains a large number of + # > extremely noisy and low-value warnings. In general, the STL does not attempt to be `/Wall` clean. + string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") # add_compile_options(/W4) elseif (UNIX) # https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html diff --git a/externals/coda-oss/modules/c++/coda-oss.vcxproj b/externals/coda-oss/modules/c++/coda-oss.vcxproj index 492ff6e7f3..1199fd0d6f 100644 --- a/externals/coda-oss/modules/c++/coda-oss.vcxproj +++ b/externals/coda-oss/modules/c++/coda-oss.vcxproj @@ -566,7 +566,7 @@ - EnableAllWarnings + Level4 true _DEBUG;_LIB;%(PreprocessorDefinitions);CODA_OSS_EXPORTS;CODA_OSS_DLL;MT_DEFAULT_PINNING=0;RE_ENABLE_STD_REGEX=1 pch.h @@ -598,7 +598,6 @@ - Level3 true true true @@ -617,6 +616,7 @@ stdcpp17 stdc11 true + Level3 diff --git a/externals/coda-oss/modules/c++/str/include/str/Convert.h b/externals/coda-oss/modules/c++/str/include/str/Convert.h index c701580c4f..ca154a6a16 100644 --- a/externals/coda-oss/modules/c++/str/include/str/Convert.h +++ b/externals/coda-oss/modules/c++/str/include/str/Convert.h @@ -63,7 +63,7 @@ std::string toString_(const T& value) return buf.str(); } template -inline auto toString(const T& value) +inline std::string toString(const T& value) { return toString_(value); } @@ -105,6 +105,7 @@ inline auto toString(long double value) { return toString_(value); } + inline std::string toString(uint8_t value) { return toString(gsl::narrow(value)); diff --git a/externals/coda-oss/modules/c++/str/source/Convert.cpp b/externals/coda-oss/modules/c++/str/source/Convert.cpp index f2ae3d9f95..b8a2bc7415 100644 --- a/externals/coda-oss/modules/c++/str/source/Convert.cpp +++ b/externals/coda-oss/modules/c++/str/source/Convert.cpp @@ -42,32 +42,25 @@ template<> std::string str::toType(const std::string& s) template<> bool str::toType(const std::string& s) { - std::string ss = s; - str::lower(ss); - - if (ss == "true") + if (eq(s, "true")) // case-insensitive compare { return true; } - else if (ss == "false") + if (eq(s, "false")) // case-insensitive compare { return false; } - else if (str::isNumeric(ss)) + + // no need for lower(), digits don't have case + if (str::isNumeric(s)) { int value(0); - std::stringstream buf(ss); + std::stringstream buf(s); buf >> value; return (value != 0); } - else - { - throw except::BadCastException(except::Context(__FILE__, __LINE__, - std::string(""), std::string(""), - std::string("Invalid bool: '") + s + std::string("'"))); - } - return false; + throw except::BadCastException(except::Context(__FILE__, __LINE__, "", "", "Invalid bool: '" + s + "'")); } long long str::strtoll(const char *str, char **endptr, int base) diff --git a/modules/c++/CMakeLists.txt b/modules/c++/CMakeLists.txt index 6b60cd28f5..320ab27053 100644 --- a/modules/c++/CMakeLists.txt +++ b/modules/c++/CMakeLists.txt @@ -3,9 +3,12 @@ set(TARGET_LANGUAGE c++) # turn on warnings as errors if (MSVC) # By default, there is a /W3 on the command-line from somewhere (?); adding - # /W4 results in a compiler warning. - #add_compile_options(/W4) # /Wall - string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") # /Wall + # /Wn results in a compiler warning. + # + # https://github.com/microsoft/STL/wiki/Changelog#vs-2022-179-preview-1 + # > *Note*: `/Wall` is not intended for regular production use, as it contains a large number of + # > extremely noisy and low-value warnings. In general, the STL does not attempt to be `/Wall` clean. + string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") # add_compile_options(/W4) elseif (UNIX) #add_compile_options(-Wall -pedantic -Wextra) diff --git a/modules/c++/nitf-c++.vcxproj b/modules/c++/nitf-c++.vcxproj index f6cef97cf0..78e844251d 100644 --- a/modules/c++/nitf-c++.vcxproj +++ b/modules/c++/nitf-c++.vcxproj @@ -161,6 +161,7 @@ + @@ -213,7 +214,7 @@ - EnableAllWarnings + Level4 true _DEBUG;%(PreprocessorDefinitions) true @@ -235,6 +236,7 @@ stdcpp17 stdc11 true + true diff --git a/modules/c++/nitf-c++.vcxproj.filters b/modules/c++/nitf-c++.vcxproj.filters index 7f786dc0b8..e936e94cbe 100644 --- a/modules/c++/nitf-c++.vcxproj.filters +++ b/modules/c++/nitf-c++.vcxproj.filters @@ -463,5 +463,8 @@ Header Files + + Header Files + \ No newline at end of file diff --git a/modules/c++/nitf/apps/show_nitf++/show_nitf++.vcxproj b/modules/c++/nitf/apps/show_nitf++/show_nitf++.vcxproj index 5ed17fc339..423eaf6ec4 100644 --- a/modules/c++/nitf/apps/show_nitf++/show_nitf++.vcxproj +++ b/modules/c++/nitf/apps/show_nitf++/show_nitf++.vcxproj @@ -47,7 +47,7 @@ - EnableAllWarnings + Level4 true _DEBUG;_CONSOLE;%(PreprocessorDefinitions) true @@ -68,6 +68,7 @@ stdcpp17 stdc11 true + true Console diff --git a/modules/c++/nitf/include/nitf/TRE.hpp b/modules/c++/nitf/include/nitf/TRE.hpp index 09fdfab2ab..e40c562839 100644 --- a/modules/c++/nitf/include/nitf/TRE.hpp +++ b/modules/c++/nitf/include/nitf/TRE.hpp @@ -366,9 +366,6 @@ DECLARE_CLASS(TRE) */ std::string getID() const; - private: - std::string truncate(const std::string& value, size_t maxDigits) const; - mutable nitf_Error error{}; }; } diff --git a/modules/c++/nitf/include/nitf/TREsTyped.hpp b/modules/c++/nitf/include/nitf/TREsTyped.hpp new file mode 100644 index 0000000000..10b796a128 --- /dev/null +++ b/modules/c++/nitf/include/nitf/TREsTyped.hpp @@ -0,0 +1,120 @@ +/* ========================================================================= + * This file is part of NITRO + * ========================================================================= + * + * (C) Copyright 2004 - 2014, MDA Information Systems LLC + * © Copyright 2023, Maxar Technologies, Inc. + * + * NITRO is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, If not, + * see . + * + */ + +#pragma once + +#include "TREField.hpp" + + // A sample (and simple) "strongly-typed" TRE; see ENGRDA in the +// unittests for something a bit more elaborate (not included because it's incomplete). +namespace nitf +{ +namespace TREs +{ + class TEST_DES final + { + nitf::TRE tre_; + static constexpr const char* tag = "TEST_DES"; + + public: + // from TRE::getID() + /** + * Get the TRE identifier. This is NOT the tag, however it may be the + * same value as the tag. The ID is used to identify a specific + * version/incarnation of the TRE, if multiple are possible. For most TREs, + * this value will be the same as the tag. + */ + TEST_DES(const std::string& id = "") noexcept(false) + : tre_(tag, id.empty() ? tag : id.c_str()), + TEST_DES_COUNT(tre_, "TEST_DES_COUNT"), + TEST_DES_START(tre_, "TEST_DES_START"), + TEST_DES_INCREMENT(tre_, "TEST_DES_INCREMENT") + { + } + ~TEST_DES() = default; + TEST_DES(const TEST_DES&) = delete; + TEST_DES& operator=(const TEST_DES&) = delete; + TEST_DES(TEST_DES&&) = default; + TEST_DES& operator=(TEST_DES&&) = delete; + + // From TEST_DES.c + /* + static nitf_TREDescription TEST_DES_description[] = { + {NITF_BCS_N, 2, "Number of data values", "TEST_DES_COUNT" }, + {NITF_BCS_N, 3, "Start value in ramp", "TEST_DES_START" }, + {NITF_BCS_N, 2, "Increment between values in ramp", "TEST_DES_INCREMENT" }, + {NITF_END, 0, NULL, NULL} + }; + */ + nitf::TREField_BCS_N<2> TEST_DES_COUNT; + nitf::TREField_BCS_N<3> TEST_DES_START; + nitf::TREField_BCS_N<2> TEST_DES_INCREMENT; + + void updateFields() + { + tre_.updateFields(); + } + }; + + class TEST_PRELOADED_DES final + { + nitf::TRE tre_; + static constexpr const char* tag = "TEST_PRELOADED_DES"; + + public: + // from TRE::getID() + /** + * Get the TRE identifier. This is NOT the tag, however it may be the + * same value as the tag. The ID is used to identify a specific + * version/incarnation of the TRE, if multiple are possible. For most TREs, + * this value will be the same as the tag. + */ + TEST_PRELOADED_DES(const std::string& id = "") noexcept(false) : tre_(tag, id.empty() ? tag : id.c_str()), + COUNT(tre_, "COUNT"), START(tre_, "START"), INCREMENT(tre_, "INCREMENT") { } + ~TEST_PRELOADED_DES() = default; + TEST_PRELOADED_DES(const TEST_PRELOADED_DES&) = delete; + TEST_PRELOADED_DES& operator=(const TEST_PRELOADED_DES&) = delete; + TEST_PRELOADED_DES(TEST_PRELOADED_DES&&) = default; + TEST_PRELOADED_DES& operator=(TEST_PRELOADED_DES&&) = delete; + + // From TREs.c + /* + static nitf_TREDescription TEST_PRELOADED_DES_description[] = { + {NITF_BCS_N, 2, "Number of data values", "COUNT" }, + {NITF_BCS_N, 3, "Start value in ramp", "START" }, + {NITF_BCS_N, 2, "Increment between values in ramp", "INCREMENT" }, + {NITF_END, 0, NULL, NULL} + }; + */ + nitf::TREField_BCS_N<2> COUNT; + nitf::TREField_BCS_N<3> START; + nitf::TREField_BCS_N<2> INCREMENT; + + void updateFields() + { + tre_.updateFields(); + } + }; + +} // namespace TREs +} // namespace nitf \ No newline at end of file diff --git a/modules/c++/nitf/source/TRE.cpp b/modules/c++/nitf/source/TRE.cpp index dd109d407d..f0ae63b54b 100644 --- a/modules/c++/nitf/source/TRE.cpp +++ b/modules/c++/nitf/source/TRE.cpp @@ -165,7 +165,7 @@ static bool endsWith(const std::string& s, const std::string& match) noexcept return sLen >= mLen; } -std::string TRE::truncate(const std::string& value, size_t maxDigits) const +static std::string truncate(const std::string& value, size_t maxDigits) { const size_t decimalIndex = value.find('.'); if (decimalIndex == std::string::npos) @@ -184,6 +184,40 @@ std::string TRE::truncate(const std::string& value, size_t maxDigits) const } return value; } +static std::string truncate(const nitf_Field& field, const std::string& value) +{ + auto retval = truncate(value, field.length); + + // From Field.h + if (field.type == NITF_BCS_A) + { + // is BCS-A data, it is space-filled, right-aligned. + while (retval.length() < field.length) + { + // copyAndFillSpaces() in Field.c "Spaces are added to the right" + retval += " "; + } + } + else if (field.type == NITF_BCS_N) + { + const auto decimalIndex = retval.find('.'); + + // If it is BCS-N, we expect zero-filled, left-aligned. + while (retval.length() < field.length) + { + if (decimalIndex == std::string::npos) + { + retval = "0" + retval; + } + else + { + retval += "0"; + } + } + } + + return retval; +} void TRE::setFieldValue(const std::string& key, const void* data, size_t dataLength, bool forceUpdate) { @@ -207,7 +241,7 @@ void TRE::setFieldValue(const nitf_Field& field, const std::string& key, const s else { // call truncate() first - const auto s = truncate(data, field.length); + const auto s = truncate(field, data); setFieldValue(key, s.c_str(), s.size(), forceUpdate); } } diff --git a/modules/c++/nitf/source/UnitTests.cpp b/modules/c++/nitf/source/UnitTests.cpp index 4b7be9066c..31c6511336 100644 --- a/modules/c++/nitf/source/UnitTests.cpp +++ b/modules/c++/nitf/source/UnitTests.cpp @@ -271,7 +271,7 @@ static std::string buildPluginName(const std::string& base) void nitf::Test::setNitfPluginPath() { // The name of the plugin we know exists and will always be built, see test_load_plugins - static const auto p = getNitfPluginPath(buildPluginName("ENGRDA")); + static const auto p = getNitfPluginPath(buildPluginName("TEST_DES")); sys::OS().setEnv("NITF_PLUGIN_PATH", p.string(), true /*overwrite*/); } diff --git a/modules/c++/nitf/unittests/test_create_nitf++.cpp b/modules/c++/nitf/unittests/test_create_nitf++.cpp index 10bf65413d..e36b44f018 100644 --- a/modules/c++/nitf/unittests/test_create_nitf++.cpp +++ b/modules/c++/nitf/unittests/test_create_nitf++.cpp @@ -235,8 +235,6 @@ static bool test_create_nitf_with_byte_provider__testRead(const std::string& pat TEST_CASE(test_create_nitf_with_byte_provider_test) { - nitf::Test::setNitfPluginPath(); - // We can't actually compress. This is just for illustration. const bool shouldCompress = false; const std::string outname("test_create.nitf"); @@ -397,8 +395,6 @@ static bool test_create_nitf__testRead(const std::string& pathname, bool isMono TEST_CASE(test_create_nitf_test) { - nitf::Test::setNitfPluginPath(); - const std::string outname("test_create.nitf"); @@ -474,8 +470,6 @@ static void RecordThread_run() TEST_CASE(test_mt_record) { - nitf::Test::setNitfPluginPath(); - constexpr int NTHR = 2; std::array thrs; @@ -500,10 +494,9 @@ TEST_CASE(test_mt_record) TEST_ASSERT_TRUE(true); } - - - TEST_MAIN( + nitf::Test::setNitfPluginPath(); + TEST_CHECK(test_create_nitf_with_byte_provider_test); TEST_CHECK(test_create_nitf_test); TEST_CHECK(test_mt_record); diff --git a/modules/c++/nitf/unittests/test_j2k_compress_tile.cpp b/modules/c++/nitf/unittests/test_j2k_compress_tile.cpp index dedefd5ce4..4548f1e25f 100644 --- a/modules/c++/nitf/unittests/test_j2k_compress_tile.cpp +++ b/modules/c++/nitf/unittests/test_j2k_compress_tile.cpp @@ -181,8 +181,6 @@ static bool equals(const std::vector& lhs, const std::vector make_Tester(bool setBlocking, std::optional maxRo TEST_CASE(j2k_compressed_byte_provider_maxRowsPerSegment0) { - nitf::Test::setNitfPluginPath(); { auto tester = make_Tester(true /*setBlocking*/); tester.testMultipleWritesBlocked(); @@ -605,8 +604,6 @@ TEST_CASE(j2k_compressed_byte_provider_maxRowsPerSegment0) TEST_CASE(j2k_compressed_byte_provider) { - nitf::Test::setNitfPluginPath(); - // Run tests forcing various numbers of segments // Blocking is set at 40 rows / block so can't go less than this // Actual limit is a bit higher, since j2k needs a minimum size @@ -636,6 +633,8 @@ TEST_CASE(j2k_do_nothing) } TEST_MAIN( + nitf::Test::j2kSetNitfPluginPath(); + TEST_CHECK(j2k_do_nothing); //TEST_CHECK(j2k_compressed_byte_provider_maxRowsPerSegment0); // TODO: get working with CMake //TEST_CHECK(j2k_compressed_byte_provider); // TODO: get working with CMake diff --git a/modules/c++/nitf/unittests/test_load_plugins.cpp b/modules/c++/nitf/unittests/test_load_plugins.cpp index 4f84931dcd..9e59a2405d 100644 --- a/modules/c++/nitf/unittests/test_load_plugins.cpp +++ b/modules/c++/nitf/unittests/test_load_plugins.cpp @@ -78,16 +78,18 @@ TEST_CASE(test_retrieveTREHandler) TEST_CASE(test_load_PTPRAA) { + TEST_ASSERT_TRUE(nitf_PluginRegistry_PreloadedTREHandlerEnable("PTPRAA", NRT_TRUE)); retrieveTREHandler(testName, "PTPRAA"); } TEST_CASE(test_load_ENGRDA) { + TEST_ASSERT_TRUE(nitf_PluginRegistry_PreloadedTREHandlerEnable("ENGRDA", NRT_TRUE)); retrieveTREHandler(testName, "ENGRDA"); } TEST_CASE(test_load_all_TREs) { - const nitf::TRE tre("ACCPOB"); + const nitf::TRE ACCPOB("ACCPOB"); for (const auto& tre : all_TREs()) { diff --git a/modules/c++/nitf/unittests/test_tre_create++.cpp b/modules/c++/nitf/unittests/test_tre_create++.cpp index bc3f884fc7..883c0fd8fd 100644 --- a/modules/c++/nitf/unittests/test_tre_create++.cpp +++ b/modules/c++/nitf/unittests/test_tre_create++.cpp @@ -9,6 +9,7 @@ TEST_CASE(test_tre_create_329) { // https://github.com/mdaus/nitro/issues/329 + TEST_ASSERT_TRUE(nitf_PluginRegistry_PreloadedTREHandlerEnable("HISTOA", NRT_TRUE)); nitf::TRE tre("HISTOA", "HISTOA"); // allocates fields SYSTEM .. NEVENTS tre.setField("SYSTYPE", "M1"); TEST_ASSERT_TRUE(true); @@ -39,8 +40,6 @@ TEST_CASE(test_tre_clone_329) } TEST_MAIN( - nitf::Test::setNitfPluginPath(); - TEST_CHECK(test_tre_create_329); TEST_CHECK(test_tre_clone_329); ) diff --git a/modules/c++/nitf/unittests/test_tre_mods++.cpp b/modules/c++/nitf/unittests/test_tre_mods++.cpp index 1c2b4a8705..bb9963e039 100644 --- a/modules/c++/nitf/unittests/test_tre_mods++.cpp +++ b/modules/c++/nitf/unittests/test_tre_mods++.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -58,7 +59,7 @@ #include "nitf/TRE.hpp" #include "nitf/exports.hpp" -#include "nitf/TREField.hpp" +#include "nitf/TREsTyped.hpp" // A sample "strongly-typed" TRE. There are too many TREs (and too much unwillingness to change) to // actually hook this up. But it's kind of neat code that I don't want to lose. @@ -159,7 +160,7 @@ struct /*namespace*/ TREs TEST_CASE(setFields) { - // create an ACFTA TRE + TEST_ASSERT_TRUE( nitf_PluginRegistry_PreloadedTREHandlerEnable("ACFTA", NRT_TRUE) ); nitf::TRE tre("ACFTA"); // set a field @@ -178,6 +179,7 @@ TEST_CASE(setFields) TEST_CASE(setBinaryFields) { + TEST_ASSERT_TRUE( nitf_PluginRegistry_PreloadedTREHandlerEnable("RPFHDR", NRT_TRUE) ); nitf::TRE tre("RPFHDR"); const int value = 123; tre.setField("LOCSEC", value); @@ -189,6 +191,7 @@ TEST_CASE(setBinaryFields) TEST_CASE(cloneTRE) { + TEST_ASSERT_TRUE( nitf_PluginRegistry_PreloadedTREHandlerEnable("JITCID", NRT_TRUE) ); nitf::TRE tre("JITCID"); tre.setField("FILCMT", "fyi"); @@ -202,6 +205,7 @@ TEST_CASE(cloneTRE) TEST_CASE(basicIteration) { + TEST_ASSERT_TRUE( nitf_PluginRegistry_PreloadedTREHandlerEnable("ACCPOB", NRT_TRUE) ); nitf::TRE tre("ACCPOB"); // The entire TRE is one loop, and we haven't told it @@ -227,8 +231,47 @@ TEST_CASE(basicIteration) TEST_ASSERT_EQ(numFields, static_cast(29)); } +static void test_des_(const std::string& testName, nitf::TRE& des, const std::string& prefix) +{ + des.setField(prefix + "COUNT", 12); + des.setField(prefix + "START", 345); + des.setField(prefix + "INCREMENT", 67); + + TEST_ASSERT_EQ(des.getFieldValue(prefix + "COUNT"), 12); + TEST_ASSERT_EQ(des.getFieldValue(prefix + "START"), 345); + TEST_ASSERT_EQ(des.getFieldValue(prefix + "INCREMENT"), 67); +} +TEST_CASE(use_TEST_DES) +{ + TEST_ASSERT_TRUE( nitf_PluginRegistry_PreloadedTREHandlerEnable("TEST_PRELOADED_DES", NRT_TRUE) ); + nitf::TRE preloaded("TEST_PRELOADED_DES", "TEST_PRELOADED_DES"); + test_des_(testName, preloaded, ""); + + nitf::TREs::TEST_PRELOADED_DES test_preloaded_des; + test_preloaded_des.COUNT = 12; + test_preloaded_des.START = 345; + test_preloaded_des.INCREMENT = 67; + TEST_ASSERT_EQ(test_preloaded_des.COUNT, 12); + TEST_ASSERT_EQ(test_preloaded_des.START, 345); + TEST_ASSERT_EQ(test_preloaded_des.INCREMENT, 67); + + /***********************************************************/ + + nitf::TRE des("TEST_DES", "TEST_DES"); + test_des_(testName, des, "TEST_DES_"); + + nitf::TREs::TEST_DES test_des; + test_des.TEST_DES_COUNT = 12; + test_des.TEST_DES_START = 345; + test_des.TEST_DES_INCREMENT = 67; + TEST_ASSERT_EQ(test_des.TEST_DES_COUNT, 12); + TEST_ASSERT_EQ(test_des.TEST_DES_START, 345); + TEST_ASSERT_EQ(test_des.TEST_DES_INCREMENT, 67); +} + TEST_CASE(use_ENGRDA) { + TEST_ASSERT_TRUE( nitf_PluginRegistry_PreloadedTREHandlerEnable("ENGRDA", NRT_TRUE) ); nitf::TRE engrda("ENGRDA", "ENGRDA"); engrda.setField("RESRC", "HSS"); @@ -253,6 +296,7 @@ TEST_CASE(use_ENGRDA) TEST_CASE(use_ENGRDA_typed_fields) { + TEST_ASSERT_TRUE( nitf_PluginRegistry_PreloadedTREHandlerEnable("ENGRDA", NRT_TRUE) ); nitf::TRE engrda("ENGRDA", "ENGRDA"); nitf::TREField_BCS_A<20> RESRC(engrda, "RESRC"); @@ -285,6 +329,7 @@ TEST_CASE(use_ENGRDA_typed_fields) TEST_CASE(use_typed_ENGRDA) { + TEST_ASSERT_TRUE( nitf_PluginRegistry_PreloadedTREHandlerEnable("ENGRDA", NRT_TRUE) ); TREs::ENGRDA engrda; // nitf::TRE engrda("ENGRDA", "ENGRDA"); engrda.RESRC = "HSS"; // engrda.setField("RESRC", "HSS"); @@ -333,6 +378,7 @@ TEST_CASE(use_typed_ENGRDA) TEST_CASE(use_CSEXRB_typed_fields) { + TEST_ASSERT_TRUE( nitf_PluginRegistry_PreloadedTREHandlerEnable("CSEXRB", NRT_TRUE) ); nitf::TRE tre("CSEXRB", "CSEXRB"); constexpr auto length = 12; @@ -346,6 +392,7 @@ TEST_CASE(use_CSEXRB_typed_fields) TEST_CASE(populateWhileIterating) { + TEST_ASSERT_TRUE( nitf_PluginRegistry_PreloadedTREHandlerEnable("ACCPOB", NRT_TRUE) ); nitf::TRE tre("ACCPOB"); size_t numFields = 0; for (auto it = tre.begin(); it != tre.end(); ++it) @@ -370,6 +417,7 @@ TEST_CASE(populateWhileIterating) TEST_CASE(overflowingNumericFields) { + TEST_ASSERT_TRUE( nitf_PluginRegistry_PreloadedTREHandlerEnable("CSCRNA", NRT_TRUE) ); nitf::TRE tre("CSCRNA"); // This field has a length of 9, so check that it's properly @@ -398,12 +446,14 @@ TEST_CASE(overflowingNumericFields) } TEST_MAIN( + // must be set before making any NITRO calls nitf::Test::setNitfPluginPath(); TEST_CHECK(setFields); TEST_CHECK(setBinaryFields); TEST_CHECK(cloneTRE); TEST_CHECK(basicIteration); + TEST_CHECK(use_TEST_DES); TEST_CHECK(use_ENGRDA); TEST_CHECK(use_ENGRDA_typed_fields); TEST_CHECK(use_typed_ENGRDA); diff --git a/modules/c++/nitf/unittests/test_tre_mods.cpp b/modules/c++/nitf/unittests/test_tre_mods.cpp index 5bee638c71..e7246b1e11 100644 --- a/modules/c++/nitf/unittests/test_tre_mods.cpp +++ b/modules/c++/nitf/unittests/test_tre_mods.cpp @@ -26,6 +26,8 @@ TEST_CASE(testNestedMod) { + TEST_ASSERT_TRUE( nitf_PluginRegistry_PreloadedTREHandlerEnable("ACCHZB", NRT_TRUE) ); + nitf_Error error; NITF_BOOL exists; nitf_TRE* tre = nitf_TRE_construct("ACCHZB", NULL, &error); @@ -59,6 +61,8 @@ TEST_CASE(testNestedMod) TEST_CASE(testIncompleteCondMod) { + TEST_ASSERT_TRUE( nitf_PluginRegistry_PreloadedTREHandlerEnable("ACCPOB", NRT_TRUE) ); + nitf_Error error; NITF_BOOL exists; nitf_TRE* tre = nitf_TRE_construct("ACCPOB", NULL, &error); @@ -90,6 +94,7 @@ TEST_CASE(testClone) nitf_Field* clonedField = NULL; nitf_Error error; + TEST_ASSERT_TRUE( nitf_PluginRegistry_PreloadedTREHandlerEnable("JITCID", NRT_TRUE) ); nitf_TRE* tre = nitf_TRE_construct("JITCID", NULL, &error); TEST_ASSERT(tre != NULL); @@ -110,13 +115,14 @@ TEST_CASE(testClone) TEST_CASE(testBasicMod) { + TEST_ASSERT_TRUE( nitf_PluginRegistry_PreloadedTREHandlerEnable("ACFTA", NRT_TRUE) ); + /* construct a tre */ NITF_BOOL exists; nitf_Error error; - nitf_Field* field; nitf_TRE *tre = nitf_TRE_construct("ACFTA", "ACFTA_132", &error); TEST_ASSERT(tre != NULL); - field = (nitf_TRE_getField(tre, "AC_MSN_ID")); + nitf_Field* field = (nitf_TRE_getField(tre, "AC_MSN_ID")); TEST_ASSERT_EQ_STR(field->raw, " "); exists = nitf_TRE_setField(tre, "AC_MSN_ID", "fly-by", 6, &error); @@ -139,6 +145,7 @@ TEST_CASE(testBasicMod) TEST_CASE(testSize) { + TEST_ASSERT_TRUE( nitf_PluginRegistry_PreloadedTREHandlerEnable("AIMIDB", NRT_TRUE) ); nitf_Error error; int treLength; nitf_TRE* tre = nitf_TRE_construct("AIMIDB", NULL, &error); @@ -174,18 +181,17 @@ TEST_CASE(iterateUnfilled) TEST_CASE(populateThenIterate) { + TEST_ASSERT_TRUE( nitf_PluginRegistry_PreloadedTREHandlerEnable("ACCPOB", NRT_TRUE) ); nitf_Error error; - nitf_TRECursor cursor; nitf_TRE* tre = nitf_TRE_construct("ACCPOB", NULL, &error); - uint32_t numFields = 0; - TEST_ASSERT(tre != NULL); + TEST_ASSERT_NOT_NULL(tre); + uint32_t numFields = 0; nitf_TRE_setField(tre, "NUMACPO", "2", 1, &error); nitf_TRE_setField(tre, "NUMPTS[0]", "3", 1, &error); nitf_TRE_setField(tre, "NUMPTS[1]", "2", 1, &error); - cursor = nitf_TRECursor_begin(tre); - + nitf_TRECursor cursor = nitf_TRECursor_begin(tre); while (!nitf_TRECursor_isDone(&cursor)) { TEST_ASSERT(nitf_TRECursor_iterate(&cursor, &error) != 0); @@ -200,13 +206,13 @@ TEST_CASE(populateThenIterate) TEST_CASE(populateWhileIterating) { + TEST_ASSERT_TRUE( nitf_PluginRegistry_PreloadedTREHandlerEnable("ACCPOB", NRT_TRUE) ); nitf_Error error; - nitf_TRECursor cursor; nitf_TRE* tre = nitf_TRE_construct("ACCPOB", NULL, &error); - uint32_t numFields = 0; - TEST_ASSERT(tre != NULL); + TEST_ASSERT_NOT_NULL(tre); - cursor = nitf_TRECursor_begin(tre); + uint32_t numFields = 0; + nitf_TRECursor cursor = nitf_TRECursor_begin(tre); while (!nitf_TRECursor_isDone(&cursor)) { TEST_ASSERT(nitf_TRECursor_iterate(&cursor, &error) != 0); @@ -231,8 +237,6 @@ TEST_CASE(populateWhileIterating) } TEST_MAIN( - nitf::Test::setNitfPluginPath(); - TEST_CHECK(testClone); TEST_CHECK(testSize); TEST_CHECK(testBasicMod); diff --git a/modules/c/CMakeLists.txt b/modules/c/CMakeLists.txt index 6e6b185dcf..3d2a216343 100644 --- a/modules/c/CMakeLists.txt +++ b/modules/c/CMakeLists.txt @@ -4,9 +4,12 @@ set(TARGET_LANGUAGE c) # turn on warnings as errors if (MSVC) # By default, there is a /W3 on the command-line from somewhere (?); adding - # /W4 results in a compiler warning. - #add_compile_options(/W4) # /Wall - string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") # /Wall + # /Wn results in a compiler warning. + # + # https://github.com/microsoft/STL/wiki/Changelog#vs-2022-179-preview-1 + # > *Note*: `/Wall` is not intended for regular production use, as it contains a large number of + # > extremely noisy and low-value warnings. In general, the STL does not attempt to be `/Wall` clean. + string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") # add_compile_options(/W4) add_compile_options(/wd4996) # '...': This function or variable may be unsafe. elseif (UNIX) diff --git a/modules/c/j2k/J2KCompress.vcxproj b/modules/c/j2k/J2KCompress.vcxproj index 2853bc47b7..328651cf96 100644 --- a/modules/c/j2k/J2KCompress.vcxproj +++ b/modules/c/j2k/J2KCompress.vcxproj @@ -62,7 +62,7 @@ - EnableAllWarnings + Level4 true _DEBUG;_LIB;%(PreprocessorDefinitions);NRT_MODULE_EXPORTS;NITRO_PCH;HAVE_J2K_H true diff --git a/modules/c/j2k/J2KDecompress.vcxproj b/modules/c/j2k/J2KDecompress.vcxproj index 11596eec56..e5485c2dfd 100644 --- a/modules/c/j2k/J2KDecompress.vcxproj +++ b/modules/c/j2k/J2KDecompress.vcxproj @@ -62,7 +62,7 @@ - EnableAllWarnings + Level4 true _DEBUG;_LIB;%(PreprocessorDefinitions);NRT_MODULE_EXPORTS;NITRO_PCH;HAVE_J2K_H true diff --git a/modules/c/nitf-c.vcxproj b/modules/c/nitf-c.vcxproj index 5c8502e4c7..eb575fba2f 100644 --- a/modules/c/nitf-c.vcxproj +++ b/modules/c/nitf-c.vcxproj @@ -48,7 +48,7 @@ - EnableAllWarnings + Level4 true _DEBUG;%(PreprocessorDefinitions);HAVE_OPENJPEG_H true @@ -71,6 +71,7 @@ stdcpp17 stdc11 true + true diff --git a/modules/c/nitf/ACCPOB.vcxproj b/modules/c/nitf/ACCPOB.vcxproj deleted file mode 100644 index 1a20da5898..0000000000 --- a/modules/c/nitf/ACCPOB.vcxproj +++ /dev/null @@ -1,119 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - - - - - {f06550ad-cfc7-40b8-8727-6c82c69a8982} - - - - 16.0 - Win32Proj - {730B1E6E-2469-4F9E-B093-D0C6262453C9} - nitro - 10.0 - ACCPOB - - - - DynamicLibrary - true - v143 - - - DynamicLibrary - false - v143 - true - - - - - - - - - - - - - - - true - $(SolutionDir)$(Platform)\$(Configuration)\share\nitf\plugins\ - $(Platform)\$(Configuration)\$(ProjectName)\ - - - false - $(SolutionDir)$(Platform)\$(Configuration)\share\nitf\plugins\ - $(Platform)\$(Configuration)\$(ProjectName)\ - - - - EnableAllWarnings - true - _DEBUG;_LIB;%(PreprocessorDefinitions);NRT_MODULE_EXPORTS;NITRO_PCH - true - $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - true - CompileAsCpp - Guard - MultiThreadedDebugDLL - true - ProgramDatabase - AdvancedVectorExtensions2 - true - stdcpp17 - stdc11 - true - - - - - true - - - - - Level3 - true - true - true - NDEBUG;_LIB;%(PreprocessorDefinitions);NRT_MODULE_EXPORTS;NITRO_PCH - true - $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - true - CompileAsCpp - Guard - true - AdvancedVectorExtensions2 - stdcpp17 - stdc11 - true - - - - - true - true - true - - - - - - \ No newline at end of file diff --git a/modules/c/nitf/ACFTA.vcxproj b/modules/c/nitf/ACFTA.vcxproj deleted file mode 100644 index e0f0a6e414..0000000000 --- a/modules/c/nitf/ACFTA.vcxproj +++ /dev/null @@ -1,119 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - - - - - {f06550ad-cfc7-40b8-8727-6c82c69a8982} - - - - 16.0 - Win32Proj - {51D7B426-899E-428D-9F69-5DDAC9E403FB} - nitro - 10.0 - ACFTA - - - - DynamicLibrary - true - v143 - - - DynamicLibrary - false - v143 - true - - - - - - - - - - - - - - - true - $(SolutionDir)$(Platform)\$(Configuration)\share\nitf\plugins\ - $(Platform)\$(Configuration)\$(ProjectName)\ - - - false - $(SolutionDir)$(Platform)\$(Configuration)\share\nitf\plugins\ - $(Platform)\$(Configuration)\$(ProjectName)\ - - - - EnableAllWarnings - true - _DEBUG;_LIB;%(PreprocessorDefinitions);NRT_MODULE_EXPORTS;NITRO_PCH - true - $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - true - CompileAsCpp - Guard - MultiThreadedDebugDLL - true - ProgramDatabase - AdvancedVectorExtensions2 - true - stdcpp17 - stdc11 - true - - - - - true - - - - - Level3 - true - true - true - NDEBUG;_LIB;%(PreprocessorDefinitions);NRT_MODULE_EXPORTS;NITRO_PCH - true - $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - true - CompileAsCpp - Guard - true - AdvancedVectorExtensions2 - stdcpp17 - stdc11 - true - - - - - true - true - true - - - - - - \ No newline at end of file diff --git a/modules/c/nitf/AIMIDB.vcxproj b/modules/c/nitf/AIMIDB.vcxproj deleted file mode 100644 index fc16085c8a..0000000000 --- a/modules/c/nitf/AIMIDB.vcxproj +++ /dev/null @@ -1,119 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - - - - - {f06550ad-cfc7-40b8-8727-6c82c69a8982} - - - - 16.0 - Win32Proj - {12AA0752-4EE3-4E0A-85AF-0E5DEADBF343} - nitro - 10.0 - AIMIDB - - - - DynamicLibrary - true - v143 - - - DynamicLibrary - false - v143 - true - - - - - - - - - - - - - - - true - $(SolutionDir)$(Platform)\$(Configuration)\share\nitf\plugins\ - $(Platform)\$(Configuration)\$(ProjectName)\ - - - false - $(SolutionDir)$(Platform)\$(Configuration)\share\nitf\plugins\ - $(Platform)\$(Configuration)\$(ProjectName)\ - - - - EnableAllWarnings - true - _DEBUG;_LIB;%(PreprocessorDefinitions);NRT_MODULE_EXPORTS;NITRO_PCH - true - $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - true - CompileAsCpp - Guard - MultiThreadedDebugDLL - true - ProgramDatabase - AdvancedVectorExtensions2 - true - stdcpp17 - stdc11 - true - - - - - true - - - - - Level3 - true - true - true - NDEBUG;_LIB;%(PreprocessorDefinitions);NRT_MODULE_EXPORTS;NITRO_PCH - true - $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - true - CompileAsCpp - Guard - true - AdvancedVectorExtensions2 - stdcpp17 - stdc11 - true - - - - - true - true - true - - - - - - \ No newline at end of file diff --git a/modules/c/nitf/CSCRNA.vcxproj b/modules/c/nitf/CSCRNA.vcxproj deleted file mode 100644 index 3a92ddd136..0000000000 --- a/modules/c/nitf/CSCRNA.vcxproj +++ /dev/null @@ -1,119 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - - - - - {f06550ad-cfc7-40b8-8727-6c82c69a8982} - - - - 16.0 - Win32Proj - {023DE06D-3967-4406-B1B8-032118BB2552} - nitro - 10.0 - CSCRNA - - - - DynamicLibrary - true - v143 - - - DynamicLibrary - false - v143 - true - - - - - - - - - - - - - - - true - $(SolutionDir)$(Platform)\$(Configuration)\share\nitf\plugins\ - $(Platform)\$(Configuration)\$(ProjectName)\ - - - false - $(SolutionDir)$(Platform)\$(Configuration)\share\nitf\plugins\ - $(Platform)\$(Configuration)\$(ProjectName)\ - - - - EnableAllWarnings - true - _DEBUG;_LIB;%(PreprocessorDefinitions);NRT_MODULE_EXPORTS;NITRO_PCH - true - $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - true - CompileAsCpp - Guard - MultiThreadedDebugDLL - true - ProgramDatabase - AdvancedVectorExtensions2 - true - stdcpp17 - stdc11 - true - - - - - true - - - - - Level3 - true - true - true - NDEBUG;_LIB;%(PreprocessorDefinitions);NRT_MODULE_EXPORTS;NITRO_PCH - true - $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - true - CompileAsCpp - Guard - true - AdvancedVectorExtensions2 - stdcpp17 - stdc11 - true - - - - - true - true - true - - - - - - \ No newline at end of file diff --git a/modules/c/nitf/CSEXRB.vcxproj b/modules/c/nitf/CSEXRB.vcxproj deleted file mode 100644 index 20790c316f..0000000000 --- a/modules/c/nitf/CSEXRB.vcxproj +++ /dev/null @@ -1,119 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - - - - - {f06550ad-cfc7-40b8-8727-6c82c69a8982} - - - - 16.0 - Win32Proj - {0A9BDA26-092F-4A2C-BBEF-00C64BF0C65E} - nitro - 10.0 - CSEXRB - - - - DynamicLibrary - true - v143 - - - DynamicLibrary - false - v143 - true - - - - - - - - - - - - - - - true - $(SolutionDir)$(Platform)\$(Configuration)\share\nitf\plugins\ - $(Platform)\$(Configuration)\$(ProjectName)\ - - - false - $(SolutionDir)$(Platform)\$(Configuration)\share\nitf\plugins\ - $(Platform)\$(Configuration)\$(ProjectName)\ - - - - EnableAllWarnings - true - _DEBUG;_LIB;%(PreprocessorDefinitions);NRT_MODULE_EXPORTS;NITRO_PCH - true - $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - true - CompileAsCpp - Guard - MultiThreadedDebugDLL - true - ProgramDatabase - AdvancedVectorExtensions2 - true - stdcpp17 - stdc11 - true - - - - - true - - - - - Level3 - true - true - true - NDEBUG;_LIB;%(PreprocessorDefinitions);NRT_MODULE_EXPORTS;NITRO_PCH - true - $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - true - CompileAsCpp - Guard - true - AdvancedVectorExtensions2 - stdcpp17 - stdc11 - true - - - - - true - true - true - - - - - - \ No newline at end of file diff --git a/modules/c/nitf/ENGRDA.vcxproj b/modules/c/nitf/ENGRDA.vcxproj deleted file mode 100644 index 7e52916b66..0000000000 --- a/modules/c/nitf/ENGRDA.vcxproj +++ /dev/null @@ -1,119 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - - - - - {f06550ad-cfc7-40b8-8727-6c82c69a8982} - - - - 16.0 - Win32Proj - {53F9F908-C678-4DEE-9309-E71C1E03A45F} - nitro - 10.0 - ENGRDA - - - - DynamicLibrary - true - v143 - - - DynamicLibrary - false - v143 - true - - - - - - - - - - - - - - - true - $(SolutionDir)$(Platform)\$(Configuration)\share\nitf\plugins\ - $(Platform)\$(Configuration)\$(ProjectName)\ - - - false - $(SolutionDir)$(Platform)\$(Configuration)\share\nitf\plugins\ - $(Platform)\$(Configuration)\$(ProjectName)\ - - - - EnableAllWarnings - true - _DEBUG;_LIB;%(PreprocessorDefinitions);NRT_MODULE_EXPORTS;NITRO_PCH - true - $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - true - CompileAsCpp - Guard - MultiThreadedDebugDLL - true - ProgramDatabase - AdvancedVectorExtensions2 - true - stdcpp17 - stdc11 - true - - - - - true - - - - - Level3 - true - true - true - NDEBUG;_LIB;%(PreprocessorDefinitions);NRT_MODULE_EXPORTS;NITRO_PCH - true - $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - true - CompileAsCpp - Guard - true - AdvancedVectorExtensions2 - stdcpp17 - stdc11 - true - - - - - true - true - true - - - - - - \ No newline at end of file diff --git a/modules/c/nitf/HISTOA.vcxproj b/modules/c/nitf/HISTOA.vcxproj deleted file mode 100644 index 03e4a43256..0000000000 --- a/modules/c/nitf/HISTOA.vcxproj +++ /dev/null @@ -1,119 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - - - - - {f06550ad-cfc7-40b8-8727-6c82c69a8982} - - - - 16.0 - Win32Proj - {D749AA73-4C9A-473D-96BB-070A6D9CAA54} - nitro - 10.0 - HISTOA - - - - DynamicLibrary - true - v143 - - - DynamicLibrary - false - v143 - true - - - - - - - - - - - - - - - true - $(SolutionDir)$(Platform)\$(Configuration)\share\nitf\plugins\ - $(Platform)\$(Configuration)\$(ProjectName)\ - - - false - $(SolutionDir)$(Platform)\$(Configuration)\share\nitf\plugins\ - $(Platform)\$(Configuration)\$(ProjectName)\ - - - - EnableAllWarnings - true - _DEBUG;_LIB;%(PreprocessorDefinitions);NRT_MODULE_EXPORTS;NITRO_PCH - true - $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - true - CompileAsCpp - Guard - MultiThreadedDebugDLL - true - ProgramDatabase - AdvancedVectorExtensions2 - true - stdcpp17 - stdc11 - true - - - - - true - - - - - Level3 - true - true - true - NDEBUG;_LIB;%(PreprocessorDefinitions);NRT_MODULE_EXPORTS;NITRO_PCH - true - $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - true - CompileAsCpp - Guard - true - AdvancedVectorExtensions2 - stdcpp17 - stdc11 - true - - - - - true - true - true - - - - - - \ No newline at end of file diff --git a/modules/c/nitf/JITCID.vcxproj b/modules/c/nitf/JITCID.vcxproj deleted file mode 100644 index 812a0e1050..0000000000 --- a/modules/c/nitf/JITCID.vcxproj +++ /dev/null @@ -1,119 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - - - - - {f06550ad-cfc7-40b8-8727-6c82c69a8982} - - - - 16.0 - Win32Proj - {D1D7FCD3-6130-4504-9DA0-9D80506BE55E} - nitro - 10.0 - JITCID - - - - DynamicLibrary - true - v143 - - - DynamicLibrary - false - v143 - true - - - - - - - - - - - - - - - true - $(SolutionDir)$(Platform)\$(Configuration)\share\nitf\plugins\ - $(Platform)\$(Configuration)\$(ProjectName)\ - - - false - $(SolutionDir)$(Platform)\$(Configuration)\share\nitf\plugins\ - $(Platform)\$(Configuration)\$(ProjectName)\ - - - - EnableAllWarnings - true - _DEBUG;_LIB;%(PreprocessorDefinitions);NRT_MODULE_EXPORTS;NITRO_PCH - true - $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - true - CompileAsCpp - Guard - MultiThreadedDebugDLL - true - ProgramDatabase - AdvancedVectorExtensions2 - true - stdcpp17 - stdc11 - true - - - - - true - - - - - Level3 - true - true - true - NDEBUG;_LIB;%(PreprocessorDefinitions);NRT_MODULE_EXPORTS;NITRO_PCH - true - $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - true - CompileAsCpp - Guard - true - AdvancedVectorExtensions2 - stdcpp17 - stdc11 - true - - - - - true - true - true - - - - - - \ No newline at end of file diff --git a/modules/c/nitf/PTPRAA.vcxproj b/modules/c/nitf/PTPRAA.vcxproj deleted file mode 100644 index 958059fbe2..0000000000 --- a/modules/c/nitf/PTPRAA.vcxproj +++ /dev/null @@ -1,119 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - - - - - {f06550ad-cfc7-40b8-8727-6c82c69a8982} - - - - 16.0 - Win32Proj - {2BAAACA9-A5A4-412C-AE52-B16C2D107F55} - nitro - 10.0 - PTPRAA - - - - DynamicLibrary - true - v143 - - - DynamicLibrary - false - v143 - true - - - - - - - - - - - - - - - true - $(SolutionDir)$(Platform)\$(Configuration)\share\nitf\plugins\ - $(Platform)\$(Configuration)\$(ProjectName)\ - - - false - $(SolutionDir)$(Platform)\$(Configuration)\share\nitf\plugins\ - $(Platform)\$(Configuration)\$(ProjectName)\ - - - - EnableAllWarnings - true - _DEBUG;_LIB;%(PreprocessorDefinitions);NRT_MODULE_EXPORTS;NITRO_PCH - true - $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - true - CompileAsCpp - Guard - MultiThreadedDebugDLL - true - ProgramDatabase - AdvancedVectorExtensions2 - true - stdcpp17 - stdc11 - true - - - - - true - - - - - Level3 - true - true - true - NDEBUG;_LIB;%(PreprocessorDefinitions);NRT_MODULE_EXPORTS;NITRO_PCH - true - $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - true - CompileAsCpp - Guard - true - AdvancedVectorExtensions2 - stdcpp17 - stdc11 - true - - - - - true - true - true - - - - - - \ No newline at end of file diff --git a/modules/c/nitf/RPFHDR.vcxproj b/modules/c/nitf/RPFHDR.vcxproj deleted file mode 100644 index e6b42bec62..0000000000 --- a/modules/c/nitf/RPFHDR.vcxproj +++ /dev/null @@ -1,119 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - - - - - {f06550ad-cfc7-40b8-8727-6c82c69a8982} - - - - 16.0 - Win32Proj - {CF5B4F02-364D-4117-9FB9-6C9C7938E412} - nitro - 10.0 - RPFHDR - - - - DynamicLibrary - true - v143 - - - DynamicLibrary - false - v143 - true - - - - - - - - - - - - - - - true - $(SolutionDir)$(Platform)\$(Configuration)\share\nitf\plugins\ - $(Platform)\$(Configuration)\$(ProjectName)\ - - - false - $(SolutionDir)$(Platform)\$(Configuration)\share\nitf\plugins\ - $(Platform)\$(Configuration)\$(ProjectName)\ - - - - EnableAllWarnings - true - _DEBUG;_LIB;%(PreprocessorDefinitions);NRT_MODULE_EXPORTS;NITRO_PCH - true - $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - true - CompileAsCpp - Guard - MultiThreadedDebugDLL - true - ProgramDatabase - AdvancedVectorExtensions2 - true - stdcpp17 - stdc11 - true - - - - - true - - - - - Level3 - true - true - true - NDEBUG;_LIB;%(PreprocessorDefinitions);NRT_MODULE_EXPORTS;NITRO_PCH - true - $(ProjectDir)include;$(ProjectDir)..\nrt\include;%(AdditionalIncludeDirectories) - /FS %(AdditionalOptions) - true - CompileAsCpp - Guard - true - AdvancedVectorExtensions2 - stdcpp17 - stdc11 - true - - - - - true - true - true - - - - - - \ No newline at end of file diff --git a/modules/c/nitf/ACCHZB.vcxproj b/modules/c/nitf/TEST_DES.vcxproj similarity index 98% rename from modules/c/nitf/ACCHZB.vcxproj rename to modules/c/nitf/TEST_DES.vcxproj index c8d851879c..84021cde79 100644 --- a/modules/c/nitf/ACCHZB.vcxproj +++ b/modules/c/nitf/TEST_DES.vcxproj @@ -24,7 +24,7 @@ {53F9F908-C678-4DEE-9309-E71C1D03A45F} nitro 10.0 - ACCHZB + TEST_DES @@ -62,7 +62,7 @@ - EnableAllWarnings + Level4 true _DEBUG;_LIB;%(PreprocessorDefinitions);NRT_MODULE_EXPORTS;NITRO_PCH true diff --git a/modules/c/nitf/XML_DATA_CONTENT.vcxproj b/modules/c/nitf/XML_DATA_CONTENT.vcxproj index 8dba8a2672..3604dbdf93 100644 --- a/modules/c/nitf/XML_DATA_CONTENT.vcxproj +++ b/modules/c/nitf/XML_DATA_CONTENT.vcxproj @@ -62,7 +62,7 @@ - EnableAllWarnings + Level4 true _DEBUG;_LIB;%(PreprocessorDefinitions);NRT_MODULE_EXPORTS;NITRO_PCH true diff --git a/modules/c/nitf/include/nitf/PluginIdentifier.h b/modules/c/nitf/include/nitf/PluginIdentifier.h index da1203f2ce..125ccd9029 100644 --- a/modules/c/nitf/include/nitf/PluginIdentifier.h +++ b/modules/c/nitf/include/nitf/PluginIdentifier.h @@ -70,6 +70,7 @@ typedef struct _nitf_TREPreloaded const char* name; NITF_PLUGIN_INIT_FUNCTION init; NITF_PLUGIN_TRE_HANDLER_FUNCTION handler; + NITF_BOOL enabled; // most preloaded TREs are disabled by default } nitf_TREPreloaded; /* diff --git a/modules/c/nitf/include/nitf/PluginRegistry.h b/modules/c/nitf/include/nitf/PluginRegistry.h index 858d486fe1..54feddb3fd 100644 --- a/modules/c/nitf/include/nitf/PluginRegistry.h +++ b/modules/c/nitf/include/nitf/PluginRegistry.h @@ -165,8 +165,6 @@ NITFAPI(NITF_BOOL) nitf_PluginRegistry_loadDir(const char* dirName, nitf_Error * error); -NITFAPI(NITF_BOOL) - nitf_PluginRegistry_insertPlugin_(const char* msg, nitf_PluginRegistry* reg, const char** ident, nitf_DLL* dll, nitf_Error* error); NITFAPI(NITF_BOOL) nitf_PluginRegistry_loadPlugin(const char* fullPathName, nitf_Error* error); @@ -182,6 +180,19 @@ nitf_PluginRegistry_TREHandlerExists(const char* ident); NITFAPI(NITF_BOOL) nitf_PluginRegistry_TREHandlerExistsLog(const char* ident, FILE* log); +/*! + * Enable (or disable) a pre-loaded TRE. + * + * \param ident ID of the TRE + * + * \return true if a pre-loaded TRE handler exists, false otherwise + */ + +NITFAPI(NITF_BOOL) +nitf_PluginRegistry_PreloadedTREHandlerEnable(const char* ident, NITF_BOOL enable); +NITFAPI(void) +nitf_PluginRegistry_PreloadedTREHandlersEnable(NITF_BOOL enable); // "Handlers", not "Handler" + /*! * Checks if a compression handler exists for 'ident' * diff --git a/modules/c/nitf/source/PluginRegistry.c b/modules/c/nitf/source/PluginRegistry.c index e05bc2a84f..e675d53609 100644 --- a/modules/c/nitf/source/PluginRegistry.c +++ b/modules/c/nitf/source/PluginRegistry.c @@ -20,6 +20,8 @@ * */ +#include + #include "nitf/PluginRegistry.h" NITFPRIV(nitf_PluginRegistry*) implicitConstruct(nitf_Error* error, FILE* log); @@ -967,15 +969,21 @@ insertCreator(nitf_DLL* dso, return nitf_HashTable_insert(hash, ident, (NITF_DATA*)dsoMain, error); } -/* - * Function is now greatly simplified. We only retrieve TREs from - * the hash table. If they are there, we are good, if not fail - * - * No more talking to the DSOs directly - */ -static const nitf_TREPreloaded* findPreloadedTRE(const char* keyName) +// Somebody might want to use a different set of preloadedTREs, or we might even want multiple +// sets of preloaded TREs. There's nothing to support either of those right now, but it's easy enough +// to put the infrastructure in place to make it easy to hook-up. +extern nitf_TREPreloaded defaultPreloadedTREs[]; +static nitf_TREPreloaded* findPreloadedTRE_(nitf_TREPreloaded preloadedTREs[], const char* keyName) { - extern const nitf_TREPreloaded preloadedTREs[]; + if (preloadedTREs == NULL) + { + return NULL; + } + if (keyName == NULL) + { + return NULL; + } + for (size_t i = 0;; i++) { const char* pKeyName = preloadedTREs[i].name; @@ -989,6 +997,56 @@ static const nitf_TREPreloaded* findPreloadedTRE(const char* keyName) } } } +static const nitf_TREPreloaded* findPreloadedTRE(nitf_TREPreloaded preloadedTREs[], const char* keyName) +{ + const nitf_TREPreloaded* retval = findPreloadedTRE_(preloadedTREs, keyName); + if ((retval != NULL) && (retval->enabled)) + { + return retval; + } + return NULL; +} + +static NITF_BOOL PreloadedTREHandlerEnable(nitf_TREPreloaded preloadedTREs[], + const char* keyName, NITF_BOOL enable) +{ + nitf_TREPreloaded* result = findPreloadedTRE_(preloadedTREs, keyName); + if (result != NULL) + { + result->enabled = enable; + return NRT_TRUE; + } + return NRT_FALSE; +} +NITFAPI(NITF_BOOL) +nitf_PluginRegistry_PreloadedTREHandlerEnable(const char* keyName, NITF_BOOL enable) +{ + return PreloadedTREHandlerEnable(defaultPreloadedTREs, keyName, enable); +} + +static void preloadedTREHandlersEnable(nitf_TREPreloaded preloadedTREs[], NITF_BOOL enable) +{ + if (preloadedTREs == NULL) + { + return; + } + + for (size_t i = 0;; i++) + { + const char* pKeyName = preloadedTREs[i].name; + if (pKeyName == NULL) // end of list + { + return; + } + + preloadedTREs[i].enabled = enable; + } +} +NITFAPI(void) +nitf_PluginRegistry_PreloadedTREHandlersEnable(NITF_BOOL enable) +{ + preloadedTREHandlersEnable(defaultPreloadedTREs, enable); +} /* * Initialize a DSO. The init hook is retrieved and called once @@ -1006,7 +1064,8 @@ static const char** preload_doInit(NITF_PLUGIN_INIT_FUNCTION init, const char* p return ident; } -static NRT_BOOL preloadTRE(const char* keyName, nitf_Error* error) +static NRT_BOOL preloadTRE(nitf_TREPreloaded preloadedTREs[], + const char* keyName, nitf_Error* error) { const char** ident; nitf_PluginRegistry* reg = nitf_PluginRegistry_getInstance(error); @@ -1020,7 +1079,7 @@ static NRT_BOOL preloadTRE(const char* keyName, nitf_Error* error) dll->lib = NULL; // not a real DLL dll->dsoMain = NULL; // filled in after successful findPreloadedTRE() - const nitf_TREPreloaded* plugin = findPreloadedTRE(keyName); + const nitf_TREPreloaded* plugin = findPreloadedTRE(preloadedTREs, keyName); if (plugin == NULL) { return NITF_FAILURE; @@ -1069,10 +1128,10 @@ nitf_PluginRegistry_retrieveTREHandler_(nitf_PluginRegistry* reg, return theHandler; } -static nitf_TREHandler* retrievePreloadedTREHandler(nitf_PluginRegistry* reg, const char* treIdent, - int* hadError, nitf_Error* error) +static nitf_TREHandler* retrievePreloadedTREHandler(nitf_TREPreloaded preloadedTREs[], + nitf_PluginRegistry* reg, const char* treIdent, int* hadError, nitf_Error* error) { - if (!preloadTRE(treIdent, error)) + if (!preloadTRE(preloadedTREs, treIdent, error)) { *hadError = 1; return NULL; @@ -1082,31 +1141,40 @@ static nitf_TREHandler* retrievePreloadedTREHandler(nitf_PluginRegistry* reg, co return nitf_PluginRegistry_retrieveTREHandler_(reg, treIdent, hadError, error); } -NITFPROT(nitf_TREHandler*) -nitf_PluginRegistry_retrieveTREHandler(nitf_PluginRegistry* reg, - const char* treIdent, - int* hadError, - nitf_Error* error) +static nitf_TREHandler* retrieveTREHandler(nitf_TREPreloaded preloadedTREs[], + nitf_PluginRegistry* reg, const char* treIdent, int* hadError, nitf_Error* error) { nitf_TREHandler* handler = nitf_PluginRegistry_retrieveTREHandler_(reg, treIdent, hadError, error); - if (*hadError) { + // Got an error; try a preloaded TRE. *hadError = 0; - return retrievePreloadedTREHandler(reg, treIdent, hadError, error); + return retrievePreloadedTREHandler(preloadedTREs, reg, treIdent, hadError, error); } - // Normally, a NULL handler is **not** an error. + // Normally, a NULL handler is **not** an error ... if (handler == NULL) { - int bad = 0; - nitf_TREHandler* preloadedHandler = retrievePreloadedTREHandler(reg, treIdent, &bad, error); + // ... but, if we can use a pre-loaded TRE, go with that. + int bad = 0; // retrievePreloadedTREHandler() might cause an error + nitf_TREHandler* preloadedHandler = retrievePreloadedTREHandler(preloadedTREs, reg, treIdent, &bad, error); if (!bad) - return preloadedHandler; + { + // no error, go with the pre-loaded handler + assert(preloadedHandler != NULL); // I supposed this *could* be NULL, but why? It makes no sense to preload a default handler. + return preloadedHandler; + } } - return handler; } +NITFPROT(nitf_TREHandler*) +nitf_PluginRegistry_retrieveTREHandler(nitf_PluginRegistry* reg, + const char* treIdent, + int* hadError, + nitf_Error* error) +{ + return retrieveTREHandler(defaultPreloadedTREs, reg, treIdent, hadError, error); +} NITFPROT(nitf_CompressionInterface*) nitf_PluginRegistry_retrieveCompInterface(const char* comp, nitf_Error* error) diff --git a/modules/c/nitf/source/TREs.c b/modules/c/nitf/source/TREs.c index 8cedb44e5b..c8cbf18251 100644 --- a/modules/c/nitf/source/TREs.c +++ b/modules/c/nitf/source/TREs.c @@ -3,6 +3,7 @@ * ========================================================================= * * (C) Copyright 2004 - 2014, MDA Information Systems LLC + * © Copyright 2023, Maxar Technologies, Inc. * * NITRO is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -43,25 +44,86 @@ #include "../shared/RPFHDR.c" #include "../shared/TEST_DES.c" +#include "../shared/XML_DATA_CONTENT.c" -#define NITF_preload_TRE(Tre_) { #Tre_, Tre_##_init, Tre_##_handler } - -extern const nitf_TREPreloaded preloadedTREs[]; -const nitf_TREPreloaded preloadedTREs[] = { -/* - NITF_preload_TRE(ACCHZB), - NITF_preload_TRE(ACCPOB), - NITF_preload_TRE(ACFTA), - NITF_preload_TRE(AIMIDB), - NITF_preload_TRE(CSCRNA), - NITF_preload_TRE(CSEXRB), - //NITF_preload_TRE(ENGRDA), - NITF_preload_TRE(HISTOA), - NITF_preload_TRE(JITCID), - NITF_preload_TRE(PTPRAA), - NITF_preload_TRE(RPFHDR), - - NITF_preload_TRE(TEST_DES), -*/ - { NULL, NULL, NULL } + /******************************************************************************/ + /* + * Simple example DES for testing. + + This file defines a very simple Data Extension Segment. This example is + used for test of the UserSegment object and can be used aa an example + and starting point for the development of DES. + + This example defines a "standard" DE segment which means the user + header can be implemented via a TRE object and there are no out of + segment dependencies + + The DES ID will be TEST_PRELOADED_DES + + The user header will have three fields + + COUNT - Number of data values + START - Start value in ramp + INCREMENT - Increment between values in ramp + + The data is an 8-bit ramp defined by the three values. in testing, the + ramp will be setup to contain printable values. + */ + + /* TRE description for user header */ +static nitf_TREDescription TEST_PRELOADED_DES_description[] = { + {NITF_BCS_N, 2, "Number of data values", "COUNT" }, + {NITF_BCS_N, 3, "Start value in ramp", "START" }, + {NITF_BCS_N, 2, "Increment between values in ramp", "INCREMENT" }, + {NITF_END, 0, NULL, NULL} +}; +static nitf_TREDescriptionInfo TEST_PRELOADED_DES_descriptions[] = { + { "Preloaded DES (for testing)", TEST_PRELOADED_DES_description, NITF_TRE_DESC_NO_LENGTH }, + { "TEST_PRELOADED_DES", TEST_PRELOADED_DES_description, NITF_TRE_DESC_NO_LENGTH }, + { NULL, NULL, NITF_TRE_DESC_NO_LENGTH } +}; +static nitf_TREDescriptionSet TEST_PRELOADED_DES_descriptionSet = { 0, TEST_PRELOADED_DES_descriptions }; + +static const char* TEST_PRELOADED_DES_ident[] = +{ + NITF_PLUGIN_TRE_KEY, "TEST_PRELOADED_DES", "Preloaded DES (for testing)", NULL +}; + +static nitf_TREHandler TEST_PRELOADED_DESHandler; +static const char** TEST_PRELOADED_DES_init(nitf_Error* error) +{ + if (!nitf_TREUtils_createBasicHandler(&TEST_PRELOADED_DES_descriptionSet, + &TEST_PRELOADED_DESHandler, error)) + return NULL; + return TEST_PRELOADED_DES_ident; +} +static nitf_TREHandler* TEST_PRELOADED_DES_handler(nitf_Error* error) { + (void)error; + return &TEST_PRELOADED_DESHandler; +} + +/******************************************************************************/ + +#define NITF_preload_TRE_(Tre_, enabled_) { #Tre_, Tre_##_init, Tre_##_handler, enabled_ } +#define NITF_preload_TRE(Tre_) NITF_preload_TRE_(Tre_, NRT_FALSE /*enabled*/) + +nitf_TREPreloaded defaultPreloadedTREs[] = { + // Not preloading any TREs right now: with the existing system, + // a TRE can be removed by deleting the DLL/SO. If that same TRE + // were preloaded, there would be no way to get rid of it. + NITF_preload_TRE(ACCHZB), + NITF_preload_TRE(ACCPOB), + NITF_preload_TRE(ACFTA), + NITF_preload_TRE(AIMIDB), + NITF_preload_TRE(CSCRNA), + NITF_preload_TRE(CSEXRB), + NITF_preload_TRE(ENGRDA), + NITF_preload_TRE(HISTOA), + NITF_preload_TRE(JITCID), + NITF_preload_TRE(PTPRAA), + NITF_preload_TRE(RPFHDR), + + NITF_preload_TRE_(TEST_PRELOADED_DES, NRT_TRUE /*enabled*/), + + { NULL, NULL, NULL, NRT_FALSE } // end of list }; diff --git a/modules/c/nrt/source/DLLUnix.c b/modules/c/nrt/source/DLLUnix.c index fb68470ccf..d1887e1af6 100644 --- a/modules/c/nrt/source/DLLUnix.c +++ b/modules/c/nrt/source/DLLUnix.c @@ -127,7 +127,7 @@ NRTAPI(NRT_DLL_FUNCTION_PTR) nrt_DLL_retrieve(nrt_DLL * dll, // This might be a "preloaded" TRE if (dll->dsoMain) { - const char* underscore = strchr(function, '_'); + const char* underscore = strrchr(function, '_'); if ((underscore != NULL) && strcmp(underscore, "_handler") == 0) { return dll->dsoMain; diff --git a/modules/c/nrt/source/DLLWin32.c b/modules/c/nrt/source/DLLWin32.c index d5a59e621c..6cf64fb974 100644 --- a/modules/c/nrt/source/DLLWin32.c +++ b/modules/c/nrt/source/DLLWin32.c @@ -137,7 +137,7 @@ NRTAPI(NRT_DLL_FUNCTION_PTR) nrt_DLL_retrieve(nrt_DLL * dll, // This might be a "preloaded" TRE if (dll->dsoMain) { - const char* underscore = strchr(function, '_'); + const char* underscore = strrchr(function, '_'); if ((underscore != NULL) && strcmp(underscore, "_handler") == 0) { return dll->dsoMain; diff --git a/nitro.sln b/nitro.sln index 56cfb2e041..0f6fc7c9d7 100644 --- a/nitro.sln +++ b/nitro.sln @@ -20,26 +20,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nitf-c++", "modules\c++\nit {A676EDF3-F231-47C8-A6E6-0FE50B50B71B} = {A676EDF3-F231-47C8-A6E6-0FE50B50B71B} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACCPOB", "modules\c\nitf\ACCPOB.vcxproj", "{730B1E6E-2469-4F9E-B093-D0C6262453C9}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACFTA", "modules\c\nitf\ACFTA.vcxproj", "{51D7B426-899E-428D-9F69-5DDAC9E403FB}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AIMIDB", "modules\c\nitf\AIMIDB.vcxproj", "{12AA0752-4EE3-4E0A-85AF-0E5DEADBF343}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JITCID", "modules\c\nitf\JITCID.vcxproj", "{D1D7FCD3-6130-4504-9DA0-9D80506BE55E}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "c-nitf-shared", "c-nitf-shared", "{27A2685A-E869-42A2-956D-92994F60C536}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CSCRNA", "modules\c\nitf\CSCRNA.vcxproj", "{023DE06D-3967-4406-B1B8-032118BB2552}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RPFHDR", "modules\c\nitf\RPFHDR.vcxproj", "{CF5B4F02-364D-4117-9FB9-6C9C7938E412}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "show_nitf++", "modules\c++\nitf\apps\show_nitf++\show_nitf++.vcxproj", "{839FF52C-57D1-45B6-81FD-5C7D72523EE5}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PTPRAA", "modules\c\nitf\PTPRAA.vcxproj", "{2BAAACA9-A5A4-412C-AE52-B16C2D107F55}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ENGRDA", "modules\c\nitf\ENGRDA.vcxproj", "{53F9F908-C678-4DEE-9309-E71C1E03A45F}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "J2KCompress", "modules\c\j2k\J2KCompress.vcxproj", "{A676EDF3-F231-47C8-A6E6-0FE50B50B71B}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "J2KDecompress", "modules\c\j2k\J2KDecompress.vcxproj", "{C787537A-0CAC-4D6D-A6D6-A66765A06753}" @@ -51,20 +35,16 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github-workflows", ".githu .github\workflows\main.yml = .github\workflows\main.yml EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CSEXRB", "modules\c\nitf\CSEXRB.vcxproj", "{0A9BDA26-092F-4A2C-BBEF-00C64BF0C65E}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "externals", "externals", "{7D26D571-0014-4C50-BF86-612E743E64B6}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "coda-oss", "externals\coda-oss\modules\c++\coda-oss.vcxproj", "{9997E895-5161-4DDF-8F3F-099894CB2F21}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UnitTest", "UnitTest\UnitTest.vcxproj", "{8ACE478C-8F6F-4D42-9B43-7D75882D4BE1}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ACCHZB", "modules\c\nitf\ACCHZB.vcxproj", "{53F9F908-C678-4DEE-9309-E71C1D03A45F}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HISTOA", "modules\c\nitf\HISTOA.vcxproj", "{D749AA73-4C9A-473D-96BB-070A6D9CAA54}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XML_DATA_CONTENT", "modules\c\nitf\XML_DATA_CONTENT.vcxproj", "{78849481-D356-4CC7-B182-31C21F857ED1}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TEST_DES", "modules\c\nitf\TEST_DES.vcxproj", "{53F9F908-C678-4DEE-9309-E71C1D03A45F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -79,42 +59,10 @@ Global {8F357A19-799E-4971-850E-3F28485C130B}.Debug|x64.Build.0 = Debug|x64 {8F357A19-799E-4971-850E-3F28485C130B}.Release|x64.ActiveCfg = Release|x64 {8F357A19-799E-4971-850E-3F28485C130B}.Release|x64.Build.0 = Release|x64 - {730B1E6E-2469-4F9E-B093-D0C6262453C9}.Debug|x64.ActiveCfg = Debug|x64 - {730B1E6E-2469-4F9E-B093-D0C6262453C9}.Debug|x64.Build.0 = Debug|x64 - {730B1E6E-2469-4F9E-B093-D0C6262453C9}.Release|x64.ActiveCfg = Release|x64 - {730B1E6E-2469-4F9E-B093-D0C6262453C9}.Release|x64.Build.0 = Release|x64 - {51D7B426-899E-428D-9F69-5DDAC9E403FB}.Debug|x64.ActiveCfg = Debug|x64 - {51D7B426-899E-428D-9F69-5DDAC9E403FB}.Debug|x64.Build.0 = Debug|x64 - {51D7B426-899E-428D-9F69-5DDAC9E403FB}.Release|x64.ActiveCfg = Release|x64 - {51D7B426-899E-428D-9F69-5DDAC9E403FB}.Release|x64.Build.0 = Release|x64 - {12AA0752-4EE3-4E0A-85AF-0E5DEADBF343}.Debug|x64.ActiveCfg = Debug|x64 - {12AA0752-4EE3-4E0A-85AF-0E5DEADBF343}.Debug|x64.Build.0 = Debug|x64 - {12AA0752-4EE3-4E0A-85AF-0E5DEADBF343}.Release|x64.ActiveCfg = Release|x64 - {12AA0752-4EE3-4E0A-85AF-0E5DEADBF343}.Release|x64.Build.0 = Release|x64 - {D1D7FCD3-6130-4504-9DA0-9D80506BE55E}.Debug|x64.ActiveCfg = Debug|x64 - {D1D7FCD3-6130-4504-9DA0-9D80506BE55E}.Debug|x64.Build.0 = Debug|x64 - {D1D7FCD3-6130-4504-9DA0-9D80506BE55E}.Release|x64.ActiveCfg = Release|x64 - {D1D7FCD3-6130-4504-9DA0-9D80506BE55E}.Release|x64.Build.0 = Release|x64 - {023DE06D-3967-4406-B1B8-032118BB2552}.Debug|x64.ActiveCfg = Debug|x64 - {023DE06D-3967-4406-B1B8-032118BB2552}.Debug|x64.Build.0 = Debug|x64 - {023DE06D-3967-4406-B1B8-032118BB2552}.Release|x64.ActiveCfg = Release|x64 - {023DE06D-3967-4406-B1B8-032118BB2552}.Release|x64.Build.0 = Release|x64 - {CF5B4F02-364D-4117-9FB9-6C9C7938E412}.Debug|x64.ActiveCfg = Debug|x64 - {CF5B4F02-364D-4117-9FB9-6C9C7938E412}.Debug|x64.Build.0 = Debug|x64 - {CF5B4F02-364D-4117-9FB9-6C9C7938E412}.Release|x64.ActiveCfg = Release|x64 - {CF5B4F02-364D-4117-9FB9-6C9C7938E412}.Release|x64.Build.0 = Release|x64 {839FF52C-57D1-45B6-81FD-5C7D72523EE5}.Debug|x64.ActiveCfg = Debug|x64 {839FF52C-57D1-45B6-81FD-5C7D72523EE5}.Debug|x64.Build.0 = Debug|x64 {839FF52C-57D1-45B6-81FD-5C7D72523EE5}.Release|x64.ActiveCfg = Release|x64 {839FF52C-57D1-45B6-81FD-5C7D72523EE5}.Release|x64.Build.0 = Release|x64 - {2BAAACA9-A5A4-412C-AE52-B16C2D107F55}.Debug|x64.ActiveCfg = Debug|x64 - {2BAAACA9-A5A4-412C-AE52-B16C2D107F55}.Debug|x64.Build.0 = Debug|x64 - {2BAAACA9-A5A4-412C-AE52-B16C2D107F55}.Release|x64.ActiveCfg = Release|x64 - {2BAAACA9-A5A4-412C-AE52-B16C2D107F55}.Release|x64.Build.0 = Release|x64 - {53F9F908-C678-4DEE-9309-E71C1E03A45F}.Debug|x64.ActiveCfg = Debug|x64 - {53F9F908-C678-4DEE-9309-E71C1E03A45F}.Debug|x64.Build.0 = Debug|x64 - {53F9F908-C678-4DEE-9309-E71C1E03A45F}.Release|x64.ActiveCfg = Release|x64 - {53F9F908-C678-4DEE-9309-E71C1E03A45F}.Release|x64.Build.0 = Release|x64 {A676EDF3-F231-47C8-A6E6-0FE50B50B71B}.Debug|x64.ActiveCfg = Debug|x64 {A676EDF3-F231-47C8-A6E6-0FE50B50B71B}.Debug|x64.Build.0 = Debug|x64 {A676EDF3-F231-47C8-A6E6-0FE50B50B71B}.Release|x64.ActiveCfg = Release|x64 @@ -123,10 +71,6 @@ Global {C787537A-0CAC-4D6D-A6D6-A66765A06753}.Debug|x64.Build.0 = Debug|x64 {C787537A-0CAC-4D6D-A6D6-A66765A06753}.Release|x64.ActiveCfg = Release|x64 {C787537A-0CAC-4D6D-A6D6-A66765A06753}.Release|x64.Build.0 = Release|x64 - {0A9BDA26-092F-4A2C-BBEF-00C64BF0C65E}.Debug|x64.ActiveCfg = Debug|x64 - {0A9BDA26-092F-4A2C-BBEF-00C64BF0C65E}.Debug|x64.Build.0 = Debug|x64 - {0A9BDA26-092F-4A2C-BBEF-00C64BF0C65E}.Release|x64.ActiveCfg = Release|x64 - {0A9BDA26-092F-4A2C-BBEF-00C64BF0C65E}.Release|x64.Build.0 = Release|x64 {9997E895-5161-4DDF-8F3F-099894CB2F21}.Debug|x64.ActiveCfg = Debug|x64 {9997E895-5161-4DDF-8F3F-099894CB2F21}.Debug|x64.Build.0 = Debug|x64 {9997E895-5161-4DDF-8F3F-099894CB2F21}.Release|x64.ActiveCfg = Release|x64 @@ -135,39 +79,25 @@ Global {8ACE478C-8F6F-4D42-9B43-7D75882D4BE1}.Debug|x64.Build.0 = Debug|x64 {8ACE478C-8F6F-4D42-9B43-7D75882D4BE1}.Release|x64.ActiveCfg = Release|x64 {8ACE478C-8F6F-4D42-9B43-7D75882D4BE1}.Release|x64.Build.0 = Release|x64 - {53F9F908-C678-4DEE-9309-E71C1D03A45F}.Debug|x64.ActiveCfg = Debug|x64 - {53F9F908-C678-4DEE-9309-E71C1D03A45F}.Debug|x64.Build.0 = Debug|x64 - {53F9F908-C678-4DEE-9309-E71C1D03A45F}.Release|x64.ActiveCfg = Release|x64 - {53F9F908-C678-4DEE-9309-E71C1D03A45F}.Release|x64.Build.0 = Release|x64 - {D749AA73-4C9A-473D-96BB-070A6D9CAA54}.Debug|x64.ActiveCfg = Debug|x64 - {D749AA73-4C9A-473D-96BB-070A6D9CAA54}.Debug|x64.Build.0 = Debug|x64 - {D749AA73-4C9A-473D-96BB-070A6D9CAA54}.Release|x64.ActiveCfg = Release|x64 - {D749AA73-4C9A-473D-96BB-070A6D9CAA54}.Release|x64.Build.0 = Release|x64 {78849481-D356-4CC7-B182-31C21F857ED1}.Debug|x64.ActiveCfg = Debug|x64 {78849481-D356-4CC7-B182-31C21F857ED1}.Debug|x64.Build.0 = Debug|x64 {78849481-D356-4CC7-B182-31C21F857ED1}.Release|x64.ActiveCfg = Release|x64 {78849481-D356-4CC7-B182-31C21F857ED1}.Release|x64.Build.0 = Release|x64 + {53F9F908-C678-4DEE-9309-E71C1D03A45F}.Debug|x64.ActiveCfg = Debug|x64 + {53F9F908-C678-4DEE-9309-E71C1D03A45F}.Debug|x64.Build.0 = Debug|x64 + {53F9F908-C678-4DEE-9309-E71C1D03A45F}.Release|x64.ActiveCfg = Release|x64 + {53F9F908-C678-4DEE-9309-E71C1D03A45F}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {730B1E6E-2469-4F9E-B093-D0C6262453C9} = {27A2685A-E869-42A2-956D-92994F60C536} - {51D7B426-899E-428D-9F69-5DDAC9E403FB} = {27A2685A-E869-42A2-956D-92994F60C536} - {12AA0752-4EE3-4E0A-85AF-0E5DEADBF343} = {27A2685A-E869-42A2-956D-92994F60C536} - {D1D7FCD3-6130-4504-9DA0-9D80506BE55E} = {27A2685A-E869-42A2-956D-92994F60C536} - {023DE06D-3967-4406-B1B8-032118BB2552} = {27A2685A-E869-42A2-956D-92994F60C536} - {CF5B4F02-364D-4117-9FB9-6C9C7938E412} = {27A2685A-E869-42A2-956D-92994F60C536} - {2BAAACA9-A5A4-412C-AE52-B16C2D107F55} = {27A2685A-E869-42A2-956D-92994F60C536} - {53F9F908-C678-4DEE-9309-E71C1E03A45F} = {27A2685A-E869-42A2-956D-92994F60C536} {A676EDF3-F231-47C8-A6E6-0FE50B50B71B} = {27A2685A-E869-42A2-956D-92994F60C536} {C787537A-0CAC-4D6D-A6D6-A66765A06753} = {27A2685A-E869-42A2-956D-92994F60C536} {A45CB073-25A7-411D-A7E7-589BCC8AF547} = {5C5727E7-0CFF-42B4-8F5A-D31B3BC81F21} - {0A9BDA26-092F-4A2C-BBEF-00C64BF0C65E} = {27A2685A-E869-42A2-956D-92994F60C536} {9997E895-5161-4DDF-8F3F-099894CB2F21} = {7D26D571-0014-4C50-BF86-612E743E64B6} - {53F9F908-C678-4DEE-9309-E71C1D03A45F} = {27A2685A-E869-42A2-956D-92994F60C536} - {D749AA73-4C9A-473D-96BB-070A6D9CAA54} = {27A2685A-E869-42A2-956D-92994F60C536} {78849481-D356-4CC7-B182-31C21F857ED1} = {27A2685A-E869-42A2-956D-92994F60C536} + {53F9F908-C678-4DEE-9309-E71C1D03A45F} = {27A2685A-E869-42A2-956D-92994F60C536} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {2D7AC542-BBB6-4BAC-8BF1-7E76C714BBA4}