From ab1535224edae9ae023e4c6b71a01edb2bacc34c Mon Sep 17 00:00:00 2001 From: Nikolas Koesling <66275131+NikolasK-source@users.noreply.github.com> Date: Mon, 1 Aug 2022 16:39:23 +0200 Subject: [PATCH 1/7] Update README.md Info for using privileged ports --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index ab97585..3eca6fc 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,15 @@ The modbus registers are mapped to shared memory objects: AI | Discrete Input Registers | read-only | AI ``` +### Use privileged ports +The standard modbus port (502) can be used only by the root user under linux by default. +To circumvent this, you can create an entry in the iptables that redirects packets on the standard modbus port to a higher port. +The following example redirects packets from port 502 (standard modbus port) to port 5020 +``` +iptables -A PREROUTING -t nat -p tcp --dport 502 -j REDIRECT --to-port 5020 +``` +The modbus client must be called with the option ```-p 5020``` + ## Libraries This application uses the following libraries: - cxxopts by jarro2783 (https://github.com/jarro2783/cxxopts) From da2ee94769b0b62df5b395a5efef3d04d2465247 Mon Sep 17 00:00:00 2001 From: Nikolas Koesling Date: Mon, 1 Aug 2022 21:24:24 +0200 Subject: [PATCH 2/7] github io doc --- html_docs/_config.yml | 1 + html_docs/index.md | 78 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 html_docs/_config.yml create mode 100644 html_docs/index.md diff --git a/html_docs/_config.yml b/html_docs/_config.yml new file mode 100644 index 0000000..c419263 --- /dev/null +++ b/html_docs/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-cayman \ No newline at end of file diff --git a/html_docs/index.md b/html_docs/index.md new file mode 100644 index 0000000..891c2f0 --- /dev/null +++ b/html_docs/index.md @@ -0,0 +1,78 @@ +# Shared Memory Modbus TCP Client + +This project is a simple command line based Modbus TCP client for POXIX compatible operating systems that stores the contents of its registers in shared memory. + +## Basic operating principle + +The client creates four shared memories. +One for each register type: +- Discrete Output Coils (DO) +- Discrete Input Coils (DI) +- Discrete Output Registers (AO) +- Discrete Input Registers (AI) + +All registers are initialized with 0 at the beginning. +The Modbus master reads and writes directly the values from these shared memories. + +The actual functionality of the client is realized by applications that read data from or write data to the shared memory. + + +## Use the Application +The application can be started completely without command line arguments. +In this case the client listens for connections on all IPs on port 502 (the default modbus port). +The application terminates if the master disconnects. + +The arguments ```--port``` and ```--ip``` can be used to specify port and ip to listen to. + +By using the command line argument ```--monitor``` all incoming and outgoing packets are printed on stdout. +This option should be used carefully, as it generates large amounts of output depending on the masters polling cycle and the number of used registers. + +The ```--reconnect``` option can be used to specify that the application is not terminated when the master disconnects, but waits for a new connection. + +### Use privileged ports +Ports below 1024 cannot be used by standard users. +Therefore, the default modbus port (502) cannot be used without further action. + +Here are two ways to use the port anyway: +#### iptables (recommended) +An entry can be added to the iptables that forwards the packets on the actual port to a higher port. + +The following example redirects all tcp packets on port 502 to port 5020: +``` +iptables -A PREROUTING -t nat -p tcp --dport 502 -j REDIRECT --to-port 5020 +``` + +#### setcap +The command ```setcap``` can be used to allow the application to access privileged ports. +However, this option gives the application significantly more rights than it actually needs and should therefore be avoided. + +This option cannot be used with flatpaks. + +``` +setcap 'cap_net_bind_service=+ep' /path/to/binary +``` + + + +## Build from Source + +The following packages are required for building the application: +- cmake +- clang or gcc + +Additionally, the following packages are required to build the modbus library: +- autoconf +- automake +- libtool + + +Use the following commands to build the application: +``` +git clone --recursive https://github.com/NikolasK-source/modbus_tcp_client_shm.git +cd modbus_tcp_client_shm +mkdir build +cmake -B build . -DCMAKE_BUILD_TYPE=Release -DCLANG_FORMAT=OFF -DCOMPILER_WARNINGS=OFF +cmake --build build +``` + +The binary is located in the build directory. From a164e62b009fd0e75a4249550b093f6c4c012b03 Mon Sep 17 00:00:00 2001 From: Nikolas Koesling Date: Mon, 1 Aug 2022 21:26:10 +0200 Subject: [PATCH 3/7] rename docs --- .gitignore | 3 ++ html_docs/_config.yml | 1 - html_docs/index.md | 78 ------------------------------------------- 3 files changed, 3 insertions(+), 79 deletions(-) delete mode 100644 html_docs/_config.yml delete mode 100644 html_docs/index.md diff --git a/.gitignore b/.gitignore index 3fb0ff2..56c7f82 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,9 @@ build* docs/ +!docs/index.md +!docs/_config.yml + # editor files ## eclipse diff --git a/html_docs/_config.yml b/html_docs/_config.yml deleted file mode 100644 index c419263..0000000 --- a/html_docs/_config.yml +++ /dev/null @@ -1 +0,0 @@ -theme: jekyll-theme-cayman \ No newline at end of file diff --git a/html_docs/index.md b/html_docs/index.md deleted file mode 100644 index 891c2f0..0000000 --- a/html_docs/index.md +++ /dev/null @@ -1,78 +0,0 @@ -# Shared Memory Modbus TCP Client - -This project is a simple command line based Modbus TCP client for POXIX compatible operating systems that stores the contents of its registers in shared memory. - -## Basic operating principle - -The client creates four shared memories. -One for each register type: -- Discrete Output Coils (DO) -- Discrete Input Coils (DI) -- Discrete Output Registers (AO) -- Discrete Input Registers (AI) - -All registers are initialized with 0 at the beginning. -The Modbus master reads and writes directly the values from these shared memories. - -The actual functionality of the client is realized by applications that read data from or write data to the shared memory. - - -## Use the Application -The application can be started completely without command line arguments. -In this case the client listens for connections on all IPs on port 502 (the default modbus port). -The application terminates if the master disconnects. - -The arguments ```--port``` and ```--ip``` can be used to specify port and ip to listen to. - -By using the command line argument ```--monitor``` all incoming and outgoing packets are printed on stdout. -This option should be used carefully, as it generates large amounts of output depending on the masters polling cycle and the number of used registers. - -The ```--reconnect``` option can be used to specify that the application is not terminated when the master disconnects, but waits for a new connection. - -### Use privileged ports -Ports below 1024 cannot be used by standard users. -Therefore, the default modbus port (502) cannot be used without further action. - -Here are two ways to use the port anyway: -#### iptables (recommended) -An entry can be added to the iptables that forwards the packets on the actual port to a higher port. - -The following example redirects all tcp packets on port 502 to port 5020: -``` -iptables -A PREROUTING -t nat -p tcp --dport 502 -j REDIRECT --to-port 5020 -``` - -#### setcap -The command ```setcap``` can be used to allow the application to access privileged ports. -However, this option gives the application significantly more rights than it actually needs and should therefore be avoided. - -This option cannot be used with flatpaks. - -``` -setcap 'cap_net_bind_service=+ep' /path/to/binary -``` - - - -## Build from Source - -The following packages are required for building the application: -- cmake -- clang or gcc - -Additionally, the following packages are required to build the modbus library: -- autoconf -- automake -- libtool - - -Use the following commands to build the application: -``` -git clone --recursive https://github.com/NikolasK-source/modbus_tcp_client_shm.git -cd modbus_tcp_client_shm -mkdir build -cmake -B build . -DCMAKE_BUILD_TYPE=Release -DCLANG_FORMAT=OFF -DCOMPILER_WARNINGS=OFF -cmake --build build -``` - -The binary is located in the build directory. From 31259c245c2de6f1d65e8ede8da7a4dedea5620d Mon Sep 17 00:00:00 2001 From: Nikolas Koesling Date: Mon, 1 Aug 2022 21:28:12 +0200 Subject: [PATCH 4/7] remove docs dir from gitignore --- .gitignore | 2 +- docs/_config.yml | 1 + docs/index.md | 78 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 docs/_config.yml create mode 100644 docs/index.md diff --git a/.gitignore b/.gitignore index 56c7f82..aa61eca 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ # general build* -docs/ +docs/* !docs/index.md !docs/_config.yml diff --git a/docs/_config.yml b/docs/_config.yml new file mode 100644 index 0000000..c419263 --- /dev/null +++ b/docs/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-cayman \ No newline at end of file diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..891c2f0 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,78 @@ +# Shared Memory Modbus TCP Client + +This project is a simple command line based Modbus TCP client for POXIX compatible operating systems that stores the contents of its registers in shared memory. + +## Basic operating principle + +The client creates four shared memories. +One for each register type: +- Discrete Output Coils (DO) +- Discrete Input Coils (DI) +- Discrete Output Registers (AO) +- Discrete Input Registers (AI) + +All registers are initialized with 0 at the beginning. +The Modbus master reads and writes directly the values from these shared memories. + +The actual functionality of the client is realized by applications that read data from or write data to the shared memory. + + +## Use the Application +The application can be started completely without command line arguments. +In this case the client listens for connections on all IPs on port 502 (the default modbus port). +The application terminates if the master disconnects. + +The arguments ```--port``` and ```--ip``` can be used to specify port and ip to listen to. + +By using the command line argument ```--monitor``` all incoming and outgoing packets are printed on stdout. +This option should be used carefully, as it generates large amounts of output depending on the masters polling cycle and the number of used registers. + +The ```--reconnect``` option can be used to specify that the application is not terminated when the master disconnects, but waits for a new connection. + +### Use privileged ports +Ports below 1024 cannot be used by standard users. +Therefore, the default modbus port (502) cannot be used without further action. + +Here are two ways to use the port anyway: +#### iptables (recommended) +An entry can be added to the iptables that forwards the packets on the actual port to a higher port. + +The following example redirects all tcp packets on port 502 to port 5020: +``` +iptables -A PREROUTING -t nat -p tcp --dport 502 -j REDIRECT --to-port 5020 +``` + +#### setcap +The command ```setcap``` can be used to allow the application to access privileged ports. +However, this option gives the application significantly more rights than it actually needs and should therefore be avoided. + +This option cannot be used with flatpaks. + +``` +setcap 'cap_net_bind_service=+ep' /path/to/binary +``` + + + +## Build from Source + +The following packages are required for building the application: +- cmake +- clang or gcc + +Additionally, the following packages are required to build the modbus library: +- autoconf +- automake +- libtool + + +Use the following commands to build the application: +``` +git clone --recursive https://github.com/NikolasK-source/modbus_tcp_client_shm.git +cd modbus_tcp_client_shm +mkdir build +cmake -B build . -DCMAKE_BUILD_TYPE=Release -DCLANG_FORMAT=OFF -DCOMPILER_WARNINGS=OFF +cmake --build build +``` + +The binary is located in the build directory. From 947a0e23b9eefef82d0a335451c4759df52fc02e Mon Sep 17 00:00:00 2001 From: Nikolas Koesling Date: Mon, 1 Aug 2022 22:25:35 +0200 Subject: [PATCH 5/7] add flatpak manifest --- .gitignore | 2 ++ network.koesling.modbus_tcp_client_shm.yml | 26 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 network.koesling.modbus_tcp_client_shm.yml diff --git a/.gitignore b/.gitignore index aa61eca..da30fc7 100644 --- a/.gitignore +++ b/.gitignore @@ -465,3 +465,5 @@ modules.order Module.symvers Mkfile.old dkms.conf + +!network.koesling.modbus_tcp_client_shm.yml \ No newline at end of file diff --git a/network.koesling.modbus_tcp_client_shm.yml b/network.koesling.modbus_tcp_client_shm.yml new file mode 100644 index 0000000..cc84e6f --- /dev/null +++ b/network.koesling.modbus_tcp_client_shm.yml @@ -0,0 +1,26 @@ +id: network.koesling.modbus_tcp_client_shm +runtime: org.freedesktop.Platform +runtime-version: '21.08' +sdk: org.freedesktop.Sdk +command: Modbus_TCP_client_shm +finish-args: + - --device=shm + - --share=network +modules: + - name: Modbus_TCP_client_shm + buildsystem: simple + build-commands: + # build + - mkdir build + - cmake -B build . -DCMAKE_BUILD_TYPE=Release -DCLANG_FORMAT=OFF -DCOMPILER_WARNINGS=OFF + - cmake --build build + + # install + - mkdir -p "${FLATPAK_DEST}/bin" + - cp build/Modbus_TCP_client_shm ${FLATPAK_DEST}/bin + - ls -lah ${FLATPAK_DEST} + sources: + - type: git + branch: release + url: https://github.com/NikolasK-source/modbus_tcp_client_shm.git + From 703c6283981e79a3174b7f0d9de102dfabee1080 Mon Sep 17 00:00:00 2001 From: Nikolas Koesling Date: Tue, 2 Aug 2022 12:28:07 +0200 Subject: [PATCH 6/7] add licenses --- CMakeLists.txt | 2 +- LICENSE | 2 +- src/CMakeLists.txt | 2 + src/Modbus_TCP_Slave.hpp | 4 +- src/license.cpp | 558 +++++++++++++++++++++++++++++++++++++++ src/license.hpp | 5 + src/main.cpp | 34 +-- src/modbus_shm.hpp | 2 +- 8 files changed, 580 insertions(+), 29 deletions(-) create mode 100644 src/license.cpp create mode 100644 src/license.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 158408a..4c437e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.13.4 FATAL_ERROR) # ====================================================================================================================== # project -project(Modbus_TCP_client_shm LANGUAGES CXX VERSION 1.0.2) +project(Modbus_TCP_client_shm LANGUAGES CXX VERSION 1.0.3) # settings set(Target "Modbus_TCP_client_shm") # Executable name (without file extension!) diff --git a/LICENSE b/LICENSE index 187c98f..2df420f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021 Nikolas Koesling +Copyright (c) 2021-2022 Nikolas Koesling Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6d79bc6..e897917 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -4,12 +4,14 @@ target_sources(${Target} PRIVATE main.cpp) target_sources(${Target} PRIVATE modbus_shm.cpp) target_sources(${Target} PRIVATE Modbus_TCP_Slave.cpp) +target_sources(${Target} PRIVATE license.cpp) # ---------------------------------------- header files (*.jpp, *.h, ...) ---------------------------------------------- # ====================================================================================================================== target_sources(${Target} PRIVATE modbus_shm.hpp) target_sources(${Target} PRIVATE Modbus_TCP_Slave.hpp) +target_sources(${Target} PRIVATE license.hpp) diff --git a/src/Modbus_TCP_Slave.hpp b/src/Modbus_TCP_Slave.hpp index 08bc9ff..b2b2c0d 100644 --- a/src/Modbus_TCP_Slave.hpp +++ b/src/Modbus_TCP_Slave.hpp @@ -9,7 +9,7 @@ namespace TCP { //! Modbus TCP slave class Slave { private: - modbus_t * modbus; //!< modbus object (see libmodbus library) + modbus_t *modbus; //!< modbus object (see libmodbus library) modbus_mapping_t *mapping; //!< modbus data object (see libmodbus library) bool delete_mapping; //!< indicates whether the mapping object was created by this instance int socket = -1; //!< socket of the modbus connection @@ -23,7 +23,7 @@ class Slave { */ explicit Slave(const std::string &ip = "0.0.0.0", short unsigned int port = 502, - modbus_mapping_t * mapping = nullptr); + modbus_mapping_t *mapping = nullptr); /*! \brief destroy the modbus slave * diff --git a/src/license.cpp b/src/license.cpp new file mode 100644 index 0000000..6a0f519 --- /dev/null +++ b/src/license.cpp @@ -0,0 +1,558 @@ +#include "license.hpp" + +void print_licenses(std::ostream &o) { + o << "This Application (" << PROJECT_NAME << ' ' << PROJECT_VERSION "): " << std::endl; + o << std::endl; + o << " MIT License" << std::endl; + o << std::endl; + o << " Copyright (c) 2021-2022 Nikolas Koesling" << std::endl; + o << std::endl; + o << " Permission is hereby granted, free of charge, to any person obtaining a copy" << std::endl; + o << " of this software and associated documentation files (the \"Software\"), to deal" << std::endl; + o << " in the Software without restriction, including without limitation the rights" << std::endl; + o << " to use, copy, modify, merge, publish, distribute, sublicense, and/or sell" << std::endl; + o << " copies of the Software, and to permit persons to whom the Software is" << std::endl; + o << " furnished to do so, subject to the following conditions:" << std::endl; + o << std::endl; + o << " The above copyright notice and this permission notice shall be included in all" << std::endl; + o << " copies or substantial portions of the Software." << std::endl; + o << std::endl; + o << " THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR" << std::endl; + o << " IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY," << std::endl; + o << " FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE" << std::endl; + o << " AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER" << std::endl; + o << " LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM," << std::endl; + o << " OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE" << std::endl; + o << " SOFTWARE." << std::endl; + o << std::endl; + o << std::endl; + o << "cxxopts Library (https://github.com/jarro2783/cxxopts)" << std::endl; + o << std::endl; + o << " MIT License" << std::endl; + o << std::endl; + o << " Copyright (c) 2014 Jarryd Beck" << std::endl; + o << std::endl; + o << " Permission is hereby granted, free of charge, to any person obtaining a copy" << std::endl; + o << " of this software and associated documentation files (the \"Software\"), to deal" << std::endl; + o << " in the Software without restriction, including without limitation the rights" << std::endl; + o << " to use, copy, modify, merge, publish, distribute, sublicense, and/or sell" << std::endl; + o << " copies of the Software, and to permit persons to whom the Software is" << std::endl; + o << " furnished to do so, subject to the following conditions:" << std::endl; + o << std::endl; + o << " The above copyright notice and this permission notice shall be included in" << std::endl; + o << " all copies or substantial portions of the Software." << std::endl; + o << std::endl; + o << " THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR" << std::endl; + o << " IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY," << std::endl; + o << " FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE" << std::endl; + o << " AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER" << std::endl; + o << " LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM," << std::endl; + o << " OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN" << std::endl; + o << " THE SOFTWARE." << std::endl; + o << std::endl; + o << std::endl; + o << "Modbus Library (https://github.com/stephane/libmodbus):" << std::endl; + o << std::endl; + o << " GNU LESSER GENERAL PUBLIC LICENSE" << std::endl; + o << " Version 2.1, February 1999" << std::endl; + o << std::endl; + o << " Copyright (C) 1991, 1999 Free Software Foundation, Inc." << std::endl; + o << " 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA" << std::endl; + o << " Everyone is permitted to copy and distribute verbatim copies" << std::endl; + o << " of this license document, but changing it is not allowed." << std::endl; + o << std::endl; + o << " [This is the first released version of the Lesser GPL. It also counts" << std::endl; + o << " as the successor of the GNU Library Public License, version 2, hence" << std::endl; + o << " the version number 2.1.]" << std::endl; + o << std::endl; + o << " Preamble" << std::endl; + o << std::endl; + o << " The licenses for most software are designed to take away your" << std::endl; + o << " freedom to share and change it. By contrast, the GNU General Public" << std::endl; + o << " Licenses are intended to guarantee your freedom to share and change" << std::endl; + o << " free software--to make sure the software is free for all its users." << std::endl; + o << std::endl; + o << " This license, the Lesser General Public License, applies to some" << std::endl; + o << " specially designated software packages--typically libraries--of the" << std::endl; + o << " Free Software Foundation and other authors who decide to use it. You" << std::endl; + o << " can use it too, but we suggest you first think carefully about whether" << std::endl; + o << " this license or the ordinary General Public License is the better" << std::endl; + o << " strategy to use in any particular case, based on the explanations below." << std::endl; + o << std::endl; + o << " When we speak of free software, we are referring to freedom of use," << std::endl; + o << " not price. Our General Public Licenses are designed to make sure that" << std::endl; + o << " you have the freedom to distribute copies of free software (and charge" << std::endl; + o << " for this service if you wish); that you receive source code or can get" << std::endl; + o << " it if you want it; that you can change the software and use pieces of" << std::endl; + o << " it in new free programs; and that you are informed that you can do" << std::endl; + o << " these things." << std::endl; + o << std::endl; + o << " To protect your rights, we need to make restrictions that forbid" << std::endl; + o << " distributors to deny you these rights or to ask you to surrender these" << std::endl; + o << " rights. These restrictions translate to certain responsibilities for" << std::endl; + o << " you if you distribute copies of the library or if you modify it." << std::endl; + o << std::endl; + o << " For example, if you distribute copies of the library, whether gratis" << std::endl; + o << " or for a fee, you must give the recipients all the rights that we gave" << std::endl; + o << " you. You must make sure that they, too, receive or can get the source" << std::endl; + o << " code. If you link other code with the library, you must provide" << std::endl; + o << " complete object files to the recipients, so that they can relink them" << std::endl; + o << " with the library after making changes to the library and recompiling" << std::endl; + o << " it. And you must show them these terms so they know their rights." << std::endl; + o << std::endl; + o << " We protect your rights with a two-step method: (1) we copyright the" << std::endl; + o << " library, and (2) we offer you this license, which gives you legal" << std::endl; + o << " permission to copy, distribute and/or modify the library." << std::endl; + o << std::endl; + o << " To protect each distributor, we want to make it very clear that" << std::endl; + o << " there is no warranty for the free library. Also, if the library is" << std::endl; + o << " modified by someone else and passed on, the recipients should know" << std::endl; + o << " that what they have is not the original version, so that the original" << std::endl; + o << " author's reputation will not be affected by problems that might be" << std::endl; + o << " introduced by others." << std::endl; + o << std::endl; + o << " Finally, software patents pose a constant threat to the existence of" << std::endl; + o << " any free program. We wish to make sure that a company cannot" << std::endl; + o << " effectively restrict the users of a free program by obtaining a" << std::endl; + o << " restrictive license from a patent holder. Therefore, we insist that" << std::endl; + o << " any patent license obtained for a version of the library must be" << std::endl; + o << " consistent with the full freedom of use specified in this license." << std::endl; + o << std::endl; + o << " Most GNU software, including some libraries, is covered by the" << std::endl; + o << " ordinary GNU General Public License. This license, the GNU Lesser" << std::endl; + o << " General Public License, applies to certain designated libraries, and" << std::endl; + o << " is quite different from the ordinary General Public License. We use" << std::endl; + o << " this license for certain libraries in order to permit linking those" << std::endl; + o << " libraries into non-free programs." << std::endl; + o << std::endl; + o << " When a program is linked with a library, whether statically or using" << std::endl; + o << " a shared library, the combination of the two is legally speaking a" << std::endl; + o << " combined work, a derivative of the original library. The ordinary" << std::endl; + o << " General Public License therefore permits such linking only if the" << std::endl; + o << " entire combination fits its criteria of freedom. The Lesser General" << std::endl; + o << " Public License permits more lax criteria for linking other code with" << std::endl; + o << " the library." << std::endl; + o << std::endl; + o << " We call this license the \"Lesser\" General Public License because it" << std::endl; + o << " does Less to protect the user's freedom than the ordinary General" << std::endl; + o << " Public License. It also provides other free software developers Less" << std::endl; + o << " of an advantage over competing non-free programs. These disadvantages" << std::endl; + o << " are the reason we use the ordinary General Public License for many" << std::endl; + o << " libraries. However, the Lesser license provides advantages in certain" << std::endl; + o << " special circumstances." << std::endl; + o << std::endl; + o << " For example, on rare occasions, there may be a special need to" << std::endl; + o << " encourage the widest possible use of a certain library, so that it becomes" << std::endl; + o << " a de-facto standard. To achieve this, non-free programs must be" << std::endl; + o << " allowed to use the library. A more frequent case is that a free" << std::endl; + o << " library does the same job as widely used non-free libraries. In this" << std::endl; + o << " case, there is little to gain by limiting the free library to free" << std::endl; + o << " software only, so we use the Lesser General Public License." << std::endl; + o << std::endl; + o << " In other cases, permission to use a particular library in non-free" << std::endl; + o << " programs enables a greater number of people to use a large body of" << std::endl; + o << " free software. For example, permission to use the GNU C Library in" << std::endl; + o << " non-free programs enables many more people to use the whole GNU" << std::endl; + o << " operating system, as well as its variant, the GNU/Linux operating" << std::endl; + o << " system." << std::endl; + o << std::endl; + o << " Although the Lesser General Public License is Less protective of the" << std::endl; + o << " users' freedom, it does ensure that the user of a program that is" << std::endl; + o << " linked with the Library has the freedom and the wherewithal to run" << std::endl; + o << " that program using a modified version of the Library." << std::endl; + o << std::endl; + o << " The precise terms and conditions for copying, distribution and" << std::endl; + o << " modification follow. Pay close attention to the difference between a" << std::endl; + o << " \"work based on the library\" and a \"work that uses the library\". The" << std::endl; + o << " former contains code derived from the library, whereas the latter must" << std::endl; + o << " be combined with the library in order to run." << std::endl; + o << std::endl; + o << " GNU LESSER GENERAL PUBLIC LICENSE" << std::endl; + o << " TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION" << std::endl; + o << std::endl; + o << " 0. This License Agreement applies to any software library or other" << std::endl; + o << " program which contains a notice placed by the copyright holder or" << std::endl; + o << " other authorized party saying it may be distributed under the terms of" << std::endl; + o << " this Lesser General Public License (also called \"this License\")." << std::endl; + o << " Each licensee is addressed as \"you\"." << std::endl; + o << std::endl; + o << " A \"library\" means a collection of software functions and/or data" << std::endl; + o << " prepared so as to be conveniently linked with application programs" << std::endl; + o << " (which use some of those functions and data) to form executables." << std::endl; + o << std::endl; + o << " The \"Library\", below, refers to any such software library or work" << std::endl; + o << " which has been distributed under these terms. A \"work based on the" << std::endl; + o << " Library\" means either the Library or any derivative work under" << std::endl; + o << " copyright law: that is to say, a work containing the Library or a" << std::endl; + o << " portion of it, either verbatim or with modifications and/or translated" << std::endl; + o << " straightforwardly into another language. (Hereinafter, translation is" << std::endl; + o << " included without limitation in the term \"modification\".)" << std::endl; + o << std::endl; + o << " \"Source code\" for a work means the preferred form of the work for" << std::endl; + o << " making modifications to it. For a library, complete source code means" << std::endl; + o << " all the source code for all modules it contains, plus any associated" << std::endl; + o << " interface definition files, plus the scripts used to control compilation" << std::endl; + o << " and installation of the library." << std::endl; + o << std::endl; + o << " Activities other than copying, distribution and modification are not" << std::endl; + o << " covered by this License; they are outside its scope. The act of" << std::endl; + o << " running a program using the Library is not restricted, and output from" << std::endl; + o << " such a program is covered only if its contents constitute a work based" << std::endl; + o << " on the Library (independent of the use of the Library in a tool for" << std::endl; + o << " writing it). Whether that is true depends on what the Library does" << std::endl; + o << " and what the program that uses the Library does." << std::endl; + o << std::endl; + o << " 1. You may copy and distribute verbatim copies of the Library's" << std::endl; + o << " complete source code as you receive it, in any medium, provided that" << std::endl; + o << " you conspicuously and appropriately publish on each copy an" << std::endl; + o << " appropriate copyright notice and disclaimer of warranty; keep intact" << std::endl; + o << " all the notices that refer to this License and to the absence of any" << std::endl; + o << " warranty; and distribute a copy of this License along with the" << std::endl; + o << " Library." << std::endl; + o << std::endl; + o << " You may charge a fee for the physical act of transferring a copy," << std::endl; + o << " and you may at your option offer warranty protection in exchange for a" << std::endl; + o << " fee." << std::endl; + o << std::endl; + o << " 2. You may modify your copy or copies of the Library or any portion" << std::endl; + o << " of it, thus forming a work based on the Library, and copy and" << std::endl; + o << " distribute such modifications or work under the terms of Section 1" << std::endl; + o << " above, provided that you also meet all of these conditions:" << std::endl; + o << std::endl; + o << " a) The modified work must itself be a software library." << std::endl; + o << std::endl; + o << " b) You must cause the files modified to carry prominent notices" << std::endl; + o << " stating that you changed the files and the date of any change." << std::endl; + o << std::endl; + o << " c) You must cause the whole of the work to be licensed at no" << std::endl; + o << " charge to all third parties under the terms of this License." << std::endl; + o << std::endl; + o << " d) If a facility in the modified Library refers to a function or a" << std::endl; + o << " table of data to be supplied by an application program that uses" << std::endl; + o << " the facility, other than as an argument passed when the facility" << std::endl; + o << " is invoked, then you must make a good faith effort to ensure that," << std::endl; + o << " in the event an application does not supply such function or" << std::endl; + o << " table, the facility still operates, and performs whatever part of" << std::endl; + o << " its purpose remains meaningful." << std::endl; + o << std::endl; + o << " (For example, a function in a library to compute square roots has" << std::endl; + o << " a purpose that is entirely well-defined independent of the" << std::endl; + o << " application. Therefore, Subsection 2d requires that any" << std::endl; + o << " application-supplied function or table used by this function must" << std::endl; + o << " be optional: if the application does not supply it, the square" << std::endl; + o << " root function must still compute square roots.)" << std::endl; + o << std::endl; + o << " These requirements apply to the modified work as a whole. If" << std::endl; + o << " identifiable sections of that work are not derived from the Library," << std::endl; + o << " and can be reasonably considered independent and separate works in" << std::endl; + o << " themselves, then this License, and its terms, do not apply to those" << std::endl; + o << " sections when you distribute them as separate works. But when you" << std::endl; + o << " distribute the same sections as part of a whole which is a work based" << std::endl; + o << " on the Library, the distribution of the whole must be on the terms of" << std::endl; + o << " this License, whose permissions for other licensees extend to the" << std::endl; + o << " entire whole, and thus to each and every part regardless of who wrote" << std::endl; + o << " it." << std::endl; + o << std::endl; + o << " Thus, it is not the intent of this section to claim rights or contest" << std::endl; + o << " your rights to work written entirely by you; rather, the intent is to" << std::endl; + o << " exercise the right to control the distribution of derivative or" << std::endl; + o << " collective works based on the Library." << std::endl; + o << std::endl; + o << " In addition, mere aggregation of another work not based on the Library" << std::endl; + o << " with the Library (or with a work based on the Library) on a volume of" << std::endl; + o << " a storage or distribution medium does not bring the other work under" << std::endl; + o << " the scope of this License." << std::endl; + o << std::endl; + o << " 3. You may opt to apply the terms of the ordinary GNU General Public" << std::endl; + o << " License instead of this License to a given copy of the Library. To do" << std::endl; + o << " this, you must alter all the notices that refer to this License, so" << std::endl; + o << " that they refer to the ordinary GNU General Public License, version 2," << std::endl; + o << " instead of to this License. (If a newer version than version 2 of the" << std::endl; + o << " ordinary GNU General Public License has appeared, then you can specify" << std::endl; + o << " that version instead if you wish.) Do not make any other change in" << std::endl; + o << " these notices." << std::endl; + o << std::endl; + o << " Once this change is made in a given copy, it is irreversible for" << std::endl; + o << " that copy, so the ordinary GNU General Public License applies to all" << std::endl; + o << " subsequent copies and derivative works made from that copy." << std::endl; + o << std::endl; + o << " This option is useful when you wish to copy part of the code of" << std::endl; + o << " the Library into a program that is not a library." << std::endl; + o << std::endl; + o << " 4. You may copy and distribute the Library (or a portion or" << std::endl; + o << " derivative of it, under Section 2) in object code or executable form" << std::endl; + o << " under the terms of Sections 1 and 2 above provided that you accompany" << std::endl; + o << " it with the complete corresponding machine-readable source code, which" << std::endl; + o << " must be distributed under the terms of Sections 1 and 2 above on a" << std::endl; + o << " medium customarily used for software interchange." << std::endl; + o << std::endl; + o << " If distribution of object code is made by offering access to copy" << std::endl; + o << " from a designated place, then offering equivalent access to copy the" << std::endl; + o << " source code from the same place satisfies the requirement to" << std::endl; + o << " distribute the source code, even though third parties are not" << std::endl; + o << " compelled to copy the source along with the object code." << std::endl; + o << std::endl; + o << " 5. A program that contains no derivative of any portion of the" << std::endl; + o << " Library, but is designed to work with the Library by being compiled or" << std::endl; + o << " linked with it, is called a \"work that uses the Library\". Such a" << std::endl; + o << " work, in isolation, is not a derivative work of the Library, and" << std::endl; + o << " therefore falls outside the scope of this License." << std::endl; + o << std::endl; + o << " However, linking a \"work that uses the Library\" with the Library" << std::endl; + o << " creates an executable that is a derivative of the Library (because it" << std::endl; + o << " contains portions of the Library), rather than a \"work that uses the" << std::endl; + o << " library\". The executable is therefore covered by this License." << std::endl; + o << " Section 6 states terms for distribution of such executables." << std::endl; + o << std::endl; + o << " When a \"work that uses the Library\" uses material from a header file" << std::endl; + o << " that is part of the Library, the object code for the work may be a" << std::endl; + o << " derivative work of the Library even though the source code is not." << std::endl; + o << " Whether this is true is especially significant if the work can be" << std::endl; + o << " linked without the Library, or if the work is itself a library. The" << std::endl; + o << " threshold for this to be true is not precisely defined by law." << std::endl; + o << std::endl; + o << " If such an object file uses only numerical parameters, data" << std::endl; + o << " structure layouts and accessors, and small macros and small inline" << std::endl; + o << " functions (ten lines or less in length), then the use of the object" << std::endl; + o << " file is unrestricted, regardless of whether it is legally a derivative" << std::endl; + o << " work. (Executables containing this object code plus portions of the" << std::endl; + o << " Library will still fall under Section 6.)" << std::endl; + o << std::endl; + o << " Otherwise, if the work is a derivative of the Library, you may" << std::endl; + o << " distribute the object code for the work under the terms of Section 6." << std::endl; + o << " Any executables containing that work also fall under Section 6," << std::endl; + o << " whether or not they are linked directly with the Library itself." << std::endl; + o << std::endl; + o << " 6. As an exception to the Sections above, you may also combine or" << std::endl; + o << " link a \"work that uses the Library\" with the Library to produce a" << std::endl; + o << " work containing portions of the Library, and distribute that work" << std::endl; + o << " under terms of your choice, provided that the terms permit" << std::endl; + o << " modification of the work for the customer's own use and reverse" << std::endl; + o << " engineering for debugging such modifications." << std::endl; + o << std::endl; + o << " You must give prominent notice with each copy of the work that the" << std::endl; + o << " Library is used in it and that the Library and its use are covered by" << std::endl; + o << " this License. You must supply a copy of this License. If the work" << std::endl; + o << " during execution displays copyright notices, you must include the" << std::endl; + o << " copyright notice for the Library among them, as well as a reference" << std::endl; + o << " directing the user to the copy of this License. Also, you must do one" << std::endl; + o << " of these things:" << std::endl; + o << std::endl; + o << " a) Accompany the work with the complete corresponding" << std::endl; + o << " machine-readable source code for the Library including whatever" << std::endl; + o << " changes were used in the work (which must be distributed under" << std::endl; + o << " Sections 1 and 2 above); and, if the work is an executable linked" << std::endl; + o << " with the Library, with the complete machine-readable \"work that" << std::endl; + o << " uses the Library\", as object code and/or source code, so that the" << std::endl; + o << " user can modify the Library and then relink to produce a modified" << std::endl; + o << " executable containing the modified Library. (It is understood" << std::endl; + o << " that the user who changes the contents of definitions files in the" << std::endl; + o << " Library will not necessarily be able to recompile the application" << std::endl; + o << " to use the modified definitions.)" << std::endl; + o << std::endl; + o << " b) Use a suitable shared library mechanism for linking with the" << std::endl; + o << " Library. A suitable mechanism is one that (1) uses at run time a" << std::endl; + o << " copy of the library already present on the user's computer system," << std::endl; + o << " rather than copying library functions into the executable, and (2)" << std::endl; + o << " will operate properly with a modified version of the library, if" << std::endl; + o << " the user installs one, as long as the modified version is" << std::endl; + o << " interface-compatible with the version that the work was made with." << std::endl; + o << std::endl; + o << " c) Accompany the work with a written offer, valid for at" << std::endl; + o << " least three years, to give the same user the materials" << std::endl; + o << " specified in Subsection 6a, above, for a charge no more" << std::endl; + o << " than the cost of performing this distribution." << std::endl; + o << std::endl; + o << " d) If distribution of the work is made by offering access to copy" << std::endl; + o << " from a designated place, offer equivalent access to copy the above" << std::endl; + o << " specified materials from the same place." << std::endl; + o << std::endl; + o << " e) Verify that the user has already received a copy of these" << std::endl; + o << " materials or that you have already sent this user a copy." << std::endl; + o << std::endl; + o << " For an executable, the required form of the \"work that uses the" << std::endl; + o << " Library\" must include any data and utility programs needed for" << std::endl; + o << " reproducing the executable from it. However, as a special exception," << std::endl; + o << " the materials to be distributed need not include anything that is" << std::endl; + o << " normally distributed (in either source or binary form) with the major" << std::endl; + o << " components (compiler, kernel, and so on) of the operating system on" << std::endl; + o << " which the executable runs, unless that component itself accompanies" << std::endl; + o << " the executable." << std::endl; + o << std::endl; + o << " It may happen that this requirement contradicts the license" << std::endl; + o << " restrictions of other proprietary libraries that do not normally" << std::endl; + o << " accompany the operating system. Such a contradiction means you cannot" << std::endl; + o << " use both them and the Library together in an executable that you" << std::endl; + o << " distribute." << std::endl; + o << std::endl; + o << " 7. You may place library facilities that are a work based on the" << std::endl; + o << " Library side-by-side in a single library together with other library" << std::endl; + o << " facilities not covered by this License, and distribute such a combined" << std::endl; + o << " library, provided that the separate distribution of the work based on" << std::endl; + o << " the Library and of the other library facilities is otherwise" << std::endl; + o << " permitted, and provided that you do these two things:" << std::endl; + o << std::endl; + o << " a) Accompany the combined library with a copy of the same work" << std::endl; + o << " based on the Library, uncombined with any other library" << std::endl; + o << " facilities. This must be distributed under the terms of the" << std::endl; + o << " Sections above." << std::endl; + o << std::endl; + o << " b) Give prominent notice with the combined library of the fact" << std::endl; + o << " that part of it is a work based on the Library, and explaining" << std::endl; + o << " where to find the accompanying uncombined form of the same work." << std::endl; + o << std::endl; + o << " 8. You may not copy, modify, sublicense, link with, or distribute" << std::endl; + o << " the Library except as expressly provided under this License. Any" << std::endl; + o << " attempt otherwise to copy, modify, sublicense, link with, or" << std::endl; + o << " distribute the Library is void, and will automatically terminate your" << std::endl; + o << " rights under this License. However, parties who have received copies," << std::endl; + o << " or rights, from you under this License will not have their licenses" << std::endl; + o << " terminated so long as such parties remain in full compliance." << std::endl; + o << std::endl; + o << " 9. You are not required to accept this License, since you have not" << std::endl; + o << " signed it. However, nothing else grants you permission to modify or" << std::endl; + o << " distribute the Library or its derivative works. These actions are" << std::endl; + o << " prohibited by law if you do not accept this License. Therefore, by" << std::endl; + o << " modifying or distributing the Library (or any work based on the" << std::endl; + o << " Library), you indicate your acceptance of this License to do so, and" << std::endl; + o << " all its terms and conditions for copying, distributing or modifying" << std::endl; + o << " the Library or works based on it." << std::endl; + o << std::endl; + o << " 10. Each time you redistribute the Library (or any work based on the" << std::endl; + o << " Library), the recipient automatically receives a license from the" << std::endl; + o << " original licensor to copy, distribute, link with or modify the Library" << std::endl; + o << " subject to these terms and conditions. You may not impose any further" << std::endl; + o << " restrictions on the recipients' exercise of the rights granted herein." << std::endl; + o << " You are not responsible for enforcing compliance by third parties with" << std::endl; + o << " this License." << std::endl; + o << std::endl; + o << " 11. If, as a consequence of a court judgment or allegation of patent" << std::endl; + o << " infringement or for any other reason (not limited to patent issues)," << std::endl; + o << " conditions are imposed on you (whether by court order, agreement or" << std::endl; + o << " otherwise) that contradict the conditions of this License, they do not" << std::endl; + o << " excuse you from the conditions of this License. If you cannot" << std::endl; + o << " distribute so as to satisfy simultaneously your obligations under this" << std::endl; + o << " License and any other pertinent obligations, then as a consequence you" << std::endl; + o << " may not distribute the Library at all. For example, if a patent" << std::endl; + o << " license would not permit royalty-free redistribution of the Library by" << std::endl; + o << " all those who receive copies directly or indirectly through you, then" << std::endl; + o << " the only way you could satisfy both it and this License would be to" << std::endl; + o << " refrain entirely from distribution of the Library." << std::endl; + o << std::endl; + o << " If any portion of this section is held invalid or unenforceable under any" << std::endl; + o << " particular circumstance, the balance of the section is intended to apply," << std::endl; + o << " and the section as a whole is intended to apply in other circumstances." << std::endl; + o << std::endl; + o << " It is not the purpose of this section to induce you to infringe any" << std::endl; + o << " patents or other property right claims or to contest validity of any" << std::endl; + o << " such claims; this section has the sole purpose of protecting the" << std::endl; + o << " integrity of the free software distribution system which is" << std::endl; + o << " implemented by public license practices. Many people have made" << std::endl; + o << " generous contributions to the wide range of software distributed" << std::endl; + o << " through that system in reliance on consistent application of that" << std::endl; + o << " system; it is up to the author/donor to decide if he or she is willing" << std::endl; + o << " to distribute software through any other system and a licensee cannot" << std::endl; + o << " impose that choice." << std::endl; + o << std::endl; + o << " This section is intended to make thoroughly clear what is believed to" << std::endl; + o << " be a consequence of the rest of this License." << std::endl; + o << std::endl; + o << " 12. If the distribution and/or use of the Library is restricted in" << std::endl; + o << " certain countries either by patents or by copyrighted interfaces, the" << std::endl; + o << " original copyright holder who places the Library under this License may add" << std::endl; + o << " an explicit geographical distribution limitation excluding those countries," << std::endl; + o << " so that distribution is permitted only in or among countries not thus" << std::endl; + o << " excluded. In such case, this License incorporates the limitation as if" << std::endl; + o << " written in the body of this License." << std::endl; + o << std::endl; + o << " 13. The Free Software Foundation may publish revised and/or new" << std::endl; + o << " versions of the Lesser General Public License from time to time." << std::endl; + o << " Such new versions will be similar in spirit to the present version," << std::endl; + o << " but may differ in detail to address new problems or concerns." << std::endl; + o << std::endl; + o << " Each version is given a distinguishing version number. If the Library" << std::endl; + o << " specifies a version number of this License which applies to it and" << std::endl; + o << " \"any later version\", you have the option of following the terms and" << std::endl; + o << " conditions either of that version or of any later version published by" << std::endl; + o << " the Free Software Foundation. If the Library does not specify a" << std::endl; + o << " license version number, you may choose any version ever published by" << std::endl; + o << " the Free Software Foundation." << std::endl; + o << std::endl; + o << " 14. If you wish to incorporate parts of the Library into other free" << std::endl; + o << " programs whose distribution conditions are incompatible with these," << std::endl; + o << " write to the author to ask for permission. For software which is" << std::endl; + o << " copyrighted by the Free Software Foundation, write to the Free" << std::endl; + o << " Software Foundation; we sometimes make exceptions for this. Our" << std::endl; + o << " decision will be guided by the two goals of preserving the free status" << std::endl; + o << " of all derivatives of our free software and of promoting the sharing" << std::endl; + o << " and reuse of software generally." << std::endl; + o << std::endl; + o << " NO WARRANTY" << std::endl; + o << std::endl; + o << " 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO" << std::endl; + o << " WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW." << std::endl; + o << " EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR" << std::endl; + o << " OTHER PARTIES PROVIDE THE LIBRARY \"AS IS\" WITHOUT WARRANTY OF ANY" << std::endl; + o << " KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE" << std::endl; + o << " IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR" << std::endl; + o << " PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE" << std::endl; + o << " LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME" << std::endl; + o << " THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION." << std::endl; + o << std::endl; + o << " 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN" << std::endl; + o << " WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY" << std::endl; + o << " AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU" << std::endl; + o << " FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR" << std::endl; + o << " CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE" << std::endl; + o << " LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING" << std::endl; + o << " RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A" << std::endl; + o << " FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF" << std::endl; + o << " SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH" << std::endl; + o << " DAMAGES." << std::endl; + o << std::endl; + o << " END OF TERMS AND CONDITIONS" << std::endl; + o << std::endl; + o << " How to Apply These Terms to Your New Libraries" << std::endl; + o << std::endl; + o << " If you develop a new library, and you want it to be of the greatest" << std::endl; + o << " possible use to the public, we recommend making it free software that" << std::endl; + o << " everyone can redistribute and change. You can do so by permitting" << std::endl; + o << " redistribution under these terms (or, alternatively, under the terms of the" << std::endl; + o << " ordinary General Public License)." << std::endl; + o << std::endl; + o << " To apply these terms, attach the following notices to the library. It is" << std::endl; + o << " safest to attach them to the start of each source file to most effectively" << std::endl; + o << " convey the exclusion of warranty; and each file should have at least the" << std::endl; + o << " \"copyright\" line and a pointer to where the full notice is found." << std::endl; + o << std::endl; + o << " " << std::endl; + o << " Copyright (C) " << std::endl; + o << std::endl; + o << " This library is free software; you can redistribute it and/or" << std::endl; + o << " modify it under the terms of the GNU Lesser General Public" << std::endl; + o << " License as published by the Free Software Foundation; either" << std::endl; + o << " version 2.1 of the License, or (at your option) any later version." << std::endl; + o << std::endl; + o << " This library is distributed in the hope that it will be useful," << std::endl; + o << " but WITHOUT ANY WARRANTY; without even the implied warranty of" << std::endl; + o << " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU" << std::endl; + o << " Lesser General Public License for more details." << std::endl; + o << std::endl; + o << " You should have received a copy of the GNU Lesser General Public" << std::endl; + o << " License along with this library; if not, write to the Free Software" << std::endl; + o << " Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA" << std::endl; + o << std::endl; + o << " Also add information on how to contact you by electronic and paper mail." << std::endl; + o << std::endl; + o << " You should also get your employer (if you work as a programmer) or your" << std::endl; + o << " school, if any, to sign a \"copyright disclaimer\" for the library, if" << std::endl; + o << " necessary. Here is a sample; alter the names:" << std::endl; + o << std::endl; + o << " Yoyodyne, Inc., hereby disclaims all copyright interest in the" << std::endl; + o << " library `Frob' (a library for tweaking knobs) written by James Random Hacker." << std::endl; + o << std::endl; + o << " , 1 April 1990" << std::endl; + o << " Ty Coon, President of Vice" << std::endl; + o << std::endl; + o << " That's all there is to it!" << std::endl; +} diff --git a/src/license.hpp b/src/license.hpp new file mode 100644 index 0000000..4d34728 --- /dev/null +++ b/src/license.hpp @@ -0,0 +1,5 @@ +#pragma once + +#include + +void print_licenses(std::ostream &o); diff --git a/src/main.cpp b/src/main.cpp index 5b02b03..d94f31f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,6 +7,7 @@ #include #include "Modbus_TCP_Slave.hpp" +#include "license.hpp" #include "modbus_shm.hpp" //! terminate flag @@ -83,7 +84,9 @@ int main(int argc, char **argv) { ("h,help", "print usage") ("version", - "print version information"); + "print version information") + ("license", + "show licences"); // clang-format on // parse arguments @@ -111,29 +114,6 @@ int main(int argc, char **argv) { std::cout << "This application uses the following libraries:" << std::endl; std::cout << " - cxxopts by jarro2783 (https://github.com/jarro2783/cxxopts)" << std::endl; std::cout << " - libmodbus by Stéphane Raimbault (https://github.com/stephane/libmodbus)" << std::endl; - std::cout << std::endl; - std::cout << std::endl; - std::cout << "MIT License:" << std::endl; - std::cout << std::endl; - std::cout << "Copyright (c) 2021 Nikolas Koesling" << std::endl; - std::cout << std::endl; - std::cout << "Permission is hereby granted, free of charge, to any person obtaining a copy" << std::endl; - std::cout << "of this software and associated documentation files (the \"Software\"), to deal" << std::endl; - std::cout << "in the Software without restriction, including without limitation the rights" << std::endl; - std::cout << "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell" << std::endl; - std::cout << "copies of the Software, and to permit persons to whom the Software is" << std::endl; - std::cout << "furnished to do so, subject to the following conditions:" << std::endl; - std::cout << std::endl; - std::cout << "The above copyright notice and this permission notice shall be included in all" << std::endl; - std::cout << "copies or substantial portions of the Software." << std::endl; - std::cout << std::endl; - std::cout << "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR" << std::endl; - std::cout << "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY," << std::endl; - std::cout << "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE" << std::endl; - std::cout << "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER" << std::endl; - std::cout << "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM," << std::endl; - std::cout << "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE" << std::endl; - std::cout << "SOFTWARE." << std::endl; exit(EX_OK); } @@ -143,6 +123,12 @@ int main(int argc, char **argv) { exit(EX_OK); } + // print licenses + if (args.count("license")) { + print_licenses(std::cout); + exit(EX_OK); + } + // check arguments if (args["do-registers"].as() > 0x10000) { std::cerr << "to many do_registers (maximum: 65536)." << std::endl; diff --git a/src/modbus_shm.hpp b/src/modbus_shm.hpp index 4e2e3d7..3f8da82 100644 --- a/src/modbus_shm.hpp +++ b/src/modbus_shm.hpp @@ -21,7 +21,7 @@ class Shm_Mapping { std::string name = std::string(); //!< name of the object int fd = -1; //!< file descriptor std::size_t size; //!< size in bytes - void * addr = nullptr; //!< mapped address + void *addr = nullptr; //!< mapped address }; //! modbus lib storage object From 7200007e7191415716d327f9e1fafa6361043071 Mon Sep 17 00:00:00 2001 From: Nikolas Koesling Date: Tue, 2 Aug 2022 12:32:50 +0200 Subject: [PATCH 7/7] add copyright file header --- src/Modbus_TCP_Slave.cpp | 5 +++++ src/Modbus_TCP_Slave.hpp | 5 +++++ src/license.cpp | 5 +++++ src/license.hpp | 9 +++++++++ src/main.cpp | 5 +++++ src/modbus_shm.cpp | 6 +++++- src/modbus_shm.hpp | 5 +++++ 7 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/Modbus_TCP_Slave.cpp b/src/Modbus_TCP_Slave.cpp index 3ba5387..3f85822 100644 --- a/src/Modbus_TCP_Slave.cpp +++ b/src/Modbus_TCP_Slave.cpp @@ -1,3 +1,8 @@ +/* + * Copyright (C) 2021-2022 Nikolas Koesling . + * This program is free software. You can redistribute it and/or modify it under the terms of the MIT License. + */ + #include "Modbus_TCP_Slave.hpp" #include diff --git a/src/Modbus_TCP_Slave.hpp b/src/Modbus_TCP_Slave.hpp index b2b2c0d..36ef755 100644 --- a/src/Modbus_TCP_Slave.hpp +++ b/src/Modbus_TCP_Slave.hpp @@ -1,3 +1,8 @@ +/* + * Copyright (C) 2021-2022 Nikolas Koesling . + * This program is free software. You can redistribute it and/or modify it under the terms of the MIT License. + */ + #pragma once #include diff --git a/src/license.cpp b/src/license.cpp index 6a0f519..f0673f0 100644 --- a/src/license.cpp +++ b/src/license.cpp @@ -1,3 +1,8 @@ +/* + * Copyright (C) 2022 Nikolas Koesling . + * This program is free software. You can redistribute it and/or modify it under the terms of the MIT License. + */ + #include "license.hpp" void print_licenses(std::ostream &o) { diff --git a/src/license.hpp b/src/license.hpp index 4d34728..ab3da6b 100644 --- a/src/license.hpp +++ b/src/license.hpp @@ -1,5 +1,14 @@ +/* + * Copyright (C) 2022 Nikolas Koesling . + * This program is free software. You can redistribute it and/or modify it under the terms of the MIT License. + */ + #pragma once #include +/** + * \brief print licences + * @param o output stream used to print licenses + */ void print_licenses(std::ostream &o); diff --git a/src/main.cpp b/src/main.cpp index d94f31f..6e5bdf9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,3 +1,8 @@ +/* + * Copyright (C) 2021-2022 Nikolas Koesling . + * This program is free software. You can redistribute it and/or modify it under the terms of the MIT License. + */ + #include #include #include diff --git a/src/modbus_shm.cpp b/src/modbus_shm.cpp index 53df5b0..8834735 100644 --- a/src/modbus_shm.cpp +++ b/src/modbus_shm.cpp @@ -1,7 +1,11 @@ +/* + * Copyright (C) 2021-2022 Nikolas Koesling . + * This program is free software. You can redistribute it and/or modify it under the terms of the MIT License. + */ + #include "modbus_shm.hpp" #include -#include #include #include #include diff --git a/src/modbus_shm.hpp b/src/modbus_shm.hpp index 3f8da82..cd64dfb 100644 --- a/src/modbus_shm.hpp +++ b/src/modbus_shm.hpp @@ -1,3 +1,8 @@ +/* + * Copyright (C) 2021-2022 Nikolas Koesling . + * This program is free software. You can redistribute it and/or modify it under the terms of the MIT License. + */ + #pragma once #include "modbus/modbus.h"