From 1d1ad5c792d6fda9ea7bd6bb7024504e6684d88d Mon Sep 17 00:00:00 2001 From: PhilipDeegan Date: Sun, 16 Jun 2024 17:27:30 +0200 Subject: [PATCH] ++ --- .github/workflows/build_nix.yml | 10 +-- .github/workflows/build_osx.yml | 11 ++- .github/workflows/build_win.yml | 21 +++-- .sublime-project | 20 +++++ .sublime-project.sublime-workspace | 3 + .travis.yml | 45 ----------- LICENSE.md | 2 +- README.noformat | 9 +-- appveyor.yml | 25 ------ conanfile.txt | 2 +- inc/mkn/ram/asio/fcgi.hpp | 5 +- inc/mkn/ram/html/def.hpp | 2 +- inc/mkn/ram/html/page.hpp | 2 +- inc/mkn/ram/html/tag.hpp | 8 +- inc/mkn/ram/html4.hpp | 5 +- inc/mkn/ram/http.hpp | 6 +- inc/mkn/ram/http/def.hpp | 6 +- inc/mkn/ram/http/session.hpp | 6 +- inc/mkn/ram/https.hpp | 7 +- inc/mkn/ram/mpi.hpp | 5 +- inc/mkn/ram/os/nixish/http.hpp | 19 +++-- inc/mkn/ram/os/nixish/https.hpp | 38 ++++----- inc/mkn/ram/os/nixish/tcp.hpp | 41 +++++----- inc/mkn/ram/os/win/http.hpp | 2 +- inc/mkn/ram/os/win/https.hpp | 19 +++-- inc/mkn/ram/os/win/tcp.hpp | 7 +- inc/mkn/ram/tcp.hpp | 6 +- inc/mkn/ram/tcp/def.hpp | 6 +- lgtm.yml | 10 --- mkn.yaml | 108 ++++++++++++------------- os/nixish/inc/mkn/ram/http.hpp | 19 +++-- os/nixish/inc/mkn/ram/https.hpp | 45 ++++++----- os/nixish/inc/mkn/ram/tcp.hpp | 37 ++++----- os/nixish/src/http/multi.cpp | 2 +- os/nixish/src/http/server.cpp | 4 +- os/nixish/src/https/multi.cpp | 2 +- os/nixish/src/https/request.cpp | 6 +- os/nixish/src/https/server.cpp | 8 +- os/win/inc/mkn/ram/http.hpp | 4 +- os/win/inc/mkn/ram/https.hpp | 18 +++-- os/win/inc/mkn/ram/tcp.hpp | 11 ++- os/win/src/http/multi.cpp | 2 +- os/win/src/http/server.cpp | 2 +- os/win/src/https/multi.cpp | 2 +- os/win/src/https/request.cpp | 6 +- os/win/src/https/server.cpp | 4 +- remotes.json => res/conan_remotes.json | 0 src/fcgi/server.cpp | 11 ++- src/http/request.cpp | 4 +- src/http/response.cpp | 2 +- src/http/server.cpp | 12 ++- test/client.cpp | 21 +++-- test/fcgi.cpp | 3 +- test/server.cpp | 36 ++++----- test.cpp => test/test.cpp | 13 +-- usage.cpp => test/usage.cpp | 42 +++++----- 56 files changed, 357 insertions(+), 415 deletions(-) create mode 100644 .sublime-project create mode 100644 .sublime-project.sublime-workspace delete mode 100644 .travis.yml delete mode 100644 appveyor.yml delete mode 100644 lgtm.yml rename remotes.json => res/conan_remotes.json (100%) rename test.cpp => test/test.cpp (88%) rename usage.cpp => test/usage.cpp (91%) diff --git a/.github/workflows/build_nix.yml b/.github/workflows/build_nix.yml index 325be0b..b387892 100644 --- a/.github/workflows/build_nix.yml +++ b/.github/workflows/build_nix.yml @@ -10,10 +10,10 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - - name: "Build/Test" # contains slash so use quotes otherwise UB + - name: "Build/Test" run: | - wget https://github.com/PhilipDeegan/mkn/releases/download/latest/mkn_nix - chmod +x mkn_nix - KLOG=3 ./mkn_nix clean build run -dtOp test -a "-std=c++17 -fPIC" -l -pthread + curl -Lo mkn https://github.com/mkn/mkn/releases/download/latest/mkn_nix + chmod +x mkn + KLOG=3 ./mkn clean build run -dtOp test -a "-std=c++17 -fPIC" -l -pthread diff --git a/.github/workflows/build_osx.yml b/.github/workflows/build_osx.yml index 4f2369e..225c1d3 100644 --- a/.github/workflows/build_osx.yml +++ b/.github/workflows/build_osx.yml @@ -10,13 +10,12 @@ jobs: build: runs-on: macos-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - - name: "Build/Test" # contains slash so use quotes otherwise UB + - name: "Build/Test" env: MKN_LIB_LINK_LIB: 1 + SSL_DIR: /opt/homebrew/Cellar/openssl@3/3.3.1 run: | - brew install openssl - wget https://github.com/PhilipDeegan/mkn/releases/download/latest/mkn_osx - chmod +x mkn_osx - KLOG=3 ./mkn_osx clean build run -dtOp test -a "-std=c++17 -fPIC" -b /usr/local/opt/openssl@3/include -B /usr/local/opt/openssl@3/lib + curl -Lo mkn https://github.com/mkn/mkn/releases/download/latest/mkn_arm_osx && chmod +x mkn + KLOG=3 ./mkn clean build run -dtOp test -a "-std=c++17 -fPIC" -b "${SSL_DIR}/include" -B "${SSL_DIR}/lib" diff --git a/.github/workflows/build_win.yml b/.github/workflows/build_win.yml index c6766eb..a0250f4 100644 --- a/.github/workflows/build_win.yml +++ b/.github/workflows/build_win.yml @@ -10,25 +10,24 @@ jobs: build: runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 + + - uses: ilammy/msvc-dev-cmd@v1 + with: + arch: amd64 - uses: actions/setup-python@v2 with: - python-version: '3.9.6' # 3.10 is possibly too new + python-version: '3.11.9' - name: "Build/Test" shell: cmd env: MKN_CL_PREFERRED: 1 + MKN_LIB_LINK_LIB: 1 run: | # /bin/link interferes with cl/link.exe bash -c "rm /bin/link" - call "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat" - - bash -c "python3 -m pip install wheel --upgrade" - bash -c "python3 -m pip install conan --upgrade" - bash -c "mkdir -p /c/Users/runneradmin/.conan && cp remotes.json /c/Users/runneradmin/.conan/remotes.json" - - bash -c "curl -Lo mkn.exe https://github.com/PhilipDeegan/mkn/releases/download/latest/mkn.exe" + bash -c "python3 -m pip install wheel -U && python3 -m pip install conan -U" + bash -c "mkdir -p /c/Users/runneradmin/.conan && cp conan_remotes.json /c/Users/runneradmin/.conan/remotes.json" + bash -c "curl -Lo mkn.exe https://github.com/mkn/mkn/releases/download/latest/mkn.exe" bash -c 'KLOG=3 ./mkn clean build -dtKOp test -a "-EHsc -std:c++17"' - - diff --git a/.sublime-project b/.sublime-project new file mode 100644 index 0000000..30e6209 --- /dev/null +++ b/.sublime-project @@ -0,0 +1,20 @@ +{ + "folders": + [ + { + "path": ".", + }, + ], + "settings": + { + "ClangFormat": + { + "binary": "clang-format", + "format_on_save": true, + "style": "file", + }, + "python-black": { + "format_on_save": "on", + }, + }, +} diff --git a/.sublime-project.sublime-workspace b/.sublime-project.sublime-workspace new file mode 100644 index 0000000..5a07207 --- /dev/null +++ b/.sublime-project.sublime-workspace @@ -0,0 +1,3 @@ +{ + "project": ".sublime-project" +} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 445a499..0000000 --- a/.travis.yml +++ /dev/null @@ -1,45 +0,0 @@ - -git: - depth: 3 -matrix: - include: - - os: linux - dist: bionic - sudo: required - compiler: gcc - addons: - apt: - sources: - - sourceline: 'ppa:ubuntu-toolchain-r/test' - packages: - - g++-8 - env: - - MATRIX_EVAL="CC=gcc-8 && CXX=g++-8" - - os: osx - sudo: required - osx_image: xcode11 - compiler: clang - -before_install: - - | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - brew update - brew install openssl - brew unlink openssl && brew link openssl --force - fi -script: - - set -e - - | - export MKN_LIB_LINK_LIB="1" KUL_GIT_CO="--depth 3" KLOG="3" - git clone https://github.com/Dekken/maiken -b master --depth 3 maiken - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - SSL="/usr/local/opt/openssl@1.1" - make bsd -C maiken CXX=clang++ && cp maiken/mkn . - ./mkn build -dtOa "-std=c++14" -l "-pthread -ldl" -p test run -b ${SSL}/include -B ${SSL}/lib - fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then - eval "${MATRIX_EVAL}" - export CC CXX - make nix -C maiken && cp maiken/mkn . - ./mkn build -dtOa "-std=c++14 -fPIC" -l "-pthread -ldl" -p test run - fi diff --git a/LICENSE.md b/LICENSE.md index 9a1802b..a89b593 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,4 @@ -Copyright (c) 2013, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/README.noformat b/README.noformat index 39514ee..d113281 100644 --- a/README.noformat +++ b/README.noformat @@ -6,17 +6,10 @@ C++ Remote Applications Management Convenience library providing cross platform http/https services How to use: -view tst/kul.ram.test.hpp +view test/usage.cpp License: BSD -OpenSSL on Windows found @ - https://www.npcglib.org/~stathis/blog/precompiled-openssl/ - -mkn command for compiling with windows looks like - - mkn clean build -dtKa "-EHsc -Zc:inline -O2 -MT" -l "libsslMT.lib libcryptoMT.lib Crypt32.lib User32.lib" - Switches - OSX is considered BSD for swiches unless otherwise noted Key __MKN_RAM_TCP_BIND_SOCKTOPTS__ diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 5cb6a9b..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,25 +0,0 @@ -version: 0.1.{build} -image: Visual Studio 2019 -init: git config --global core.autocrlf input -clone_depth: 1 -hosts: - queue-server: 127.0.0.1 - db.server.com: 127.0.0.2 -platform: x64 -configuration: Release -cache: - - C:\ProgramData\chocolatey\bin -> appveyor.yml - - C:\ProgramData\chocolatey\lib -> appveyor.yml -build_script: - - SET PATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.23.28105\bin\Hostx64\x64;C:\Program Files\Git\usr\bin;%PATH% - - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat" - - curl -Lo mkn.exe https://github.com/PhilipDeegan/maiken/releases/download/latest/mkn.exe - - SET MKN_CL_PREFERRED=1 - - SET KLOG=3 - - rm "C:\Program Files\Git\usr\bin\link.exe" # messes with msvc link.exe - - SET PYTHON=C:\Python37-x64\python.exe - - C:\Python37-x64\Scripts\pip install wheel --upgrade - - C:\Python37-x64\Scripts\pip install conan flawfinder --upgrade - - bash -c "mkdir -p /c/Users/appveyor/.conan && cp remotes.json /c/Users/appveyor/.conan/remotes.json" - - mkn clean build -dtKOp usage -a "-EHsc -std:c++17" - - C:\Python37-x64\Scripts\flawfinder.exe . diff --git a/conanfile.txt b/conanfile.txt index 94815ef..35285f5 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -1,2 +1,2 @@ [requires] -OpenSSL/1.1.0k@conan/stable +openssl/3.2.2 diff --git a/inc/mkn/ram/asio/fcgi.hpp b/inc/mkn/ram/asio/fcgi.hpp index c96df95..aa4395c 100644 --- a/inc/mkn/ram/asio/fcgi.hpp +++ b/inc/mkn/ram/asio/fcgi.hpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2016, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -44,7 +44,8 @@ namespace fcgi { class Exception : public mkn::kul::Exception { public: - Exception(const char* f, const uint16_t& l, const std::string& s) : mkn::kul::Exception(f, l, s) {} + Exception(const char* f, const uint16_t& l, const std::string& s) + : mkn::kul::Exception(f, l, s) {} }; class Server; diff --git a/inc/mkn/ram/html/def.hpp b/inc/mkn/ram/html/def.hpp index b68e5a4..dff1d2b 100644 --- a/inc/mkn/ram/html/def.hpp +++ b/inc/mkn/ram/html/def.hpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2016, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/inc/mkn/ram/html/page.hpp b/inc/mkn/ram/html/page.hpp index 345e6df..a8c16b2 100644 --- a/inc/mkn/ram/html/page.hpp +++ b/inc/mkn/ram/html/page.hpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2016, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/inc/mkn/ram/html/tag.hpp b/inc/mkn/ram/html/tag.hpp index e38144b..ce8c778 100644 --- a/inc/mkn/ram/html/tag.hpp +++ b/inc/mkn/ram/html/tag.hpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2016, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -31,11 +31,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef _MKN_RAM_HTML_TAG_HPP_ #define _MKN_RAM_HTML_TAG_HPP_ +#include "mkn/kul/except.hpp" #include "mkn/kul/log.hpp" #include "mkn/kul/map.hpp" -#include "mkn/kul/except.hpp" #include "mkn/kul/string.hpp" - #include "mkn/ram/html/def.hpp" namespace mkn { @@ -134,7 +133,8 @@ namespace tag { class Exception : public mkn::kul::Exception { public: - Exception(const char* f, const uint16_t& l, const std::string& s) : mkn::kul::Exception(f, l, s) {} + Exception(const char* f, const uint16_t& l, const std::string& s) + : mkn::kul::Exception(f, l, s) {} }; class Named : public Tag { diff --git a/inc/mkn/ram/html4.hpp b/inc/mkn/ram/html4.hpp index 0f95d4d..1d9cf81 100644 --- a/inc/mkn/ram/html4.hpp +++ b/inc/mkn/ram/html4.hpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2016, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -39,7 +39,8 @@ namespace html4 { class Exception : public mkn::kul::Exception { public: - Exception(const char* f, const uint16_t& l, const std::string& s) : mkn::kul::Exception(f, l, s) {} + Exception(const char* f, const uint16_t& l, const std::string& s) + : mkn::kul::Exception(f, l, s) {} }; } // namespace html4 diff --git a/inc/mkn/ram/http.hpp b/inc/mkn/ram/http.hpp index 97684c1..8616f3e 100644 --- a/inc/mkn/ram/http.hpp +++ b/inc/mkn/ram/http.hpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2013, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -35,7 +35,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef _MKN_RAM_HTTP_HPP_ #define _MKN_RAM_HTTP_HPP_ - #include "mkn/kul/map.hpp" #include "mkn/kul/string.hpp" #include "mkn/ram/tcp.hpp" @@ -48,7 +47,8 @@ typedef std::unordered_map Headers; class Exception : public mkn::kul::Exception { public: - Exception(const char* f, const uint16_t& l, const std::string& s) : mkn::kul::Exception(f, l, s) {} + Exception(const char* f, const uint16_t& l, const std::string& s) + : mkn::kul::Exception(f, l, s) {} }; class Cookie { diff --git a/inc/mkn/ram/http/def.hpp b/inc/mkn/ram/http/def.hpp index 668022b..9e9a1ef 100644 --- a/inc/mkn/ram/http/def.hpp +++ b/inc/mkn/ram/http/def.hpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2016, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -33,10 +33,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef _MKN_RAM_HTTP_SESSION_TTL_ #define _MKN_RAM_HTTP_SESSION_TTL_ 600 // seconds -#endif /* _MKN_RAM_HTTP_SESSION_TTL_ */ +#endif /* _MKN_RAM_HTTP_SESSION_TTL_ */ #ifndef _MKN_RAM_HTTP_SESSION_CHECK_ #define _MKN_RAM_HTTP_SESSION_CHECK_ 10000 // milliseconds to sleep between checks -#endif /* _MKN_RAM_HTTP_SESSION_CHECK_ */ +#endif /* _MKN_RAM_HTTP_SESSION_CHECK_ */ #endif /* _MKN_RAM_HTTP_DEF_HPP_ */ diff --git a/inc/mkn/ram/http/session.hpp b/inc/mkn/ram/http/session.hpp index 1a44bee..cf4e294 100644 --- a/inc/mkn/ram/http/session.hpp +++ b/inc/mkn/ram/http/session.hpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2016, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -31,10 +31,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef _MKN_RAM_HTTP_SESSION_HPP_ #define _MKN_RAM_HTTP_SESSION_HPP_ -#include "mkn/ram/http.hpp" -#include "mkn/ram/http/def.hpp" #include "mkn/kul/threads.hpp" #include "mkn/kul/time.hpp" +#include "mkn/ram/http.hpp" +#include "mkn/ram/http/def.hpp" namespace mkn { namespace ram { diff --git a/inc/mkn/ram/https.hpp b/inc/mkn/ram/https.hpp index 08c9ec8..7b6615a 100644 --- a/inc/mkn/ram/https.hpp +++ b/inc/mkn/ram/https.hpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2013, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -38,7 +38,8 @@ namespace ram { namespace https { class Exception : public mkn::kul::Exception { public: - Exception(const char* f, const uint16_t& l, const std::string& s) : mkn::kul::Exception(f, l, s) {} + Exception(const char* f, const uint16_t& l, const std::string& s) + : mkn::kul::Exception(f, l, s) {} }; } // namespace https } // namespace ram @@ -50,6 +51,4 @@ class Exception : public mkn::kul::Exception { #include "mkn/ram/os/nixish/https.hpp" #endif - - #endif //_MKN_RAM_INCLUDE_HTTPS_HPP_ diff --git a/inc/mkn/ram/mpi.hpp b/inc/mkn/ram/mpi.hpp index 5081bbf..ae5865f 100644 --- a/inc/mkn/ram/mpi.hpp +++ b/inc/mkn/ram/mpi.hpp @@ -1,6 +1,6 @@ /** -Copyright (c) 2013, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -40,7 +40,8 @@ namespace mpi { class Exception : public mkn::kul::Exception { public: - Exception(const char* f, const uint16_t& l, const std::string& s) : mkn::kul::Exception(f, l, s) {} + Exception(const char* f, const uint16_t& l, const std::string& s) + : mkn::kul::Exception(f, l, s) {} }; template diff --git a/inc/mkn/ram/os/nixish/http.hpp b/inc/mkn/ram/os/nixish/http.hpp index 8402e18..fa27d21 100644 --- a/inc/mkn/ram/os/nixish/http.hpp +++ b/inc/mkn/ram/os/nixish/http.hpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2013, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -34,9 +34,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include "mkn/kul/threads.hpp" - -#include "mkn/ram/tcp.hpp" #include "mkn/ram/http/def.hpp" +#include "mkn/ram/tcp.hpp" namespace mkn { namespace ram { @@ -48,13 +47,13 @@ class Server : public mkn::ram::http::AServer { std::unordered_map> inBuffers; protected: - virtual char *getOrCreateBufferFor(int const& fd) { + virtual char *getOrCreateBufferFor(int const &fd) { if (!inBuffers.count(fd)) inBuffers.insert(std::make_pair(fd, std::unique_ptr(new char[fdSize]))); return inBuffers[fd].get(); } - virtual bool receive(std::map &fds, int const& fd) override; + virtual bool receive(std::map &fds, int const &fd) override; public: Server(const short &p = 80) : AServer(p) {} @@ -68,7 +67,7 @@ class MultiServer : public mkn::ram::http::Server { mkn::kul::ConcurrentThreadPool<> _acceptPool; mkn::kul::ConcurrentThreadPool<> _workerPool; - virtual void handleBuffer(std::map &fds, int const& fd, char *in, int const& read, + virtual void handleBuffer(std::map &fds, int const &fd, char *in, int const &read, int &e) override { _workerPool.async( std::bind(&MultiServer::operateBuffer, std::ref(*this), &fds, fd, in, read, e), @@ -76,7 +75,7 @@ class MultiServer : public mkn::ram::http::Server { e = 1; } - void operateBuffer(std::map *fds, int const& fd, char *in, int const& read, + void operateBuffer(std::map *fds, int const &fd, char *in, int const &read, int &e) { mkn::ram::http::Server::handleBuffer(*fds, fd, in, read, e); if (e <= 0) { @@ -84,9 +83,9 @@ class MultiServer : public mkn::ram::http::Server { closeFDs(*fds, del); } } - virtual void errorBuffer( mkn::kul::Exception const& e) { KERR << e.stack(); }; + virtual void errorBuffer(mkn::kul::Exception const &e) { KERR << e.stack(); }; - void operateAccept(size_t const& threadID) { + void operateAccept(size_t const &threadID) { std::map fds; fds.insert(std::make_pair(0, 0)); for (size_t i = threadID; i < _MKN_RAM_TCP_MAX_CLIENT_; i += _acceptThreads) @@ -129,7 +128,7 @@ class MultiServer : public mkn::ram::http::Server { _acceptPool.interrupt(); _workerPool.interrupt(); } - auto& exception() const { return _acceptPool.exception(); } + auto &exception() const { return _acceptPool.exception(); } }; } // namespace http } // namespace ram diff --git a/inc/mkn/ram/os/nixish/https.hpp b/inc/mkn/ram/os/nixish/https.hpp index 7b4df43..a7e2177 100644 --- a/inc/mkn/ram/os/nixish/https.hpp +++ b/inc/mkn/ram/os/nixish/https.hpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2013, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -31,12 +31,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef _MKN_RAM_OS_NIXISH_HTTPS_HPP_ #define _MKN_RAM_OS_NIXISH_HTTPS_HPP_ -#include -#include - #include +#include #include #include +#include #include #include @@ -56,8 +55,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endif /* OPENSSL_VERSION_NUMBER < 0x10100000L */ #endif /* _MKN_RAM_HTTPS_METHOD_ */ -#define _MKN_RAM_HTTPS_CLIENT_METHOD_ MKN_RAM_HTTPS_METHOD_APPENDER(_MKN_RAM_HTTPS_METHOD_, _client_method) -#define _MKN_RAM_HTTPS_SERVER_METHOD_ MKN_RAM_HTTPS_METHOD_APPENDER(_MKN_RAM_HTTPS_METHOD_, _server_method) +#define _MKN_RAM_HTTPS_CLIENT_METHOD_ \ + MKN_RAM_HTTPS_METHOD_APPENDER(_MKN_RAM_HTTPS_METHOD_, _client_method) +#define _MKN_RAM_HTTPS_SERVER_METHOD_ \ + MKN_RAM_HTTPS_METHOD_APPENDER(_MKN_RAM_HTTPS_METHOD_, _server_method) #else @@ -84,15 +85,16 @@ class Server : public mkn::ram::http::Server { virtual void loop(std::map &fds) KTHROW(mkn::ram::tcp::Exception) override; - virtual bool receive(std::map &fds, int const& fd) override; + virtual bool receive(std::map &fds, int const &fd) override; - virtual void handleBuffer(std::map &fds, int const& fd, char *in, int const& read, + virtual void handleBuffer(std::map &fds, int const &fd, char *in, int const &read, int &e) override; public: - Server(const short &p, const mkn::kul::File &c, const mkn::kul::File &k, std::string const& cs = "") + Server(const short &p, const mkn::kul::File &c, const mkn::kul::File &k, + std::string const &cs = "") : mkn::ram::http::Server(p), crt(c), key(k), cs(cs) {} - Server(const mkn::kul::File &c, const mkn::kul::File &k, std::string const& cs = "") + Server(const mkn::kul::File &c, const mkn::kul::File &k, std::string const &cs = "") : mkn::ram::https::Server(443, c, k, cs) {} virtual ~Server() { if (s) stop(); @@ -109,7 +111,7 @@ class MultiServer : public mkn::ram::https::Server { mkn::kul::ChroncurrentThreadPool<> _acceptPool; mkn::kul::ChroncurrentThreadPool<> _workerPool; - void operateAccept(size_t const& threadID) { + void operateAccept(size_t const &threadID) { KUL_DBG_FUNC_ENTER std::map fds; fds.insert(std::make_pair(0, 0)); @@ -130,7 +132,7 @@ class MultiServer : public mkn::ram::https::Server { KEXCEPTION("SHOULD NOT HAPPEN"); } - virtual void handleBuffer(std::map &fds, int const& fd, char *in, int const& read, + virtual void handleBuffer(std::map &fds, int const &fd, char *in, int const &read, int &e) override { KUL_DBG_FUNC_ENTER _workerPool.async( @@ -139,7 +141,7 @@ class MultiServer : public mkn::ram::https::Server { e = 1; } - void operateBuffer(std::map *fds, int const& fd, char *in, int const& read, + void operateBuffer(std::map *fds, int const &fd, char *in, int const &read, int &e) { KUL_DBG_FUNC_ENTER mkn::ram::https::Server::handleBuffer(*fds, fd, in, read, e); @@ -157,7 +159,7 @@ class MultiServer : public mkn::ram::https::Server { public: MultiServer(const short &p, const uint8_t &acceptThreads, const uint8_t &workerThreads, - const mkn::kul::File &c, const mkn::kul::File &k, std::string const& cs = "") + const mkn::kul::File &c, const mkn::kul::File &k, std::string const &cs = "") : mkn::ram::https::Server(p, c, k, cs), _acceptThreads(acceptThreads), _workerThreads(workerThreads), @@ -168,7 +170,7 @@ class MultiServer : public mkn::ram::https::Server { if (workerThreads < 1) KEXCEPTION("MultiServer cannot have less than one threads for working"); } MultiServer(const uint8_t &acceptThreads, const uint8_t &workerThreads, const mkn::kul::File &c, - const mkn::kul::File &k, std::string const& cs = "") + const mkn::kul::File &k, std::string const &cs = "") : MultiServer(443, acceptThreads, workerThreads, c, k, cs) {} virtual ~MultiServer() { @@ -229,13 +231,13 @@ class A1_1Request { class Requester { public: - static void send(std::string const& h, std::string const& req, uint16_t const& p, + static void send(std::string const &h, std::string const &req, uint16_t const &p, std::stringstream &ss, SSL *ssl); }; class _1_1GetRequest : public http::_1_1GetRequest, https::A1_1Request { public: - _1_1GetRequest(std::string const& host, std::string const& path = "", uint16_t const& port = 443) + _1_1GetRequest(std::string const &host, std::string const &path = "", uint16_t const &port = 443) : http::_1_1GetRequest(host, path, port) {} virtual ~_1_1GetRequest() {} virtual void send() KTHROW(mkn::ram::http::Exception) override; @@ -244,7 +246,7 @@ using Get = _1_1GetRequest; class _1_1PostRequest : public http::_1_1PostRequest, https::A1_1Request { public: - _1_1PostRequest(std::string const& host, std::string const& path = "", uint16_t const& port = 443) + _1_1PostRequest(std::string const &host, std::string const &path = "", uint16_t const &port = 443) : http::_1_1PostRequest(host, path, port) {} virtual void send() KTHROW(mkn::ram::http::Exception) override; }; diff --git a/inc/mkn/ram/os/nixish/tcp.hpp b/inc/mkn/ram/os/nixish/tcp.hpp index 431d819..794e851 100644 --- a/inc/mkn/ram/os/nixish/tcp.hpp +++ b/inc/mkn/ram/os/nixish/tcp.hpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2013, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -41,13 +41,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include + #include #include #include "mkn/kul/byte.hpp" #include "mkn/kul/log.hpp" -#include "mkn/ram/tcp/def.hpp" #include "mkn/kul/time.hpp" +#include "mkn/ram/tcp/def.hpp" #ifndef __MKN_RAM_TCP_BIND_SOCKTOPTS__ #define __MKN_RAM_TCP_BIND_SOCKTOPTS__ SO_REUSEADDR @@ -66,7 +67,7 @@ class Socket : public ASocket { virtual ~Socket() { if (this->open) close(); } - virtual bool connect(std::string const& host, int16_t const& port) override { + virtual bool connect(std::string const &host, int16_t const &port) override { KUL_DBG_FUNC_ENTER if (!SOCKET(sck) || !CONNECT(sck, host, port)) return false; this->open = true; @@ -81,11 +82,12 @@ class Socket : public ASocket { } return o1; } - virtual size_t read(T *data, size_t const& len) { + virtual size_t read(T *data, size_t const &len) { bool more = false; return read(data, len, more); } - virtual size_t read(T *data, size_t const& len, bool &more) KTHROW(mkn::ram::tcp::Exception) override { + virtual size_t read(T *data, size_t const &len, bool &more) + KTHROW(mkn::ram::tcp::Exception) override { KUL_DBG_FUNC_ENTER struct timeval tv; fd_set fds; @@ -149,18 +151,18 @@ class Socket : public ASocket { } return ret; } - virtual size_t write(const T *data, size_t const& len) override { + virtual size_t write(const T *data, size_t const &len) override { return ::send(sck, data, len, 0); } - static bool SOCKET(int &sck, int16_t const& domain = AF_INET, int16_t const& type = SOCK_STREAM, - int16_t const& protocol = IPPROTO_TCP) { + static bool SOCKET(int &sck, int16_t const &domain = AF_INET, int16_t const &type = SOCK_STREAM, + int16_t const &protocol = IPPROTO_TCP) { KUL_DBG_FUNC_ENTER sck = socket(domain, type, protocol); if (sck < 0) KLOG(ERR) << "SOCKET ERROR CODE: " << sck; return sck >= 0; } - static bool CONNECT(int const& sck, std::string const& host, int16_t const& port) { + static bool CONNECT(int const &sck, std::string const &host, int16_t const &port) { KUL_DBG_FUNC_ENTER struct sockaddr_in servAddr; memset(&servAddr, 0, sizeof(servAddr)); @@ -208,7 +210,7 @@ class SocketServer : public ASocketServer { socklen_t clilen; struct sockaddr_in serv_addr, cli_addr[_MKN_RAM_TCP_MAX_CLIENT_]; - virtual bool handle(T *const in, size_t const& inLen, T *const out, size_t &outLen) { + virtual bool handle(T *const in, size_t const &inLen, T *const out, size_t &outLen) { // default overridable function (void)in; (void)inLen; @@ -217,7 +219,7 @@ class SocketServer : public ASocketServer { return true; } - virtual int readFrom(int const& fd, T *in, int opts = 0) { + virtual int readFrom(int const &fd, T *in, int opts = 0) { size_t size = 0; int64_t val = 0; while (1) { @@ -228,10 +230,10 @@ class SocketServer : public ASocketServer { } return size; } - virtual int writeTo(int const& fd, const T *const out, size_t size) { + virtual int writeTo(int const &fd, const T *const out, size_t size) { return ::send(m_fds[fd].fd, out, size, 0); } - virtual bool receive(std::map &fds, int const& fd) { + virtual bool receive(std::map &fds, int const &fd) { (void)fds; KUL_DBG_FUNC_ENTER T in[_MKN_RAM_TCP_READ_BUFFER_]; @@ -319,17 +321,17 @@ class SocketServer : public ASocketServer { mkn::kul::this_thread::sleep(timeout); return 0; } else if (errno == 2 || errno == 17 || errno == 32) { - // skip + // skip } else if (errno) { KLOG(ERR) << std::to_string(errno) << " - " << std::string(strerror(errno)); return -1; } return p; } - virtual int accept(int const& fd) { + virtual int accept(int const &fd) { return ::accept(lisock, (struct sockaddr *)&cli_addr[fd], &clilen); } - virtual void validAccept(std::map &fds, int const& newlisock, int const& nfd) { + virtual void validAccept(std::map &fds, int const &newlisock, int const &nfd) { KUL_DBG_FUNC_ENTER; KOUT(DBG) << "New connection , socket fd is " << newlisock << ", is : " << inet_ntoa(cli_addr[nfd].sin_addr) @@ -342,7 +344,7 @@ class SocketServer : public ASocketServer { } public: - SocketServer(uint16_t const& p, bool _bind = 1) : mkn::ram::tcp::ASocketServer(p) { + SocketServer(uint16_t const &p, bool _bind = 1) : mkn::ram::tcp::ASocketServer(p) { if (_bind) bind(__MKN_RAM_TCP_BIND_SOCKTOPTS__); memset(m_fds, 0, sizeof(m_fds)); } @@ -368,8 +370,9 @@ class SocketServer : public ASocketServer { bzero((char *)&serv_addr, sizeof(serv_addr)); serv_addr.sin_family = AF_INET; serv_addr.sin_addr.s_addr = INADDR_ANY; - serv_addr.sin_port = !kul::byte::isBigEndian() ? htons(this->port()) - : mkn::kul::byte::LittleEndian::UINT32(this->port()); + serv_addr.sin_port = !kul::byte::isBigEndian() + ? htons(this->port()) + : mkn::kul::byte::LittleEndian::UINT32(this->port()); int16_t e = 0; if ((e = ::bind(lisock, (struct sockaddr *)&serv_addr, sizeof(serv_addr))) < 0) { KERR << std::to_string(errno) << " - " << std::string(strerror(errno)); diff --git a/inc/mkn/ram/os/win/http.hpp b/inc/mkn/ram/os/win/http.hpp index 29395ae..e3f8ecd 100644 --- a/inc/mkn/ram/os/win/http.hpp +++ b/inc/mkn/ram/os/win/http.hpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2013, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/inc/mkn/ram/os/win/https.hpp b/inc/mkn/ram/os/win/https.hpp index e636d27..0d68a96 100644 --- a/inc/mkn/ram/os/win/https.hpp +++ b/inc/mkn/ram/os/win/https.hpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2013, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -31,12 +31,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef _MKN_RAM_OS_WIN_HTTPS_HPP_ #define _MKN_RAM_OS_WIN_HTTPS_HPP_ -#include -#include - #include +#include #include #include +#include #include #include "mkn/ram/http.hpp" @@ -50,8 +49,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define _MKN_RAM_HTTPS_METHOD_ TLS #endif /* _MKN_RAM_HTTPS_METHOD_ */ -#define _MKN_RAM_HTTPS_CLIENT_METHOD_ MKN_RAM_HTTPS_METHOD_APPENDER(_MKN_RAM_HTTPS_METHOD_, _client_method) -#define _MKN_RAM_HTTPS_SERVER_METHOD_ MKN_RAM_HTTPS_METHOD_APPENDER(_MKN_RAM_HTTPS_METHOD_, _server_method) +#define _MKN_RAM_HTTPS_CLIENT_METHOD_ \ + MKN_RAM_HTTPS_METHOD_APPENDER(_MKN_RAM_HTTPS_METHOD_, _client_method) +#define _MKN_RAM_HTTPS_SERVER_METHOD_ \ + MKN_RAM_HTTPS_METHOD_APPENDER(_MKN_RAM_HTTPS_METHOD_, _server_method) #else @@ -76,7 +77,8 @@ class Server : public mkn::ram::http::Server { mkn::kul::File crt, key; const std::string cs; - virtual KUL_PUBLISH void loop(std::map& fds) KTHROW(mkn::ram::tcp::Exception) override; + virtual KUL_PUBLISH void loop(std::map& fds) + KTHROW(mkn::ram::tcp::Exception) override; virtual KUL_PUBLISH bool receive(std::map& fds, const int& fd) override; @@ -84,7 +86,8 @@ class Server : public mkn::ram::http::Server { const int& read, int& e); public: - Server(const short& p, const mkn::kul::File& c, const mkn::kul::File& k, const std::string& cs = "") + Server(const short& p, const mkn::kul::File& c, const mkn::kul::File& k, + const std::string& cs = "") : mkn::ram::http::Server(p), crt(c), key(k), cs(cs) {} Server(mkn::kul::File const& c, mkn::kul::File const& k, std::string const& cs = "") : mkn::ram::https::Server(443, c, k, cs) {} diff --git a/inc/mkn/ram/os/win/tcp.hpp b/inc/mkn/ram/os/win/tcp.hpp index 16b354b..58ddd7b 100644 --- a/inc/mkn/ram/os/win/tcp.hpp +++ b/inc/mkn/ram/os/win/tcp.hpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2013, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -36,13 +36,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #undef UNICODE #define WIN32_LEAN_AND_MEAN +#include +#include #include #include #include -#include -#include - #include #include diff --git a/inc/mkn/ram/tcp.hpp b/inc/mkn/ram/tcp.hpp index cf76659..3fb4663 100644 --- a/inc/mkn/ram/tcp.hpp +++ b/inc/mkn/ram/tcp.hpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2013, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -39,7 +39,8 @@ namespace tcp { class Exception : public mkn::kul::Exception { public: - Exception(const char* f, const uint16_t& l, const std::string& s) : mkn::kul::Exception(f, l, s) {} + Exception(const char* f, const uint16_t& l, const std::string& s) + : mkn::kul::Exception(f, l, s) {} }; template @@ -79,7 +80,6 @@ class ASocketServer { } // namespace ram } // namespace mkn - #if defined(_WIN32) #include "mkn/ram/os/win/tcp.hpp" #else diff --git a/inc/mkn/ram/tcp/def.hpp b/inc/mkn/ram/tcp/def.hpp index bc6f898..26f39ee 100644 --- a/inc/mkn/ram/tcp/def.hpp +++ b/inc/mkn/ram/tcp/def.hpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2016, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -33,11 +33,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef _MKN_RAM_TCP_SESSION_TTL_ #define _MKN_RAM_TCP_SESSION_TTL_ 600 // seconds -#endif /* _MKN_RAM_TCP_SESSION_TTL_ */ +#endif /* _MKN_RAM_TCP_SESSION_TTL_ */ #ifndef _MKN_RAM_TCP_SESSION_CHECK_ #define _MKN_RAM_TCP_SESSION_CHECK_ 10000 // milliseconds to sleep between checks -#endif /* _MKN_RAM_TCP_SESSION_CHECK_ */ +#endif /* _MKN_RAM_TCP_SESSION_CHECK_ */ #ifndef _MKN_RAM_TCP_READ_BUFFER_ #define _MKN_RAM_TCP_READ_BUFFER_ 963210 diff --git a/lgtm.yml b/lgtm.yml deleted file mode 100644 index 937fa79..0000000 --- a/lgtm.yml +++ /dev/null @@ -1,10 +0,0 @@ -extraction: - cpp: - prepare: - packages: "build-essential" - configure: - command: - - git clone https://github.com/PhilipDeegan/maiken -b master --depth 1 maiken - - cd maiken; make nix; mv mkn ..; cd ..; rm -rf maiken - index: - build_command: ./mkn diff --git a/mkn.yaml b/mkn.yaml index 2513409..99efc0a 100644 --- a/mkn.yaml +++ b/mkn.yaml @@ -5,66 +5,66 @@ name: mkn.ram parent: lib profile: - - name: base - inc: ./inc - src: ./src - if_src: - bsd: ./os/nixish/src - nix: ./os/nixish/src - win: ./os/win/src +- name: base + inc: ./inc + src: ./src + if_src: + bsd: ./os/nixish/src + nix: ./os/nixish/src + win: ./os/win/src - - name: lib - parent: base - dep: mkn.kul - if_arg: - win_shared: -DKUL_SHARED -DKUL_EXPORT +- name: lib + parent: base + dep: mkn.kul + if_arg: + win_shared: -DKUL_SHARED -DKUL_EXPORT - - name: https - parent: lib - arg: -D_MKN_RAM_INCLUDE_HTTPS_ - if_mod: - win: - - name: conan.install - init: - install: -s compiler="Visual Studio" - if_lib: - nix: ssl crypto - bsd: ssl crypto - win: User32 Crypt32 libssl libcrypto +- name: https + parent: lib + arg: -D_MKN_RAM_INCLUDE_HTTPS_ + if_mod: + win: + - name: conan.install + init: + install: -s compiler="Visual Studio" + if_lib: + nix: ssl crypto + bsd: ssl crypto + win: User32 Crypt32 libssl libcrypto - - name: fcgi - parent: lib - arg: -D_KUL_INCLUDE_FCGI_ +- name: fcgi + parent: lib + arg: -D_KUL_INCLUDE_FCGI_ - - name: usage - self: https - main: usage.cpp - arg: -D_MKN_RAM_INCLUDE_HTTPS_ - if_link: - win_cl: -nodefaultlib:libucrt.lib ucrt.lib +- name: usage + self: https + main: test/usage.cpp + arg: -D_MKN_RAM_INCLUDE_HTTPS_ + if_link: + win_cl: -nodefaultlib:libucrt.lib ucrt.lib - - name: test_fcgi - main: test/fcgi.cpp - self: fcgi +- name: test_fcgi + main: test/fcgi.cpp + self: fcgi - - name: test - self: https - mode: none - main: test.cpp +- name: test + self: https + mode: none + main: test/test.cpp - - name: test.client - parent: lib - main: test/client.cpp +- name: test.client + parent: lib + main: test/client.cpp - - name: test.server - parent: lib - main: test/server.cpp +- name: test.server + parent: lib + main: test/server.cpp - - name: format - mod: - - name: clang.format - init: - style: file - types: cpp:cxx:cc:h:hpp - paths: . - args: -D_MKN_RAM_INCLUDE_HTTPS_ +- name: format + mod: + - name: clang.format + init: + style: file + types: cpp:cxx:cc:h:hpp + paths: . + args: -D_MKN_RAM_INCLUDE_HTTPS_ diff --git a/os/nixish/inc/mkn/ram/http.hpp b/os/nixish/inc/mkn/ram/http.hpp index 1d8b4d8..ea531b5 100644 --- a/os/nixish/inc/mkn/ram/http.hpp +++ b/os/nixish/inc/mkn/ram/http.hpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2013, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -33,11 +33,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#include "mkn/ram/http.hpp" #include "mkn/kul/http/def.hpp" -#include "mkn/ram/tcp.hpp" - #include "mkn/kul/threads.hpp" +#include "mkn/ram/http.hpp" +#include "mkn/ram/tcp.hpp" namespace mkn { namespace ram { @@ -49,13 +48,13 @@ class Server : public mkn::ram::http::AServer { std::unordered_map> inBuffers; protected: - virtual char *getOrCreateBufferFor(int const& fd) { + virtual char *getOrCreateBufferFor(int const &fd) { if (!inBuffers.count(fd)) inBuffers.insert(std::make_pair(fd, std::unique_ptr(new char[fdSize]))); return inBuffers[fd].get(); } - virtual bool receive(std::map &fds, int const& fd) override; + virtual bool receive(std::map &fds, int const &fd) override; public: Server(const short &p = 80) : AServer(p) {} @@ -69,7 +68,7 @@ class MultiServer : public mkn::ram::http::Server { ConcurrentThreadPool<> _acceptPool; ConcurrentThreadPool<> _workerPool; - virtual void handleBuffer(std::map &fds, int const& fd, char *in, int const& read, + virtual void handleBuffer(std::map &fds, int const &fd, char *in, int const &read, int &e) override { _workerPool.async( std::bind(&MultiServer::operateBuffer, std::ref(*this), &fds, fd, in, read, e), @@ -77,7 +76,7 @@ class MultiServer : public mkn::ram::http::Server { e = 1; } - void operateBuffer(std::map *fds, int const& fd, char *in, int const& read, + void operateBuffer(std::map *fds, int const &fd, char *in, int const &read, int &e) { mkn::ram::http::Server::handleBuffer(*fds, fd, in, read, e); if (e <= 0) { @@ -87,7 +86,7 @@ class MultiServer : public mkn::ram::http::Server { } virtual void errorBuffer(const mkn::kul::Exception &e) { KERR << e.stack(); }; - void operateAccept(size_t const& threadID) { + void operateAccept(size_t const &threadID) { std::map fds; fds.insert(std::make_pair(0, 0)); for (size_t i = threadID; i < _MKN_RAM_TCP_MAX_CLIENT_; i += _acceptThreads) @@ -134,6 +133,6 @@ class MultiServer : public mkn::ram::http::Server { }; } // namespace http } // namespace ram -} // namespace kul +} // namespace mkn #endif /* _MKN_RAM_NIXISH_HTTP_HPP_ */ diff --git a/os/nixish/inc/mkn/ram/https.hpp b/os/nixish/inc/mkn/ram/https.hpp index 6bc532c..1d4fd8c 100644 --- a/os/nixish/inc/mkn/ram/https.hpp +++ b/os/nixish/inc/mkn/ram/https.hpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2013, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -31,15 +31,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef _MKN_RAM_NIXISH_HTTPS_HPP_ #define _MKN_RAM_NIXISH_HTTPS_HPP_ -#include -#include - #include +#include #include #include +#include #include #include + #include "mkn/ram/http.hpp" #define MKN_RAM_HTTPS_METHOD_APPENDER2(x, y) x##y @@ -55,8 +55,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #endif /* OPENSSL_VERSION_NUMBER < 0x10100000L */ #endif /* _MKN_RAM_HTTPS_METHOD_ */ -#define _MKN_RAM_HTTPS_CLIENT_METHOD_ MKN_RAM_HTTPS_METHOD_APPENDER(_MKN_RAM_HTTPS_METHOD_, _client_method) -#define _MKN_RAM_HTTPS_SERVER_METHOD_ MKN_RAM_HTTPS_METHOD_APPENDER(_MKN_RAM_HTTPS_METHOD_, _server_method) +#define _MKN_RAM_HTTPS_CLIENT_METHOD_ \ + MKN_RAM_HTTPS_METHOD_APPENDER(_MKN_RAM_HTTPS_METHOD_, _client_method) +#define _MKN_RAM_HTTPS_SERVER_METHOD_ \ + MKN_RAM_HTTPS_METHOD_APPENDER(_MKN_RAM_HTTPS_METHOD_, _server_method) #else @@ -82,20 +84,21 @@ class Server : public mkn::ram::http::Server { virtual void loop(std::map &fds) KTHROW(kul::tcp::Exception) override; - virtual bool receive(std::map &fds, int const& fd) override; + virtual bool receive(std::map &fds, int const &fd) override; - virtual void handleBuffer(std::map &fds, int const& fd, char *in, int const& read, + virtual void handleBuffer(std::map &fds, int const &fd, char *in, int const &read, int &e) override; public: - Server(const short &p, mkn::kul::File const& c, mkn::kul::File const& k, std::string const& cs = "") + Server(const short &p, mkn::kul::File const &c, mkn::kul::File const &k, + std::string const &cs = "") : mkn::ram::http::Server(p), crt(c), key(k), cs(cs) {} - Server(kul::File const& c, mkn::kul::File const& k, std::string const& cs = "") + Server(kul::File const &c, mkn::kul::File const &k, std::string const &cs = "") : mkn::ram::https::Server(443, c, k, cs) {} virtual ~Server() { if (s) Server::stop(); } - void setChain(kul::File const& f); + void setChain(kul::File const &f); Server &init(); virtual void stop() override; }; @@ -107,7 +110,7 @@ class MultiServer : public mkn::ram::https::Server { ChroncurrentThreadPool<> _acceptPool; ChroncurrentThreadPool<> _workerPool; - void operateAccept(size_t const& threadID) { + void operateAccept(size_t const &threadID) { KUL_DBG_FUNC_ENTER std::map fds; fds.insert(std::make_pair(0, 0)); @@ -128,7 +131,7 @@ class MultiServer : public mkn::ram::https::Server { KEXCEPTION("SHOULD NOT HAPPEN"); } - virtual void handleBuffer(std::map &fds, int const& fd, char *in, int const& read, + virtual void handleBuffer(std::map &fds, int const &fd, char *in, int const &read, int &e) override { KUL_DBG_FUNC_ENTER _workerPool.async( @@ -137,7 +140,7 @@ class MultiServer : public mkn::ram::https::Server { e = 1; } - void operateBuffer(std::map *fds, int const& fd, char *in, int const& read, + void operateBuffer(std::map *fds, int const &fd, char *in, int const &read, int &e) { KUL_DBG_FUNC_ENTER mkn::ram::https::Server::handleBuffer(*fds, fd, in, read, e); @@ -155,7 +158,7 @@ class MultiServer : public mkn::ram::https::Server { public: MultiServer(const short &p, const uint8_t &acceptThreads, const uint8_t &workerThreads, - mkn::kul::File const& c, mkn::kul::File const& k, std::string const& cs = "") + mkn::kul::File const &c, mkn::kul::File const &k, std::string const &cs = "") : mkn::ram::https::Server(p, c, k, cs), _acceptThreads(acceptThreads), _workerThreads(workerThreads), @@ -165,8 +168,8 @@ class MultiServer : public mkn::ram::https::Server { KEXCEPTION("MultiServer cannot have less than one threads for accepting"); if (workerThreads < 1) KEXCEPTION("MultiServer cannot have less than one threads for working"); } - MultiServer(const uint8_t &acceptThreads, const uint8_t &workerThreads, mkn::kul::File const& c, - mkn::kul::File const& k, std::string const& cs = "") + MultiServer(const uint8_t &acceptThreads, const uint8_t &workerThreads, mkn::kul::File const &c, + mkn::kul::File const &k, std::string const &cs = "") : MultiServer(443, acceptThreads, workerThreads, c, k, cs) {} virtual ~MultiServer() { @@ -227,13 +230,13 @@ class A1_1Request { class Requester { public: - static void send(std::string const& h, std::string const& req, uint16_t const& p, + static void send(std::string const &h, std::string const &req, uint16_t const &p, std::stringstream &ss, SSL *ssl); }; class _1_1GetRequest : public http::_1_1GetRequest, https::A1_1Request { public: - _1_1GetRequest(std::string const& host, std::string const& path = "", uint16_t const& port = 443) + _1_1GetRequest(std::string const &host, std::string const &path = "", uint16_t const &port = 443) : http::_1_1GetRequest(host, path, port) {} virtual ~_1_1GetRequest() {} virtual void send() KTHROW(mkn::ram::http::Exception) override; @@ -242,11 +245,11 @@ using Get = _1_1GetRequest; class _1_1PostRequest : public http::_1_1PostRequest, https::A1_1Request { public: - _1_1PostRequest(std::string const& host, std::string const& path = "", uint16_t const& port = 443) + _1_1PostRequest(std::string const &host, std::string const &path = "", uint16_t const &port = 443) : http::_1_1PostRequest(host, path, port) {} virtual void send() KTHROW(mkn::ram::http::Exception) override; }; using Post = _1_1PostRequest; } // namespace https -} // namespace kul +} // namespace mkn #endif //_MKN_RAM_NIXISH_HTTPS_HPP_ diff --git a/os/nixish/inc/mkn/ram/tcp.hpp b/os/nixish/inc/mkn/ram/tcp.hpp index ba31ced..9d13a34 100644 --- a/os/nixish/inc/mkn/ram/tcp.hpp +++ b/os/nixish/inc/mkn/ram/tcp.hpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2013, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -41,13 +41,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include + #include #include #include "mkn/kul/byte.hpp" #include "mkn/kul/log.hpp" #include "mkn/kul/time.hpp" - #include "mkn/ram/tcp.base.hpp" #include "mkn/ram/tcp/def.hpp" @@ -68,7 +68,7 @@ class Socket : public ASocket { virtual ~Socket() { if (this->open) close(); } - virtual bool connect(std::string const& host, int16_t const& port) override { + virtual bool connect(std::string const &host, int16_t const &port) override { KUL_DBG_FUNC_ENTER if (!SOCKET(sck) || !CONNECT(sck, host, port)) return false; this->open = true; @@ -83,11 +83,11 @@ class Socket : public ASocket { } return o1; } - virtual size_t read(T *data, size_t const& len) { + virtual size_t read(T *data, size_t const &len) { bool more = false; return read(data, len, more); } - virtual size_t read(T *data, size_t const& len, bool &more) KTHROW(kul::tcp::Exception) override { + virtual size_t read(T *data, size_t const &len, bool &more) KTHROW(kul::tcp::Exception) override { KUL_DBG_FUNC_ENTER struct timeval tv; fd_set fds; @@ -150,18 +150,18 @@ class Socket : public ASocket { } return ret; } - virtual size_t write(const T *data, size_t const& len) override { + virtual size_t write(const T *data, size_t const &len) override { return ::send(sck, data, len, 0); } - static bool SOCKET(int &sck, int16_t const& domain = AF_INET, int16_t const& type = SOCK_STREAM, - int16_t const& protocol = IPPROTO_TCP) { + static bool SOCKET(int &sck, int16_t const &domain = AF_INET, int16_t const &type = SOCK_STREAM, + int16_t const &protocol = IPPROTO_TCP) { KUL_DBG_FUNC_ENTER sck = socket(domain, type, protocol); if (sck < 0) KLOG(ERR) << "SOCKET ERROR CODE: " << sck; return sck >= 0; } - static bool CONNECT(int const& sck, std::string const& host, int16_t const& port) { + static bool CONNECT(int const &sck, std::string const &host, int16_t const &port) { KUL_DBG_FUNC_ENTER struct sockaddr_in servAddr; memset(&servAddr, 0, sizeof(servAddr)); @@ -209,7 +209,7 @@ class SocketServer : public ASocketServer { socklen_t clilen; struct sockaddr_in serv_addr, cli_addr[_MKN_RAM_TCP_MAX_CLIENT_]; - virtual bool handle(T *const in, size_t const& inLen, T *const out, size_t &outLen) { + virtual bool handle(T *const in, size_t const &inLen, T *const out, size_t &outLen) { // default overridable function (void)in; (void)inLen; @@ -218,7 +218,7 @@ class SocketServer : public ASocketServer { return true; } - virtual int readFrom(int const& fd, T *in, int opts = 0) { + virtual int readFrom(int const &fd, T *in, int opts = 0) { size_t size = 0; int64_t val = 0; while (1) { @@ -229,10 +229,10 @@ class SocketServer : public ASocketServer { } return size; } - virtual int writeTo(int const& fd, const T *const out, size_t size) { + virtual int writeTo(int const &fd, const T *const out, size_t size) { return ::send(m_fds[fd].fd, out, size, 0); } - virtual bool receive(std::map &fds, int const& fd) { + virtual bool receive(std::map &fds, int const &fd) { (void)fds; KUL_DBG_FUNC_ENTER T in[_MKN_RAM_TCP_READ_BUFFER_]; @@ -326,10 +326,10 @@ class SocketServer : public ASocketServer { } return p; } - virtual int accept(int const& fd) { + virtual int accept(int const &fd) { return ::accept(lisock, (struct sockaddr *)&cli_addr[fd], &clilen); } - virtual void validAccept(std::map &fds, int const& newlisock, int const& nfd) { + virtual void validAccept(std::map &fds, int const &newlisock, int const &nfd) { KUL_DBG_FUNC_ENTER; KOUT(DBG) << "New connection , socket fd is " << newlisock << ", is : " << inet_ntoa(cli_addr[nfd].sin_addr) @@ -342,7 +342,7 @@ class SocketServer : public ASocketServer { } public: - SocketServer(uint16_t const& p, bool _bind = 1) : mkn::ram::tcp::ASocketServer(p) { + SocketServer(uint16_t const &p, bool _bind = 1) : mkn::ram::tcp::ASocketServer(p) { if (_bind) bind(__MKN_RAM_TCP_BIND_SOCKTOPTS__); memset(m_fds, 0, sizeof(m_fds)); } @@ -368,8 +368,9 @@ class SocketServer : public ASocketServer { bzero((char *)&serv_addr, sizeof(serv_addr)); serv_addr.sin_family = AF_INET; serv_addr.sin_addr.s_addr = INADDR_ANY; - serv_addr.sin_port = !kul::byte::isBigEndian() ? htons(this->port()) - : mkn::kul::byte::LittleEndian::UINT32(this->port()); + serv_addr.sin_port = !kul::byte::isBigEndian() + ? htons(this->port()) + : mkn::kul::byte::LittleEndian::UINT32(this->port()); int16_t e = 0; if ((e = ::bind(lisock, (struct sockaddr *)&serv_addr, sizeof(serv_addr))) < 0) { KERR << std::to_string(errno) << " - " << std::string(strerror(errno)); diff --git a/os/nixish/src/http/multi.cpp b/os/nixish/src/http/multi.cpp index ad81c90..0542b34 100644 --- a/os/nixish/src/http/multi.cpp +++ b/os/nixish/src/http/multi.cpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2017, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/os/nixish/src/http/server.cpp b/os/nixish/src/http/server.cpp index 15869f6..edeca48 100644 --- a/os/nixish/src/http/server.cpp +++ b/os/nixish/src/http/server.cpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2016, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -30,7 +30,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "mkn/ram/http.hpp" -bool mkn::ram::http::Server::receive(std::map &fds, int const& fd) { +bool mkn::ram::http::Server::receive(std::map &fds, int const &fd) { KUL_DBG_FUNC_ENTER; char *in = getOrCreateBufferFor(fd); bzero(in, _MKN_RAM_TCP_READ_BUFFER_); diff --git a/os/nixish/src/https/multi.cpp b/os/nixish/src/https/multi.cpp index e35588b..a66d1cc 100644 --- a/os/nixish/src/https/multi.cpp +++ b/os/nixish/src/https/multi.cpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2017, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/os/nixish/src/https/request.cpp b/os/nixish/src/https/request.cpp index 250e220..3c410ca 100644 --- a/os/nixish/src/https/request.cpp +++ b/os/nixish/src/https/request.cpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2016, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -31,8 +31,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifdef _MKN_RAM_INCLUDE_HTTPS_ #include "mkn/ram/https.hpp" -void mkn::ram::https::Requester::send(std::string const& h, std::string const& req, uint16_t const& p, - std::stringstream &ss, SSL *ssl) { +void mkn::ram::https::Requester::send(std::string const &h, std::string const &req, + uint16_t const &p, std::stringstream &ss, SSL *ssl) { KUL_DBG_FUNC_ENTER int sck = 0; if (!mkn::ram::tcp::Socket::SOCKET(sck, PF_INET, SOCK_STREAM, 0)) diff --git a/os/nixish/src/https/server.cpp b/os/nixish/src/https/server.cpp index c1eb5a0..1c709ac 100644 --- a/os/nixish/src/https/server.cpp +++ b/os/nixish/src/https/server.cpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2016, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -138,8 +138,8 @@ void mkn::ram::https::Server::stop() { mkn::ram::http::Server::stop(); } -void mkn::ram::https::Server::handleBuffer(std::map &fds, int const& fd, char *in, - int const& read, int &e) { +void mkn::ram::https::Server::handleBuffer(std::map &fds, int const &fd, char *in, + int const &read, int &e) { KUL_DBG_FUNC_ENTER in[read] = '\0'; std::string res; @@ -165,7 +165,7 @@ void mkn::ram::https::Server::handleBuffer(std::map &fds, int cons fds[fd] = 1; } -bool mkn::ram::https::Server::receive(std::map &fds, int const& fd) { +bool mkn::ram::https::Server::receive(std::map &fds, int const &fd) { KUL_DBG_FUNC_ENTER char *in = getOrCreateBufferFor(fd); bzero(in, _MKN_RAM_TCP_READ_BUFFER_); diff --git a/os/win/inc/mkn/ram/http.hpp b/os/win/inc/mkn/ram/http.hpp index 85b4d63..1e1cc87 100644 --- a/os/win/inc/mkn/ram/http.hpp +++ b/os/win/inc/mkn/ram/http.hpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2013, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -39,9 +39,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define WIN32_LEAN_AND_MEAN #endif -#include "mkn/ram/http.hpp" #include "mkn/kul/log.hpp" #include "mkn/kul/threads.hpp" +#include "mkn/ram/http.hpp" #ifndef UNICODE #define UNICODE diff --git a/os/win/inc/mkn/ram/https.hpp b/os/win/inc/mkn/ram/https.hpp index aa8810f..c558862 100644 --- a/os/win/inc/mkn/ram/https.hpp +++ b/os/win/inc/mkn/ram/https.hpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2013, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -31,12 +31,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef _MKN_RAM_HTTPS_HPP_ #define _MKN_RAM_HTTPS_HPP_ -#include -#include - #include +#include #include #include +#include #include #include "mkn/ram/http.hpp" @@ -50,8 +49,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define _MKN_RAM_HTTPS_METHOD_ TLS #endif /* _MKN_RAM_HTTPS_METHOD_ */ -#define _MKN_RAM_HTTPS_CLIENT_METHOD_ MKN_RAM_HTTPS_METHOD_APPENDER(_MKN_RAM_HTTPS_METHOD_, _client_method) -#define _MKN_RAM_HTTPS_SERVER_METHOD_ MKN_RAM_HTTPS_METHOD_APPENDER(_MKN_RAM_HTTPS_METHOD_, _server_method) +#define _MKN_RAM_HTTPS_CLIENT_METHOD_ \ + MKN_RAM_HTTPS_METHOD_APPENDER(_MKN_RAM_HTTPS_METHOD_, _client_method) +#define _MKN_RAM_HTTPS_SERVER_METHOD_ \ + MKN_RAM_HTTPS_METHOD_APPENDER(_MKN_RAM_HTTPS_METHOD_, _server_method) #else @@ -84,7 +85,8 @@ class Server : public mkn::ram::http::Server { const int& read, int& e); public: - Server(const short& p, const mkn::kul::File& c, const mkn::kul::File& k, const std::string& cs = "") + Server(const short& p, const mkn::kul::File& c, const mkn::kul::File& k, + const std::string& cs = "") : mkn::ram::http::Server(p), crt(c), key(k), cs(cs) {} Server(const mkn::kul::File& c, const mkn::kul::File& k, const std::string& cs = "") : mkn::ram::https::Server(443, c, k, cs) {} @@ -235,5 +237,5 @@ using Post = _1_1PostRequest; } // namespace https } // namespace ram -} // namespace kul +} // namespace mkn #endif //_MKN_RAM_INCLUDE_HTTPS_HPP_ diff --git a/os/win/inc/mkn/ram/tcp.hpp b/os/win/inc/mkn/ram/tcp.hpp index e898b29..d686edb 100644 --- a/os/win/inc/mkn/ram/tcp.hpp +++ b/os/win/inc/mkn/ram/tcp.hpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2013, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -36,18 +36,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #undef UNICODE #define WIN32_LEAN_AND_MEAN +#include +#include #include #include #include -#include -#include - -#include "mkn/kul/tcp.base.hpp" - #include #include +#include "mkn/kul/tcp.base.hpp" + #pragma comment(lib, "Ws2_32.lib") #pragma comment(lib, "Mswsock.lib") #pragma comment(lib, "AdvApi32.lib") diff --git a/os/win/src/http/multi.cpp b/os/win/src/http/multi.cpp index 6631cf5..12f4753 100644 --- a/os/win/src/http/multi.cpp +++ b/os/win/src/http/multi.cpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2017, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/os/win/src/http/server.cpp b/os/win/src/http/server.cpp index cc9f011..978bcfe 100644 --- a/os/win/src/http/server.cpp +++ b/os/win/src/http/server.cpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2016, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/os/win/src/https/multi.cpp b/os/win/src/https/multi.cpp index e35588b..a66d1cc 100644 --- a/os/win/src/https/multi.cpp +++ b/os/win/src/https/multi.cpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2017, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/os/win/src/https/request.cpp b/os/win/src/https/request.cpp index 059c884..60551b8 100644 --- a/os/win/src/https/request.cpp +++ b/os/win/src/https/request.cpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2016, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -31,8 +31,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifdef _MKN_RAM_INCLUDE_HTTPS_ #include "mkn/ram/https.hpp" -void mkn::ram::https::Requester::send(const std::string& h, const std::string& req, const uint16_t& p, - std::stringstream& ss, SSL* ssl) { +void mkn::ram::https::Requester::send(const std::string& h, const std::string& req, + const uint16_t& p, std::stringstream& ss, SSL* ssl) { KUL_DBG_FUNC_ENTER { mkn::ram::tcp::Socket sock; if (!sock.connect(h, p)) KEXCEPTION("TCP FAILED TO CONNECT!"); diff --git a/os/win/src/https/server.cpp b/os/win/src/https/server.cpp index acdb01d..409471b 100644 --- a/os/win/src/https/server.cpp +++ b/os/win/src/https/server.cpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2016, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -137,7 +137,7 @@ void mkn::ram::https::Server::stop() { } void mkn::ram::https::Server::handleBuffer(std::map& fds, const int& fd, char* in, - const int& read, int& e) { + const int& read, int& e) { in[read] = '\0'; std::string res; try { diff --git a/remotes.json b/res/conan_remotes.json similarity index 100% rename from remotes.json rename to res/conan_remotes.json diff --git a/src/fcgi/server.cpp b/src/fcgi/server.cpp index 9ee2cbe..bfe45d1 100644 --- a/src/fcgi/server.cpp +++ b/src/fcgi/server.cpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2016, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -31,7 +31,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifdef _KUL_INCLUDE_FCGI_ #include "mkn/kul/asio/fcgi.hpp" - #include "mkn/ram/http.hpp" void mkn::ram::asio::fcgi::Server::start() KTHROW(Exception) { @@ -72,8 +71,8 @@ bool mkn::ram::asio::fcgi::Server::receive(std::map& fds, const in return false; } -void mkn::ram::asio::fcgi::Server::write(std::map& fds, const int& fd, const uint8_t* out, - const size_t size) { +void mkn::ram::asio::fcgi::Server::write(std::map& fds, const int& fd, + const uint8_t* out, const size_t size) { KUL_DBG_FUNC_ENTER writeTo(fd, out, size); receive(fds, fd); @@ -82,7 +81,7 @@ void mkn::ram::asio::fcgi::Server::write(std::map& fds, const int& } void mkn::ram::asio::fcgi::Server::PARSE_FIRST(std::map& fds, uint8_t* const in, - const int& inLen, const int& fd) + const int& inLen, const int& fd) KTHROW(kul::fcgi::Exception) { KUL_DBG_FUNC_ENTER @@ -107,7 +106,7 @@ void mkn::ram::asio::fcgi::Server::PARSE_FIRST(std::map& fds, uint } void mkn::ram::asio::fcgi::Server::PARSE(std::map& fds, uint8_t* const in, - const int& inLen, const int& fd, size_t pos) + const int& inLen, const int& fd, size_t pos) KTHROW(kul::fcgi::Exception) { KUL_DBG_FUNC_ENTER diff --git a/src/http/request.cpp b/src/http/request.cpp index f609bee..210ca31 100644 --- a/src/http/request.cpp +++ b/src/http/request.cpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2016, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -68,7 +68,7 @@ class RequestHeaders { return i; } mkn::kul::hash::map::S2S defaultHeaders(const mkn::ram::http::A1_1Request& r, - const std::string& body = "") const { + const std::string& body = "") const { mkn::kul::hash::map::S2S hs1; for (const auto& h : _hs) if (!r.header("Transfer-Encoding")) hs1.insert(h.first, h.second); diff --git a/src/http/response.cpp b/src/http/response.cpp index 54e651e..81c6414 100644 --- a/src/http/response.cpp +++ b/src/http/response.cpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2016, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/src/http/server.cpp b/src/http/server.cpp index beedd29..95242c8 100644 --- a/src/http/server.cpp +++ b/src/http/server.cpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2016, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -30,9 +30,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "mkn/ram/http.hpp" -std::shared_ptr mkn::ram::http::AServer::handleRequest(const int& fd, - const std::string& b, - std::string& path) { +std::shared_ptr mkn::ram::http::AServer::handleRequest( + const int& fd, const std::string& b, std::string& path) { KUL_DBG_FUNC_ENTER std::string a; std::shared_ptr req; @@ -53,8 +52,7 @@ std::shared_ptr mkn::ram::http::AServer::handleRequ } } else if (l0[0] == "POST") { // req = post(); - } - else + } else KEXCEPTION("HTTP Server request type not handled: " + l0[0]); mode = l0[0]; path = s; @@ -106,7 +104,7 @@ std::shared_ptr mkn::ram::http::AServer::handleRequ } void mkn::ram::http::AServer::handleBuffer(std::map& fds, const int& fd, char* in, - const int& read, int& e) { + const int& read, int& e) { KUL_DBG_FUNC_ENTER; in[read] = '\0'; std::string res; diff --git a/test/client.cpp b/test/client.cpp index f0bf177..b70ca33 100644 --- a/test/client.cpp +++ b/test/client.cpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2013, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -31,9 +31,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include "mkn/kul/signal.hpp" - -#include "mkn/ram/tcp.hpp" #include "mkn/ram/http.hpp" +#include "mkn/ram/tcp.hpp" #ifdef _MKN_RAM_INCLUDE_HTTPS_ #include "mkn/ram/https.hpp" @@ -53,7 +52,7 @@ class HTTPS_Get : public mkn::ram::https::_1_1GetRequest { public: HTTPS_Get(std::string const& host, std::string const& path = "", uint16_t const& port = 80) : mkn::ram::https::_1_1GetRequest(host, path, port) {} - void handleResponse(const mkn::kul::hash::map::S2S &h, std::string const& b) override { + void handleResponse(const mkn::kul::hash::map::S2S& h, std::string const& b) override { KLOG(INF) << "HTTPS GET RESPONSE:\n" << b; } }; @@ -61,9 +60,9 @@ class HTTPS_Post : public mkn::ram::https::_1_1PostRequest { public: HTTPS_Post(std::string const& host, std::string const& path = "", uint16_t const& port = 80) : mkn::ram::https::_1_1PostRequest(host, path, port) {} - void handleResponse(const mkn::kul::hash::map::S2S &h, std::string const& b) override { + void handleResponse(const mkn::kul::hash::map::S2S& h, std::string const& b) override { KUL_DBG_FUNC_ENTER - for (const auto &p : h) KOUT(NON) << "HEADER: " << p.first << " : " << p.second; + for (const auto& p : h) KOUT(NON) << "HEADER: " << p.first << " : " << p.second; KOUT(NON) << "HTTPS POST RESPONSE:\n" << b; } }; @@ -73,7 +72,7 @@ class Get : public mkn::ram::http::_1_1GetRequest { public: Get(std::string const& host, std::string const& path = "", uint16_t const& port = 80) : mkn::ram::http::_1_1GetRequest(host, path, port) {} - void handleResponse(const mkn::kul::hash::map::S2S &h, std::string const& b) override { + void handleResponse(const mkn::kul::hash::map::S2S& h, std::string const& b) override { KLOG(INF) << b; // if(b.substr(0, b.size() - 2) != "MULTI HTTP PROVIDED BY KUL") // KEXCEPTION("Body failed :" + b + ":"); @@ -83,7 +82,7 @@ class Post : public mkn::ram::http::_1_1PostRequest { public: Post(std::string const& host, std::string const& path = "", uint16_t const& port = 80) : mkn::ram::http::_1_1PostRequest(host, path, port) {} - void handleResponse(const mkn::kul::hash::map::S2S &h, std::string const& b) override { + void handleResponse(const mkn::kul::hash::map::S2S& h, std::string const& b) override { if (b.substr(0, b.size() - 2) != "MULTI HTTP PROVIDED BY KUL") KEXCEPTION("Body failed :" + b + ":"); } @@ -91,7 +90,7 @@ class Post : public mkn::ram::http::_1_1PostRequest { } } -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { mkn::kul::Signal s; try { mkn::kul::ram::Get g("localhost", "index.html", _MKN_RAM_HTTP_TEST_PORT_); @@ -134,10 +133,10 @@ int main(int argc, char *argv[]) { // _MKN_RAM_HTTP_TEST_PORT_).send(); // #endif//_MKN_RAM_INCLUDE_HTTPS_ - } catch (const mkn::kul::Exception &e) { + } catch (const mkn::kul::Exception& e) { KERR << e.stack(); return 1; - } catch (const std::exception &e) { + } catch (const std::exception& e) { KERR << e.what(); return 2; } catch (...) { diff --git a/test/fcgi.cpp b/test/fcgi.cpp index c33ce00..44cf48b 100644 --- a/test/fcgi.cpp +++ b/test/fcgi.cpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2016, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -29,6 +29,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "mkn/kul/asio/fcgi.hpp" + #include "mkn/kul/signal.hpp" int main(int argc, char *argv[]) { diff --git a/test/server.cpp b/test/server.cpp index f13d5f2..993882b 100644 --- a/test/server.cpp +++ b/test/server.cpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2013, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -30,15 +30,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include -#include "mkn/ram/http.hpp" #include "mkn/kul/tcp.hpp" +#include "mkn/ram/http.hpp" #ifdef _MKN_RAM_INCLUDE_HTTPS_ #include "mkn/ram/https.hpp" #endif //_MKN_RAM_INCLUDE_HTTPS_ #include "mkn/kul/html4.hpp" - #include "mkn/kul/signal.hpp" #ifndef _MKN_RAM_HTTP_TEST_PORT_ @@ -48,7 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace mkn { namespace ram { -void addResponseHeaders(mkn::ram::http::_1_1Response &r) { +void addResponseHeaders(mkn::ram::http::_1_1Response& r) { if (!r.header("Date")) r.header("Date", mkn::kul::DateTime::NOW()); if (!r.header("Connection")) r.header("Connection", "close"); if (!r.header("Content-Type")) r.header("Content-Type", "text/html"); @@ -104,7 +103,7 @@ class TestHTTPSServer : public mkn::ram::https::Server { } TestHTTPSServer() : mkn::ram::https::Server(_MKN_RAM_HTTP_TEST_PORT_, mkn::kul::File("res/test/server.crt"), - mkn::kul::File("res/test/server.key")) {} + mkn::kul::File("res/test/server.key")) {} friend class mkn::kul::Thread; }; @@ -121,8 +120,9 @@ class TestMultiHTTPSServer : public mkn::ram::https::MultiServer { return r; } TestMultiHTTPSServer() - : mkn::ram::https::MultiServer(_MKN_RAM_HTTP_TEST_PORT_, 3, mkn::kul::File("res/test/server.crt"), - mkn::kul::File("res/test/server.key")) {} + : mkn::ram::https::MultiServer(_MKN_RAM_HTTP_TEST_PORT_, 3, + mkn::kul::File("res/test/server.crt"), + mkn::kul::File("res/test/server.key")) {} friend class mkn::kul::Thread; }; @@ -130,7 +130,7 @@ class HTTPS_Get : public mkn::ram::https::_1_1GetRequest { public: HTTPS_Get(std::string const& host, std::string const& path = "", uint16_t const& port = 80) : mkn::ram::https::_1_1GetRequest(host, path, port) {} - void handleResponse(const mkn::kul::hash::map::S2S &h, std::string const& b) override { + void handleResponse(const mkn::kul::hash::map::S2S& h, std::string const& b) override { KLOG(INF) << "HTTPS GET RESPONSE:\n" << b; } }; @@ -138,9 +138,9 @@ class HTTPS_Post : public mkn::ram::https::_1_1PostRequest { public: HTTPS_Post(std::string const& host, std::string const& path = "", uint16_t const& port = 80) : mkn::ram::https::_1_1PostRequest(host, path, port) {} - void handleResponse(const mkn::kul::hash::map::S2S &h, std::string const& b) override { + void handleResponse(const mkn::kul::hash::map::S2S& h, std::string const& b) override { KUL_DBG_FUNC_ENTER - for (const auto &p : h) KOUT(NON) << "HEADER: " << p.first << " : " << p.second; + for (const auto& p : h) KOUT(NON) << "HEADER: " << p.first << " : " << p.second; KOUT(NON) << "HTTPS POST RESPONSE:\n" << b; } }; @@ -151,7 +151,7 @@ class TestSocketServer : public mkn::ram::tcp::SocketServer { void operator()() { start(); } public: - bool handle(char *in, char *out) override { + bool handle(char* in, char* out) override { KUL_DBG_FUNC_ENTER mkn::ram::http::_1_1Response getResponse; addResponseHeaders(getResponse); @@ -168,7 +168,7 @@ class Get : public mkn::ram::http::_1_1GetRequest { public: Get(std::string const& host, std::string const& path = "", uint16_t const& port = 80) : mkn::ram::http::_1_1GetRequest(host, path, port) {} - void handleResponse(const mkn::kul::hash::map::S2S &h, std::string const& b) override { + void handleResponse(const mkn::kul::hash::map::S2S& h, std::string const& b) override { KLOG(INF) << "GET RESPONSE:\n" << b; } }; @@ -176,16 +176,16 @@ class Post : public mkn::ram::http::_1_1PostRequest { public: Post(std::string const& host, std::string const& path = "", uint16_t const& port = 80) : mkn::ram::http::_1_1PostRequest(host, path, port) {} - void handleResponse(const mkn::kul::hash::map::S2S &h, std::string const& b) override { + void handleResponse(const mkn::kul::hash::map::S2S& h, std::string const& b) override { KUL_DBG_FUNC_ENTER - for (const auto &p : h) KOUT(NON) << "HEADER: " << p.first << " : " << p.second; + for (const auto& p : h) KOUT(NON) << "HEADER: " << p.first << " : " << p.second; KOUT(NON) << "POST RESPONSE:\n" << b; } }; } // namespace ram -} // namespace kul +} // namespace mkn -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { mkn::kul::Signal s; try { // KOUT(NON) << "TCP Socket SERVER"; @@ -254,10 +254,10 @@ int main(int argc, char *argv[]) { // } #endif //_MKN_RAM_INCLUDE_HTTPS_ - } catch (const mkn::kul::Exception &e) { + } catch (const mkn::kul::Exception& e) { KERR << e.stack(); return 1; - } catch (const std::exception &e) { + } catch (const std::exception& e) { KERR << e.what(); return 2; } catch (...) { diff --git a/test.cpp b/test/test.cpp similarity index 88% rename from test.cpp rename to test/test.cpp index 4def9e3..35475bc 100644 --- a/test.cpp +++ b/test/test.cpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2016, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -38,7 +38,7 @@ class TestHTTPSServer : public mkn::ram::https::Server { public: TestHTTPSServer() : mkn::ram::https::Server(_MKN_RAM_HTTP_TEST_PORT_, mkn::kul::File("res/test/server.crt"), - mkn::kul::File("res/test/server.key")) {} + mkn::kul::File("res/test/server.key")) {} friend class mkn::kul::Thread; }; class HTTPS_Get : public mkn::ram::https::_1_1GetRequest { @@ -46,11 +46,11 @@ class HTTPS_Get : public mkn::ram::https::_1_1GetRequest { HTTPS_Get(std::string const& host, std::string const& path = "", uint16_t const& port = 80) : mkn::ram::https::_1_1GetRequest(host, path, port) {} }; -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { using namespace mkn::ram::http; { TestHTTPSServer serv; - serv.init().withResponse([](const A1_1Request &r) { + serv.init().withResponse([](const A1_1Request& r) { KLOG(NON) << mkn::kul::os::EOL() << r.toString(); return _1_1Response{}.withBody("HELLO WORLD"); }); @@ -61,8 +61,9 @@ int main(int argc, char *argv[]) { { HTTPS_Get get("localhost", "index.html", _MKN_RAM_HTTP_TEST_PORT_); KLOG(NON) << mkn::kul::os::EOL() << get.toString(); - get.withResponse( - [](const mkn::ram::http::_1_1Response &r) { KLOG(INF) << mkn::kul::os::EOL() << r.toString(); }) + get.withResponse([](const mkn::ram::http::_1_1Response& r) { + KLOG(INF) << mkn::kul::os::EOL() << r.toString(); + }) .send(); } serv.stop(); diff --git a/usage.cpp b/test/usage.cpp similarity index 91% rename from usage.cpp rename to test/usage.cpp index 94eea21..947b1dd 100644 --- a/usage.cpp +++ b/test/usage.cpp @@ -1,5 +1,5 @@ /** -Copyright (c) 2013, Philip Deegan. +Copyright (c) 2024, Philip Deegan. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -31,9 +31,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include "mkn/kul/signal.hpp" - -#include "mkn/ram/tcp.hpp" #include "mkn/ram/http.hpp" +#include "mkn/ram/tcp.hpp" #ifdef _MKN_RAM_INCLUDE_HTTPS_ #include "mkn/ram/https.hpp" @@ -41,7 +40,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "mkn/ram/html4.hpp" - #ifdef _WIN32 #define bzero ZeroMemory #endif @@ -91,7 +89,7 @@ class TestHTTPSServer : public mkn::ram::https::Server { } TestHTTPSServer() : mkn::ram::https::Server(_MKN_RAM_HTTP_TEST_PORT_, mkn::kul::File("res/test/server.crt"), - mkn::kul::File("res/test/server.key")) {} + mkn::kul::File("res/test/server.key")) {} friend class mkn::kul::Thread; }; @@ -104,10 +102,10 @@ class TestMultiHTTPSServer : public mkn::ram::https::MultiServer { mkn::ram::http::_1_1Response r; return r.withBody("MULTI HTTPS PROVIDED BY KUL: " + req.method()).withDefaultHeaders(); } - TestMultiHTTPSServer(const uint8_t &acceptThreads = 1, const uint8_t &workerThreads = 1) + TestMultiHTTPSServer(const uint8_t& acceptThreads = 1, const uint8_t& workerThreads = 1) : mkn::ram::https::MultiServer(_MKN_RAM_HTTP_TEST_PORT_, acceptThreads, workerThreads, - mkn::kul::File("res/test/server.crt"), - mkn::kul::File("res/test/server.key")) {} + mkn::kul::File("res/test/server.crt"), + mkn::kul::File("res/test/server.key")) {} friend class mkn::kul::Thread; }; @@ -123,8 +121,8 @@ class HTTPS_Post : public mkn::ram::https::_1_1PostRequest { public: HTTPS_Post(std::string const& host, std::string const& path = "", uint16_t const& port = 80) : mkn::ram::https::_1_1PostRequest(host, path, port) {} - void handleResponse(const mkn::ram::http::_1_1Response &r) override { - for (const auto &p : r.headers()) KOUT(NON) << "HEADER: " << p.first << " : " << p.second; + void handleResponse(const mkn::ram::http::_1_1Response& r) override { + for (const auto& p : r.headers()) KOUT(NON) << "HEADER: " << p.first << " : " << p.second; KOUT(NON) << "HTTPS POST RESPONSE: " << r.body(); } }; @@ -135,7 +133,7 @@ class TestSocketServer : public mkn::ram::tcp::SocketServer { void operator()() { start(); } public: - bool handle(char *const in, size_t const& inLen, char *const out, size_t &outLen) override { + bool handle(char* const in, size_t const& inLen, char* const out, size_t& outLen) override { std::string rep("TCP PROVIDED BY KUL"); std::strcpy(out, rep.c_str()); outLen = rep.size(); @@ -149,7 +147,7 @@ class Get : public mkn::ram::http::_1_1GetRequest { public: Get(std::string const& host, std::string const& path = "", uint16_t const& port = 80) : mkn::ram::http::_1_1GetRequest(host, path, port) {} - void handleResponse(const mkn::ram::http::_1_1Response &r) override { + void handleResponse(const mkn::ram::http::_1_1Response& r) override { KLOG(INF) << "GET RESPONSE: " << r.body(); } }; @@ -157,8 +155,8 @@ class Post : public mkn::ram::http::_1_1PostRequest { public: Post(std::string const& host, std::string const& path = "", uint16_t const& port = 80) : mkn::ram::http::_1_1PostRequest(host, path, port) {} - void handleResponse(const mkn::ram::http::_1_1Response &r) override { - for (const auto &p : r.headers()) KOUT(NON) << "HEADER: " << p.first << " : " << p.second; + void handleResponse(const mkn::ram::http::_1_1Response& r) override { + for (const auto& p : r.headers()) KOUT(NON) << "HEADER: " << p.first << " : " << p.second; KOUT(NON) << "HTTPS POST RESPONSE: " << r.body(); } }; @@ -203,7 +201,7 @@ class Test { HTTPS_Get("localhost", "index.html_" + std::to_string(index++), _MKN_RAM_HTTP_TEST_PORT_) .send(); }; - auto except = [&t](const mkn::kul::Exception &e) { + auto except = [&t](const mkn::kul::Exception& e) { KLOG(ERR) << e.stack(); if (t.exception()) std::rethrow_exception(t.exception()); }; @@ -245,7 +243,7 @@ class Test { { mkn::ram::tcp::Socket sock; if (!sock.connect("google.com", 80)) - KEXCEPT(mkn::ram::tcp::Exception, "TCP FAILED TO CONNECT!"); + KEXCEPT(mkn::ram::tcp::Exception, "TCP FAILED TO CONNECT!"); Get get("google.com"); std::string req(get.toString()); @@ -274,9 +272,9 @@ class Test { for (size_t i = 0; i < 5; i++) { mkn::ram::tcp::Socket sock; if (!sock.connect("localhost", _MKN_RAM_HTTP_TEST_PORT_)) - KEXCEPT(mkn::ram::tcp::Exception, "TCP FAILED TO CONNECT!"); + KEXCEPT(mkn::ram::tcp::Exception, "TCP FAILED TO CONNECT!"); - const char *c = "socketserver"; + const char* c = "socketserver"; sock.write(c, strlen(c)); char buf[_MKN_RAM_TCP_REQUEST_BUFFER_]; @@ -308,18 +306,18 @@ class Test { } }; } // namespace ram -} // namespace kul +} // namespace mkn #ifndef __MKN_RAM_NOMAIN__ -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { mkn::kul::Signal s; try { mkn::ram::Test(); - } catch (const mkn::kul::Exception &e) { + } catch (const mkn::kul::Exception& e) { KERR << e.stack(); return 1; - } catch (const std::exception &e) { + } catch (const std::exception& e) { KERR << e.what(); return 2; } catch (...) {