diff --git a/net/nginx-util/Makefile b/net/nginx-util/Makefile index 4730b2d1a..b07206c9b 100644 --- a/net/nginx-util/Makefile +++ b/net/nginx-util/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=nginx-util -PKG_VERSION:=1.0 +PKG_VERSION:=1.1 PKG_RELEASE:=1 include $(INCLUDE_DIR)/package.mk diff --git a/net/nginx-util/src/CMakeLists.txt b/net/nginx-util/src/CMakeLists.txt index d78ec5d59..df7440d38 100644 --- a/net/nginx-util/src/CMakeLists.txt +++ b/net/nginx-util/src/CMakeLists.txt @@ -9,7 +9,7 @@ FIND_LIBRARY(ubox NAMES ubox) FIND_LIBRARY(ubus NAMES ubus) INCLUDE_DIRECTORIES(${ubus_include_dir}) -ADD_DEFINITIONS(-Os -Wall -Werror -Wextra --std=c++17 -g3) +ADD_DEFINITIONS(-Os -Wall -Werror -Wextra --std=c++2a -g3) ADD_DEFINITIONS(-Wno-unused-parameter -Wmissing-declarations) SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") diff --git a/net/nginx-util/src/nginx-ssl-util.cpp b/net/nginx-util/src/nginx-ssl-util.cpp index f4a857397..fcd81a405 100644 --- a/net/nginx-util/src/nginx-ssl-util.cpp +++ b/net/nginx-util/src/nginx-ssl-util.cpp @@ -100,7 +100,7 @@ void del_ssl_directives_from(const std::string & name, bool isdefault); void del_ssl(const std::string & name); -static constexpr auto _begin = _Line{ +constexpr auto _begin = _Line{ [](const std::string & /*param*/, const std::string & begin) -> std::string { return begin; }, @@ -110,7 +110,7 @@ static constexpr auto _begin = _Line{ }; -static constexpr auto _space = _Line{ +constexpr auto _space = _Line{ [](const std::string & /*param*/, const std::string & /*begin*/) -> std::string { return std::string{" "}; }, @@ -121,7 +121,7 @@ static constexpr auto _space = _Line{ }; -static constexpr auto _newline = _Line{ +constexpr auto _newline = _Line{ [](const std::string & /*param*/, const std::string & /*begin*/) -> std::string { return std::string{"\n"}; }, @@ -132,7 +132,7 @@ static constexpr auto _newline = _Line{ }; -static constexpr auto _end = _Line{ +constexpr auto _end = _Line{ [](const std::string & /*param*/, const std::string & /*begin*/) -> std::string { return std::string{";"}; }, @@ -144,7 +144,7 @@ static constexpr auto _end = _Line{ template -static constexpr auto _capture = _Line{ +constexpr auto _capture = _Line{ [](const std::string & param, const std::string & /*begin*/) -> std::string { return '\'' + param + '\''; }, @@ -159,10 +159,14 @@ static constexpr auto _capture = _Line{ template -static constexpr auto _escape = _Line{ +constexpr auto _escape = _Line{ [](const std::string & /*param*/, const std::string & /*begin*/) -> std::string - { return clim + std::string{strptr.data()} + clim; }, + { + return clim=='\0' ? + std::string{strptr.data()} : + clim + std::string{strptr.data()} + clim; + }, [](const std::string & /*param*/, const std::string & /*begin*/) -> std::string @@ -184,17 +188,17 @@ static constexpr auto _escape = _Line{ }; -static constexpr std::string_view _server_name = "server_name"; +constexpr std::string_view _server_name = "server_name"; -static constexpr std::string_view _include = "include"; +constexpr std::string_view _include = "include"; -static constexpr std::string_view _ssl_certificate = "ssl_certificate"; +constexpr std::string_view _ssl_certificate = "ssl_certificate"; -static constexpr std::string_view _ssl_certificate_key = "ssl_certificate_key"; +constexpr std::string_view _ssl_certificate_key = "ssl_certificate_key"; -static constexpr std::string_view _ssl_session_cache = "ssl_session_cache"; +constexpr std::string_view _ssl_session_cache = "ssl_session_cache"; -static constexpr std::string_view _ssl_session_timeout = "ssl_session_timeout"; +constexpr std::string_view _ssl_session_timeout = "ssl_session_timeout"; // For a compile time regex lib, this must be fixed, use one of these options: diff --git a/net/nginx-util/src/nginx-util.cpp b/net/nginx-util/src/nginx-util.cpp index 7e675986a..935a005f2 100644 --- a/net/nginx-util/src/nginx-util.cpp +++ b/net/nginx-util/src/nginx-util.cpp @@ -91,7 +91,8 @@ void get_env() std::cout<<"LAN_LISTEN="<<"'"< #include #include #include #include -#include "px5g-openssl.hpp" class argv_view { // TODO(pst): use std::span when available. diff --git a/net/nginx-util/src/ubus-cxx.hpp b/net/nginx-util/src/ubus-cxx.hpp index 21dc26ff8..22edae77e 100644 --- a/net/nginx-util/src/ubus-cxx.hpp +++ b/net/nginx-util/src/ubus-cxx.hpp @@ -109,28 +109,29 @@ extern "C" { //TODO(pst): remove when in upstream namespace ubus { +using msg_ptr = std::shared_ptr; using strings = std::vector; -inline void append(strings & /*dest*/) {} +inline auto concat(strings dest) { return dest; } template -inline void append(strings & dest, strings src, Strings ...more) +inline auto concat(strings dest, strings src, Strings ...more) { dest.reserve(dest.size() + src.size()); dest.insert(std::end(dest), std::make_move_iterator(std::begin(src)), std::make_move_iterator(std::end(src))); - append(dest, std::move(more)...); + return concat(std::move(dest), std::move(more)...); } template -inline void append(strings & dest, S src, Strings ...more) +inline auto concat(strings dest, S src, Strings ...more) { dest.push_back(std::move(src)); - append(dest, std::move(more)...); + return concat(std::move(dest), std::move(more)...); } @@ -208,7 +209,7 @@ public: auto operator++() -> iterator &; - inline ~iterator() = default; + inline ~iterator() { if (cur.get()==this) { cur.release(); } } }; @@ -218,15 +219,14 @@ class message { private: - const std::shared_ptr msg{}; // initialized by callback. + const msg_ptr msg{}; // initialized by callback. const strings keys{}; public: - inline explicit message(std::shared_ptr message, - strings filter={""}) + inline explicit message(msg_ptr message, strings filter={""}) : msg{std::move(message)}, keys{std::move(filter)} {} @@ -258,7 +258,7 @@ public: { strings both{}; if (keys.size()!=1 || !keys[0].empty()) { both = keys; } - append(both, std::move(filter)...); + both = concat(std::move(both), std::move(filter)...); return std::move(message{msg, std::move(both)}); } @@ -408,20 +408,20 @@ inline auto call(const char * path, const char * method, const int timeout) ubus::unlock_shared_blob_buf(); if (err==0) { - using msg_t = std::shared_ptr; - msg_t msg; - req.priv = &msg; + msg_ptr msg; /* Cannot capture anything (msg), the lambda would be another type. * Pass a location where to save the message as priv pointer when * invoking and get it back here: */ + req.priv = &msg; + req.data_cb = [](ubus_request * req, int /*type*/, blob_attr * msg) { - if ((req == nullptr) || (msg == nullptr)) { return; } + if (req==nullptr || msg==nullptr) { return; } - auto saved = static_cast(req->priv); + auto saved = static_cast(req->priv); if (saved==nullptr || *saved) { return; } saved->reset(blob_memdup(msg), free);