From 5fb5b34f5c2f5d0a3210708c04779367b1072c32 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Wed, 4 Jan 2023 15:25:40 +0100 Subject: Adjust to new lib API --- common.mk | 3 +++ debian/control | 2 +- https.cpp | 1 + plugins/cgi/cgi.cpp | 1 + plugins/static-files/static-files.cpp | 2 ++ plugins/statistics/statistics.cpp | 1 + plugins/webbox/webbox.cpp | 4 ++++ plugins/weblog/weblog.cpp | 2 ++ response.cpp | 1 + tests/test-webserver.cpp | 25 +++++++++++++++++++++++++ 10 files changed, 41 insertions(+), 1 deletion(-) diff --git a/common.mk b/common.mk index 5770d7d..cb4a426 100644 --- a/common.mk +++ b/common.mk @@ -97,6 +97,9 @@ LIBS+= \ CXXTYPE=g++ endif +CXXFLAGS+=$(shell pkg-config --cflags fmt) +LIBS+=$(shell pkg-config --libs fmt) + SRC_ROOT=$(shell echo $(MAKEFILE_LIST) | tr " " "\n" | grep common.mk | sed -e 's/\([^ ]*\)common.mk/\1/g') VERSION=$(shell dpkg-parsechangelog --show-field Version --file $(SRC_ROOT)/debian/changelog) CXXFLAGS+=-DVERSION=\"$(VERSION)\" diff --git a/debian/control b/debian/control index a48c5df..e0de083 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: webserver Section: httpd Priority: optional Maintainer: Roland Reichwein -Build-Depends: debhelper (>= 12), libssl-dev, libboost-all-dev | libboost1.71-all-dev, clang | g++, llvm | g++, lld | g++, uglifyjs, python3-pkg-resources, htmlmin, cleancss, libreichwein-dev, gcovr +Build-Depends: debhelper (>= 12), libssl-dev, libboost-all-dev | libboost1.71-all-dev, clang | g++, llvm | g++, lld | g++, uglifyjs, python3-pkg-resources, htmlmin, cleancss, libreichwein-dev, gcovr, libfmt-dev Standards-Version: 4.5.0 Homepage: http://www.reichwein.it/webserver/ diff --git a/https.cpp b/https.cpp index 768cdba..1e8bec1 100644 --- a/https.cpp +++ b/https.cpp @@ -40,6 +40,7 @@ namespace http = beast::http; // from namespace net = boost::asio; // from namespace ssl = boost::asio::ssl; // from using tcp = boost::asio::ip::tcp; // from +using namespace Reichwein; namespace { diff --git a/plugins/cgi/cgi.cpp b/plugins/cgi/cgi.cpp index 4e4f6c7..23c9bc4 100644 --- a/plugins/cgi/cgi.cpp +++ b/plugins/cgi/cgi.cpp @@ -16,6 +16,7 @@ using namespace std::string_literals; namespace bp = boost::process; namespace fs = std::filesystem; +using namespace Reichwein::Mime; namespace { diff --git a/plugins/static-files/static-files.cpp b/plugins/static-files/static-files.cpp index e889bc5..4dd8499 100644 --- a/plugins/static-files/static-files.cpp +++ b/plugins/static-files/static-files.cpp @@ -12,6 +12,8 @@ using namespace std::string_literals; namespace fs = std::filesystem; +using namespace Reichwein::Mime; +using namespace Reichwein::URL; namespace { diff --git a/plugins/statistics/statistics.cpp b/plugins/statistics/statistics.cpp index 54450a8..959fd33 100644 --- a/plugins/statistics/statistics.cpp +++ b/plugins/statistics/statistics.cpp @@ -18,6 +18,7 @@ using namespace std::string_literals; namespace bp = boost::process; namespace fs = std::filesystem; +using namespace Reichwein; namespace { diff --git a/plugins/webbox/webbox.cpp b/plugins/webbox/webbox.cpp index 90975b5..df7e946 100644 --- a/plugins/webbox/webbox.cpp +++ b/plugins/webbox/webbox.cpp @@ -27,6 +27,10 @@ using namespace std::string_literals; namespace fs = std::filesystem; namespace pt = boost::property_tree; +using namespace Reichwein::Mime; +using namespace Reichwein::Stringutil; +using namespace Reichwein::URL; +using namespace Reichwein; namespace { diff --git a/plugins/weblog/weblog.cpp b/plugins/weblog/weblog.cpp index 8be5b40..1aea2f4 100644 --- a/plugins/weblog/weblog.cpp +++ b/plugins/weblog/weblog.cpp @@ -18,6 +18,8 @@ using namespace std::string_literals; namespace fs = std::filesystem; namespace pt = boost::property_tree; +using namespace Reichwein::Mime; +using namespace Reichwein::Stringutil; namespace { diff --git a/response.cpp b/response.cpp index 4f535df..92390cd 100644 --- a/response.cpp +++ b/response.cpp @@ -15,6 +15,7 @@ #include using namespace std::placeholders; +using namespace Reichwein::Mime; namespace { diff --git a/tests/test-webserver.cpp b/tests/test-webserver.cpp index 4ac550e..7826a58 100644 --- a/tests/test-webserver.cpp +++ b/tests/test-webserver.cpp @@ -15,6 +15,8 @@ #include #include +#include + #include #include #include @@ -33,6 +35,7 @@ using namespace std::string_literals; namespace fs = std::filesystem; namespace pt = boost::property_tree; +using namespace Reichwein; class WebserverProcess { @@ -118,6 +121,28 @@ public: m_pid = 0; } + bool isRunning() + { + if (m_pid == 0) + return false; + + fs::path pid_file{fmt::format("/proc/{}/stat", m_pid)}; + if (!fs::exists(pid_file)) + return false; + + std::string s{File::getFile(pid_file)}; + + auto pos0{s.find(' ', 0)}; + pos0 = s.find(' ', pos0 + 1); + pos0++; + + auto pos1{s.find(' ', pos0 + 1)}; + + std::string state{s.substr(pos0, pos1 - pos0)}; + + return state == "R" || state == "S"; + } + private: pid_t m_pid; }; -- cgit v1.2.3