From b7e21d931c1dfb49e5169c0e7e4322c38154ded1 Mon Sep 17 00:00:00 2001 From: hevake_lcj Date: Tue, 19 Jul 2022 23:43:15 +0800 Subject: [PATCH 01/24] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=94=B1=E6=9E=90?= =?UTF-8?q?=E6=9E=84=E5=87=BD=E6=95=B0=E4=B8=AD=E6=89=93=E5=8D=B0=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E5=AF=BC=E8=87=B4=E5=9C=A8FileAsyncChannel=E4=B8=AD?= =?UTF-8?q?=E8=AE=BF=E9=97=AE=E9=9D=9E=E6=97=A0=E6=95=88=E5=86=85=E5=AD=98?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/log.cpp | 1 + main/main.cpp | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/main/log.cpp b/main/log.cpp index 260f302..5575eb8 100644 --- a/main/log.cpp +++ b/main/log.cpp @@ -153,6 +153,7 @@ bool Log::initialize(const char *proc_name, Context &ctx, const Json &cfg) void Log::cleanup() { filelog_.cleanup(); + filelog_.disable(); } void Log::buildTerminalNodes(TerminalNodes &term) diff --git a/main/main.cpp b/main/main.cpp index 52c7bb8..8da7fcd 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -104,8 +104,6 @@ int Main(int argc, char **argv) } LogInfo("Bye!"); - - log.cleanup(); return 0; } -- Gitee From 22c71c57b3a80dfff2fc584bc491bfafb5acd48a Mon Sep 17 00:00:00 2001 From: hevake_lcj Date: Wed, 20 Jul 2022 16:51:52 +0800 Subject: [PATCH 02/24] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E4=B8=AD=E6=97=A0=E6=B3=95=E6=8C=87=E5=AE=9A=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E8=BE=93=E5=87=BA=E7=AD=89=E7=BA=A7=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/log.cpp | 79 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 56 insertions(+), 23 deletions(-) diff --git a/main/log.cpp b/main/log.cpp index 5575eb8..1cfc5c6 100644 --- a/main/log.cpp +++ b/main/log.cpp @@ -27,17 +27,20 @@ void Log::fillDefaultConfig(Json &cfg) const { "stdout": { "enable": true, - "enable_color": true + "enable_color": true, + "levels": {"":6} }, "filelog": { "enable": true, + "enable_color": false, + "levels": {"":3}, "prefix": "sample", "path": "/tmp/tbox", - "max_size": 1024, - "enable_color": false + "max_size": 1024 }, "syslog": { - "enable": false + "enable": false, + "levels": {"":3} } } )"_json; @@ -71,6 +74,16 @@ bool Log::initialize(const char *proc_name, Context &ctx, const Json &cfg) cerr << "WARN: stdout.enable_color not boolean." << endl; } } + + if (js.contains("levels")) { + auto &js_levels = js.at("levels"); + if (js_levels.is_object()) { + for (auto it = js_levels.begin(); it != js_levels.end(); ++it) + stdout_.setLevel(it.value(), it.key()); + } else { + cerr << "WARN: stdout.levels not object." << endl; + } + } } if (js_log.contains("syslog")) { @@ -86,6 +99,16 @@ bool Log::initialize(const char *proc_name, Context &ctx, const Json &cfg) cerr << "WARN: syslog.enable not boolean." << endl; } } + + if (js.contains("levels")) { + auto &js_levels = js.at("levels"); + if (js_levels.is_object()) { + for (auto it = js_levels.begin(); it != js_levels.end(); ++it) + syslog_.setLevel(it.value(), it.key()); + } else { + cerr << "WARN: stdout.levels not object." << endl; + } + } } do { @@ -98,6 +121,35 @@ bool Log::initialize(const char *proc_name, Context &ctx, const Json &cfg) break; } + if (js.contains("enable")) { + auto &js_enable = js.at("enable"); + if (js_enable.is_boolean()) { + if (js_enable.get()) + filelog_.enable(); + else + filelog_.disable(); + } else + cerr << "WARN: filelog.enable not boolean" << endl; + } + + if (js.contains("enable_color")) { + auto &js_enable = js.at("enable_color"); + if (js_enable.is_boolean()) { + filelog_.enableColor(js_enable.get()); + } else + cerr << "WARN: filelog.enable_color not boolean" << endl; + } + + if (js.contains("levels")) { + auto &js_levels = js.at("levels"); + if (js_levels.is_object()) { + for (auto it = js_levels.begin(); it != js_levels.end(); ++it) + filelog_.setLevel(it.value(), it.key()); + } else { + cerr << "WARN: stdout.levels not object." << endl; + } + } + auto &js_path = js.at("path"); if (!js_path.is_string()) { cerr << "WARN: filelog.path not string." << endl; @@ -125,25 +177,6 @@ bool Log::initialize(const char *proc_name, Context &ctx, const Json &cfg) else cerr << "WARN: filelog.max_size not number" << endl; } - - if (js.contains("enable")) { - auto &js_enable = js.at("enable"); - if (js_enable.is_boolean()) { - if (js_enable.get()) - filelog_.enable(); - else - filelog_.disable(); - } else - cerr << "WARN: filelog.enable not boolean" << endl; - } - - if (js.contains("enable_color")) { - auto &js_enable = js.at("enable_color"); - if (js_enable.is_boolean()) { - filelog_.enableColor(js_enable.get()); - } else - cerr << "WARN: filelog.enable_color not boolean" << endl; - } } while (false); } -- Gitee From 9eada2e0fb1215708d934d339c7a3b879c851f40 Mon Sep 17 00:00:00 2001 From: hevake_lcj Date: Fri, 22 Jul 2022 00:07:33 +0800 Subject: [PATCH 03/24] Fix segment fault while process exit, caused by CommonLoop::onSignal() --- event/common_loop_signal.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/event/common_loop_signal.cpp b/event/common_loop_signal.cpp index 64f01f3..ad8d2e0 100644 --- a/event/common_loop_signal.cpp +++ b/event/common_loop_signal.cpp @@ -119,7 +119,8 @@ void CommonLoop::onSignal() //LogTrace("signo:%d", signo); auto iter = all_signals_subscribers_.find(signo); if (iter != all_signals_subscribers_.end()) { - for (auto s : iter->second) { + auto todo = iter->second; //!FIXME:Crash if SignalSubscribuer be deleted in callback + for (auto s : todo) { s->onSignal(signo); } } -- Gitee From b716fbca8e286b5079bbf81026d2818664dca0a5 Mon Sep 17 00:00:00 2001 From: Hevake Date: Fri, 22 Jul 2022 09:39:44 +0800 Subject: [PATCH 04/24] =?UTF-8?q?=E4=BF=AE=E5=A4=8Devent=E4=B8=ADsignal=5F?= =?UTF-8?q?example=E7=A4=BA=E4=BE=8B=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- event/example/basic/signal_example.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/event/example/basic/signal_example.cpp b/event/example/basic/signal_example.cpp index b59942f..1e64bde 100644 --- a/event/example/basic/signal_example.cpp +++ b/event/example/basic/signal_example.cpp @@ -7,7 +7,7 @@ using namespace std; using namespace tbox; using namespace tbox::event; -void SignalCallback() +void SignalCallback(int signo) { cout << "Got interupt signal" << endl; } -- Gitee From a96c24a0d750aca069900cc28892cde894b96c66 Mon Sep 17 00:00:00 2001 From: hevake_lcj Date: Sat, 23 Jul 2022 19:10:11 +0800 Subject: [PATCH 05/24] =?UTF-8?q?=E4=BF=AE=E5=A4=8DStateMachine=E7=9A=84?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E8=AD=A6=E5=91=8A=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- util/state_machine.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/state_machine.cpp b/util/state_machine.cpp index a83cb35..a6fbff6 100644 --- a/util/state_machine.cpp +++ b/util/state_machine.cpp @@ -122,7 +122,7 @@ bool StateMachine::isTerminated() const /////////////////////// -StateMachine::Impl::State StateMachine::Impl::_term_state_ = { 0 }; +StateMachine::Impl::State StateMachine::Impl::_term_state_ = { 0, nullptr, nullptr, nullptr, { } }; StateMachine::Impl::~Impl() { @@ -142,7 +142,7 @@ bool StateMachine::Impl::newState(StateID state_id, const ActionFunc &enter_acti return false; } - auto new_state = new State { state_id, enter_action, exit_action, nullptr }; + auto new_state = new State { state_id, enter_action, exit_action, nullptr, { } }; states_[state_id] = new_state; return true; -- Gitee From e2f8bbd33b287d40cba65edce8a67bf5cdd30404 Mon Sep 17 00:00:00 2001 From: Hevake Date: Sun, 24 Jul 2022 20:53:20 +0800 Subject: [PATCH 06/24] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=BD=BF=E7=94=A8util?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=EF=BC=8C=E9=93=BE=E6=8E=A5=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/example/00_empty/Makefile | 1 + main/example/01_one_app/Makefile | 1 + main/example/02_more_than_one_apps/Makefile | 1 + main/example/03_nc_client_and_echo_server/Makefile | 1 + main/example/04_initiate_runtime_error/Makefile | 1 + sample/Makefile | 1 + util/Makefile | 2 +- 7 files changed, 7 insertions(+), 1 deletion(-) diff --git a/main/example/00_empty/Makefile b/main/example/00_empty/Makefile index 6bdfcde..00adba7 100644 --- a/main/example/00_empty/Makefile +++ b/main/example/00_empty/Makefile @@ -13,6 +13,7 @@ LDFLAGS += -L.. \ -ltbox_event \ -ltbox_util \ -ltbox_base \ + -ldl \ -lpthread CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer diff --git a/main/example/01_one_app/Makefile b/main/example/01_one_app/Makefile index 577137d..8db7754 100644 --- a/main/example/01_one_app/Makefile +++ b/main/example/01_one_app/Makefile @@ -13,6 +13,7 @@ LDFLAGS += -L.. \ -ltbox_event \ -ltbox_util \ -ltbox_base \ + -ldl \ -lpthread CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer diff --git a/main/example/02_more_than_one_apps/Makefile b/main/example/02_more_than_one_apps/Makefile index 92b8ff5..088539c 100644 --- a/main/example/02_more_than_one_apps/Makefile +++ b/main/example/02_more_than_one_apps/Makefile @@ -19,6 +19,7 @@ LDFLAGS += -L.. \ -ltbox_event \ -ltbox_util \ -ltbox_base \ + -ldl \ -lpthread CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer diff --git a/main/example/03_nc_client_and_echo_server/Makefile b/main/example/03_nc_client_and_echo_server/Makefile index 3b9206c..4eacdcf 100644 --- a/main/example/03_nc_client_and_echo_server/Makefile +++ b/main/example/03_nc_client_and_echo_server/Makefile @@ -18,6 +18,7 @@ LDFLAGS += -L.. \ -ltbox_event \ -ltbox_util \ -ltbox_base \ + -ldl \ -lpthread CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer diff --git a/main/example/04_initiate_runtime_error/Makefile b/main/example/04_initiate_runtime_error/Makefile index 494b843..a0a3c01 100644 --- a/main/example/04_initiate_runtime_error/Makefile +++ b/main/example/04_initiate_runtime_error/Makefile @@ -14,6 +14,7 @@ LDFLAGS += -L.. \ -ltbox_util \ -ltbox_base \ -lpthread \ + -ldl \ -rdynamic \ CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer diff --git a/sample/Makefile b/sample/Makefile index b22e4d3..0b3f8d5 100644 --- a/sample/Makefile +++ b/sample/Makefile @@ -21,6 +21,7 @@ LDFLAGS += \ -ltbox_util \ -ltbox_base \ -lpthread \ + -ldl \ -rdynamic TEST_LDFLAGS += $(LDFLAGS) diff --git a/util/Makefile b/util/Makefile index 797633b..7a12104 100644 --- a/util/Makefile +++ b/util/Makefile @@ -43,7 +43,7 @@ TEST_CPP_SRC_FILES = \ state_machine_test.cpp \ async_pipe_test.cpp \ -TEST_LDFLAGS := $(LDFLAGS) -ltbox_base +TEST_LDFLAGS := $(LDFLAGS) -ltbox_base -ldl ENABLE_SHARED_LIB = no -- Gitee From ee630bc2c834cbd64d86524fdf1dea3a7d4f117c Mon Sep 17 00:00:00 2001 From: Hevake Date: Sun, 24 Jul 2022 23:47:13 +0800 Subject: [PATCH 07/24] Fixbug of util/TimeCounter, can't print correct time in raspberry --- util/time_counter.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/util/time_counter.cpp b/util/time_counter.cpp index c8fc006..f6ef3b1 100644 --- a/util/time_counter.cpp +++ b/util/time_counter.cpp @@ -21,11 +21,13 @@ TimeCounter::~TimeCounter() void TimeCounter::stop() { + auto now = steady_clock::now(); + if (stoped_) return; - auto cost_us = duration_cast(steady_clock::now() - start_time_point_).count(); - LogPrintfFunc("TC", func_name_, file_name_, line_, LOG_LEVEL_TRACE, true, "timecost: %u us", cost_us); + auto cost = now - start_time_point_; + LogPrintfFunc("TC", func_name_, file_name_, line_, LOG_LEVEL_TRACE, true, "timecost: %llu ns", cost.count()); stoped_ = true; } -- Gitee From b43cedacc9a613519aed4c64a91b29686c74c874 Mon Sep 17 00:00:00 2001 From: hevake_lcj Date: Mon, 25 Jul 2022 09:51:06 +0800 Subject: [PATCH 08/24] =?UTF-8?q?=E4=BF=AE=E6=94=B9util/TimeCounter?= =?UTF-8?q?=EF=BC=8C=E5=B0=86=E5=85=B6=E8=BE=93=E5=87=BA=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E6=94=B9=E6=88=90cout=EF=BC=8C=E5=B9=B6=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E5=85=B6=E5=9C=A8=E5=90=8C=E4=B8=80=E5=9F=9F=E4=B8=AD=E5=A4=9A?= =?UTF-8?q?=E6=AC=A1=E4=BD=BF=E7=94=A8SetTimeCountr()=E5=BC=95=E8=B5=B7?= =?UTF-8?q?=E7=9A=84=E7=BC=96=E8=AF=91=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/scope_exit_test.cpp | 10 ++++++++++ util/time_counter.cpp | 5 +++-- util/time_counter.h | 3 ++- util/time_counter_test.cpp | 1 + 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/base/scope_exit_test.cpp b/base/scope_exit_test.cpp index 08ae702..0342dbc 100644 --- a/base/scope_exit_test.cpp +++ b/base/scope_exit_test.cpp @@ -14,6 +14,16 @@ TEST(ScopeExitAction, no_name) EXPECT_TRUE(tag); } +TEST(ScopeExitAction, no_name_1) +{ + int count = 3; + { + SetScopeExitAction([&] { ++count; }); + SetScopeExitAction([&] { count *= 2; }); + } + EXPECT_EQ(count, 7); +} + TEST(ScopeExitAction, named) { bool tag = false; diff --git a/util/time_counter.cpp b/util/time_counter.cpp index f6ef3b1..b850df9 100644 --- a/util/time_counter.cpp +++ b/util/time_counter.cpp @@ -1,9 +1,10 @@ #include "time_counter.h" -#include +#include namespace tbox { namespace util { +using namespace std; using namespace std::chrono; TimeCounter::TimeCounter(const char *file_name, const char *func_name, int line) : @@ -27,7 +28,7 @@ void TimeCounter::stop() return; auto cost = now - start_time_point_; - LogPrintfFunc("TC", func_name_, file_name_, line_, LOG_LEVEL_TRACE, true, "timecost: %llu ns", cost.count()); + cout << "TimeCounter at " << file_name_ << ",L" << line_ << " in " << func_name_ << "(): " << cost.count() << " ns" << endl; stoped_ = true; } diff --git a/util/time_counter.h b/util/time_counter.h index 0dd717f..87e2713 100644 --- a/util/time_counter.h +++ b/util/time_counter.h @@ -26,7 +26,8 @@ class TimeCounter { } //! 无名计时器,用行号命名 -#define _TimeCounter_0(file,func,line) tbox::util::TimeCounter _timer_counter_at_##line(file,func,line) +#define _TimeCounter_1(file,func,line) tbox::util::TimeCounter _timer_counter_at_##line(file,func,line) +#define _TimeCounter_0(file,func,line) _TimeCounter_1(file,func,line) #define SetTimeCounter() _TimeCounter_0(__FILE__, __func__, __LINE__) //! 有名计时器 diff --git a/util/time_counter_test.cpp b/util/time_counter_test.cpp index 5418912..3ea9a95 100644 --- a/util/time_counter_test.cpp +++ b/util/time_counter_test.cpp @@ -10,6 +10,7 @@ TEST(TimeCounter, basic) SetTimeCounter(); std::this_thread::sleep_for(std::chrono::seconds(1)); + SetTimeCounter(); } TEST(TimeCounter, stop) -- Gitee From 995ff214a9b6224aae6ebdb812862bd9ea345d24 Mon Sep 17 00:00:00 2001 From: hevake_lcj Date: Thu, 28 Jul 2022 10:14:50 +0800 Subject: [PATCH 09/24] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86terminal/termi?= =?UTF-8?q?nal=5Fnodes.h=EF=BC=8C=E6=B7=BB=E5=8A=A0=E4=BA=86=E5=AF=B9sessi?= =?UTF-8?q?on.h=E7=9A=84=E5=8C=85=E5=90=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- terminal/terminal_nodes.h | 1 + 1 file changed, 1 insertion(+) diff --git a/terminal/terminal_nodes.h b/terminal/terminal_nodes.h index ad9ae0e..b09b052 100644 --- a/terminal/terminal_nodes.h +++ b/terminal/terminal_nodes.h @@ -2,6 +2,7 @@ #define TBOX_TERMINAL_NODES_H_20220214 #include "types.h" +#include "session.h" namespace tbox { namespace terminal { -- Gitee From 2bd4ec58559e6f6054519dace0dfaa3db43a6491 Mon Sep 17 00:00:00 2001 From: hevake_lcj Date: Thu, 28 Jul 2022 12:01:56 +0800 Subject: [PATCH 10/24] =?UTF-8?q?=E8=A7=A3=E5=86=B3event=E4=B8=ADEpollFdEv?= =?UTF-8?q?ent=E5=9C=A8=E6=9E=90=E6=9E=84=E6=97=B6=E5=87=BA=E7=8E=B0d=5F?= =?UTF-8?q?=E4=B8=BA=E7=A9=BA=E6=8C=87=E9=92=88=E5=BC=95=E8=B5=B7=E7=9A=84?= =?UTF-8?q?=E6=AE=B5=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- event/engins/epoll/fd_event.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/event/engins/epoll/fd_event.cpp b/event/engins/epoll/fd_event.cpp index f341b40..58ff0ed 100644 --- a/event/engins/epoll/fd_event.cpp +++ b/event/engins/epoll/fd_event.cpp @@ -28,10 +28,12 @@ EpollFdEvent::~EpollFdEvent() disable(); - --d_->ref; - if (d_->ref == 0) { - wp_loop_->removeFdSharedData(fd_); - delete d_; + if (d_ != nullptr) { + --d_->ref; + if (d_->ref == 0) { + wp_loop_->removeFdSharedData(fd_); + delete d_; + } } } -- Gitee From 58e9d6492432ac574d9c9753733b092d5aed16a7 Mon Sep 17 00:00:00 2001 From: hevake_lcj Date: Fri, 12 Aug 2022 15:33:57 +0800 Subject: [PATCH 11/24] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=89=93=E5=8D=B0=EF=BC=8C=E9=BB=98=E8=AE=A4=E4=B8=8D=E5=BC=80?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/log.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/log.cpp b/main/log.cpp index 1cfc5c6..eb932e5 100644 --- a/main/log.cpp +++ b/main/log.cpp @@ -31,7 +31,7 @@ void Log::fillDefaultConfig(Json &cfg) const "levels": {"":6} }, "filelog": { - "enable": true, + "enable": false, "enable_color": false, "levels": {"":3}, "prefix": "sample", -- Gitee From 29611ededd10a2dc6eec93dd63946a299976fcc2 Mon Sep 17 00:00:00 2001 From: Hevake Date: Sat, 13 Aug 2022 18:50:38 +0800 Subject: [PATCH 12/24] =?UTF-8?q?=E6=B6=88=E9=99=A4event,=20log,=20util?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E4=B8=AD=E7=9A=84=E7=BC=96=E8=AF=91=E8=AD=A6?= =?UTF-8?q?=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- event/common_loop_signal.cpp | 6 ++- log/file_async_channel.cpp | 2 +- util/serializer.cpp | 86 +++++++++++++++++++++++++++--------- util/serializer.h | 2 + 4 files changed, 71 insertions(+), 25 deletions(-) diff --git a/event/common_loop_signal.cpp b/event/common_loop_signal.cpp index ad8d2e0..8586dce 100644 --- a/event/common_loop_signal.cpp +++ b/event/common_loop_signal.cpp @@ -102,8 +102,10 @@ void CommonLoop::HandleSignal(int signo) { //LogTrace("got signal :%d", signo); auto &this_signal_fds = _signal_write_fds_[signo]; - for (int fd : this_signal_fds) - write(fd, &signo, sizeof(signo)); + for (int fd : this_signal_fds) { + auto wsize = write(fd, &signo, sizeof(signo)); + (void)wsize; //! 消除编译警告 + } } void CommonLoop::onSignal() diff --git a/log/file_async_channel.cpp b/log/file_async_channel.cpp index 169fb40..7366a4c 100644 --- a/log/file_async_channel.cpp +++ b/log/file_async_channel.cpp @@ -56,7 +56,7 @@ void FileAsyncChannel::onLogBackEnd(const std::string &log_text) ofs_ << log_text << endl << flush; - if (ofs_.tellp() >= file_max_size_) + if (static_cast(ofs_.tellp()) >= file_max_size_) ofs_.close(); } diff --git a/util/serializer.cpp b/util/serializer.cpp index a354e2e..853295a 100644 --- a/util/serializer.cpp +++ b/util/serializer.cpp @@ -22,6 +22,18 @@ Serializer::Serializer(std::vector &block, Endian endian) : endian_(endian) { } +bool Serializer::extendSize(size_t need_size) +{ + size_t whole_size = pos_ + need_size; + if (type_ == kRaw) + return whole_size <= size_; + else { + p_block_->resize(whole_size); + start_ = p_block_->data(); + return true; + } +} + bool Serializer::append(uint8_t in) { if (!extendSize(1)) @@ -107,25 +119,35 @@ bool Serializer::append(const void *p_in, size_t size) if (!extendSize(size)) return false; - uint8_t *p = start_ + pos_; - memcpy(p, p_in, size); + uint8_t *p_out = start_ + pos_; + memcpy(p_out, p_in, size); pos_ += size; return true; } -bool Serializer::extendSize(size_t need_size) +bool Serializer::appendPOD(const void *p, size_t size) { - size_t whole_size = pos_ + need_size; - if (type_ == kRaw) - return whole_size <= size_; - else { - p_block_->resize(whole_size); - start_ = p_block_->data(); - return true; + if (!extendSize(size)) + return false; + + uint8_t *p_out = start_ + pos_; + if (endian_ == Endian::kLittle) { + memcpy(p_out, p, size); + } else { + //! 倒序写入 + const uint8_t *p_in = static_cast(p); + p_out += size - 1; + size_t times = size; + while (times-- > 0) + *p_out-- = *p_in++; } + + pos_ += size; + return true; } + ////////////// // 反序列化 // ////////////// @@ -137,6 +159,11 @@ Deserializer::Deserializer(const void *start, size_t size, Endian endian) : pos_(0) { } +bool Deserializer::checkSize(size_t need_size) const +{ + return (pos_ + need_size) <= size_; +} + bool Deserializer::fetch(uint8_t &out) { if (!checkSize(1)) @@ -219,13 +246,33 @@ bool Deserializer::fetch(uint64_t &out) return true; } -bool Deserializer::fetch(void *p_out, size_t size) +bool Deserializer::fetch(void *p, size_t size) { if (!checkSize(size)) return false; - const uint8_t *p = start_ + pos_; - memcpy(p_out, p, size); + const uint8_t *p_in = start_ + pos_; + memcpy(p, p_in, size); + + pos_ += size; + return true; +} + +bool Deserializer::fetchPOD(void *p, size_t size) +{ + if (!checkSize(size)) + return false; + + const uint8_t *p_in = start_ + pos_; + if (endian_ == Endian::kLittle) { + memcpy(p, p_in, size); + } else { + //! 倒序读出 + uint8_t *p_out = static_cast(p) + size - 1; + size_t times = size; + while (times-- > 0) + *p_out-- = *p_in++; + } pos_ += size; return true; @@ -242,11 +289,6 @@ const void* Deserializer::fetchNoCopy(size_t size) return p; } -bool Deserializer::checkSize(size_t need_size) const -{ - return (pos_ + need_size) <= size_; -} - } } @@ -261,8 +303,8 @@ Serializer& operator << (Serializer &s, uint32_t in) { s.append(in); return s; } Serializer& operator << (Serializer &s, int32_t in) { s.append(static_cast(in)); return s; } Serializer& operator << (Serializer &s, uint64_t in) { s.append(in); return s; } Serializer& operator << (Serializer &s, int64_t in) { s.append(static_cast(in)); return s; } -Serializer& operator << (Serializer &s, float in) { s.append(*reinterpret_cast(&in)); return s; } -Serializer& operator << (Serializer &s, double in) { s.append(*reinterpret_cast(&in)); return s; } +Serializer& operator << (Serializer &s, float in) { s.appendPOD(&in, sizeof(in)); return s; } +Serializer& operator << (Serializer &s, double in) { s.appendPOD(&in, sizeof(in)); return s; } Deserializer& operator >> (Deserializer &s, Endian endian) { s.setEndian(endian); return s; } Deserializer& operator >> (Deserializer &s, uint8_t &out) { s.fetch(out); return s; } @@ -273,5 +315,5 @@ Deserializer& operator >> (Deserializer &s, uint32_t &out) { s.fetch(out); retur Deserializer& operator >> (Deserializer &s, int32_t &out) { s.fetch(*((uint32_t*)&out)); return s; } Deserializer& operator >> (Deserializer &s, uint64_t &out) { s.fetch(out); return s; } Deserializer& operator >> (Deserializer &s, int64_t &out) { s.fetch(*((uint64_t*)&out)); return s; } -Deserializer& operator >> (Deserializer &s, float &out) { s.fetch(*reinterpret_cast(&out)); return s; } -Deserializer& operator >> (Deserializer &s, double &out) { s.fetch(*reinterpret_cast(&out)); return s; } +Deserializer& operator >> (Deserializer &s, float &out) { s.fetchPOD(&out, sizeof(out)); return s; } +Deserializer& operator >> (Deserializer &s, double &out) { s.fetchPOD(&out, sizeof(out)); return s; } diff --git a/util/serializer.h b/util/serializer.h index 6788e83..a056bf5 100644 --- a/util/serializer.h +++ b/util/serializer.h @@ -23,6 +23,7 @@ class Serializer { bool append(uint32_t in); bool append(uint64_t in); bool append(const void *p, size_t s); + bool appendPOD(const void *p, size_t s); protected: bool extendSize(size_t size); @@ -50,6 +51,7 @@ class Deserializer { bool fetch(uint32_t &out); bool fetch(uint64_t &out); bool fetch(void *p, size_t s); + bool fetchPOD(void *p, size_t s); const void* fetchNoCopy(size_t s); protected: -- Gitee From 3fdd079aeed8e294365918b54f2d5ca2341cd02c Mon Sep 17 00:00:00 2001 From: Hevake Date: Sat, 13 Aug 2022 19:29:03 +0800 Subject: [PATCH 13/24] =?UTF-8?q?=E4=BF=AE=E6=94=B9Makefile=EF=BC=8C?= =?UTF-8?q?=E5=B0=86=E5=BC=80=E5=90=AFASan=E5=86=85=E5=AD=98=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E4=BD=9C=E4=B8=BA=E5=8D=95=E7=8B=AC=E7=9A=84=E9=80=89?= =?UTF-8?q?=E9=A1=B9=20ENABLE=5FASAN?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 727af72..2cafdd7 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,11 @@ CCFLAGS := -Wall ifeq ($(RELEASE), 1) CCFLAGS += -O2 -Os else -CCFLAGS += -fsanitize=address -fno-omit-frame-pointer -DDEBUG=1 -O0 -ggdb +CCFLAGS += -DDEBUG=1 -O0 -ggdb +endif + +ifeq ($(ENABLE_ASAN), 1) +CCFLAGS += -fsanitize=address -fno-omit-frame-pointer LDFLAGS += -fsanitize=address -static-libasan endif -- Gitee From ecb5eec0aac52b46baf31177a68e250e50181da7 Mon Sep 17 00:00:00 2001 From: Hevake Date: Mon, 15 Aug 2022 08:04:59 +0800 Subject: [PATCH 14/24] =?UTF-8?q?=E5=B0=86main=E4=B8=8B=E7=9A=84example?= =?UTF-8?q?=E7=A7=BB=E5=88=B0example/main=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.mk | 3 +- example/Makefile | 6 +++ example/base/Makefile | 6 +++ example/coroutine/Makefile | 6 +++ example/event/Makefile | 6 +++ example/eventx/Makefile | 6 +++ example/http/Makefile | 6 +++ example/log/Makefile | 6 +++ example/main/00_empty/Makefile | 18 +++++++++ example/main/01_one_app/Makefile | 22 +++++++++++ .../main}/01_one_app/app.cpp | 0 .../example => example/main}/01_one_app/app.h | 0 .../main}/01_one_app/main.cpp | 0 .../main/02_more_than_one_apps}/.gitignore | 0 .../main}/02_more_than_one_apps/Makefile | 38 +++++++------------ .../main}/02_more_than_one_apps/app1/app.cpp | 0 .../main}/02_more_than_one_apps/app1/app.h | 0 .../main/02_more_than_one_apps/app1/app.mk | 3 ++ .../main}/02_more_than_one_apps/app1/sub.cpp | 0 .../main}/02_more_than_one_apps/app1/sub.h | 0 .../main}/02_more_than_one_apps/app2/app.cpp | 0 .../main}/02_more_than_one_apps/app2/app.h | 0 .../main/02_more_than_one_apps/app2/app.mk | 2 + .../main}/02_more_than_one_apps/app3/app.cpp | 0 .../main}/02_more_than_one_apps/app3/app.h | 0 .../main/02_more_than_one_apps/app3/app.mk | 2 + .../main}/02_more_than_one_apps/main.cpp | 0 .../03_nc_client_and_echo_server}/.gitignore | 0 .../03_nc_client_and_echo_server/Makefile | 36 ++++++------------ .../03_nc_client_and_echo_server/README.md | 0 .../echo_server/app.cpp | 0 .../echo_server/app.h | 0 .../echo_server/app.mk | 2 +- .../03_nc_client_and_echo_server/main.cpp | 0 .../nc_client/app.cpp | 0 .../nc_client/app.h | 0 .../nc_client/app.mk | 2 +- .../04_initiate_runtime_error}/.gitignore | 0 .../main/04_initiate_runtime_error/Makefile | 21 ++++++++++ .../04_initiate_runtime_error/README.txt | 0 .../main}/04_initiate_runtime_error/main.cpp | 0 example/main/Makefile | 6 +++ {main/example => example/main}/README.md | 0 example/mqtt/Makefile | 6 +++ example/network/Makefile | 6 +++ example/terminal/Makefile | 6 +++ main/example/00_empty/Makefile | 31 --------------- main/example/01_one_app/Makefile | 32 ---------------- .../example/02_more_than_one_apps/app1/app.mk | 1 - .../example/02_more_than_one_apps/app2/app.mk | 1 - .../example/02_more_than_one_apps/app3/app.mk | 1 - .../03_nc_client_and_echo_server/.gitignore | 1 - .../04_initiate_runtime_error/.gitignore | 1 - .../04_initiate_runtime_error/Makefile | 33 ---------------- main/example/build_env.mk | 29 -------------- 55 files changed, 163 insertions(+), 182 deletions(-) create mode 100644 example/Makefile create mode 100644 example/base/Makefile create mode 100644 example/coroutine/Makefile create mode 100644 example/event/Makefile create mode 100644 example/eventx/Makefile create mode 100644 example/http/Makefile create mode 100644 example/log/Makefile create mode 100644 example/main/00_empty/Makefile create mode 100644 example/main/01_one_app/Makefile rename {main/example => example/main}/01_one_app/app.cpp (100%) rename {main/example => example/main}/01_one_app/app.h (100%) rename {main/example => example/main}/01_one_app/main.cpp (100%) rename {main/example/00_empty => example/main/02_more_than_one_apps}/.gitignore (100%) rename {main/example => example/main}/02_more_than_one_apps/Makefile (33%) rename {main/example => example/main}/02_more_than_one_apps/app1/app.cpp (100%) rename {main/example => example/main}/02_more_than_one_apps/app1/app.h (100%) create mode 100644 example/main/02_more_than_one_apps/app1/app.mk rename {main/example => example/main}/02_more_than_one_apps/app1/sub.cpp (100%) rename {main/example => example/main}/02_more_than_one_apps/app1/sub.h (100%) rename {main/example => example/main}/02_more_than_one_apps/app2/app.cpp (100%) rename {main/example => example/main}/02_more_than_one_apps/app2/app.h (100%) create mode 100644 example/main/02_more_than_one_apps/app2/app.mk rename {main/example => example/main}/02_more_than_one_apps/app3/app.cpp (100%) rename {main/example => example/main}/02_more_than_one_apps/app3/app.h (100%) create mode 100644 example/main/02_more_than_one_apps/app3/app.mk rename {main/example => example/main}/02_more_than_one_apps/main.cpp (100%) rename {main/example/01_one_app => example/main/03_nc_client_and_echo_server}/.gitignore (100%) rename {main/example => example/main}/03_nc_client_and_echo_server/Makefile (32%) rename {main/example => example/main}/03_nc_client_and_echo_server/README.md (100%) rename {main/example => example/main}/03_nc_client_and_echo_server/echo_server/app.cpp (100%) rename {main/example => example/main}/03_nc_client_and_echo_server/echo_server/app.h (100%) rename {main/example => example/main}/03_nc_client_and_echo_server/echo_server/app.mk (41%) rename {main/example => example/main}/03_nc_client_and_echo_server/main.cpp (100%) rename {main/example => example/main}/03_nc_client_and_echo_server/nc_client/app.cpp (100%) rename {main/example => example/main}/03_nc_client_and_echo_server/nc_client/app.h (100%) rename {main/example => example/main}/03_nc_client_and_echo_server/nc_client/app.mk (42%) rename {main/example/02_more_than_one_apps => example/main/04_initiate_runtime_error}/.gitignore (100%) create mode 100644 example/main/04_initiate_runtime_error/Makefile rename {main/example => example/main}/04_initiate_runtime_error/README.txt (100%) rename {main/example => example/main}/04_initiate_runtime_error/main.cpp (100%) create mode 100644 example/main/Makefile rename {main/example => example/main}/README.md (100%) create mode 100644 example/mqtt/Makefile create mode 100644 example/network/Makefile create mode 100644 example/terminal/Makefile delete mode 100644 main/example/00_empty/Makefile delete mode 100644 main/example/01_one_app/Makefile delete mode 100644 main/example/02_more_than_one_apps/app1/app.mk delete mode 100644 main/example/02_more_than_one_apps/app2/app.mk delete mode 100644 main/example/02_more_than_one_apps/app3/app.mk delete mode 100644 main/example/03_nc_client_and_echo_server/.gitignore delete mode 100644 main/example/04_initiate_runtime_error/.gitignore delete mode 100644 main/example/04_initiate_runtime_error/Makefile delete mode 100644 main/example/build_env.mk diff --git a/config.mk b/config.mk index 7b1b536..d493c0a 100644 --- a/config.mk +++ b/config.mk @@ -9,4 +9,5 @@ app_y += coroutine app_y += mqtt app_y += terminal app_y += main -app_y += sample +#app_y += sample +app_y += example diff --git a/example/Makefile b/example/Makefile new file mode 100644 index 0000000..79265bf --- /dev/null +++ b/example/Makefile @@ -0,0 +1,6 @@ +subdirs := $(shell find -maxdepth 1 -type d | grep -v '.') + +all test clean distclean: + @for i in $(subdirs); do \ + $(MAKE) -C $$i $@ || exit $$? ; \ + done diff --git a/example/base/Makefile b/example/base/Makefile new file mode 100644 index 0000000..7c302e4 --- /dev/null +++ b/example/base/Makefile @@ -0,0 +1,6 @@ +subdirs := $(shell ls | grep -v Makefile) + +all test clean distclean: + @for i in $(subdirs); do \ + $(MAKE) -C $$i $@ || exit $$? ; \ + done diff --git a/example/coroutine/Makefile b/example/coroutine/Makefile new file mode 100644 index 0000000..7c302e4 --- /dev/null +++ b/example/coroutine/Makefile @@ -0,0 +1,6 @@ +subdirs := $(shell ls | grep -v Makefile) + +all test clean distclean: + @for i in $(subdirs); do \ + $(MAKE) -C $$i $@ || exit $$? ; \ + done diff --git a/example/event/Makefile b/example/event/Makefile new file mode 100644 index 0000000..7c302e4 --- /dev/null +++ b/example/event/Makefile @@ -0,0 +1,6 @@ +subdirs := $(shell ls | grep -v Makefile) + +all test clean distclean: + @for i in $(subdirs); do \ + $(MAKE) -C $$i $@ || exit $$? ; \ + done diff --git a/example/eventx/Makefile b/example/eventx/Makefile new file mode 100644 index 0000000..7c302e4 --- /dev/null +++ b/example/eventx/Makefile @@ -0,0 +1,6 @@ +subdirs := $(shell ls | grep -v Makefile) + +all test clean distclean: + @for i in $(subdirs); do \ + $(MAKE) -C $$i $@ || exit $$? ; \ + done diff --git a/example/http/Makefile b/example/http/Makefile new file mode 100644 index 0000000..7c302e4 --- /dev/null +++ b/example/http/Makefile @@ -0,0 +1,6 @@ +subdirs := $(shell ls | grep -v Makefile) + +all test clean distclean: + @for i in $(subdirs); do \ + $(MAKE) -C $$i $@ || exit $$? ; \ + done diff --git a/example/log/Makefile b/example/log/Makefile new file mode 100644 index 0000000..7c302e4 --- /dev/null +++ b/example/log/Makefile @@ -0,0 +1,6 @@ +subdirs := $(shell ls | grep -v Makefile) + +all test clean distclean: + @for i in $(subdirs); do \ + $(MAKE) -C $$i $@ || exit $$? ; \ + done diff --git a/example/main/00_empty/Makefile b/example/main/00_empty/Makefile new file mode 100644 index 0000000..6ac3306 --- /dev/null +++ b/example/main/00_empty/Makefile @@ -0,0 +1,18 @@ +EXE_NAME := example/main/00_empty + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_main \ + -ltbox_terminal \ + -ltbox_network \ + -ltbox_eventx \ + -ltbox_eventx \ + -ltbox_event \ + -ltbox_log \ + -ltbox_util \ + -ltbox_base \ + -lpthread \ + -ldl \ + -rdynamic + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/example/main/01_one_app/Makefile b/example/main/01_one_app/Makefile new file mode 100644 index 0000000..0206ff7 --- /dev/null +++ b/example/main/01_one_app/Makefile @@ -0,0 +1,22 @@ +EXE_NAME := example/main/01_one_app + +CPP_SRC_FILES = \ + app.cpp \ + main.cpp \ + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_main \ + -ltbox_terminal \ + -ltbox_network \ + -ltbox_eventx \ + -ltbox_eventx \ + -ltbox_event \ + -ltbox_log \ + -ltbox_util \ + -ltbox_base \ + -lpthread \ + -ldl \ + -rdynamic + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/main/example/01_one_app/app.cpp b/example/main/01_one_app/app.cpp similarity index 100% rename from main/example/01_one_app/app.cpp rename to example/main/01_one_app/app.cpp diff --git a/main/example/01_one_app/app.h b/example/main/01_one_app/app.h similarity index 100% rename from main/example/01_one_app/app.h rename to example/main/01_one_app/app.h diff --git a/main/example/01_one_app/main.cpp b/example/main/01_one_app/main.cpp similarity index 100% rename from main/example/01_one_app/main.cpp rename to example/main/01_one_app/main.cpp diff --git a/main/example/00_empty/.gitignore b/example/main/02_more_than_one_apps/.gitignore similarity index 100% rename from main/example/00_empty/.gitignore rename to example/main/02_more_than_one_apps/.gitignore diff --git a/main/example/02_more_than_one_apps/Makefile b/example/main/02_more_than_one_apps/Makefile similarity index 33% rename from main/example/02_more_than_one_apps/Makefile rename to example/main/02_more_than_one_apps/Makefile index 088539c..e42e8b6 100644 --- a/main/example/02_more_than_one_apps/Makefile +++ b/example/main/02_more_than_one_apps/Makefile @@ -1,37 +1,25 @@ -include ../build_env.mk +EXE_NAME := example/main/02_more_than_one_apps -.PHONY : all clean distclean +CPP_SRC_FILES = \ + main.cpp \ -TARGET := sample -OBJECTS := main.o - -include app1/app.mk -include app2/app.mk -include app3/app.mk - -CXXFLAGS += -ggdb -DLOG_MODULE_ID='"demo"' -LDFLAGS += -L.. \ +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ -ltbox_main \ - -ltbox_log \ -ltbox_terminal \ -ltbox_network \ -ltbox_eventx \ + -ltbox_eventx \ -ltbox_event \ + -ltbox_log \ -ltbox_util \ -ltbox_base \ + -lpthread \ -ldl \ - -lpthread - -CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer -LDFLAGS += -fsanitize=address -static-libasan - -all : $(TARGET) - -$(TARGET): $(OBJECTS) - $(CXX) -o $@ $^ $(CXXFLAGS) $(LDFLAGS) + -rdynamic -clean: - rm -rf $(OBJECTS) +include app1/app.mk +include app2/app.mk +include app3/app.mk -distclean: clean - rm -rf $(TARGET) +include ${TOP_DIR}/tools/exe_common.mk diff --git a/main/example/02_more_than_one_apps/app1/app.cpp b/example/main/02_more_than_one_apps/app1/app.cpp similarity index 100% rename from main/example/02_more_than_one_apps/app1/app.cpp rename to example/main/02_more_than_one_apps/app1/app.cpp diff --git a/main/example/02_more_than_one_apps/app1/app.h b/example/main/02_more_than_one_apps/app1/app.h similarity index 100% rename from main/example/02_more_than_one_apps/app1/app.h rename to example/main/02_more_than_one_apps/app1/app.h diff --git a/example/main/02_more_than_one_apps/app1/app.mk b/example/main/02_more_than_one_apps/app1/app.mk new file mode 100644 index 0000000..8c1e5b0 --- /dev/null +++ b/example/main/02_more_than_one_apps/app1/app.mk @@ -0,0 +1,3 @@ +CPP_SRC_FILES += \ + app1/app.cpp \ + app1/sub.cpp \ diff --git a/main/example/02_more_than_one_apps/app1/sub.cpp b/example/main/02_more_than_one_apps/app1/sub.cpp similarity index 100% rename from main/example/02_more_than_one_apps/app1/sub.cpp rename to example/main/02_more_than_one_apps/app1/sub.cpp diff --git a/main/example/02_more_than_one_apps/app1/sub.h b/example/main/02_more_than_one_apps/app1/sub.h similarity index 100% rename from main/example/02_more_than_one_apps/app1/sub.h rename to example/main/02_more_than_one_apps/app1/sub.h diff --git a/main/example/02_more_than_one_apps/app2/app.cpp b/example/main/02_more_than_one_apps/app2/app.cpp similarity index 100% rename from main/example/02_more_than_one_apps/app2/app.cpp rename to example/main/02_more_than_one_apps/app2/app.cpp diff --git a/main/example/02_more_than_one_apps/app2/app.h b/example/main/02_more_than_one_apps/app2/app.h similarity index 100% rename from main/example/02_more_than_one_apps/app2/app.h rename to example/main/02_more_than_one_apps/app2/app.h diff --git a/example/main/02_more_than_one_apps/app2/app.mk b/example/main/02_more_than_one_apps/app2/app.mk new file mode 100644 index 0000000..0647038 --- /dev/null +++ b/example/main/02_more_than_one_apps/app2/app.mk @@ -0,0 +1,2 @@ +CPP_SRC_FILES += \ + app2/app.cpp \ diff --git a/main/example/02_more_than_one_apps/app3/app.cpp b/example/main/02_more_than_one_apps/app3/app.cpp similarity index 100% rename from main/example/02_more_than_one_apps/app3/app.cpp rename to example/main/02_more_than_one_apps/app3/app.cpp diff --git a/main/example/02_more_than_one_apps/app3/app.h b/example/main/02_more_than_one_apps/app3/app.h similarity index 100% rename from main/example/02_more_than_one_apps/app3/app.h rename to example/main/02_more_than_one_apps/app3/app.h diff --git a/example/main/02_more_than_one_apps/app3/app.mk b/example/main/02_more_than_one_apps/app3/app.mk new file mode 100644 index 0000000..6aaae2b --- /dev/null +++ b/example/main/02_more_than_one_apps/app3/app.mk @@ -0,0 +1,2 @@ +CPP_SRC_FILES += \ + app3/app.cpp \ diff --git a/main/example/02_more_than_one_apps/main.cpp b/example/main/02_more_than_one_apps/main.cpp similarity index 100% rename from main/example/02_more_than_one_apps/main.cpp rename to example/main/02_more_than_one_apps/main.cpp diff --git a/main/example/01_one_app/.gitignore b/example/main/03_nc_client_and_echo_server/.gitignore similarity index 100% rename from main/example/01_one_app/.gitignore rename to example/main/03_nc_client_and_echo_server/.gitignore diff --git a/main/example/03_nc_client_and_echo_server/Makefile b/example/main/03_nc_client_and_echo_server/Makefile similarity index 32% rename from main/example/03_nc_client_and_echo_server/Makefile rename to example/main/03_nc_client_and_echo_server/Makefile index 4eacdcf..0b10461 100644 --- a/main/example/03_nc_client_and_echo_server/Makefile +++ b/example/main/03_nc_client_and_echo_server/Makefile @@ -1,36 +1,24 @@ -include ../build_env.mk +EXE_NAME := example/main/03_nc_client_and_echo_server -.PHONY : all clean distclean +CPP_SRC_FILES = \ + main.cpp \ -TARGET := sample -OBJECTS := main.o - -include nc_client/app.mk -include echo_server/app.mk - -CXXFLAGS += -ggdb -DLOG_MODULE_ID='"demo"' -LDFLAGS += -L.. \ +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ -ltbox_main \ - -ltbox_log \ -ltbox_terminal \ -ltbox_network \ -ltbox_eventx \ + -ltbox_eventx \ -ltbox_event \ + -ltbox_log \ -ltbox_util \ -ltbox_base \ + -lpthread \ -ldl \ - -lpthread - -CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer -LDFLAGS += -fsanitize=address -static-libasan - -all : $(TARGET) + -rdynamic -$(TARGET): $(OBJECTS) - $(CXX) -o $@ $^ $(CXXFLAGS) $(LDFLAGS) - -clean: - rm -rf $(OBJECTS) +include echo_server/app.mk +include nc_client/app.mk -distclean: clean - rm -rf $(TARGET) +include ${TOP_DIR}/tools/exe_common.mk diff --git a/main/example/03_nc_client_and_echo_server/README.md b/example/main/03_nc_client_and_echo_server/README.md similarity index 100% rename from main/example/03_nc_client_and_echo_server/README.md rename to example/main/03_nc_client_and_echo_server/README.md diff --git a/main/example/03_nc_client_and_echo_server/echo_server/app.cpp b/example/main/03_nc_client_and_echo_server/echo_server/app.cpp similarity index 100% rename from main/example/03_nc_client_and_echo_server/echo_server/app.cpp rename to example/main/03_nc_client_and_echo_server/echo_server/app.cpp diff --git a/main/example/03_nc_client_and_echo_server/echo_server/app.h b/example/main/03_nc_client_and_echo_server/echo_server/app.h similarity index 100% rename from main/example/03_nc_client_and_echo_server/echo_server/app.h rename to example/main/03_nc_client_and_echo_server/echo_server/app.h diff --git a/main/example/03_nc_client_and_echo_server/echo_server/app.mk b/example/main/03_nc_client_and_echo_server/echo_server/app.mk similarity index 41% rename from main/example/03_nc_client_and_echo_server/echo_server/app.mk rename to example/main/03_nc_client_and_echo_server/echo_server/app.mk index 04bddb8..1ee8975 100644 --- a/main/example/03_nc_client_and_echo_server/echo_server/app.mk +++ b/example/main/03_nc_client_and_echo_server/echo_server/app.mk @@ -1,2 +1,2 @@ -OBJECTS += echo_server/app.o +CPP_SRC_FILES += echo_server/app.cpp LDFLAGS += -ltbox_network diff --git a/main/example/03_nc_client_and_echo_server/main.cpp b/example/main/03_nc_client_and_echo_server/main.cpp similarity index 100% rename from main/example/03_nc_client_and_echo_server/main.cpp rename to example/main/03_nc_client_and_echo_server/main.cpp diff --git a/main/example/03_nc_client_and_echo_server/nc_client/app.cpp b/example/main/03_nc_client_and_echo_server/nc_client/app.cpp similarity index 100% rename from main/example/03_nc_client_and_echo_server/nc_client/app.cpp rename to example/main/03_nc_client_and_echo_server/nc_client/app.cpp diff --git a/main/example/03_nc_client_and_echo_server/nc_client/app.h b/example/main/03_nc_client_and_echo_server/nc_client/app.h similarity index 100% rename from main/example/03_nc_client_and_echo_server/nc_client/app.h rename to example/main/03_nc_client_and_echo_server/nc_client/app.h diff --git a/main/example/03_nc_client_and_echo_server/nc_client/app.mk b/example/main/03_nc_client_and_echo_server/nc_client/app.mk similarity index 42% rename from main/example/03_nc_client_and_echo_server/nc_client/app.mk rename to example/main/03_nc_client_and_echo_server/nc_client/app.mk index f857239..948c405 100644 --- a/main/example/03_nc_client_and_echo_server/nc_client/app.mk +++ b/example/main/03_nc_client_and_echo_server/nc_client/app.mk @@ -1,2 +1,2 @@ -OBJECTS += nc_client/app.o +CPP_SRC_FILES += nc_client/app.cpp LDFLAGS += -ltbox_network diff --git a/main/example/02_more_than_one_apps/.gitignore b/example/main/04_initiate_runtime_error/.gitignore similarity index 100% rename from main/example/02_more_than_one_apps/.gitignore rename to example/main/04_initiate_runtime_error/.gitignore diff --git a/example/main/04_initiate_runtime_error/Makefile b/example/main/04_initiate_runtime_error/Makefile new file mode 100644 index 0000000..0111078 --- /dev/null +++ b/example/main/04_initiate_runtime_error/Makefile @@ -0,0 +1,21 @@ +EXE_NAME := example/main/04_initiate_runtime_error + +CPP_SRC_FILES = \ + main.cpp \ + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_main \ + -ltbox_terminal \ + -ltbox_network \ + -ltbox_eventx \ + -ltbox_eventx \ + -ltbox_event \ + -ltbox_log \ + -ltbox_util \ + -ltbox_base \ + -lpthread \ + -ldl \ + -rdynamic + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/main/example/04_initiate_runtime_error/README.txt b/example/main/04_initiate_runtime_error/README.txt similarity index 100% rename from main/example/04_initiate_runtime_error/README.txt rename to example/main/04_initiate_runtime_error/README.txt diff --git a/main/example/04_initiate_runtime_error/main.cpp b/example/main/04_initiate_runtime_error/main.cpp similarity index 100% rename from main/example/04_initiate_runtime_error/main.cpp rename to example/main/04_initiate_runtime_error/main.cpp diff --git a/example/main/Makefile b/example/main/Makefile new file mode 100644 index 0000000..79265bf --- /dev/null +++ b/example/main/Makefile @@ -0,0 +1,6 @@ +subdirs := $(shell find -maxdepth 1 -type d | grep -v '.') + +all test clean distclean: + @for i in $(subdirs); do \ + $(MAKE) -C $$i $@ || exit $$? ; \ + done diff --git a/main/example/README.md b/example/main/README.md similarity index 100% rename from main/example/README.md rename to example/main/README.md diff --git a/example/mqtt/Makefile b/example/mqtt/Makefile new file mode 100644 index 0000000..7c302e4 --- /dev/null +++ b/example/mqtt/Makefile @@ -0,0 +1,6 @@ +subdirs := $(shell ls | grep -v Makefile) + +all test clean distclean: + @for i in $(subdirs); do \ + $(MAKE) -C $$i $@ || exit $$? ; \ + done diff --git a/example/network/Makefile b/example/network/Makefile new file mode 100644 index 0000000..7c302e4 --- /dev/null +++ b/example/network/Makefile @@ -0,0 +1,6 @@ +subdirs := $(shell ls | grep -v Makefile) + +all test clean distclean: + @for i in $(subdirs); do \ + $(MAKE) -C $$i $@ || exit $$? ; \ + done diff --git a/example/terminal/Makefile b/example/terminal/Makefile new file mode 100644 index 0000000..7c302e4 --- /dev/null +++ b/example/terminal/Makefile @@ -0,0 +1,6 @@ +subdirs := $(shell ls | grep -v Makefile) + +all test clean distclean: + @for i in $(subdirs); do \ + $(MAKE) -C $$i $@ || exit $$? ; \ + done diff --git a/main/example/00_empty/Makefile b/main/example/00_empty/Makefile deleted file mode 100644 index 00adba7..0000000 --- a/main/example/00_empty/Makefile +++ /dev/null @@ -1,31 +0,0 @@ -include ../build_env.mk - -.PHONY : all clean distclean - -TARGET := sample -CXXFLAGS += -ggdb -DLOG_MODULE_ID='"demo"' -LDFLAGS += -L.. \ - -ltbox_main \ - -ltbox_log \ - -ltbox_terminal \ - -ltbox_network \ - -ltbox_eventx \ - -ltbox_event \ - -ltbox_util \ - -ltbox_base \ - -ldl \ - -lpthread - -CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer -LDFLAGS += -fsanitize=address -static-libasan - -all : $(TARGET) - -$(TARGET): $(OBJECTS) - $(CXX) -o $@ $^ $(CXXFLAGS) $(LDFLAGS) - -clean: - rm -rf $(OBJECTS) - -distclean: clean - rm -rf $(TARGET) diff --git a/main/example/01_one_app/Makefile b/main/example/01_one_app/Makefile deleted file mode 100644 index 8db7754..0000000 --- a/main/example/01_one_app/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -include ../build_env.mk - -.PHONY : all clean distclean - -TARGET := sample -CXXFLAGS += -ggdb -DLOG_MODULE_ID='"demo"' -LDFLAGS += -L.. \ - -ltbox_main \ - -ltbox_log \ - -ltbox_terminal \ - -ltbox_network \ - -ltbox_eventx \ - -ltbox_event \ - -ltbox_util \ - -ltbox_base \ - -ldl \ - -lpthread - -CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer -LDFLAGS += -fsanitize=address -static-libasan -OBJECTS := main.o app.o - -all : $(TARGET) - -$(TARGET): $(OBJECTS) - $(CXX) -o $@ $^ $(CXXFLAGS) $(LDFLAGS) - -clean: - rm -rf $(OBJECTS) - -distclean: clean - rm -rf $(TARGET) diff --git a/main/example/02_more_than_one_apps/app1/app.mk b/main/example/02_more_than_one_apps/app1/app.mk deleted file mode 100644 index b321eda..0000000 --- a/main/example/02_more_than_one_apps/app1/app.mk +++ /dev/null @@ -1 +0,0 @@ -OBJECTS += app1/app.o app1/sub.o diff --git a/main/example/02_more_than_one_apps/app2/app.mk b/main/example/02_more_than_one_apps/app2/app.mk deleted file mode 100644 index fbe78ca..0000000 --- a/main/example/02_more_than_one_apps/app2/app.mk +++ /dev/null @@ -1 +0,0 @@ -OBJECTS += app2/app.o diff --git a/main/example/02_more_than_one_apps/app3/app.mk b/main/example/02_more_than_one_apps/app3/app.mk deleted file mode 100644 index f365241..0000000 --- a/main/example/02_more_than_one_apps/app3/app.mk +++ /dev/null @@ -1 +0,0 @@ -OBJECTS += app3/app.o diff --git a/main/example/03_nc_client_and_echo_server/.gitignore b/main/example/03_nc_client_and_echo_server/.gitignore deleted file mode 100644 index ae6321f..0000000 --- a/main/example/03_nc_client_and_echo_server/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/sample diff --git a/main/example/04_initiate_runtime_error/.gitignore b/main/example/04_initiate_runtime_error/.gitignore deleted file mode 100644 index ae6321f..0000000 --- a/main/example/04_initiate_runtime_error/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/sample diff --git a/main/example/04_initiate_runtime_error/Makefile b/main/example/04_initiate_runtime_error/Makefile deleted file mode 100644 index a0a3c01..0000000 --- a/main/example/04_initiate_runtime_error/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -include ../build_env.mk - -.PHONY : all clean distclean - -TARGET := sample -CXXFLAGS += -ggdb -DLOG_MODULE_ID='"demo"' -LDFLAGS += -L.. \ - -ltbox_main \ - -ltbox_log \ - -ltbox_terminal \ - -ltbox_network \ - -ltbox_eventx \ - -ltbox_event \ - -ltbox_util \ - -ltbox_base \ - -lpthread \ - -ldl \ - -rdynamic \ - -CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer -LDFLAGS += -fsanitize=address -static-libasan -OBJECTS := main.o - -all : $(TARGET) - -$(TARGET): $(OBJECTS) - $(CXX) -o $@ $^ $(CXXFLAGS) $(LDFLAGS) - -clean: - rm -rf $(OBJECTS) - -distclean: clean - rm -rf $(TARGET) diff --git a/main/example/build_env.mk b/main/example/build_env.mk deleted file mode 100644 index 5848111..0000000 --- a/main/example/build_env.mk +++ /dev/null @@ -1,29 +0,0 @@ -STAGING_DIR := ../../../.staging - -STAGING_INCLUDE := $(STAGING_DIR)/include -STAGING_LIB := $(STAGING_DIR)/lib - -CCFLAGS := -I$(STAGING_INCLUDE) -I$(CONSTANT_INCLUDE) -CFLAGS := $(CCFLAGS) -std=c99 -CXXFLAGS := $(CCFLAGS) -std=c++11 -LDFLAGS := -L$(STAGING_LIB) -INSTALL_DIR := $(STAGING_DIR) -DESTDIR := $(STAGING_DIR) -prefix := - -TOOLCHAIN_PREFIX := -AR := $(TOOLCHAIN_PREFIX)ar -AS := $(TOOLCHAIN_PREFIX)as -CXX := $(TOOLCHAIN_PREFIX)g++ -CC := $(TOOLCHAIN_PREFIX)gcc -NM := $(TOOLCHAIN_PREFIX)nm -OBJCOPY := $(TOOLCHAIN_PREFIX)objcopy -OBJDUMP := $(TOOLCHAIN_PREFIX)objdump -STRINGS := $(TOOLCHAIN_PREFIX)strings -SSTRIP := $(TOOLCHAIN_PREFIX)sstrip -LSTRIP := $(TOOLCHAIN_PREFIX)lstrip -STRIP := $(TOOLCHAIN_PREFIX)strip - -export STAGING_INCLUDE STAGING_LIB INSTALL_DIR DESTDIR prefix -export AR AS CC NM OBJCOPY OBJDUMP CXX STRIP SSTRIP STRINGS LSTRIP -export CFLAGS CXXFLAGS LDFLAGS -- Gitee From c5027a0ec2de9dbd49012e3bda0b71d9aacd78e5 Mon Sep 17 00:00:00 2001 From: Hevake Date: Mon, 15 Aug 2022 20:35:31 +0800 Subject: [PATCH 15/24] =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BA=86event=E7=9A=84?= =?UTF-8?q?example?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- event/example/basic/.gitignore | 2 - event/example/basic/Makefile | 45 ------------------- event/example/build_env.mk | 29 ------------ event/example/calc_game/Makefile | 19 -------- example/Makefile | 6 +-- example/event/01-io/Makefile | 10 +++++ .../event/01-io/main.cpp | 0 example/event/02-timer/Makefile | 10 +++++ .../event/02-timer/main.cpp | 0 example/event/03-signal/Makefile | 10 +++++ .../event/03-signal/main.cpp | 0 example/event/04-run-in-loop/Makefile | 10 +++++ .../event/04-run-in-loop/main.cpp | 0 example/event/05-run-next-seq/Makefile | 10 +++++ .../event/05-run-next-seq/main.cpp | 0 example/event/06-stdin-timer-signal/Makefile | 10 +++++ .../event/06-stdin-timer-signal/main.cpp | 0 example/event/07-delay-delete/Makefile | 10 +++++ .../event/07-delay-delete/main.cpp | 0 .../event/08-calc-game}/.gitignore | 0 example/event/08-calc-game/Makefile | 12 +++++ .../event/08-calc-game}/game.cpp | 0 .../event/08-calc-game}/game.h | 0 .../event/08-calc-game}/game_lite.cpp | 0 .../event/08-calc-game}/game_lite.h | 0 .../event/08-calc-game}/main.cpp | 0 example/event/Makefile | 6 +-- example/main/Makefile | 6 +-- 28 files changed, 88 insertions(+), 107 deletions(-) delete mode 100644 event/example/basic/.gitignore delete mode 100644 event/example/basic/Makefile delete mode 100644 event/example/build_env.mk delete mode 100644 event/example/calc_game/Makefile create mode 100644 example/event/01-io/Makefile rename event/example/basic/io_example.cpp => example/event/01-io/main.cpp (100%) create mode 100644 example/event/02-timer/Makefile rename event/example/basic/timer_example.cpp => example/event/02-timer/main.cpp (100%) create mode 100644 example/event/03-signal/Makefile rename event/example/basic/signal_example.cpp => example/event/03-signal/main.cpp (100%) create mode 100644 example/event/04-run-in-loop/Makefile rename event/example/basic/run_in_loop_demo.cpp => example/event/04-run-in-loop/main.cpp (100%) create mode 100644 example/event/05-run-next-seq/Makefile rename event/example/basic/run_next_seq_demo.cpp => example/event/05-run-next-seq/main.cpp (100%) create mode 100644 example/event/06-stdin-timer-signal/Makefile rename event/example/basic/stdin_timer_signal_demo.cpp => example/event/06-stdin-timer-signal/main.cpp (100%) create mode 100644 example/event/07-delay-delete/Makefile rename event/example/basic/delay_delete_demo.cpp => example/event/07-delay-delete/main.cpp (100%) rename {event/example/calc_game => example/event/08-calc-game}/.gitignore (100%) create mode 100644 example/event/08-calc-game/Makefile rename {event/example/calc_game => example/event/08-calc-game}/game.cpp (100%) rename {event/example/calc_game => example/event/08-calc-game}/game.h (100%) rename {event/example/calc_game => example/event/08-calc-game}/game_lite.cpp (100%) rename {event/example/calc_game => example/event/08-calc-game}/game_lite.h (100%) rename {event/example/calc_game => example/event/08-calc-game}/main.cpp (100%) diff --git a/event/example/basic/.gitignore b/event/example/basic/.gitignore deleted file mode 100644 index 9613aa8..0000000 --- a/event/example/basic/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/*demo -/*_example diff --git a/event/example/basic/Makefile b/event/example/basic/Makefile deleted file mode 100644 index 06ad74f..0000000 --- a/event/example/basic/Makefile +++ /dev/null @@ -1,45 +0,0 @@ -include ../build_env.mk - -TARGETS=io_example timer_example signal_example \ - run_in_loop_demo stdin_timer_signal_demo \ - run_next_seq_demo delay_delete_demo - -CXXFLAGS += -ggdb -#LDFLAGS += -ltbox_event -ltbox_base -levent_core -lev -lpthread -LDFLAGS += -ltbox_event -ltbox_base -lpthread - -CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer -LDFLAGS += -fsanitize=address -static-libasan - -all: $(TARGETS) - -stdin_timer_signal_demo : stdin_timer_signal_demo.o - $(CXX) -o $@ $^ $(LDFLAGS) - -run_in_loop_demo : run_in_loop_demo.o - $(CXX) -o $@ $^ $(LDFLAGS) - -run_next_seq_demo : run_next_seq_demo.o - $(CXX) -o $@ $^ $(LDFLAGS) - -timer_example : timer_example.o - $(CXX) -o $@ $^ $(LDFLAGS) - -signal_example : signal_example.o - $(CXX) -o $@ $^ $(LDFLAGS) - -io_example : io_example.o - $(CXX) -o $@ $^ $(LDFLAGS) - -delay_delete_demo : delay_delete_demo.o - $(CXX) -o $@ $^ $(LDFLAGS) - -clean: - rm -rf *.o - -distclean : clean - rm $(TARGETS) - -install: - -uninstall: diff --git a/event/example/build_env.mk b/event/example/build_env.mk deleted file mode 100644 index 5848111..0000000 --- a/event/example/build_env.mk +++ /dev/null @@ -1,29 +0,0 @@ -STAGING_DIR := ../../../.staging - -STAGING_INCLUDE := $(STAGING_DIR)/include -STAGING_LIB := $(STAGING_DIR)/lib - -CCFLAGS := -I$(STAGING_INCLUDE) -I$(CONSTANT_INCLUDE) -CFLAGS := $(CCFLAGS) -std=c99 -CXXFLAGS := $(CCFLAGS) -std=c++11 -LDFLAGS := -L$(STAGING_LIB) -INSTALL_DIR := $(STAGING_DIR) -DESTDIR := $(STAGING_DIR) -prefix := - -TOOLCHAIN_PREFIX := -AR := $(TOOLCHAIN_PREFIX)ar -AS := $(TOOLCHAIN_PREFIX)as -CXX := $(TOOLCHAIN_PREFIX)g++ -CC := $(TOOLCHAIN_PREFIX)gcc -NM := $(TOOLCHAIN_PREFIX)nm -OBJCOPY := $(TOOLCHAIN_PREFIX)objcopy -OBJDUMP := $(TOOLCHAIN_PREFIX)objdump -STRINGS := $(TOOLCHAIN_PREFIX)strings -SSTRIP := $(TOOLCHAIN_PREFIX)sstrip -LSTRIP := $(TOOLCHAIN_PREFIX)lstrip -STRIP := $(TOOLCHAIN_PREFIX)strip - -export STAGING_INCLUDE STAGING_LIB INSTALL_DIR DESTDIR prefix -export AR AS CC NM OBJCOPY OBJDUMP CXX STRIP SSTRIP STRINGS LSTRIP -export CFLAGS CXXFLAGS LDFLAGS diff --git a/event/example/calc_game/Makefile b/event/example/calc_game/Makefile deleted file mode 100644 index 9a4eecb..0000000 --- a/event/example/calc_game/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -include ../build_env.mk - -TARGET := calc_game -OBJECTS := main.o game.o game_lite.o -LDFLAGS += -L.. -ltbox_event -ltbox_base -levent_core -lev - -CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer -LDFLAGS += -fsanitize=address -static-libasan - -all : $(TARGET) - -$(TARGET) : $(OBJECTS) - $(CXX) -o $@ $^ $(LDFLAGS) - -clean: - rm -rf $(OBJECTS) - -distclean: clean - rm -f $(TARGET) diff --git a/example/Makefile b/example/Makefile index 79265bf..2069292 100644 --- a/example/Makefile +++ b/example/Makefile @@ -1,6 +1,4 @@ -subdirs := $(shell find -maxdepth 1 -type d | grep -v '.') - all test clean distclean: - @for i in $(subdirs); do \ - $(MAKE) -C $$i $@ || exit $$? ; \ + @for i in $(shell ls); do \ + [ -d $$i ] && ( $(MAKE) -C $$i $@ || exit $$? ) || exit 0; \ done diff --git a/example/event/01-io/Makefile b/example/event/01-io/Makefile new file mode 100644 index 0000000..6341ab2 --- /dev/null +++ b/example/event/01-io/Makefile @@ -0,0 +1,10 @@ +EXE_NAME := example/event/01-io + +CPP_SRC_FILES := main.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_event \ + -ltbox_base \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/event/example/basic/io_example.cpp b/example/event/01-io/main.cpp similarity index 100% rename from event/example/basic/io_example.cpp rename to example/event/01-io/main.cpp diff --git a/example/event/02-timer/Makefile b/example/event/02-timer/Makefile new file mode 100644 index 0000000..174e5d9 --- /dev/null +++ b/example/event/02-timer/Makefile @@ -0,0 +1,10 @@ +EXE_NAME := example/event/02-timer + +CPP_SRC_FILES := main.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_event \ + -ltbox_base \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/event/example/basic/timer_example.cpp b/example/event/02-timer/main.cpp similarity index 100% rename from event/example/basic/timer_example.cpp rename to example/event/02-timer/main.cpp diff --git a/example/event/03-signal/Makefile b/example/event/03-signal/Makefile new file mode 100644 index 0000000..14b436a --- /dev/null +++ b/example/event/03-signal/Makefile @@ -0,0 +1,10 @@ +EXE_NAME := example/event/03-signal + +CPP_SRC_FILES := main.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_event \ + -ltbox_base \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/event/example/basic/signal_example.cpp b/example/event/03-signal/main.cpp similarity index 100% rename from event/example/basic/signal_example.cpp rename to example/event/03-signal/main.cpp diff --git a/example/event/04-run-in-loop/Makefile b/example/event/04-run-in-loop/Makefile new file mode 100644 index 0000000..1c3173a --- /dev/null +++ b/example/event/04-run-in-loop/Makefile @@ -0,0 +1,10 @@ +EXE_NAME := example/event/04-run-in-loop + +CPP_SRC_FILES := main.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_event \ + -ltbox_base \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/event/example/basic/run_in_loop_demo.cpp b/example/event/04-run-in-loop/main.cpp similarity index 100% rename from event/example/basic/run_in_loop_demo.cpp rename to example/event/04-run-in-loop/main.cpp diff --git a/example/event/05-run-next-seq/Makefile b/example/event/05-run-next-seq/Makefile new file mode 100644 index 0000000..c8b21ba --- /dev/null +++ b/example/event/05-run-next-seq/Makefile @@ -0,0 +1,10 @@ +EXE_NAME := example/event/05-run-next-seq + +CPP_SRC_FILES := main.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_event \ + -ltbox_base \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/event/example/basic/run_next_seq_demo.cpp b/example/event/05-run-next-seq/main.cpp similarity index 100% rename from event/example/basic/run_next_seq_demo.cpp rename to example/event/05-run-next-seq/main.cpp diff --git a/example/event/06-stdin-timer-signal/Makefile b/example/event/06-stdin-timer-signal/Makefile new file mode 100644 index 0000000..8f8f46b --- /dev/null +++ b/example/event/06-stdin-timer-signal/Makefile @@ -0,0 +1,10 @@ +EXE_NAME := example/event/06-stdin-timer-signal + +CPP_SRC_FILES := main.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_event \ + -ltbox_base \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/event/example/basic/stdin_timer_signal_demo.cpp b/example/event/06-stdin-timer-signal/main.cpp similarity index 100% rename from event/example/basic/stdin_timer_signal_demo.cpp rename to example/event/06-stdin-timer-signal/main.cpp diff --git a/example/event/07-delay-delete/Makefile b/example/event/07-delay-delete/Makefile new file mode 100644 index 0000000..6c24cf7 --- /dev/null +++ b/example/event/07-delay-delete/Makefile @@ -0,0 +1,10 @@ +EXE_NAME := example/event/07-delay-delete + +CPP_SRC_FILES := main.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_event \ + -ltbox_base \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/event/example/basic/delay_delete_demo.cpp b/example/event/07-delay-delete/main.cpp similarity index 100% rename from event/example/basic/delay_delete_demo.cpp rename to example/event/07-delay-delete/main.cpp diff --git a/event/example/calc_game/.gitignore b/example/event/08-calc-game/.gitignore similarity index 100% rename from event/example/calc_game/.gitignore rename to example/event/08-calc-game/.gitignore diff --git a/example/event/08-calc-game/Makefile b/example/event/08-calc-game/Makefile new file mode 100644 index 0000000..f98a466 --- /dev/null +++ b/example/event/08-calc-game/Makefile @@ -0,0 +1,12 @@ +EXE_NAME := example/event/08-calc-game + +CPP_SRC_FILES := \ + main.cpp \ + game.cpp \ + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_event \ + -ltbox_base \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/event/example/calc_game/game.cpp b/example/event/08-calc-game/game.cpp similarity index 100% rename from event/example/calc_game/game.cpp rename to example/event/08-calc-game/game.cpp diff --git a/event/example/calc_game/game.h b/example/event/08-calc-game/game.h similarity index 100% rename from event/example/calc_game/game.h rename to example/event/08-calc-game/game.h diff --git a/event/example/calc_game/game_lite.cpp b/example/event/08-calc-game/game_lite.cpp similarity index 100% rename from event/example/calc_game/game_lite.cpp rename to example/event/08-calc-game/game_lite.cpp diff --git a/event/example/calc_game/game_lite.h b/example/event/08-calc-game/game_lite.h similarity index 100% rename from event/example/calc_game/game_lite.h rename to example/event/08-calc-game/game_lite.h diff --git a/event/example/calc_game/main.cpp b/example/event/08-calc-game/main.cpp similarity index 100% rename from event/example/calc_game/main.cpp rename to example/event/08-calc-game/main.cpp diff --git a/example/event/Makefile b/example/event/Makefile index 7c302e4..2069292 100644 --- a/example/event/Makefile +++ b/example/event/Makefile @@ -1,6 +1,4 @@ -subdirs := $(shell ls | grep -v Makefile) - all test clean distclean: - @for i in $(subdirs); do \ - $(MAKE) -C $$i $@ || exit $$? ; \ + @for i in $(shell ls); do \ + [ -d $$i ] && ( $(MAKE) -C $$i $@ || exit $$? ) || exit 0; \ done diff --git a/example/main/Makefile b/example/main/Makefile index 79265bf..2069292 100644 --- a/example/main/Makefile +++ b/example/main/Makefile @@ -1,6 +1,4 @@ -subdirs := $(shell find -maxdepth 1 -type d | grep -v '.') - all test clean distclean: - @for i in $(subdirs); do \ - $(MAKE) -C $$i $@ || exit $$? ; \ + @for i in $(shell ls); do \ + [ -d $$i ] && ( $(MAKE) -C $$i $@ || exit $$? ) || exit 0; \ done -- Gitee From 0bd221ec38479855da2bb6190ca14046dae70cb6 Mon Sep 17 00:00:00 2001 From: Hevake Date: Mon, 15 Aug 2022 20:51:00 +0800 Subject: [PATCH 16/24] =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BA=86eventx?= =?UTF-8?q?=E7=9A=84example?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- eventx/example/build_env.mk | 29 ------------------- eventx/example/thread-pool/Makefile | 17 ----------- example/Makefile | 6 ++-- example/event/Makefile | 6 ++-- example/eventx/Makefile | 8 ++--- .../eventx}/thread-pool/.gitignore | 0 example/eventx/thread-pool/Makefile | 12 ++++++++ .../eventx}/thread-pool/main.cpp | 0 example/main/Makefile | 6 ++-- 9 files changed, 28 insertions(+), 56 deletions(-) delete mode 100644 eventx/example/build_env.mk delete mode 100644 eventx/example/thread-pool/Makefile rename {eventx/example => example/eventx}/thread-pool/.gitignore (100%) create mode 100644 example/eventx/thread-pool/Makefile rename {eventx/example => example/eventx}/thread-pool/main.cpp (100%) diff --git a/eventx/example/build_env.mk b/eventx/example/build_env.mk deleted file mode 100644 index 5848111..0000000 --- a/eventx/example/build_env.mk +++ /dev/null @@ -1,29 +0,0 @@ -STAGING_DIR := ../../../.staging - -STAGING_INCLUDE := $(STAGING_DIR)/include -STAGING_LIB := $(STAGING_DIR)/lib - -CCFLAGS := -I$(STAGING_INCLUDE) -I$(CONSTANT_INCLUDE) -CFLAGS := $(CCFLAGS) -std=c99 -CXXFLAGS := $(CCFLAGS) -std=c++11 -LDFLAGS := -L$(STAGING_LIB) -INSTALL_DIR := $(STAGING_DIR) -DESTDIR := $(STAGING_DIR) -prefix := - -TOOLCHAIN_PREFIX := -AR := $(TOOLCHAIN_PREFIX)ar -AS := $(TOOLCHAIN_PREFIX)as -CXX := $(TOOLCHAIN_PREFIX)g++ -CC := $(TOOLCHAIN_PREFIX)gcc -NM := $(TOOLCHAIN_PREFIX)nm -OBJCOPY := $(TOOLCHAIN_PREFIX)objcopy -OBJDUMP := $(TOOLCHAIN_PREFIX)objdump -STRINGS := $(TOOLCHAIN_PREFIX)strings -SSTRIP := $(TOOLCHAIN_PREFIX)sstrip -LSTRIP := $(TOOLCHAIN_PREFIX)lstrip -STRIP := $(TOOLCHAIN_PREFIX)strip - -export STAGING_INCLUDE STAGING_LIB INSTALL_DIR DESTDIR prefix -export AR AS CC NM OBJCOPY OBJDUMP CXX STRIP SSTRIP STRINGS LSTRIP -export CFLAGS CXXFLAGS LDFLAGS diff --git a/eventx/example/thread-pool/Makefile b/eventx/example/thread-pool/Makefile deleted file mode 100644 index e106c2a..0000000 --- a/eventx/example/thread-pool/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -include ../build_env.mk - -TARGET := demo -OBJECTS := main.o -CXXFLAGS += -ggdb -DLOG_MODULE_ID='"demo"' -LDFLAGS += -L.. -ltbox_eventx -ltbox_event -ltbox_base -levent_core -lev -lpthread - -CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer -LDFLAGS += -fsanitize=address -static-libasan - -all : $(TARGET) - -$(TARGET) : $(OBJECTS) - $(CXX) -o $@ $^ $(LDFLAGS) - -clean: - rm -rf $(OBJECTS) diff --git a/example/Makefile b/example/Makefile index 2069292..31374b4 100644 --- a/example/Makefile +++ b/example/Makefile @@ -1,4 +1,6 @@ all test clean distclean: - @for i in $(shell ls); do \ - [ -d $$i ] && ( $(MAKE) -C $$i $@ || exit $$? ) || exit 0; \ + @for i in $(shell ls) ; do \ + if [ -d $$i ]; then \ + $(MAKE) -C $$i $@ || exit $$? ; \ + fi \ done diff --git a/example/event/Makefile b/example/event/Makefile index 2069292..31374b4 100644 --- a/example/event/Makefile +++ b/example/event/Makefile @@ -1,4 +1,6 @@ all test clean distclean: - @for i in $(shell ls); do \ - [ -d $$i ] && ( $(MAKE) -C $$i $@ || exit $$? ) || exit 0; \ + @for i in $(shell ls) ; do \ + if [ -d $$i ]; then \ + $(MAKE) -C $$i $@ || exit $$? ; \ + fi \ done diff --git a/example/eventx/Makefile b/example/eventx/Makefile index 7c302e4..31374b4 100644 --- a/example/eventx/Makefile +++ b/example/eventx/Makefile @@ -1,6 +1,6 @@ -subdirs := $(shell ls | grep -v Makefile) - all test clean distclean: - @for i in $(subdirs); do \ - $(MAKE) -C $$i $@ || exit $$? ; \ + @for i in $(shell ls) ; do \ + if [ -d $$i ]; then \ + $(MAKE) -C $$i $@ || exit $$? ; \ + fi \ done diff --git a/eventx/example/thread-pool/.gitignore b/example/eventx/thread-pool/.gitignore similarity index 100% rename from eventx/example/thread-pool/.gitignore rename to example/eventx/thread-pool/.gitignore diff --git a/example/eventx/thread-pool/Makefile b/example/eventx/thread-pool/Makefile new file mode 100644 index 0000000..eff9390 --- /dev/null +++ b/example/eventx/thread-pool/Makefile @@ -0,0 +1,12 @@ +EXE_NAME := example/eventx/thread-pool + +CPP_SRC_FILES := main.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_eventx \ + -ltbox_event \ + -ltbox_base \ + -lpthread \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/eventx/example/thread-pool/main.cpp b/example/eventx/thread-pool/main.cpp similarity index 100% rename from eventx/example/thread-pool/main.cpp rename to example/eventx/thread-pool/main.cpp diff --git a/example/main/Makefile b/example/main/Makefile index 2069292..31374b4 100644 --- a/example/main/Makefile +++ b/example/main/Makefile @@ -1,4 +1,6 @@ all test clean distclean: - @for i in $(shell ls); do \ - [ -d $$i ] && ( $(MAKE) -C $$i $@ || exit $$? ) || exit 0; \ + @for i in $(shell ls) ; do \ + if [ -d $$i ]; then \ + $(MAKE) -C $$i $@ || exit $$? ; \ + fi \ done -- Gitee From 37b9b72ff10670ea7baa5cd61bb3edb1f63931f2 Mon Sep 17 00:00:00 2001 From: Hevake Date: Mon, 15 Aug 2022 21:41:32 +0800 Subject: [PATCH 17/24] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=AF=B9network?= =?UTF-8?q?=E7=9A=84example=E7=9A=84=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/base/Makefile | 6 ---- example/coroutine/Makefile | 6 ---- example/event/08-calc-game/.gitignore | 1 - example/eventx/thread-pool/.gitignore | 1 - example/http/Makefile | 6 ---- example/log/Makefile | 6 ---- example/main/02_more_than_one_apps/.gitignore | 1 - .../03_nc_client_and_echo_server/.gitignore | 1 - .../main/04_initiate_runtime_error/.gitignore | 1 - example/mqtt/Makefile | 6 ---- example/network/Makefile | 8 ++--- example/network/buffered_fd/Makefile | 11 +++++++ .../network}/buffered_fd/io_echo.cpp | 2 +- .../stdio_stream/01-stdin-out/Makefile | 11 +++++++ .../stdio_stream/01-stdin-out/main.cpp | 2 +- .../network/stdio_stream/02-stdio/Makefile | 11 +++++++ .../network/stdio_stream/02-stdio/main.cpp | 2 +- example/network/stdio_stream/Makefile | 6 ++++ example/network/tcp_acceptor/Makefile | 6 ++++ .../network/tcp_acceptor/tcp_echo/Makefile | 11 +++++++ .../tcp_acceptor/tcp_echo}/tcp_echo.cpp | 4 +-- .../tcp_acceptor/tcp_nc_server/Makefile | 11 +++++++ .../tcp_nc_server}/tcp_nc_server.cpp | 4 +-- example/network/tcp_client/Makefile | 6 ++++ example/network/tcp_client/tcp_echo/Makefile | 11 +++++++ .../network/tcp_client/tcp_echo}/tcp_echo.cpp | 2 +- .../tcp_client/tcp_hex_client/Makefile | 12 +++++++ .../tcp_hex_client}/tcp_hex_client.cpp | 2 +- .../network/tcp_client/tcp_nc_client/Makefile | 11 +++++++ .../tcp_nc_client}/tcp_nc_client.cpp | 2 +- example/network/tcp_connector/Makefile | 6 ++++ .../network/tcp_connector/tcp_echo/Makefile | 11 +++++++ .../tcp_connector/tcp_echo}/tcp_echo.cpp | 2 +- .../tcp_connector/tcp_nc_client/Makefile | 11 +++++++ .../tcp_nc_client}/tcp_nc_client.cpp | 2 +- example/network/tcp_server/Makefile | 6 ++++ example/network/tcp_server/tcp_echo/Makefile | 11 +++++++ .../network/tcp_server/tcp_echo}/tcp_echo.cpp | 4 +-- .../network/tcp_server/tcp_nc_server/Makefile | 11 +++++++ .../tcp_nc_server}/tcp_nc_server.cpp | 4 +-- example/network/uart/Makefile | 6 ++++ example/network/uart/uart_to_uart/Makefile | 11 +++++++ .../uart/uart_to_uart}/uart_to_uart.cpp | 2 +- example/network/uart/uart_tool/Makefile | 11 +++++++ .../network/uart/uart_tool}/uart_tool.cpp | 2 +- example/network/udp_socket/Makefile | 6 ++++ example/network/udp_socket/ping_pong/Makefile | 11 +++++++ .../udp_socket/ping_pong}/ping_pong.cpp | 0 example/network/udp_socket/recv_only/Makefile | 11 +++++++ .../udp_socket/recv_only}/recv_only.cpp | 0 example/network/udp_socket/request/Makefile | 11 +++++++ .../network/udp_socket/request}/request.cpp | 0 example/network/udp_socket/respond/Makefile | 11 +++++++ .../network/udp_socket/respond}/respond.cpp | 0 example/network/udp_socket/send_only/Makefile | 11 +++++++ .../udp_socket/send_only}/send_only.cpp | 0 example/terminal/Makefile | 6 ---- network/example/buffered_fd/.gitignore | 1 - network/example/buffered_fd/Makefile | 20 ------------ network/example/build_env.mk | 29 ----------------- network/example/stdio_stream/.gitignore | 2 -- network/example/stdio_stream/Makefile | 21 ------------- network/example/tcp_acceptor/.gitignore | 2 -- network/example/tcp_acceptor/Makefile | 22 ------------- network/example/tcp_client/.gitignore | 3 -- network/example/tcp_client/Makefile | 25 --------------- network/example/tcp_connector/.gitignore | 2 -- network/example/tcp_connector/Makefile | 22 ------------- network/example/tcp_server/.gitignore | 2 -- network/example/tcp_server/Makefile | 22 ------------- network/example/uart/.gitignore | 2 -- network/example/uart/Makefile | 21 ------------- network/example/udp_socket/.gitignore | 6 ---- network/example/udp_socket/Makefile | 31 ------------------- 74 files changed, 274 insertions(+), 296 deletions(-) delete mode 100644 example/base/Makefile delete mode 100644 example/coroutine/Makefile delete mode 100644 example/event/08-calc-game/.gitignore delete mode 100644 example/eventx/thread-pool/.gitignore delete mode 100644 example/http/Makefile delete mode 100644 example/log/Makefile delete mode 100644 example/main/02_more_than_one_apps/.gitignore delete mode 100644 example/main/03_nc_client_and_echo_server/.gitignore delete mode 100644 example/main/04_initiate_runtime_error/.gitignore delete mode 100644 example/mqtt/Makefile create mode 100644 example/network/buffered_fd/Makefile rename {network/example => example/network}/buffered_fd/io_echo.cpp (98%) create mode 100644 example/network/stdio_stream/01-stdin-out/Makefile rename network/example/stdio_stream/io_echo_1.cpp => example/network/stdio_stream/01-stdin-out/main.cpp (97%) create mode 100644 example/network/stdio_stream/02-stdio/Makefile rename network/example/stdio_stream/io_echo_2.cpp => example/network/stdio_stream/02-stdio/main.cpp (97%) create mode 100644 example/network/stdio_stream/Makefile create mode 100644 example/network/tcp_acceptor/Makefile create mode 100644 example/network/tcp_acceptor/tcp_echo/Makefile rename {network/example/tcp_acceptor => example/network/tcp_acceptor/tcp_echo}/tcp_echo.cpp (97%) create mode 100644 example/network/tcp_acceptor/tcp_nc_server/Makefile rename {network/example/tcp_acceptor => example/network/tcp_acceptor/tcp_nc_server}/tcp_nc_server.cpp (97%) create mode 100644 example/network/tcp_client/Makefile create mode 100644 example/network/tcp_client/tcp_echo/Makefile rename {network/example/tcp_client => example/network/tcp_client/tcp_echo}/tcp_echo.cpp (98%) create mode 100644 example/network/tcp_client/tcp_hex_client/Makefile rename {network/example/tcp_client => example/network/tcp_client/tcp_hex_client}/tcp_hex_client.cpp (99%) create mode 100644 example/network/tcp_client/tcp_nc_client/Makefile rename {network/example/tcp_client => example/network/tcp_client/tcp_nc_client}/tcp_nc_client.cpp (98%) create mode 100644 example/network/tcp_connector/Makefile create mode 100644 example/network/tcp_connector/tcp_echo/Makefile rename {network/example/tcp_connector => example/network/tcp_connector/tcp_echo}/tcp_echo.cpp (98%) create mode 100644 example/network/tcp_connector/tcp_nc_client/Makefile rename {network/example/tcp_connector => example/network/tcp_connector/tcp_nc_client}/tcp_nc_client.cpp (98%) create mode 100644 example/network/tcp_server/Makefile create mode 100644 example/network/tcp_server/tcp_echo/Makefile rename {network/example/tcp_server => example/network/tcp_server/tcp_echo}/tcp_echo.cpp (96%) create mode 100644 example/network/tcp_server/tcp_nc_server/Makefile rename {network/example/tcp_server => example/network/tcp_server/tcp_nc_server}/tcp_nc_server.cpp (97%) create mode 100644 example/network/uart/Makefile create mode 100644 example/network/uart/uart_to_uart/Makefile rename {network/example/uart => example/network/uart/uart_to_uart}/uart_to_uart.cpp (98%) create mode 100644 example/network/uart/uart_tool/Makefile rename {network/example/uart => example/network/uart/uart_tool}/uart_tool.cpp (98%) create mode 100644 example/network/udp_socket/Makefile create mode 100644 example/network/udp_socket/ping_pong/Makefile rename {network/example/udp_socket => example/network/udp_socket/ping_pong}/ping_pong.cpp (100%) create mode 100644 example/network/udp_socket/recv_only/Makefile rename {network/example/udp_socket => example/network/udp_socket/recv_only}/recv_only.cpp (100%) create mode 100644 example/network/udp_socket/request/Makefile rename {network/example/udp_socket => example/network/udp_socket/request}/request.cpp (100%) create mode 100644 example/network/udp_socket/respond/Makefile rename {network/example/udp_socket => example/network/udp_socket/respond}/respond.cpp (100%) create mode 100644 example/network/udp_socket/send_only/Makefile rename {network/example/udp_socket => example/network/udp_socket/send_only}/send_only.cpp (100%) delete mode 100644 example/terminal/Makefile delete mode 100644 network/example/buffered_fd/.gitignore delete mode 100644 network/example/buffered_fd/Makefile delete mode 100644 network/example/build_env.mk delete mode 100644 network/example/stdio_stream/.gitignore delete mode 100644 network/example/stdio_stream/Makefile delete mode 100644 network/example/tcp_acceptor/.gitignore delete mode 100644 network/example/tcp_acceptor/Makefile delete mode 100644 network/example/tcp_client/.gitignore delete mode 100644 network/example/tcp_client/Makefile delete mode 100644 network/example/tcp_connector/.gitignore delete mode 100644 network/example/tcp_connector/Makefile delete mode 100644 network/example/tcp_server/.gitignore delete mode 100644 network/example/tcp_server/Makefile delete mode 100644 network/example/uart/.gitignore delete mode 100644 network/example/uart/Makefile delete mode 100644 network/example/udp_socket/.gitignore delete mode 100644 network/example/udp_socket/Makefile diff --git a/example/base/Makefile b/example/base/Makefile deleted file mode 100644 index 7c302e4..0000000 --- a/example/base/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -subdirs := $(shell ls | grep -v Makefile) - -all test clean distclean: - @for i in $(subdirs); do \ - $(MAKE) -C $$i $@ || exit $$? ; \ - done diff --git a/example/coroutine/Makefile b/example/coroutine/Makefile deleted file mode 100644 index 7c302e4..0000000 --- a/example/coroutine/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -subdirs := $(shell ls | grep -v Makefile) - -all test clean distclean: - @for i in $(subdirs); do \ - $(MAKE) -C $$i $@ || exit $$? ; \ - done diff --git a/example/event/08-calc-game/.gitignore b/example/event/08-calc-game/.gitignore deleted file mode 100644 index be7c949..0000000 --- a/example/event/08-calc-game/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/calc_game diff --git a/example/eventx/thread-pool/.gitignore b/example/eventx/thread-pool/.gitignore deleted file mode 100644 index 69ff739..0000000 --- a/example/eventx/thread-pool/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/demo diff --git a/example/http/Makefile b/example/http/Makefile deleted file mode 100644 index 7c302e4..0000000 --- a/example/http/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -subdirs := $(shell ls | grep -v Makefile) - -all test clean distclean: - @for i in $(subdirs); do \ - $(MAKE) -C $$i $@ || exit $$? ; \ - done diff --git a/example/log/Makefile b/example/log/Makefile deleted file mode 100644 index 7c302e4..0000000 --- a/example/log/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -subdirs := $(shell ls | grep -v Makefile) - -all test clean distclean: - @for i in $(subdirs); do \ - $(MAKE) -C $$i $@ || exit $$? ; \ - done diff --git a/example/main/02_more_than_one_apps/.gitignore b/example/main/02_more_than_one_apps/.gitignore deleted file mode 100644 index ae6321f..0000000 --- a/example/main/02_more_than_one_apps/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/sample diff --git a/example/main/03_nc_client_and_echo_server/.gitignore b/example/main/03_nc_client_and_echo_server/.gitignore deleted file mode 100644 index ae6321f..0000000 --- a/example/main/03_nc_client_and_echo_server/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/sample diff --git a/example/main/04_initiate_runtime_error/.gitignore b/example/main/04_initiate_runtime_error/.gitignore deleted file mode 100644 index ae6321f..0000000 --- a/example/main/04_initiate_runtime_error/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/sample diff --git a/example/mqtt/Makefile b/example/mqtt/Makefile deleted file mode 100644 index 7c302e4..0000000 --- a/example/mqtt/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -subdirs := $(shell ls | grep -v Makefile) - -all test clean distclean: - @for i in $(subdirs); do \ - $(MAKE) -C $$i $@ || exit $$? ; \ - done diff --git a/example/network/Makefile b/example/network/Makefile index 7c302e4..31374b4 100644 --- a/example/network/Makefile +++ b/example/network/Makefile @@ -1,6 +1,6 @@ -subdirs := $(shell ls | grep -v Makefile) - all test clean distclean: - @for i in $(subdirs); do \ - $(MAKE) -C $$i $@ || exit $$? ; \ + @for i in $(shell ls) ; do \ + if [ -d $$i ]; then \ + $(MAKE) -C $$i $@ || exit $$? ; \ + fi \ done diff --git a/example/network/buffered_fd/Makefile b/example/network/buffered_fd/Makefile new file mode 100644 index 0000000..f28b8aa --- /dev/null +++ b/example/network/buffered_fd/Makefile @@ -0,0 +1,11 @@ +EXE_NAME := example/network/01-io-echo + +CPP_SRC_FILES := io_echo.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_network \ + -ltbox_event \ + -ltbox_base \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/network/example/buffered_fd/io_echo.cpp b/example/network/buffered_fd/io_echo.cpp similarity index 98% rename from network/example/buffered_fd/io_echo.cpp rename to example/network/buffered_fd/io_echo.cpp index d2d974c..55f39d2 100644 --- a/network/example/buffered_fd/io_echo.cpp +++ b/example/network/buffered_fd/io_echo.cpp @@ -26,7 +26,7 @@ int main() auto sp_exit = sp_loop->newSignalEvent(); sp_exit->initialize(SIGINT, event::Event::Mode::kOneshot); sp_exit->setCallback( - [=] { + [=] (int) { cout << "Info: Exit Loop" << endl; sp_loop->exitLoop(); } diff --git a/example/network/stdio_stream/01-stdin-out/Makefile b/example/network/stdio_stream/01-stdin-out/Makefile new file mode 100644 index 0000000..6779206 --- /dev/null +++ b/example/network/stdio_stream/01-stdin-out/Makefile @@ -0,0 +1,11 @@ +EXE_NAME := example/network/stdio_stream/01-stdin-out + +CPP_SRC_FILES := main.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_network \ + -ltbox_event \ + -ltbox_base \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/network/example/stdio_stream/io_echo_1.cpp b/example/network/stdio_stream/01-stdin-out/main.cpp similarity index 97% rename from network/example/stdio_stream/io_echo_1.cpp rename to example/network/stdio_stream/01-stdin-out/main.cpp index 2ea763c..7b1cc8f 100644 --- a/network/example/stdio_stream/io_echo_1.cpp +++ b/example/network/stdio_stream/01-stdin-out/main.cpp @@ -21,7 +21,7 @@ int main() auto sp_exit = sp_loop->newSignalEvent(); sp_exit->initialize(SIGINT, event::Event::Mode::kOneshot); sp_exit->setCallback( - [=] { + [=] (int) { cout << "Info: Exit Loop" << endl; sp_loop->exitLoop(); } diff --git a/example/network/stdio_stream/02-stdio/Makefile b/example/network/stdio_stream/02-stdio/Makefile new file mode 100644 index 0000000..0afe826 --- /dev/null +++ b/example/network/stdio_stream/02-stdio/Makefile @@ -0,0 +1,11 @@ +EXE_NAME := example/network/stdio_stream/02-stdio + +CPP_SRC_FILES := main.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_network \ + -ltbox_event \ + -ltbox_base \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/network/example/stdio_stream/io_echo_2.cpp b/example/network/stdio_stream/02-stdio/main.cpp similarity index 97% rename from network/example/stdio_stream/io_echo_2.cpp rename to example/network/stdio_stream/02-stdio/main.cpp index c19a353..4a48389 100644 --- a/network/example/stdio_stream/io_echo_2.cpp +++ b/example/network/stdio_stream/02-stdio/main.cpp @@ -18,7 +18,7 @@ int main() auto sp_exit = sp_loop->newSignalEvent(); sp_exit->initialize(SIGINT, event::Event::Mode::kOneshot); sp_exit->setCallback( - [=] { + [=] (int) { cout << "Info: Exit Loop" << endl; sp_loop->exitLoop(); } diff --git a/example/network/stdio_stream/Makefile b/example/network/stdio_stream/Makefile new file mode 100644 index 0000000..31374b4 --- /dev/null +++ b/example/network/stdio_stream/Makefile @@ -0,0 +1,6 @@ +all test clean distclean: + @for i in $(shell ls) ; do \ + if [ -d $$i ]; then \ + $(MAKE) -C $$i $@ || exit $$? ; \ + fi \ + done diff --git a/example/network/tcp_acceptor/Makefile b/example/network/tcp_acceptor/Makefile new file mode 100644 index 0000000..31374b4 --- /dev/null +++ b/example/network/tcp_acceptor/Makefile @@ -0,0 +1,6 @@ +all test clean distclean: + @for i in $(shell ls) ; do \ + if [ -d $$i ]; then \ + $(MAKE) -C $$i $@ || exit $$? ; \ + fi \ + done diff --git a/example/network/tcp_acceptor/tcp_echo/Makefile b/example/network/tcp_acceptor/tcp_echo/Makefile new file mode 100644 index 0000000..9d27e98 --- /dev/null +++ b/example/network/tcp_acceptor/tcp_echo/Makefile @@ -0,0 +1,11 @@ +EXE_NAME := example/network/tcp_acceptor/tcp_echo + +CPP_SRC_FILES := tcp_echo.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_network \ + -ltbox_event \ + -ltbox_base \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/network/example/tcp_acceptor/tcp_echo.cpp b/example/network/tcp_acceptor/tcp_echo/tcp_echo.cpp similarity index 97% rename from network/example/tcp_acceptor/tcp_echo.cpp rename to example/network/tcp_acceptor/tcp_echo/tcp_echo.cpp index f668b03..f13af59 100644 --- a/network/example/tcp_acceptor/tcp_echo.cpp +++ b/example/network/tcp_acceptor/tcp_echo/tcp_echo.cpp @@ -44,7 +44,7 @@ int main(int argc, char **argv) set conns; TcpAcceptor acceptor(sp_loop); - acceptor.initialize(bind_addr); + acceptor.initialize(bind_addr, 1); //! 指定有Client连接上了该做的事务 acceptor.setNewConnectionCallback( [&] (TcpConnection *new_conn) { @@ -67,7 +67,7 @@ int main(int argc, char **argv) sp_stop_ev->initialize(SIGINT, Event::Mode::kOneshot); //! 指定ctrl+C时要做的事务 sp_stop_ev->setCallback( - [sp_loop, &conns] { + [sp_loop, &conns] (int) { for (auto conn : conns) { conn->disconnect(); //! (1) 主动断开连接 delete conn; //! (2) 销毁Client对象。思考:为什么这里可以直接delete,而L51不可以? diff --git a/example/network/tcp_acceptor/tcp_nc_server/Makefile b/example/network/tcp_acceptor/tcp_nc_server/Makefile new file mode 100644 index 0000000..07074be --- /dev/null +++ b/example/network/tcp_acceptor/tcp_nc_server/Makefile @@ -0,0 +1,11 @@ +EXE_NAME := example/network/tcp_acceptor/tcp_nc_server + +CPP_SRC_FILES := tcp_nc_server.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_network \ + -ltbox_event \ + -ltbox_base \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/network/example/tcp_acceptor/tcp_nc_server.cpp b/example/network/tcp_acceptor/tcp_nc_server/tcp_nc_server.cpp similarity index 97% rename from network/example/tcp_acceptor/tcp_nc_server.cpp rename to example/network/tcp_acceptor/tcp_nc_server/tcp_nc_server.cpp index 683eb08..fffa0c3 100644 --- a/network/example/tcp_acceptor/tcp_nc_server.cpp +++ b/example/network/tcp_acceptor/tcp_nc_server/tcp_nc_server.cpp @@ -56,7 +56,7 @@ int main(int argc, char **argv) ); TcpAcceptor acceptor(sp_loop); - acceptor.initialize(bind_addr); + acceptor.initialize(bind_addr, 1); //! 指定有Client连接上了该做的事务 acceptor.setNewConnectionCallback( [&] (TcpConnection *new_conn) { @@ -79,7 +79,7 @@ int main(int argc, char **argv) sp_stop_ev->initialize(SIGINT, Event::Mode::kOneshot); //! 指定ctrl+C时要做的事务 sp_stop_ev->setCallback( - [sp_loop, &conns] { + [sp_loop, &conns] (int) { for (auto conn : conns) { conn->disconnect(); //! (1) 主动断开连接 delete conn; //! (2) 销毁Client对象。思考:为什么这里可以直接delete,而L51不可以? diff --git a/example/network/tcp_client/Makefile b/example/network/tcp_client/Makefile new file mode 100644 index 0000000..31374b4 --- /dev/null +++ b/example/network/tcp_client/Makefile @@ -0,0 +1,6 @@ +all test clean distclean: + @for i in $(shell ls) ; do \ + if [ -d $$i ]; then \ + $(MAKE) -C $$i $@ || exit $$? ; \ + fi \ + done diff --git a/example/network/tcp_client/tcp_echo/Makefile b/example/network/tcp_client/tcp_echo/Makefile new file mode 100644 index 0000000..82c1492 --- /dev/null +++ b/example/network/tcp_client/tcp_echo/Makefile @@ -0,0 +1,11 @@ +EXE_NAME := example/network/tcp_client/tcp_echo + +CPP_SRC_FILES := tcp_echo.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_network \ + -ltbox_event \ + -ltbox_base \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/network/example/tcp_client/tcp_echo.cpp b/example/network/tcp_client/tcp_echo/tcp_echo.cpp similarity index 98% rename from network/example/tcp_client/tcp_echo.cpp rename to example/network/tcp_client/tcp_echo/tcp_echo.cpp index c88d570..a572cb0 100644 --- a/network/example/tcp_client/tcp_echo.cpp +++ b/example/network/tcp_client/tcp_echo/tcp_echo.cpp @@ -51,7 +51,7 @@ int main(int argc, char **argv) sp_stop_ev->initialize(SIGINT, Event::Mode::kOneshot); //! 指定ctrl+C时要做的事务 sp_stop_ev->setCallback( - [sp_loop, &client] { + [sp_loop, &client] (int) { client.stop(); sp_loop->exitLoop(); //! (3) 退出事件循环 } diff --git a/example/network/tcp_client/tcp_hex_client/Makefile b/example/network/tcp_client/tcp_hex_client/Makefile new file mode 100644 index 0000000..32e11be --- /dev/null +++ b/example/network/tcp_client/tcp_hex_client/Makefile @@ -0,0 +1,12 @@ +EXE_NAME := example/network/tcp_client/tcp_hex_client + +CPP_SRC_FILES := tcp_hex_client.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_network \ + -ltbox_event \ + -ltbox_util \ + -ltbox_base \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/network/example/tcp_client/tcp_hex_client.cpp b/example/network/tcp_client/tcp_hex_client/tcp_hex_client.cpp similarity index 99% rename from network/example/tcp_client/tcp_hex_client.cpp rename to example/network/tcp_client/tcp_hex_client/tcp_hex_client.cpp index 0ca5191..717e6ea 100644 --- a/network/example/tcp_client/tcp_hex_client.cpp +++ b/example/network/tcp_client/tcp_hex_client/tcp_hex_client.cpp @@ -123,7 +123,7 @@ int main(int argc, char **argv) sp_stop_ev->initialize(SIGINT, Event::Mode::kOneshot); //! 指定ctrl+C时要做的事务 sp_stop_ev->setCallback( - [sp_loop, &client] { + [sp_loop, &client] (int) { client.stop(); sp_loop->exitLoop(); //! (3) 退出事件循环 } diff --git a/example/network/tcp_client/tcp_nc_client/Makefile b/example/network/tcp_client/tcp_nc_client/Makefile new file mode 100644 index 0000000..ac14ce3 --- /dev/null +++ b/example/network/tcp_client/tcp_nc_client/Makefile @@ -0,0 +1,11 @@ +EXE_NAME := example/network/tcp_client/tcp_nc_client + +CPP_SRC_FILES := tcp_nc_client.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_network \ + -ltbox_event \ + -ltbox_base \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/network/example/tcp_client/tcp_nc_client.cpp b/example/network/tcp_client/tcp_nc_client/tcp_nc_client.cpp similarity index 98% rename from network/example/tcp_client/tcp_nc_client.cpp rename to example/network/tcp_client/tcp_nc_client/tcp_nc_client.cpp index 0310c92..8ff0024 100644 --- a/network/example/tcp_client/tcp_nc_client.cpp +++ b/example/network/tcp_client/tcp_nc_client/tcp_nc_client.cpp @@ -57,7 +57,7 @@ int main(int argc, char **argv) sp_stop_ev->initialize(SIGINT, Event::Mode::kOneshot); //! 指定ctrl+C时要做的事务 sp_stop_ev->setCallback( - [sp_loop, &client] { + [sp_loop, &client] (int) { client.stop(); sp_loop->exitLoop(); //! (3) 退出事件循环 } diff --git a/example/network/tcp_connector/Makefile b/example/network/tcp_connector/Makefile new file mode 100644 index 0000000..31374b4 --- /dev/null +++ b/example/network/tcp_connector/Makefile @@ -0,0 +1,6 @@ +all test clean distclean: + @for i in $(shell ls) ; do \ + if [ -d $$i ]; then \ + $(MAKE) -C $$i $@ || exit $$? ; \ + fi \ + done diff --git a/example/network/tcp_connector/tcp_echo/Makefile b/example/network/tcp_connector/tcp_echo/Makefile new file mode 100644 index 0000000..d5144c8 --- /dev/null +++ b/example/network/tcp_connector/tcp_echo/Makefile @@ -0,0 +1,11 @@ +EXE_NAME := example/network/tcp_connector/tcp_echo + +CPP_SRC_FILES := tcp_echo.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_network \ + -ltbox_event \ + -ltbox_base \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/network/example/tcp_connector/tcp_echo.cpp b/example/network/tcp_connector/tcp_echo/tcp_echo.cpp similarity index 98% rename from network/example/tcp_connector/tcp_echo.cpp rename to example/network/tcp_connector/tcp_echo/tcp_echo.cpp index bacabc8..31f2623 100644 --- a/network/example/tcp_connector/tcp_echo.cpp +++ b/example/network/tcp_connector/tcp_echo/tcp_echo.cpp @@ -89,7 +89,7 @@ int main(int argc, char **argv) sp_stop_ev->initialize(SIGINT, Event::Mode::kOneshot); //! 指定ctrl+C时要做的事务 sp_stop_ev->setCallback( - [sp_loop, &sp_curr] { + [sp_loop, &sp_curr] (int) { if (sp_curr != nullptr) { sp_curr->disconnect(); //! (1) 主动断开连接 delete sp_curr; //! (2) 销毁Client对象。思考:为什么这里可以直接delete,而L51不可以? diff --git a/example/network/tcp_connector/tcp_nc_client/Makefile b/example/network/tcp_connector/tcp_nc_client/Makefile new file mode 100644 index 0000000..0140305 --- /dev/null +++ b/example/network/tcp_connector/tcp_nc_client/Makefile @@ -0,0 +1,11 @@ +EXE_NAME := example/network/tcp_connector/tcp_nc_client + +CPP_SRC_FILES := tcp_nc_client.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_network \ + -ltbox_event \ + -ltbox_base \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/network/example/tcp_connector/tcp_nc_client.cpp b/example/network/tcp_connector/tcp_nc_client/tcp_nc_client.cpp similarity index 98% rename from network/example/tcp_connector/tcp_nc_client.cpp rename to example/network/tcp_connector/tcp_nc_client/tcp_nc_client.cpp index 954f9c9..b549416 100644 --- a/network/example/tcp_connector/tcp_nc_client.cpp +++ b/example/network/tcp_connector/tcp_nc_client/tcp_nc_client.cpp @@ -94,7 +94,7 @@ int main(int argc, char **argv) sp_stop_ev->initialize(SIGINT, Event::Mode::kOneshot); //! 指定ctrl+C时要做的事务 sp_stop_ev->setCallback( - [sp_loop, &sp_curr] { + [sp_loop, &sp_curr] (int) { if (sp_curr != nullptr) { sp_curr->disconnect(); //! (1) 主动断开连接 delete sp_curr; //! (2) 销毁Client对象。思考:为什么这里可以直接delete,而L51不可以? diff --git a/example/network/tcp_server/Makefile b/example/network/tcp_server/Makefile new file mode 100644 index 0000000..31374b4 --- /dev/null +++ b/example/network/tcp_server/Makefile @@ -0,0 +1,6 @@ +all test clean distclean: + @for i in $(shell ls) ; do \ + if [ -d $$i ]; then \ + $(MAKE) -C $$i $@ || exit $$? ; \ + fi \ + done diff --git a/example/network/tcp_server/tcp_echo/Makefile b/example/network/tcp_server/tcp_echo/Makefile new file mode 100644 index 0000000..f1ea2eb --- /dev/null +++ b/example/network/tcp_server/tcp_echo/Makefile @@ -0,0 +1,11 @@ +EXE_NAME := example/network/tcp_server/tcp_echo + +CPP_SRC_FILES := tcp_echo.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_network \ + -ltbox_event \ + -ltbox_base \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/network/example/tcp_server/tcp_echo.cpp b/example/network/tcp_server/tcp_echo/tcp_echo.cpp similarity index 96% rename from network/example/tcp_server/tcp_echo.cpp rename to example/network/tcp_server/tcp_echo/tcp_echo.cpp index a09a635..c59c32b 100644 --- a/network/example/tcp_server/tcp_echo.cpp +++ b/example/network/tcp_server/tcp_echo/tcp_echo.cpp @@ -38,7 +38,7 @@ int main(int argc, char **argv) SetScopeExitAction([sp_loop] { delete sp_loop; }); TcpServer server(sp_loop); - server.initialize(bind_addr); + server.initialize(bind_addr, 1); //! 当收到数据时,直接往client指定对象发回去 server.setReceiveCallback( [&server] (const TcpServer::ConnToken &client, Buffer &buff) { @@ -54,7 +54,7 @@ int main(int argc, char **argv) sp_stop_ev->initialize(SIGINT, Event::Mode::kOneshot); //! 指定ctrl+C时要做的事务 sp_stop_ev->setCallback( - [sp_loop, &server] { + [sp_loop, &server] (int) { server.stop(); sp_loop->exitLoop(); //! (3) 退出事件循环 } diff --git a/example/network/tcp_server/tcp_nc_server/Makefile b/example/network/tcp_server/tcp_nc_server/Makefile new file mode 100644 index 0000000..695aa35 --- /dev/null +++ b/example/network/tcp_server/tcp_nc_server/Makefile @@ -0,0 +1,11 @@ +EXE_NAME := example/network/tcp_server/tcp_nc_server + +CPP_SRC_FILES := tcp_nc_server.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_network \ + -ltbox_event \ + -ltbox_base \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/network/example/tcp_server/tcp_nc_server.cpp b/example/network/tcp_server/tcp_nc_server/tcp_nc_server.cpp similarity index 97% rename from network/example/tcp_server/tcp_nc_server.cpp rename to example/network/tcp_server/tcp_nc_server/tcp_nc_server.cpp index 562317a..35450d9 100644 --- a/network/example/tcp_server/tcp_nc_server.cpp +++ b/example/network/tcp_server/tcp_nc_server/tcp_nc_server.cpp @@ -44,7 +44,7 @@ int main(int argc, char **argv) stdio.enable(); TcpServer server(sp_loop); - server.initialize(bind_addr); + server.initialize(bind_addr, 1); server.start(); @@ -91,7 +91,7 @@ int main(int argc, char **argv) sp_stop_ev->initialize(SIGINT, Event::Mode::kOneshot); //! 指定ctrl+C时要做的事务 sp_stop_ev->setCallback( - [sp_loop, &server, &clients] { + [sp_loop, &server, &clients] (int) { clients.clear(); server.stop(); sp_loop->exitLoop(); //! (3) 退出事件循环 diff --git a/example/network/uart/Makefile b/example/network/uart/Makefile new file mode 100644 index 0000000..31374b4 --- /dev/null +++ b/example/network/uart/Makefile @@ -0,0 +1,6 @@ +all test clean distclean: + @for i in $(shell ls) ; do \ + if [ -d $$i ]; then \ + $(MAKE) -C $$i $@ || exit $$? ; \ + fi \ + done diff --git a/example/network/uart/uart_to_uart/Makefile b/example/network/uart/uart_to_uart/Makefile new file mode 100644 index 0000000..93ecc8f --- /dev/null +++ b/example/network/uart/uart_to_uart/Makefile @@ -0,0 +1,11 @@ +EXE_NAME := example/network/uart/uart_to_uart + +CPP_SRC_FILES := uart_to_uart.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_network \ + -ltbox_event \ + -ltbox_base \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/network/example/uart/uart_to_uart.cpp b/example/network/uart/uart_to_uart/uart_to_uart.cpp similarity index 98% rename from network/example/uart/uart_to_uart.cpp rename to example/network/uart/uart_to_uart/uart_to_uart.cpp index 6bc3d97..ecb13e4 100644 --- a/network/example/uart/uart_to_uart.cpp +++ b/example/network/uart/uart_to_uart/uart_to_uart.cpp @@ -48,7 +48,7 @@ int main(int argc, char **argv) sp_exit->initialize(SIGINT, event::Event::Mode::kOneshot); sp_exit->enable(); sp_exit->setCallback( - [=] { + [=] (int) { cout << "Info: Exit Loop" << endl; sp_loop->exitLoop(); } diff --git a/example/network/uart/uart_tool/Makefile b/example/network/uart/uart_tool/Makefile new file mode 100644 index 0000000..5fdc817 --- /dev/null +++ b/example/network/uart/uart_tool/Makefile @@ -0,0 +1,11 @@ +EXE_NAME := example/network/uart/uart_tool + +CPP_SRC_FILES := uart_tool.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_network \ + -ltbox_event \ + -ltbox_base \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/network/example/uart/uart_tool.cpp b/example/network/uart/uart_tool/uart_tool.cpp similarity index 98% rename from network/example/uart/uart_tool.cpp rename to example/network/uart/uart_tool/uart_tool.cpp index 8a98564..1dd7e4d 100644 --- a/network/example/uart/uart_tool.cpp +++ b/example/network/uart/uart_tool/uart_tool.cpp @@ -47,7 +47,7 @@ int main(int argc, char **argv) sp_exit->initialize(SIGINT, event::Event::Mode::kOneshot); sp_exit->enable(); sp_exit->setCallback( - [=] { + [=] (int) { cout << "Info: Exit Loop" << endl; sp_loop->exitLoop(); } diff --git a/example/network/udp_socket/Makefile b/example/network/udp_socket/Makefile new file mode 100644 index 0000000..31374b4 --- /dev/null +++ b/example/network/udp_socket/Makefile @@ -0,0 +1,6 @@ +all test clean distclean: + @for i in $(shell ls) ; do \ + if [ -d $$i ]; then \ + $(MAKE) -C $$i $@ || exit $$? ; \ + fi \ + done diff --git a/example/network/udp_socket/ping_pong/Makefile b/example/network/udp_socket/ping_pong/Makefile new file mode 100644 index 0000000..a804440 --- /dev/null +++ b/example/network/udp_socket/ping_pong/Makefile @@ -0,0 +1,11 @@ +EXE_NAME := example/network/udp_socket/ping_pong + +CPP_SRC_FILES := ping_pong.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_network \ + -ltbox_event \ + -ltbox_base \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/network/example/udp_socket/ping_pong.cpp b/example/network/udp_socket/ping_pong/ping_pong.cpp similarity index 100% rename from network/example/udp_socket/ping_pong.cpp rename to example/network/udp_socket/ping_pong/ping_pong.cpp diff --git a/example/network/udp_socket/recv_only/Makefile b/example/network/udp_socket/recv_only/Makefile new file mode 100644 index 0000000..802321f --- /dev/null +++ b/example/network/udp_socket/recv_only/Makefile @@ -0,0 +1,11 @@ +EXE_NAME := example/network/udp_socket/recv_only + +CPP_SRC_FILES := recv_only.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_network \ + -ltbox_event \ + -ltbox_base \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/network/example/udp_socket/recv_only.cpp b/example/network/udp_socket/recv_only/recv_only.cpp similarity index 100% rename from network/example/udp_socket/recv_only.cpp rename to example/network/udp_socket/recv_only/recv_only.cpp diff --git a/example/network/udp_socket/request/Makefile b/example/network/udp_socket/request/Makefile new file mode 100644 index 0000000..0b12593 --- /dev/null +++ b/example/network/udp_socket/request/Makefile @@ -0,0 +1,11 @@ +EXE_NAME := example/network/udp_socket/request + +CPP_SRC_FILES := request.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_network \ + -ltbox_event \ + -ltbox_base \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/network/example/udp_socket/request.cpp b/example/network/udp_socket/request/request.cpp similarity index 100% rename from network/example/udp_socket/request.cpp rename to example/network/udp_socket/request/request.cpp diff --git a/example/network/udp_socket/respond/Makefile b/example/network/udp_socket/respond/Makefile new file mode 100644 index 0000000..3752fc0 --- /dev/null +++ b/example/network/udp_socket/respond/Makefile @@ -0,0 +1,11 @@ +EXE_NAME := example/network/udp_socket/respond + +CPP_SRC_FILES := respond.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_network \ + -ltbox_event \ + -ltbox_base \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/network/example/udp_socket/respond.cpp b/example/network/udp_socket/respond/respond.cpp similarity index 100% rename from network/example/udp_socket/respond.cpp rename to example/network/udp_socket/respond/respond.cpp diff --git a/example/network/udp_socket/send_only/Makefile b/example/network/udp_socket/send_only/Makefile new file mode 100644 index 0000000..9d066b3 --- /dev/null +++ b/example/network/udp_socket/send_only/Makefile @@ -0,0 +1,11 @@ +EXE_NAME := example/network/udp_socket/send_only + +CPP_SRC_FILES := send_only.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_network \ + -ltbox_event \ + -ltbox_base \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/network/example/udp_socket/send_only.cpp b/example/network/udp_socket/send_only/send_only.cpp similarity index 100% rename from network/example/udp_socket/send_only.cpp rename to example/network/udp_socket/send_only/send_only.cpp diff --git a/example/terminal/Makefile b/example/terminal/Makefile deleted file mode 100644 index 7c302e4..0000000 --- a/example/terminal/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -subdirs := $(shell ls | grep -v Makefile) - -all test clean distclean: - @for i in $(subdirs); do \ - $(MAKE) -C $$i $@ || exit $$? ; \ - done diff --git a/network/example/buffered_fd/.gitignore b/network/example/buffered_fd/.gitignore deleted file mode 100644 index 95cbf8c..0000000 --- a/network/example/buffered_fd/.gitignore +++ /dev/null @@ -1 +0,0 @@ -io_echo diff --git a/network/example/buffered_fd/Makefile b/network/example/buffered_fd/Makefile deleted file mode 100644 index 57fd8de..0000000 --- a/network/example/buffered_fd/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -include ../build_env.mk - -TARGET := io_echo -OBJECTS := io_echo.o -CXXFLAGS += -ggdb -DLOG_MODULE_ID='"demo"' -LDFLAGS += -L.. -ltbox_network -ltbox_eventx -ltbox_event -ltbox_base -levent_core -lev -lpthread - -CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer -LDFLAGS += -fsanitize=address -static-libasan - -all : $(TARGET) - -$(TARGET) : $(OBJECTS) - $(CXX) -o $@ $^ $(LDFLAGS) - -clean: - rm -rf $(OBJECTS) - -distclean: clean - rm -f $(TARGET) diff --git a/network/example/build_env.mk b/network/example/build_env.mk deleted file mode 100644 index 5848111..0000000 --- a/network/example/build_env.mk +++ /dev/null @@ -1,29 +0,0 @@ -STAGING_DIR := ../../../.staging - -STAGING_INCLUDE := $(STAGING_DIR)/include -STAGING_LIB := $(STAGING_DIR)/lib - -CCFLAGS := -I$(STAGING_INCLUDE) -I$(CONSTANT_INCLUDE) -CFLAGS := $(CCFLAGS) -std=c99 -CXXFLAGS := $(CCFLAGS) -std=c++11 -LDFLAGS := -L$(STAGING_LIB) -INSTALL_DIR := $(STAGING_DIR) -DESTDIR := $(STAGING_DIR) -prefix := - -TOOLCHAIN_PREFIX := -AR := $(TOOLCHAIN_PREFIX)ar -AS := $(TOOLCHAIN_PREFIX)as -CXX := $(TOOLCHAIN_PREFIX)g++ -CC := $(TOOLCHAIN_PREFIX)gcc -NM := $(TOOLCHAIN_PREFIX)nm -OBJCOPY := $(TOOLCHAIN_PREFIX)objcopy -OBJDUMP := $(TOOLCHAIN_PREFIX)objdump -STRINGS := $(TOOLCHAIN_PREFIX)strings -SSTRIP := $(TOOLCHAIN_PREFIX)sstrip -LSTRIP := $(TOOLCHAIN_PREFIX)lstrip -STRIP := $(TOOLCHAIN_PREFIX)strip - -export STAGING_INCLUDE STAGING_LIB INSTALL_DIR DESTDIR prefix -export AR AS CC NM OBJCOPY OBJDUMP CXX STRIP SSTRIP STRINGS LSTRIP -export CFLAGS CXXFLAGS LDFLAGS diff --git a/network/example/stdio_stream/.gitignore b/network/example/stdio_stream/.gitignore deleted file mode 100644 index af4bfae..0000000 --- a/network/example/stdio_stream/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/io_echo_1 -/io_echo_2 diff --git a/network/example/stdio_stream/Makefile b/network/example/stdio_stream/Makefile deleted file mode 100644 index ff580ba..0000000 --- a/network/example/stdio_stream/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -include ../build_env.mk - -CXXFLAGS += -ggdb -DLOG_MODULE_ID='"demo"' -LDFLAGS += -L.. -ltbox_network -ltbox_eventx -ltbox_event -ltbox_base -levent_core -lev -lpthread - -CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer -LDFLAGS += -fsanitize=address -static-libasan - -all : io_echo_1 io_echo_2 - -io_echo_1 : io_echo_1.o - $(CXX) -o $@ $^ $(LDFLAGS) - -io_echo_2 : io_echo_2.o - $(CXX) -o $@ $^ $(LDFLAGS) - -clean: - rm -rf *.o - -distclean: clean - rm -f io_echo_1 io_echo_2 diff --git a/network/example/tcp_acceptor/.gitignore b/network/example/tcp_acceptor/.gitignore deleted file mode 100644 index 5aa354c..0000000 --- a/network/example/tcp_acceptor/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/tcp_echo -/tcp_nc_server diff --git a/network/example/tcp_acceptor/Makefile b/network/example/tcp_acceptor/Makefile deleted file mode 100644 index a2352c0..0000000 --- a/network/example/tcp_acceptor/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -include ../build_env.mk - -CXXFLAGS += -ggdb -DLOG_MODULE_ID='"demo"' -LDFLAGS += -L.. -ltbox_network -ltbox_eventx -ltbox_event -ltbox_base -levent_core -lev -lpthread -TARGETS = tcp_echo tcp_nc_server - -CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer -LDFLAGS += -fsanitize=address -static-libasan - -all : $(TARGETS) - -tcp_echo : tcp_echo.o - $(CXX) -o $@ $^ $(LDFLAGS) - -tcp_nc_server : tcp_nc_server.o - $(CXX) -o $@ $^ $(LDFLAGS) - -clean: - rm -rf *.o - -distclean: clean - rm -f $(TARGETS) diff --git a/network/example/tcp_client/.gitignore b/network/example/tcp_client/.gitignore deleted file mode 100644 index 88e0b1b..0000000 --- a/network/example/tcp_client/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/tcp_echo -/tcp_nc_client -/tcp_hex_client diff --git a/network/example/tcp_client/Makefile b/network/example/tcp_client/Makefile deleted file mode 100644 index 061edb8..0000000 --- a/network/example/tcp_client/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -include ../build_env.mk - -CXXFLAGS += -ggdb -DLOG_MODULE_ID='"demo"' -LDFLAGS += -L.. -ltbox_network -ltbox_eventx -ltbox_event -ltbox_util -ltbox_base -levent_core -lev -lpthread -TARGETS = tcp_echo tcp_nc_client tcp_hex_client - -CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer -LDFLAGS += -fsanitize=address -static-libasan - -all : $(TARGETS) - -tcp_echo : tcp_echo.o - $(CXX) -o $@ $^ $(LDFLAGS) - -tcp_nc_client : tcp_nc_client.o - $(CXX) -o $@ $^ $(LDFLAGS) - -tcp_hex_client : tcp_hex_client.o - $(CXX) -o $@ $^ $(LDFLAGS) - -clean: - rm -rf *.o - -distclean: clean - rm -f $(TARGETS) diff --git a/network/example/tcp_connector/.gitignore b/network/example/tcp_connector/.gitignore deleted file mode 100644 index d94f521..0000000 --- a/network/example/tcp_connector/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/tcp_echo -/tcp_nc_client diff --git a/network/example/tcp_connector/Makefile b/network/example/tcp_connector/Makefile deleted file mode 100644 index dea16c8..0000000 --- a/network/example/tcp_connector/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -include ../build_env.mk - -CXXFLAGS += -ggdb -DLOG_MODULE_ID='"demo"' -LDFLAGS += -L.. -ltbox_network -ltbox_eventx -ltbox_event -ltbox_base -levent_core -lev -lpthread -TARGETS = tcp_echo tcp_nc_client - -CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer -LDFLAGS += -fsanitize=address -static-libasan - -all : $(TARGETS) - -tcp_echo : tcp_echo.o - $(CXX) -o $@ $^ $(LDFLAGS) - -tcp_nc_client : tcp_nc_client.o - $(CXX) -o $@ $^ $(LDFLAGS) - -clean: - rm -rf *.o - -distclean: clean - rm -f $(TARGETS) diff --git a/network/example/tcp_server/.gitignore b/network/example/tcp_server/.gitignore deleted file mode 100644 index 5aa354c..0000000 --- a/network/example/tcp_server/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/tcp_echo -/tcp_nc_server diff --git a/network/example/tcp_server/Makefile b/network/example/tcp_server/Makefile deleted file mode 100644 index a2352c0..0000000 --- a/network/example/tcp_server/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -include ../build_env.mk - -CXXFLAGS += -ggdb -DLOG_MODULE_ID='"demo"' -LDFLAGS += -L.. -ltbox_network -ltbox_eventx -ltbox_event -ltbox_base -levent_core -lev -lpthread -TARGETS = tcp_echo tcp_nc_server - -CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer -LDFLAGS += -fsanitize=address -static-libasan - -all : $(TARGETS) - -tcp_echo : tcp_echo.o - $(CXX) -o $@ $^ $(LDFLAGS) - -tcp_nc_server : tcp_nc_server.o - $(CXX) -o $@ $^ $(LDFLAGS) - -clean: - rm -rf *.o - -distclean: clean - rm -f $(TARGETS) diff --git a/network/example/uart/.gitignore b/network/example/uart/.gitignore deleted file mode 100644 index 40f9c33..0000000 --- a/network/example/uart/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/uart_tool -/uart_to_uart diff --git a/network/example/uart/Makefile b/network/example/uart/Makefile deleted file mode 100644 index 495f59b..0000000 --- a/network/example/uart/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -include ../build_env.mk - -CXXFLAGS += -ggdb -DLOG_MODULE_ID='"demo"' -LDFLAGS += -L.. -ltbox_network -ltbox_eventx -ltbox_event -ltbox_base -levent_core -lev -lpthread - -CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer -LDFLAGS += -fsanitize=address -static-libasan - -all : uart_tool uart_to_uart - -uart_tool: uart_tool.o - $(CXX) -o $@ $^ $(LDFLAGS) - -uart_to_uart : uart_to_uart.o - $(CXX) -o $@ $^ $(LDFLAGS) - -clean: - rm -rf *.o - -distclean: clean - rm -f uart_tool uart_to_uart diff --git a/network/example/udp_socket/.gitignore b/network/example/udp_socket/.gitignore deleted file mode 100644 index f0b8492..0000000 --- a/network/example/udp_socket/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/send_only -/recv_only -/request -/respond -/ping_pong -*.o diff --git a/network/example/udp_socket/Makefile b/network/example/udp_socket/Makefile deleted file mode 100644 index 2962e66..0000000 --- a/network/example/udp_socket/Makefile +++ /dev/null @@ -1,31 +0,0 @@ -include ../build_env.mk - -CXXFLAGS += -ggdb -DLOG_MODULE_ID='"demo"' -LDFLAGS += -L.. -ltbox_network -ltbox_eventx -ltbox_event -ltbox_base -levent_core -lev -lpthread -TARGETS = send_only recv_only request respond ping_pong - -CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer -LDFLAGS += -fsanitize=address -static-libasan - -all : $(TARGETS) - -send_only : send_only.o - $(CXX) -o $@ $^ $(LDFLAGS) - -recv_only : recv_only.o - $(CXX) -o $@ $^ $(LDFLAGS) - -request : request.o - $(CXX) -o $@ $^ $(LDFLAGS) - -respond : respond.o - $(CXX) -o $@ $^ $(LDFLAGS) - -ping_pong : ping_pong.o - $(CXX) -o $@ $^ $(LDFLAGS) - -clean: - rm -rf *.o - -distclean: clean - rm -f $(TARGETS) -- Gitee From 15a393807fcae5775f30f5f88432021088fa76bd Mon Sep 17 00:00:00 2001 From: hevake_lcj Date: Tue, 16 Aug 2022 10:24:08 +0800 Subject: [PATCH 18/24] =?UTF-8?q?=E4=BF=AE=E6=94=B9base/log=5Fimp.cpp?= =?UTF-8?q?=EF=BC=8C=E8=A7=A3=E5=86=B3=E6=97=A5=E5=BF=97=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=90=8D=E8=BF=87=E9=95=BF=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E6=94=B9=E6=88=90=E5=8F=AA=E6=98=BE=E7=A4=BAbasename=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E6=98=BE=E7=A4=BA=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/log_imp.cpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/base/log_imp.cpp b/base/log_imp.cpp index 19088d8..3a54c0f 100644 --- a/base/log_imp.cpp +++ b/base/log_imp.cpp @@ -8,12 +8,10 @@ #include #include -#ifdef __cplusplus -extern "C" { -#endif +namespace { -static std::mutex _lock; -static uint32_t _id_alloc = 0; +std::mutex _lock; +uint32_t _id_alloc = 0; struct OutputChannel { uint32_t id; @@ -21,7 +19,19 @@ struct OutputChannel { void *ptr; }; -static std::vector _output_channels; +std::vector _output_channels; + +const char* Basename(const char *full_path) +{ + const char *p_last = full_path; + for (const char *p = full_path; *p; ++p) { + if (*p == '/') + p_last = p + 1; + } + return p_last; +} + +} /** * \brief 日志格式化打印接口的实现 @@ -52,7 +62,7 @@ void LogPrintfFunc(const char *module_id, const char *func_name, const char *fil }, .module_id = module_id_be_print, .func_name = func_name, - .file_name = file_name, + .file_name = Basename(file_name), .line = line, .level = level, .with_args = with_args, @@ -103,6 +113,3 @@ bool LogRemovePrintfFunc(uint32_t id) return false; } -#ifdef __cplusplus -} -#endif -- Gitee From bafbfd890cbac10340017a577bf2af4e2118bb3f Mon Sep 17 00:00:00 2001 From: Hevake Date: Wed, 17 Aug 2022 00:03:31 +0800 Subject: [PATCH 19/24] =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BA=86mqtt=E7=9A=84e?= =?UTF-8?q?xample?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/mqtt/Makefile | 6 ++++ example/mqtt/conn/Makefile | 12 ++++++++ .../basic => example/mqtt/conn}/conn.cpp | 2 +- example/mqtt/pub/Makefile | 12 ++++++++ .../basic => example/mqtt/pub}/pub.cpp | 0 example/mqtt/sub/Makefile | 12 ++++++++ .../basic => example/mqtt/sub}/sub.cpp | 2 +- mqtt/example/basic/.gitignore | 3 -- mqtt/example/basic/Makefile | 22 -------------- mqtt/example/build_env.mk | 29 ------------------- 10 files changed, 44 insertions(+), 56 deletions(-) create mode 100644 example/mqtt/Makefile create mode 100644 example/mqtt/conn/Makefile rename {mqtt/example/basic => example/mqtt/conn}/conn.cpp (97%) create mode 100644 example/mqtt/pub/Makefile rename {mqtt/example/basic => example/mqtt/pub}/pub.cpp (100%) create mode 100644 example/mqtt/sub/Makefile rename {mqtt/example/basic => example/mqtt/sub}/sub.cpp (98%) delete mode 100644 mqtt/example/basic/.gitignore delete mode 100644 mqtt/example/basic/Makefile delete mode 100644 mqtt/example/build_env.mk diff --git a/example/mqtt/Makefile b/example/mqtt/Makefile new file mode 100644 index 0000000..31374b4 --- /dev/null +++ b/example/mqtt/Makefile @@ -0,0 +1,6 @@ +all test clean distclean: + @for i in $(shell ls) ; do \ + if [ -d $$i ]; then \ + $(MAKE) -C $$i $@ || exit $$? ; \ + fi \ + done diff --git a/example/mqtt/conn/Makefile b/example/mqtt/conn/Makefile new file mode 100644 index 0000000..e7698de --- /dev/null +++ b/example/mqtt/conn/Makefile @@ -0,0 +1,12 @@ +EXE_NAME := example/mqtt/conn + +CPP_SRC_FILES := conn.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_mqtt \ + -ltbox_event \ + -ltbox_base \ + -lmosquitto \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/mqtt/example/basic/conn.cpp b/example/mqtt/conn/conn.cpp similarity index 97% rename from mqtt/example/basic/conn.cpp rename to example/mqtt/conn/conn.cpp index f5f409a..68974f4 100644 --- a/mqtt/example/basic/conn.cpp +++ b/example/mqtt/conn/conn.cpp @@ -51,7 +51,7 @@ int main(int argc, char **argv) stop_ev->initialize(SIGINT, Event::Mode::kOneshot); stop_ev->enable(); stop_ev->setCallback( - [sp_loop, &mqtt] { + [sp_loop, &mqtt] (int) { mqtt.stop(); sp_loop->exitLoop(); } diff --git a/example/mqtt/pub/Makefile b/example/mqtt/pub/Makefile new file mode 100644 index 0000000..72adff9 --- /dev/null +++ b/example/mqtt/pub/Makefile @@ -0,0 +1,12 @@ +EXE_NAME := example/mqtt/pub + +CPP_SRC_FILES := pub.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_mqtt \ + -ltbox_event \ + -ltbox_base \ + -lmosquitto \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/mqtt/example/basic/pub.cpp b/example/mqtt/pub/pub.cpp similarity index 100% rename from mqtt/example/basic/pub.cpp rename to example/mqtt/pub/pub.cpp diff --git a/example/mqtt/sub/Makefile b/example/mqtt/sub/Makefile new file mode 100644 index 0000000..f1fd40a --- /dev/null +++ b/example/mqtt/sub/Makefile @@ -0,0 +1,12 @@ +EXE_NAME := example/mqtt/sub + +CPP_SRC_FILES := sub.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_mqtt \ + -ltbox_event \ + -ltbox_base \ + -lmosquitto \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/mqtt/example/basic/sub.cpp b/example/mqtt/sub/sub.cpp similarity index 98% rename from mqtt/example/basic/sub.cpp rename to example/mqtt/sub/sub.cpp index 5f34f5f..2879242 100644 --- a/mqtt/example/basic/sub.cpp +++ b/example/mqtt/sub/sub.cpp @@ -58,7 +58,7 @@ int main(int argc, char **argv) stop_ev->initialize(SIGINT, Event::Mode::kOneshot); stop_ev->enable(); stop_ev->setCallback( - [sp_loop, &mqtt] { + [sp_loop, &mqtt] (int) { mqtt.stop(); sp_loop->exitLoop(); } diff --git a/mqtt/example/basic/.gitignore b/mqtt/example/basic/.gitignore deleted file mode 100644 index 3359baf..0000000 --- a/mqtt/example/basic/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/sub -/pub -/conn diff --git a/mqtt/example/basic/Makefile b/mqtt/example/basic/Makefile deleted file mode 100644 index c3b8f60..0000000 --- a/mqtt/example/basic/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -include ../build_env.mk - -TARGET := sub pub conn -CXXFLAGS += -ggdb -DLOG_MODULE_ID='"demo"' -LDFLAGS += -L.. -ltbox_mqtt -ltbox_event -ltbox_base -lmosquitto -lpthread - -CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer -LDFLAGS += -fsanitize=address -static-libasan - -all : $(TARGET) - -sub : sub.cpp - $(CXX) -o $@ $^ $(CXXFLAGS) $(LDFLAGS) - -pub : pub.cpp - $(CXX) -o $@ $^ $(CXXFLAGS) $(LDFLAGS) - -conn : conn.cpp - $(CXX) -o $@ $^ $(CXXFLAGS) $(LDFLAGS) - -clean: - rm -rf $(TARGET) diff --git a/mqtt/example/build_env.mk b/mqtt/example/build_env.mk deleted file mode 100644 index 5848111..0000000 --- a/mqtt/example/build_env.mk +++ /dev/null @@ -1,29 +0,0 @@ -STAGING_DIR := ../../../.staging - -STAGING_INCLUDE := $(STAGING_DIR)/include -STAGING_LIB := $(STAGING_DIR)/lib - -CCFLAGS := -I$(STAGING_INCLUDE) -I$(CONSTANT_INCLUDE) -CFLAGS := $(CCFLAGS) -std=c99 -CXXFLAGS := $(CCFLAGS) -std=c++11 -LDFLAGS := -L$(STAGING_LIB) -INSTALL_DIR := $(STAGING_DIR) -DESTDIR := $(STAGING_DIR) -prefix := - -TOOLCHAIN_PREFIX := -AR := $(TOOLCHAIN_PREFIX)ar -AS := $(TOOLCHAIN_PREFIX)as -CXX := $(TOOLCHAIN_PREFIX)g++ -CC := $(TOOLCHAIN_PREFIX)gcc -NM := $(TOOLCHAIN_PREFIX)nm -OBJCOPY := $(TOOLCHAIN_PREFIX)objcopy -OBJDUMP := $(TOOLCHAIN_PREFIX)objdump -STRINGS := $(TOOLCHAIN_PREFIX)strings -SSTRIP := $(TOOLCHAIN_PREFIX)sstrip -LSTRIP := $(TOOLCHAIN_PREFIX)lstrip -STRIP := $(TOOLCHAIN_PREFIX)strip - -export STAGING_INCLUDE STAGING_LIB INSTALL_DIR DESTDIR prefix -export AR AS CC NM OBJCOPY OBJDUMP CXX STRIP SSTRIP STRINGS LSTRIP -export CFLAGS CXXFLAGS LDFLAGS -- Gitee From fc4b4a6f5a42d5d0a32307ba23fcbf1675060fd3 Mon Sep 17 00:00:00 2001 From: Hevake Date: Wed, 17 Aug 2022 00:14:38 +0800 Subject: [PATCH 20/24] =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BA=86http=E7=9A=84e?= =?UTF-8?q?xample?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/http/Makefile | 6 ++++ example/http/server/Makefile | 6 ++++ example/http/server/async_respond/Makefile | 15 ++++++++++ .../server/async_respond}/async_respond.cpp | 0 example/http/server/router/Makefile | 15 ++++++++++ .../http/server/router}/router.cpp | 0 example/http/server/simple/Makefile | 15 ++++++++++ .../http/server/simple}/simple.cpp | 0 {sample => example/main/sample}/Makefile | 4 +-- {sample => example/main/sample}/README.md | 0 {sample => example/main/sample}/app1/app.cpp | 0 {sample => example/main/sample}/app1/app.h | 0 {sample => example/main/sample}/app1/app.mk | 0 {sample => example/main/sample}/app2/app.cpp | 0 {sample => example/main/sample}/app2/app.h | 0 {sample => example/main/sample}/app2/app.mk | 0 {sample => example/main/sample}/app_main.cpp | 0 .../main/sample}/build_time.cpp | 0 {sample => example/main/sample}/default.conf | 0 http/example/build_env.mk | 29 ------------------- http/example/server/.gitignore | 4 --- http/example/server/Makefile | 23 --------------- 22 files changed, 59 insertions(+), 58 deletions(-) create mode 100644 example/http/Makefile create mode 100644 example/http/server/Makefile create mode 100644 example/http/server/async_respond/Makefile rename {http/example/server => example/http/server/async_respond}/async_respond.cpp (100%) create mode 100644 example/http/server/router/Makefile rename {http/example/server => example/http/server/router}/router.cpp (100%) create mode 100644 example/http/server/simple/Makefile rename {http/example/server => example/http/server/simple}/simple.cpp (100%) rename {sample => example/main/sample}/Makefile (86%) rename {sample => example/main/sample}/README.md (100%) rename {sample => example/main/sample}/app1/app.cpp (100%) rename {sample => example/main/sample}/app1/app.h (100%) rename {sample => example/main/sample}/app1/app.mk (100%) rename {sample => example/main/sample}/app2/app.cpp (100%) rename {sample => example/main/sample}/app2/app.h (100%) rename {sample => example/main/sample}/app2/app.mk (100%) rename {sample => example/main/sample}/app_main.cpp (100%) rename {sample => example/main/sample}/build_time.cpp (100%) rename {sample => example/main/sample}/default.conf (100%) delete mode 100644 http/example/build_env.mk delete mode 100644 http/example/server/.gitignore delete mode 100644 http/example/server/Makefile diff --git a/example/http/Makefile b/example/http/Makefile new file mode 100644 index 0000000..31374b4 --- /dev/null +++ b/example/http/Makefile @@ -0,0 +1,6 @@ +all test clean distclean: + @for i in $(shell ls) ; do \ + if [ -d $$i ]; then \ + $(MAKE) -C $$i $@ || exit $$? ; \ + fi \ + done diff --git a/example/http/server/Makefile b/example/http/server/Makefile new file mode 100644 index 0000000..31374b4 --- /dev/null +++ b/example/http/server/Makefile @@ -0,0 +1,6 @@ +all test clean distclean: + @for i in $(shell ls) ; do \ + if [ -d $$i ]; then \ + $(MAKE) -C $$i $@ || exit $$? ; \ + fi \ + done diff --git a/example/http/server/async_respond/Makefile b/example/http/server/async_respond/Makefile new file mode 100644 index 0000000..49f3f79 --- /dev/null +++ b/example/http/server/async_respond/Makefile @@ -0,0 +1,15 @@ +EXE_NAME := example/http/server/async_respond + +CPP_SRC_FILES := async_respond.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_http \ + -ltbox_network \ + -ltbox_eventx \ + -ltbox_event \ + -ltbox_log \ + -ltbox_util \ + -ltbox_base \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/http/example/server/async_respond.cpp b/example/http/server/async_respond/async_respond.cpp similarity index 100% rename from http/example/server/async_respond.cpp rename to example/http/server/async_respond/async_respond.cpp diff --git a/example/http/server/router/Makefile b/example/http/server/router/Makefile new file mode 100644 index 0000000..4d71f20 --- /dev/null +++ b/example/http/server/router/Makefile @@ -0,0 +1,15 @@ +EXE_NAME := example/http/server/router + +CPP_SRC_FILES := router.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_http \ + -ltbox_network \ + -ltbox_eventx \ + -ltbox_event \ + -ltbox_log \ + -ltbox_util \ + -ltbox_base \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/http/example/server/router.cpp b/example/http/server/router/router.cpp similarity index 100% rename from http/example/server/router.cpp rename to example/http/server/router/router.cpp diff --git a/example/http/server/simple/Makefile b/example/http/server/simple/Makefile new file mode 100644 index 0000000..91df7aa --- /dev/null +++ b/example/http/server/simple/Makefile @@ -0,0 +1,15 @@ +EXE_NAME := example/http/server/simple + +CPP_SRC_FILES := simple.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_http \ + -ltbox_network \ + -ltbox_eventx \ + -ltbox_event \ + -ltbox_log \ + -ltbox_util \ + -ltbox_base \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/http/example/server/simple.cpp b/example/http/server/simple/simple.cpp similarity index 100% rename from http/example/server/simple.cpp rename to example/http/server/simple/simple.cpp diff --git a/sample/Makefile b/example/main/sample/Makefile similarity index 86% rename from sample/Makefile rename to example/main/sample/Makefile index 0b3f8d5..a9becd5 100644 --- a/sample/Makefile +++ b/example/main/sample/Makefile @@ -1,4 +1,4 @@ -EXE_NAME := sample +EXE_NAME := example/main/sample CPP_SRC_FILES := app_main.cpp build_time.cpp TEST_CPP_SRC_FILES := @@ -29,4 +29,4 @@ TEST_LDFLAGS += $(LDFLAGS) pre_build : touch build_time.cpp -include ../tools/exe_common.mk +include $(TOP_DIR)/tools/exe_common.mk diff --git a/sample/README.md b/example/main/sample/README.md similarity index 100% rename from sample/README.md rename to example/main/sample/README.md diff --git a/sample/app1/app.cpp b/example/main/sample/app1/app.cpp similarity index 100% rename from sample/app1/app.cpp rename to example/main/sample/app1/app.cpp diff --git a/sample/app1/app.h b/example/main/sample/app1/app.h similarity index 100% rename from sample/app1/app.h rename to example/main/sample/app1/app.h diff --git a/sample/app1/app.mk b/example/main/sample/app1/app.mk similarity index 100% rename from sample/app1/app.mk rename to example/main/sample/app1/app.mk diff --git a/sample/app2/app.cpp b/example/main/sample/app2/app.cpp similarity index 100% rename from sample/app2/app.cpp rename to example/main/sample/app2/app.cpp diff --git a/sample/app2/app.h b/example/main/sample/app2/app.h similarity index 100% rename from sample/app2/app.h rename to example/main/sample/app2/app.h diff --git a/sample/app2/app.mk b/example/main/sample/app2/app.mk similarity index 100% rename from sample/app2/app.mk rename to example/main/sample/app2/app.mk diff --git a/sample/app_main.cpp b/example/main/sample/app_main.cpp similarity index 100% rename from sample/app_main.cpp rename to example/main/sample/app_main.cpp diff --git a/sample/build_time.cpp b/example/main/sample/build_time.cpp similarity index 100% rename from sample/build_time.cpp rename to example/main/sample/build_time.cpp diff --git a/sample/default.conf b/example/main/sample/default.conf similarity index 100% rename from sample/default.conf rename to example/main/sample/default.conf diff --git a/http/example/build_env.mk b/http/example/build_env.mk deleted file mode 100644 index 5848111..0000000 --- a/http/example/build_env.mk +++ /dev/null @@ -1,29 +0,0 @@ -STAGING_DIR := ../../../.staging - -STAGING_INCLUDE := $(STAGING_DIR)/include -STAGING_LIB := $(STAGING_DIR)/lib - -CCFLAGS := -I$(STAGING_INCLUDE) -I$(CONSTANT_INCLUDE) -CFLAGS := $(CCFLAGS) -std=c99 -CXXFLAGS := $(CCFLAGS) -std=c++11 -LDFLAGS := -L$(STAGING_LIB) -INSTALL_DIR := $(STAGING_DIR) -DESTDIR := $(STAGING_DIR) -prefix := - -TOOLCHAIN_PREFIX := -AR := $(TOOLCHAIN_PREFIX)ar -AS := $(TOOLCHAIN_PREFIX)as -CXX := $(TOOLCHAIN_PREFIX)g++ -CC := $(TOOLCHAIN_PREFIX)gcc -NM := $(TOOLCHAIN_PREFIX)nm -OBJCOPY := $(TOOLCHAIN_PREFIX)objcopy -OBJDUMP := $(TOOLCHAIN_PREFIX)objdump -STRINGS := $(TOOLCHAIN_PREFIX)strings -SSTRIP := $(TOOLCHAIN_PREFIX)sstrip -LSTRIP := $(TOOLCHAIN_PREFIX)lstrip -STRIP := $(TOOLCHAIN_PREFIX)strip - -export STAGING_INCLUDE STAGING_LIB INSTALL_DIR DESTDIR prefix -export AR AS CC NM OBJCOPY OBJDUMP CXX STRIP SSTRIP STRINGS LSTRIP -export CFLAGS CXXFLAGS LDFLAGS diff --git a/http/example/server/.gitignore b/http/example/server/.gitignore deleted file mode 100644 index 546e590..0000000 --- a/http/example/server/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/simple -/async_respond -/router -*.o diff --git a/http/example/server/Makefile b/http/example/server/Makefile deleted file mode 100644 index e624455..0000000 --- a/http/example/server/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -include ../build_env.mk - -TARGET := simple async_respond router - -CXXFLAGS += -ggdb -DLOG_MODULE_ID='"main"' -LDFLAGS += -ltbox_http -ltbox_network -ltbox_log -ltbox_eventx -ltbox_event -ltbox_util -ltbox_base - -CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer -LDFLAGS += -fsanitize=address -static-libasan - -all : $(TARGET) - -simple : simple.o - $(CXX) -o $@ $^ $(CXXFLAGS) $(LDFLAGS) - -async_respond : async_respond.o - $(CXX) -o $@ $^ $(CXXFLAGS) $(LDFLAGS) - -router: router.o - $(CXX) -o $@ $^ $(CXXFLAGS) $(LDFLAGS) - -clean: - rm -rf *.o $(TARGET) -- Gitee From 600be0bdd35bafd63454b6a7dd2767f58da8d2e3 Mon Sep 17 00:00:00 2001 From: Hevake Date: Wed, 17 Aug 2022 00:37:48 +0800 Subject: [PATCH 21/24] =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BA=86mqtt=E4=B8=8Et?= =?UTF-8?q?erminal=E7=9A=84example?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/event/04-run-in-loop/Makefile | 1 + example/mqtt/conn/Makefile | 1 + example/mqtt/pub/Makefile | 1 + example/mqtt/sub/Makefile | 1 + example/terminal/Makefile | 6 ++++ example/terminal/tcp_rpc/Makefile | 13 +++++++++ .../terminal}/tcp_rpc/main.cpp | 0 example/terminal/telnetd/Makefile | 13 +++++++++ .../terminal}/telnetd/main.cpp | 0 example/util/Makefile | 6 ++++ example/util/backtrace/Makefile | 11 +++++++ .../util}/backtrace/sample.cpp | 0 {example/main/sample => sample}/Makefile | 2 +- {example/main/sample => sample}/README.md | 0 {example/main/sample => sample}/app1/app.cpp | 0 {example/main/sample => sample}/app1/app.h | 0 {example/main/sample => sample}/app1/app.mk | 0 {example/main/sample => sample}/app2/app.cpp | 0 {example/main/sample => sample}/app2/app.h | 0 {example/main/sample => sample}/app2/app.mk | 0 {example/main/sample => sample}/app_main.cpp | 0 .../main/sample => sample}/build_time.cpp | 0 {example/main/sample => sample}/default.conf | 0 terminal/example/build_env.mk | 29 ------------------- terminal/example/tcp_rpc/.gitignore | 1 - terminal/example/tcp_rpc/Makefile | 17 ----------- terminal/example/telnetd/.gitignore | 1 - terminal/example/telnetd/Makefile | 17 ----------- util/example/backtrace/.gitignore | 1 - util/example/backtrace/Makefile | 18 ------------ util/example/build_env.mk | 29 ------------------- 31 files changed, 54 insertions(+), 114 deletions(-) create mode 100644 example/terminal/Makefile create mode 100644 example/terminal/tcp_rpc/Makefile rename {terminal/example => example/terminal}/tcp_rpc/main.cpp (100%) create mode 100644 example/terminal/telnetd/Makefile rename {terminal/example => example/terminal}/telnetd/main.cpp (100%) create mode 100644 example/util/Makefile create mode 100644 example/util/backtrace/Makefile rename {util/example => example/util}/backtrace/sample.cpp (100%) rename {example/main/sample => sample}/Makefile (94%) rename {example/main/sample => sample}/README.md (100%) rename {example/main/sample => sample}/app1/app.cpp (100%) rename {example/main/sample => sample}/app1/app.h (100%) rename {example/main/sample => sample}/app1/app.mk (100%) rename {example/main/sample => sample}/app2/app.cpp (100%) rename {example/main/sample => sample}/app2/app.h (100%) rename {example/main/sample => sample}/app2/app.mk (100%) rename {example/main/sample => sample}/app_main.cpp (100%) rename {example/main/sample => sample}/build_time.cpp (100%) rename {example/main/sample => sample}/default.conf (100%) delete mode 100644 terminal/example/build_env.mk delete mode 100644 terminal/example/tcp_rpc/.gitignore delete mode 100644 terminal/example/tcp_rpc/Makefile delete mode 100644 terminal/example/telnetd/.gitignore delete mode 100644 terminal/example/telnetd/Makefile delete mode 100644 util/example/backtrace/.gitignore delete mode 100644 util/example/backtrace/Makefile delete mode 100644 util/example/build_env.mk diff --git a/example/event/04-run-in-loop/Makefile b/example/event/04-run-in-loop/Makefile index 1c3173a..2148b13 100644 --- a/example/event/04-run-in-loop/Makefile +++ b/example/event/04-run-in-loop/Makefile @@ -6,5 +6,6 @@ CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) LDFLAGS += \ -ltbox_event \ -ltbox_base \ + -lpthread \ include ${TOP_DIR}/tools/exe_common.mk diff --git a/example/mqtt/conn/Makefile b/example/mqtt/conn/Makefile index e7698de..ba1ac10 100644 --- a/example/mqtt/conn/Makefile +++ b/example/mqtt/conn/Makefile @@ -8,5 +8,6 @@ LDFLAGS += \ -ltbox_event \ -ltbox_base \ -lmosquitto \ + -lpthread \ include ${TOP_DIR}/tools/exe_common.mk diff --git a/example/mqtt/pub/Makefile b/example/mqtt/pub/Makefile index 72adff9..44b2136 100644 --- a/example/mqtt/pub/Makefile +++ b/example/mqtt/pub/Makefile @@ -8,5 +8,6 @@ LDFLAGS += \ -ltbox_event \ -ltbox_base \ -lmosquitto \ + -lpthread \ include ${TOP_DIR}/tools/exe_common.mk diff --git a/example/mqtt/sub/Makefile b/example/mqtt/sub/Makefile index f1fd40a..f1bda80 100644 --- a/example/mqtt/sub/Makefile +++ b/example/mqtt/sub/Makefile @@ -8,5 +8,6 @@ LDFLAGS += \ -ltbox_event \ -ltbox_base \ -lmosquitto \ + -lpthread \ include ${TOP_DIR}/tools/exe_common.mk diff --git a/example/terminal/Makefile b/example/terminal/Makefile new file mode 100644 index 0000000..31374b4 --- /dev/null +++ b/example/terminal/Makefile @@ -0,0 +1,6 @@ +all test clean distclean: + @for i in $(shell ls) ; do \ + if [ -d $$i ]; then \ + $(MAKE) -C $$i $@ || exit $$? ; \ + fi \ + done diff --git a/example/terminal/tcp_rpc/Makefile b/example/terminal/tcp_rpc/Makefile new file mode 100644 index 0000000..18d088e --- /dev/null +++ b/example/terminal/tcp_rpc/Makefile @@ -0,0 +1,13 @@ +EXE_NAME := example/terminal/tcp_rpc + +CPP_SRC_FILES := main.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_terminal \ + -ltbox_network \ + -ltbox_event \ + -ltbox_util \ + -ltbox_base \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/terminal/example/tcp_rpc/main.cpp b/example/terminal/tcp_rpc/main.cpp similarity index 100% rename from terminal/example/tcp_rpc/main.cpp rename to example/terminal/tcp_rpc/main.cpp diff --git a/example/terminal/telnetd/Makefile b/example/terminal/telnetd/Makefile new file mode 100644 index 0000000..5f45b03 --- /dev/null +++ b/example/terminal/telnetd/Makefile @@ -0,0 +1,13 @@ +EXE_NAME := example/terminal/telnetd + +CPP_SRC_FILES := main.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_terminal \ + -ltbox_network \ + -ltbox_event \ + -ltbox_util \ + -ltbox_base \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/terminal/example/telnetd/main.cpp b/example/terminal/telnetd/main.cpp similarity index 100% rename from terminal/example/telnetd/main.cpp rename to example/terminal/telnetd/main.cpp diff --git a/example/util/Makefile b/example/util/Makefile new file mode 100644 index 0000000..31374b4 --- /dev/null +++ b/example/util/Makefile @@ -0,0 +1,6 @@ +all test clean distclean: + @for i in $(shell ls) ; do \ + if [ -d $$i ]; then \ + $(MAKE) -C $$i $@ || exit $$? ; \ + fi \ + done diff --git a/example/util/backtrace/Makefile b/example/util/backtrace/Makefile new file mode 100644 index 0000000..a862a73 --- /dev/null +++ b/example/util/backtrace/Makefile @@ -0,0 +1,11 @@ +EXE_NAME := example/util/backstrace + +CPP_SRC_FILES := sample.cpp + +CXXFLAGS := -DLOG_MODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) +LDFLAGS += \ + -ltbox_util \ + -ltbox_base \ + -ldl \ + +include ${TOP_DIR}/tools/exe_common.mk diff --git a/util/example/backtrace/sample.cpp b/example/util/backtrace/sample.cpp similarity index 100% rename from util/example/backtrace/sample.cpp rename to example/util/backtrace/sample.cpp diff --git a/example/main/sample/Makefile b/sample/Makefile similarity index 94% rename from example/main/sample/Makefile rename to sample/Makefile index a9becd5..2e33834 100644 --- a/example/main/sample/Makefile +++ b/sample/Makefile @@ -1,4 +1,4 @@ -EXE_NAME := example/main/sample +EXE_NAME := sample CPP_SRC_FILES := app_main.cpp build_time.cpp TEST_CPP_SRC_FILES := diff --git a/example/main/sample/README.md b/sample/README.md similarity index 100% rename from example/main/sample/README.md rename to sample/README.md diff --git a/example/main/sample/app1/app.cpp b/sample/app1/app.cpp similarity index 100% rename from example/main/sample/app1/app.cpp rename to sample/app1/app.cpp diff --git a/example/main/sample/app1/app.h b/sample/app1/app.h similarity index 100% rename from example/main/sample/app1/app.h rename to sample/app1/app.h diff --git a/example/main/sample/app1/app.mk b/sample/app1/app.mk similarity index 100% rename from example/main/sample/app1/app.mk rename to sample/app1/app.mk diff --git a/example/main/sample/app2/app.cpp b/sample/app2/app.cpp similarity index 100% rename from example/main/sample/app2/app.cpp rename to sample/app2/app.cpp diff --git a/example/main/sample/app2/app.h b/sample/app2/app.h similarity index 100% rename from example/main/sample/app2/app.h rename to sample/app2/app.h diff --git a/example/main/sample/app2/app.mk b/sample/app2/app.mk similarity index 100% rename from example/main/sample/app2/app.mk rename to sample/app2/app.mk diff --git a/example/main/sample/app_main.cpp b/sample/app_main.cpp similarity index 100% rename from example/main/sample/app_main.cpp rename to sample/app_main.cpp diff --git a/example/main/sample/build_time.cpp b/sample/build_time.cpp similarity index 100% rename from example/main/sample/build_time.cpp rename to sample/build_time.cpp diff --git a/example/main/sample/default.conf b/sample/default.conf similarity index 100% rename from example/main/sample/default.conf rename to sample/default.conf diff --git a/terminal/example/build_env.mk b/terminal/example/build_env.mk deleted file mode 100644 index 5848111..0000000 --- a/terminal/example/build_env.mk +++ /dev/null @@ -1,29 +0,0 @@ -STAGING_DIR := ../../../.staging - -STAGING_INCLUDE := $(STAGING_DIR)/include -STAGING_LIB := $(STAGING_DIR)/lib - -CCFLAGS := -I$(STAGING_INCLUDE) -I$(CONSTANT_INCLUDE) -CFLAGS := $(CCFLAGS) -std=c99 -CXXFLAGS := $(CCFLAGS) -std=c++11 -LDFLAGS := -L$(STAGING_LIB) -INSTALL_DIR := $(STAGING_DIR) -DESTDIR := $(STAGING_DIR) -prefix := - -TOOLCHAIN_PREFIX := -AR := $(TOOLCHAIN_PREFIX)ar -AS := $(TOOLCHAIN_PREFIX)as -CXX := $(TOOLCHAIN_PREFIX)g++ -CC := $(TOOLCHAIN_PREFIX)gcc -NM := $(TOOLCHAIN_PREFIX)nm -OBJCOPY := $(TOOLCHAIN_PREFIX)objcopy -OBJDUMP := $(TOOLCHAIN_PREFIX)objdump -STRINGS := $(TOOLCHAIN_PREFIX)strings -SSTRIP := $(TOOLCHAIN_PREFIX)sstrip -LSTRIP := $(TOOLCHAIN_PREFIX)lstrip -STRIP := $(TOOLCHAIN_PREFIX)strip - -export STAGING_INCLUDE STAGING_LIB INSTALL_DIR DESTDIR prefix -export AR AS CC NM OBJCOPY OBJDUMP CXX STRIP SSTRIP STRINGS LSTRIP -export CFLAGS CXXFLAGS LDFLAGS diff --git a/terminal/example/tcp_rpc/.gitignore b/terminal/example/tcp_rpc/.gitignore deleted file mode 100644 index 69ff739..0000000 --- a/terminal/example/tcp_rpc/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/demo diff --git a/terminal/example/tcp_rpc/Makefile b/terminal/example/tcp_rpc/Makefile deleted file mode 100644 index bb4d9fa..0000000 --- a/terminal/example/tcp_rpc/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -include ../build_env.mk - -TARGET := demo -OBJECTS := main.o -CXXFLAGS += -ggdb -DLOG_MODULE_ID='"demo"' -LDFLAGS += -L.. -ltbox_terminal -ltbox_util -ltbox_network -ltbox_event -ltbox_base -lpthread - -CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer -LDFLAGS += -fsanitize=address -static-libasan - -all : $(TARGET) - -$(TARGET) : $(OBJECTS) - $(CXX) -o $@ $^ $(LDFLAGS) - -clean: - rm -rf $(OBJECTS) diff --git a/terminal/example/telnetd/.gitignore b/terminal/example/telnetd/.gitignore deleted file mode 100644 index 69ff739..0000000 --- a/terminal/example/telnetd/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/demo diff --git a/terminal/example/telnetd/Makefile b/terminal/example/telnetd/Makefile deleted file mode 100644 index bb4d9fa..0000000 --- a/terminal/example/telnetd/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -include ../build_env.mk - -TARGET := demo -OBJECTS := main.o -CXXFLAGS += -ggdb -DLOG_MODULE_ID='"demo"' -LDFLAGS += -L.. -ltbox_terminal -ltbox_util -ltbox_network -ltbox_event -ltbox_base -lpthread - -CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer -LDFLAGS += -fsanitize=address -static-libasan - -all : $(TARGET) - -$(TARGET) : $(OBJECTS) - $(CXX) -o $@ $^ $(LDFLAGS) - -clean: - rm -rf $(OBJECTS) diff --git a/util/example/backtrace/.gitignore b/util/example/backtrace/.gitignore deleted file mode 100644 index ae6321f..0000000 --- a/util/example/backtrace/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/sample diff --git a/util/example/backtrace/Makefile b/util/example/backtrace/Makefile deleted file mode 100644 index 6b54048..0000000 --- a/util/example/backtrace/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -include ../build_env.mk - -CXXFLAGS += -ggdb -DLOG_MODULE_ID='"demo"' -LDFLAGS += -L.. -ltbox_util - -CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer -LDFLAGS += -fsanitize=address -static-libasan - -all : sample - -sample: sample.o - $(CXX) -o $@ $^ $(LDFLAGS) -rdynamic - -clean: - rm -rf *.o - -distclean: clean - rm -f sample diff --git a/util/example/build_env.mk b/util/example/build_env.mk deleted file mode 100644 index 5848111..0000000 --- a/util/example/build_env.mk +++ /dev/null @@ -1,29 +0,0 @@ -STAGING_DIR := ../../../.staging - -STAGING_INCLUDE := $(STAGING_DIR)/include -STAGING_LIB := $(STAGING_DIR)/lib - -CCFLAGS := -I$(STAGING_INCLUDE) -I$(CONSTANT_INCLUDE) -CFLAGS := $(CCFLAGS) -std=c99 -CXXFLAGS := $(CCFLAGS) -std=c++11 -LDFLAGS := -L$(STAGING_LIB) -INSTALL_DIR := $(STAGING_DIR) -DESTDIR := $(STAGING_DIR) -prefix := - -TOOLCHAIN_PREFIX := -AR := $(TOOLCHAIN_PREFIX)ar -AS := $(TOOLCHAIN_PREFIX)as -CXX := $(TOOLCHAIN_PREFIX)g++ -CC := $(TOOLCHAIN_PREFIX)gcc -NM := $(TOOLCHAIN_PREFIX)nm -OBJCOPY := $(TOOLCHAIN_PREFIX)objcopy -OBJDUMP := $(TOOLCHAIN_PREFIX)objdump -STRINGS := $(TOOLCHAIN_PREFIX)strings -SSTRIP := $(TOOLCHAIN_PREFIX)sstrip -LSTRIP := $(TOOLCHAIN_PREFIX)lstrip -STRIP := $(TOOLCHAIN_PREFIX)strip - -export STAGING_INCLUDE STAGING_LIB INSTALL_DIR DESTDIR prefix -export AR AS CC NM OBJCOPY OBJDUMP CXX STRIP SSTRIP STRINGS LSTRIP -export CFLAGS CXXFLAGS LDFLAGS -- Gitee From 411171f6385e0a772b95c94b323312cb6f7c07ea Mon Sep 17 00:00:00 2001 From: Hevake Date: Wed, 17 Aug 2022 01:15:12 +0800 Subject: [PATCH 22/24] =?UTF-8?q?=E5=B0=86=E6=A8=A1=E5=9D=97=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=A7=BB=E5=8A=A8=E5=88=B0modules=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 14 +++++++---- config.mk | 24 +++++++++---------- example/util/Makefile | 6 ----- examples/Makefile | 4 ++++ {example => examples}/event/01-io/Makefile | 0 {example => examples}/event/01-io/main.cpp | 0 {example => examples}/event/02-timer/Makefile | 0 {example => examples}/event/02-timer/main.cpp | 0 .../event/03-signal/Makefile | 0 .../event/03-signal/main.cpp | 0 .../event/04-run-in-loop/Makefile | 0 .../event/04-run-in-loop/main.cpp | 0 .../event/05-run-next-seq/Makefile | 0 .../event/05-run-next-seq/main.cpp | 0 .../event/06-stdin-timer-signal/Makefile | 0 .../event/06-stdin-timer-signal/main.cpp | 0 .../event/07-delay-delete/Makefile | 0 .../event/07-delay-delete/main.cpp | 0 .../event/08-calc-game/Makefile | 0 .../event/08-calc-game/game.cpp | 0 .../event/08-calc-game/game.h | 0 .../event/08-calc-game/game_lite.cpp | 0 .../event/08-calc-game/game_lite.h | 0 .../event/08-calc-game/main.cpp | 0 {example => examples/event}/Makefile | 0 {example/event => examples/eventx}/Makefile | 0 .../eventx/thread-pool/Makefile | 0 .../eventx/thread-pool/main.cpp | 0 {example/eventx => examples/http}/Makefile | 0 .../http => examples/http/server}/Makefile | 0 .../http/server/async_respond/Makefile | 0 .../server/async_respond/async_respond.cpp | 0 .../http/server/router/Makefile | 0 .../http/server/router/router.cpp | 0 .../http/server/simple/Makefile | 0 .../http/server/simple/simple.cpp | 0 {example => examples}/main/00_empty/Makefile | 0 .../main/01_one_app/Makefile | 0 {example => examples}/main/01_one_app/app.cpp | 0 {example => examples}/main/01_one_app/app.h | 0 .../main/01_one_app/main.cpp | 0 .../main/02_more_than_one_apps/Makefile | 0 .../main/02_more_than_one_apps/app1/app.cpp | 0 .../main/02_more_than_one_apps/app1/app.h | 0 .../main/02_more_than_one_apps/app1/app.mk | 0 .../main/02_more_than_one_apps/app1/sub.cpp | 0 .../main/02_more_than_one_apps/app1/sub.h | 0 .../main/02_more_than_one_apps/app2/app.cpp | 0 .../main/02_more_than_one_apps/app2/app.h | 0 .../main/02_more_than_one_apps/app2/app.mk | 0 .../main/02_more_than_one_apps/app3/app.cpp | 0 .../main/02_more_than_one_apps/app3/app.h | 0 .../main/02_more_than_one_apps/app3/app.mk | 0 .../main/02_more_than_one_apps/main.cpp | 0 .../03_nc_client_and_echo_server/Makefile | 0 .../03_nc_client_and_echo_server/README.md | 0 .../echo_server/app.cpp | 0 .../echo_server/app.h | 0 .../echo_server/app.mk | 0 .../03_nc_client_and_echo_server/main.cpp | 0 .../nc_client/app.cpp | 0 .../nc_client/app.h | 0 .../nc_client/app.mk | 0 .../main/04_initiate_runtime_error/Makefile | 0 .../main/04_initiate_runtime_error/README.txt | 0 .../main/04_initiate_runtime_error/main.cpp | 0 .../http/server => examples/main}/Makefile | 0 {example => examples}/main/README.md | 0 {example/main => examples/mqtt}/Makefile | 0 {example => examples}/mqtt/conn/Makefile | 0 {example => examples}/mqtt/conn/conn.cpp | 0 {example => examples}/mqtt/pub/Makefile | 0 {example => examples}/mqtt/pub/pub.cpp | 0 {example => examples}/mqtt/sub/Makefile | 0 {example => examples}/mqtt/sub/sub.cpp | 0 {example/mqtt => examples/network}/Makefile | 0 .../network/buffered_fd/Makefile | 0 .../network/buffered_fd/io_echo.cpp | 0 .../stdio_stream/01-stdin-out/Makefile | 0 .../stdio_stream/01-stdin-out/main.cpp | 0 .../network/stdio_stream/02-stdio/Makefile | 0 .../network/stdio_stream/02-stdio/main.cpp | 0 .../network/stdio_stream}/Makefile | 0 .../network/tcp_acceptor}/Makefile | 0 .../network/tcp_acceptor/tcp_echo/Makefile | 0 .../tcp_acceptor/tcp_echo/tcp_echo.cpp | 0 .../tcp_acceptor/tcp_nc_server/Makefile | 0 .../tcp_nc_server/tcp_nc_server.cpp | 0 .../network/tcp_client}/Makefile | 0 .../network/tcp_client/tcp_echo/Makefile | 0 .../network/tcp_client/tcp_echo/tcp_echo.cpp | 0 .../tcp_client/tcp_hex_client/Makefile | 0 .../tcp_hex_client/tcp_hex_client.cpp | 0 .../network/tcp_client/tcp_nc_client/Makefile | 0 .../tcp_nc_client/tcp_nc_client.cpp | 0 .../network/tcp_connector}/Makefile | 0 .../network/tcp_connector/tcp_echo/Makefile | 0 .../tcp_connector/tcp_echo/tcp_echo.cpp | 0 .../tcp_connector/tcp_nc_client/Makefile | 0 .../tcp_nc_client/tcp_nc_client.cpp | 0 .../network/tcp_server}/Makefile | 0 .../network/tcp_server/tcp_echo/Makefile | 0 .../network/tcp_server/tcp_echo/tcp_echo.cpp | 0 .../network/tcp_server/tcp_nc_server/Makefile | 0 .../tcp_nc_server/tcp_nc_server.cpp | 0 .../network/uart}/Makefile | 0 .../network/uart/uart_to_uart/Makefile | 0 .../uart/uart_to_uart/uart_to_uart.cpp | 0 .../network/uart/uart_tool/Makefile | 0 .../network/uart/uart_tool/uart_tool.cpp | 0 .../network/udp_socket}/Makefile | 0 .../network/udp_socket/ping_pong/Makefile | 0 .../udp_socket/ping_pong/ping_pong.cpp | 0 .../network/udp_socket/recv_only/Makefile | 0 .../udp_socket/recv_only/recv_only.cpp | 0 .../network/udp_socket/request/Makefile | 0 .../network/udp_socket/request/request.cpp | 0 .../network/udp_socket/respond/Makefile | 0 .../network/udp_socket/respond/respond.cpp | 0 .../network/udp_socket/send_only/Makefile | 0 .../udp_socket/send_only/send_only.cpp | 0 .../udp_socket => examples/terminal}/Makefile | 0 .../terminal/tcp_rpc/Makefile | 0 .../terminal/tcp_rpc/main.cpp | 0 .../terminal/telnetd/Makefile | 0 .../terminal/telnetd/main.cpp | 0 {example/terminal => examples/util}/Makefile | 0 {example => examples}/util/backtrace/Makefile | 0 .../util/backtrace/sample.cpp | 0 modules/Makefile | 4 ++++ {base => modules/base}/Makefile | 2 +- {base => modules/base}/cabinet.hpp | 0 {base => modules/base}/cabinet_test.cpp | 0 {base => modules/base}/cabinet_token.h | 0 {base => modules/base}/defines.h | 0 {base => modules/base}/json.hpp | 0 {base => modules/base}/json_fwd.h | 0 {base => modules/base}/json_test.cpp | 0 {base => modules/base}/log.h | 0 {base => modules/base}/log_imp.cpp | 0 {base => modules/base}/log_imp.h | 0 {base => modules/base}/log_output.cpp | 0 {base => modules/base}/log_output.h | 0 {base => modules/base}/log_output_test.cpp | 0 {base => modules/base}/memblock.h | 0 {base => modules/base}/scope_exit.hpp | 0 {base => modules/base}/scope_exit_test.cpp | 0 {coroutine => modules/coroutine}/Makefile | 2 +- {coroutine => modules/coroutine}/README.md | 0 .../coroutine}/broadcast.hpp | 0 .../coroutine}/broadcast_test.cpp | 0 {coroutine => modules/coroutine}/channel.hpp | 0 .../coroutine}/channel_test.cpp | 0 .../coroutine}/condition.hpp | 0 .../coroutine}/condition_test.cpp | 0 {coroutine => modules/coroutine}/mutex.hpp | 0 .../coroutine}/mutex_test.cpp | 0 .../coroutine}/scheduler.cpp | 0 {coroutine => modules/coroutine}/scheduler.h | 0 .../coroutine}/scheduler_test.cpp | 0 .../coroutine}/semaphore.hpp | 0 .../coroutine}/semaphore_test.cpp | 0 {event => modules/event}/Makefile | 2 +- {event => modules/event}/common_loop.cpp | 0 {event => modules/event}/common_loop.h | 0 {event => modules/event}/common_loop_run.cpp | 0 .../event}/common_loop_signal.cpp | 0 {event => modules/event}/common_loop_test.cpp | 0 {event => modules/event}/config.mk | 0 .../event}/engins/epoll/fd_event.cpp | 0 .../event}/engins/epoll/fd_event.h | 0 .../event}/engins/epoll/loop.cpp | 0 {event => modules/event}/engins/epoll/loop.h | 0 .../event}/engins/epoll/timer_event.cpp | 0 .../event}/engins/epoll/timer_event.h | 0 .../event}/engins/libev/fd_event.cpp | 0 .../event}/engins/libev/fd_event.h | 0 .../event}/engins/libev/loop.cpp | 0 {event => modules/event}/engins/libev/loop.h | 0 .../event}/engins/libev/timer_event.cpp | 0 .../event}/engins/libev/timer_event.h | 0 .../event}/engins/libevent/common.cpp | 0 .../event}/engins/libevent/common.h | 0 .../event}/engins/libevent/fd_event.cpp | 0 .../event}/engins/libevent/fd_event.h | 0 .../event}/engins/libevent/loop.cpp | 0 .../event}/engins/libevent/loop.h | 0 .../event}/engins/libevent/timer_event.cpp | 0 .../event}/engins/libevent/timer_event.h | 0 {event => modules/event}/event.h | 0 {event => modules/event}/fd_event.h | 0 {event => modules/event}/fd_event_test.cpp | 0 {event => modules/event}/forward.h | 0 {event => modules/event}/loop.cpp | 0 {event => modules/event}/loop.h | 0 {event => modules/event}/misc.cpp | 0 {event => modules/event}/misc.h | 0 {event => modules/event}/signal_event.h | 0 .../event}/signal_event_impl.cpp | 0 {event => modules/event}/signal_event_impl.h | 0 .../event}/signal_event_test.cpp | 0 {event => modules/event}/stat.cpp | 0 {event => modules/event}/stat.h | 0 {event => modules/event}/stat_test.cpp | 0 {event => modules/event}/timer_event.h | 0 {event => modules/event}/timer_event_test.cpp | 0 {event => modules/event}/version.cpp | 0 {event => modules/event}/version.h | 0 {eventx => modules/eventx}/Makefile | 2 +- {eventx => modules/eventx}/request_pool.hpp | 0 .../eventx}/request_pool_test.cpp | 0 {eventx => modules/eventx}/thread_pool.cpp | 0 {eventx => modules/eventx}/thread_pool.h | 0 .../eventx}/thread_pool_test.cpp | 0 .../eventx}/timeout_monitor.cpp | 0 {eventx => modules/eventx}/timeout_monitor.h | 0 .../eventx}/timeout_monitor_test.cpp | 0 {eventx => modules/eventx}/timer_pool.cpp | 0 {eventx => modules/eventx}/timer_pool.h | 0 .../eventx}/timer_pool_test.cpp | 0 {http => modules/http}/Makefile | 2 +- {http => modules/http}/README.md | 0 {http => modules/http}/client/client.cpp | 0 {http => modules/http}/client/client.h | 0 {http => modules/http}/common.cpp | 0 {http => modules/http}/common.h | 0 {http => modules/http}/common_test.cpp | 0 {http => modules/http}/request.cpp | 0 {http => modules/http}/request.h | 0 {http => modules/http}/request_test.cpp | 0 {http => modules/http}/respond.cpp | 0 {http => modules/http}/respond.h | 0 {http => modules/http}/respond_test.cpp | 0 {http => modules/http}/server/context.cpp | 0 {http => modules/http}/server/context.h | 0 {http => modules/http}/server/middleware.h | 0 .../http}/server/request_parser.cpp | 0 .../http}/server/request_parser.h | 0 .../http}/server/request_parser_test.cpp | 0 {http => modules/http}/server/router.cpp | 0 {http => modules/http}/server/router.h | 0 {http => modules/http}/server/server.cpp | 0 {http => modules/http}/server/server.h | 0 {http => modules/http}/server/server_imp.cpp | 0 {http => modules/http}/server/server_imp.h | 0 {http => modules/http}/server/types.h | 0 {http => modules/http}/url.cpp | 0 {http => modules/http}/url.h | 0 {http => modules/http}/url_test.cpp | 0 {log => modules/log}/Makefile | 2 +- {log => modules/log}/async_channel.cpp | 0 {log => modules/log}/async_channel.h | 0 {log => modules/log}/async_channel_test.cpp | 0 {log => modules/log}/channel.cpp | 0 {log => modules/log}/channel.h | 0 {log => modules/log}/file_async_channel.cpp | 0 {log => modules/log}/file_async_channel.h | 0 .../log}/file_async_channel_test.cpp | 0 {log => modules/log}/stdout_channel.cpp | 0 {log => modules/log}/stdout_channel.h | 0 {log => modules/log}/stdout_channel_test.cpp | 0 {log => modules/log}/syslog_channel.cpp | 0 {log => modules/log}/syslog_channel.h | 0 {log => modules/log}/syslog_channel_test.cpp | 0 {main => modules/main}/Makefile | 2 +- {main => modules/main}/README.md | 0 {main => modules/main}/args.cpp | 0 {main => modules/main}/args.h | 0 {main => modules/main}/context.h | 0 {main => modules/main}/context_imp.cpp | 0 {main => modules/main}/context_imp.h | 0 {main => modules/main}/log.cpp | 0 {main => modules/main}/log.h | 0 {main => modules/main}/main.cpp | 0 {main => modules/main}/main.h | 0 {main => modules/main}/misc.cpp | 0 {main => modules/main}/module.cpp | 0 {main => modules/main}/module.h | 0 {main => modules/main}/signal.cpp | 0 {mqtt => modules/mqtt}/Makefile | 2 +- {mqtt => modules/mqtt}/client.cpp | 0 {mqtt => modules/mqtt}/client.h | 0 {network => modules/network}/Makefile | 2 +- {network => modules/network}/README | 0 {network => modules/network}/buffer.cpp | 0 {network => modules/network}/buffer.h | 0 {network => modules/network}/buffer_test.cpp | 0 {network => modules/network}/buffered_fd.cpp | 0 {network => modules/network}/buffered_fd.h | 0 .../network}/buffered_fd_test.cpp | 0 {network => modules/network}/byte_stream.h | 0 {network => modules/network}/fd.cpp | 0 {network => modules/network}/fd.h | 0 {network => modules/network}/fd_test.cpp | 0 {network => modules/network}/ip_address.cpp | 0 {network => modules/network}/ip_address.h | 0 .../network}/ip_address_test.cpp | 0 {network => modules/network}/sockaddr.cpp | 0 {network => modules/network}/sockaddr.h | 0 .../network}/sockaddr_test.cpp | 0 {network => modules/network}/socket_fd.cpp | 0 {network => modules/network}/socket_fd.h | 0 {network => modules/network}/stdio_stream.cpp | 0 {network => modules/network}/stdio_stream.h | 0 {network => modules/network}/tcp_acceptor.cpp | 0 {network => modules/network}/tcp_acceptor.h | 0 {network => modules/network}/tcp_client.cpp | 0 {network => modules/network}/tcp_client.h | 0 .../network}/tcp_connection.cpp | 0 {network => modules/network}/tcp_connection.h | 0 .../network}/tcp_connector.cpp | 0 {network => modules/network}/tcp_connector.h | 0 {network => modules/network}/tcp_server.cpp | 0 {network => modules/network}/tcp_server.h | 0 {network => modules/network}/uart.cpp | 0 {network => modules/network}/uart.h | 0 {network => modules/network}/uart_test.cpp | 0 {network => modules/network}/udp_socket.cpp | 0 {network => modules/network}/udp_socket.h | 0 .../network}/udp_socket_test.cpp | 0 {terminal => modules/terminal}/Makefile | 2 +- {terminal => modules/terminal}/README.md | 0 {terminal => modules/terminal}/connection.h | 0 .../terminal}/impl/dir_node.cpp | 0 .../terminal}/impl/dir_node.h | 0 .../terminal}/impl/func_node.cpp | 0 .../terminal}/impl/func_node.h | 0 .../terminal}/impl/inner_types.h | 0 .../terminal}/impl/key_event_scanner.cpp | 0 .../terminal}/impl/key_event_scanner.h | 0 .../terminal}/impl/key_event_scanner_test.cpp | 0 {terminal => modules/terminal}/impl/node.h | 0 .../terminal}/impl/service/tcp_rpc.cpp | 0 .../terminal}/impl/service/tcp_rpc.h | 0 .../terminal}/impl/service/telnetd.cpp | 0 .../terminal}/impl/service/telnetd.h | 0 .../terminal}/impl/session_context.h | 0 .../terminal}/impl/terminal.cpp | 0 .../terminal}/impl/terminal.h | 0 .../terminal}/impl/terminal_commands.cpp | 0 .../terminal}/impl/terminal_key_events.cpp | 0 .../terminal}/impl/terminal_nodes.cpp | 0 .../terminal}/service/tcp_rpc.cpp | 0 .../terminal}/service/tcp_rpc.h | 0 .../terminal}/service/telnetd.cpp | 0 .../terminal}/service/telnetd.h | 0 {terminal => modules/terminal}/session.cpp | 0 {terminal => modules/terminal}/session.h | 0 {terminal => modules/terminal}/terminal.cpp | 0 {terminal => modules/terminal}/terminal.h | 0 .../terminal}/terminal_interact.h | 0 .../terminal}/terminal_nodes.h | 0 {terminal => modules/terminal}/types.h | 0 {util => modules/util}/Makefile | 2 +- {util => modules/util}/argument_parser.cpp | 0 {util => modules/util}/argument_parser.h | 0 .../util}/argument_parser_test.cpp | 0 {util => modules/util}/async_pipe.cpp | 0 {util => modules/util}/async_pipe.h | 0 {util => modules/util}/async_pipe_test.cpp | 0 {util => modules/util}/backtrace.cpp | 0 {util => modules/util}/backtrace.h | 0 {util => modules/util}/fs.cpp | 0 {util => modules/util}/fs.h | 0 {util => modules/util}/fs_test.cpp | 0 {util => modules/util}/pid_file.cpp | 0 {util => modules/util}/pid_file.h | 0 {util => modules/util}/pid_file_test.cpp | 0 {util => modules/util}/serializer.cpp | 0 {util => modules/util}/serializer.h | 0 {util => modules/util}/serializer_test.cpp | 0 {util => modules/util}/split_cmdline.cpp | 0 {util => modules/util}/split_cmdline.h | 0 {util => modules/util}/split_cmdline_test.cpp | 0 {util => modules/util}/state_machine.cpp | 0 {util => modules/util}/state_machine.h | 0 {util => modules/util}/state_machine_test.cpp | 0 {util => modules/util}/string.cpp | 0 {util => modules/util}/string.h | 0 {util => modules/util}/string_test.cpp | 0 {util => modules/util}/thread_wdog.cpp | 0 {util => modules/util}/thread_wdog.h | 0 {util => modules/util}/thread_wdog_test.cpp | 0 {util => modules/util}/time_counter.cpp | 0 {util => modules/util}/time_counter.h | 0 {util => modules/util}/time_counter_test.cpp | 0 386 files changed, 39 insertions(+), 35 deletions(-) delete mode 100644 example/util/Makefile create mode 100644 examples/Makefile rename {example => examples}/event/01-io/Makefile (100%) rename {example => examples}/event/01-io/main.cpp (100%) rename {example => examples}/event/02-timer/Makefile (100%) rename {example => examples}/event/02-timer/main.cpp (100%) rename {example => examples}/event/03-signal/Makefile (100%) rename {example => examples}/event/03-signal/main.cpp (100%) rename {example => examples}/event/04-run-in-loop/Makefile (100%) rename {example => examples}/event/04-run-in-loop/main.cpp (100%) rename {example => examples}/event/05-run-next-seq/Makefile (100%) rename {example => examples}/event/05-run-next-seq/main.cpp (100%) rename {example => examples}/event/06-stdin-timer-signal/Makefile (100%) rename {example => examples}/event/06-stdin-timer-signal/main.cpp (100%) rename {example => examples}/event/07-delay-delete/Makefile (100%) rename {example => examples}/event/07-delay-delete/main.cpp (100%) rename {example => examples}/event/08-calc-game/Makefile (100%) rename {example => examples}/event/08-calc-game/game.cpp (100%) rename {example => examples}/event/08-calc-game/game.h (100%) rename {example => examples}/event/08-calc-game/game_lite.cpp (100%) rename {example => examples}/event/08-calc-game/game_lite.h (100%) rename {example => examples}/event/08-calc-game/main.cpp (100%) rename {example => examples/event}/Makefile (100%) rename {example/event => examples/eventx}/Makefile (100%) rename {example => examples}/eventx/thread-pool/Makefile (100%) rename {example => examples}/eventx/thread-pool/main.cpp (100%) rename {example/eventx => examples/http}/Makefile (100%) rename {example/http => examples/http/server}/Makefile (100%) rename {example => examples}/http/server/async_respond/Makefile (100%) rename {example => examples}/http/server/async_respond/async_respond.cpp (100%) rename {example => examples}/http/server/router/Makefile (100%) rename {example => examples}/http/server/router/router.cpp (100%) rename {example => examples}/http/server/simple/Makefile (100%) rename {example => examples}/http/server/simple/simple.cpp (100%) rename {example => examples}/main/00_empty/Makefile (100%) rename {example => examples}/main/01_one_app/Makefile (100%) rename {example => examples}/main/01_one_app/app.cpp (100%) rename {example => examples}/main/01_one_app/app.h (100%) rename {example => examples}/main/01_one_app/main.cpp (100%) rename {example => examples}/main/02_more_than_one_apps/Makefile (100%) rename {example => examples}/main/02_more_than_one_apps/app1/app.cpp (100%) rename {example => examples}/main/02_more_than_one_apps/app1/app.h (100%) rename {example => examples}/main/02_more_than_one_apps/app1/app.mk (100%) rename {example => examples}/main/02_more_than_one_apps/app1/sub.cpp (100%) rename {example => examples}/main/02_more_than_one_apps/app1/sub.h (100%) rename {example => examples}/main/02_more_than_one_apps/app2/app.cpp (100%) rename {example => examples}/main/02_more_than_one_apps/app2/app.h (100%) rename {example => examples}/main/02_more_than_one_apps/app2/app.mk (100%) rename {example => examples}/main/02_more_than_one_apps/app3/app.cpp (100%) rename {example => examples}/main/02_more_than_one_apps/app3/app.h (100%) rename {example => examples}/main/02_more_than_one_apps/app3/app.mk (100%) rename {example => examples}/main/02_more_than_one_apps/main.cpp (100%) rename {example => examples}/main/03_nc_client_and_echo_server/Makefile (100%) rename {example => examples}/main/03_nc_client_and_echo_server/README.md (100%) rename {example => examples}/main/03_nc_client_and_echo_server/echo_server/app.cpp (100%) rename {example => examples}/main/03_nc_client_and_echo_server/echo_server/app.h (100%) rename {example => examples}/main/03_nc_client_and_echo_server/echo_server/app.mk (100%) rename {example => examples}/main/03_nc_client_and_echo_server/main.cpp (100%) rename {example => examples}/main/03_nc_client_and_echo_server/nc_client/app.cpp (100%) rename {example => examples}/main/03_nc_client_and_echo_server/nc_client/app.h (100%) rename {example => examples}/main/03_nc_client_and_echo_server/nc_client/app.mk (100%) rename {example => examples}/main/04_initiate_runtime_error/Makefile (100%) rename {example => examples}/main/04_initiate_runtime_error/README.txt (100%) rename {example => examples}/main/04_initiate_runtime_error/main.cpp (100%) rename {example/http/server => examples/main}/Makefile (100%) rename {example => examples}/main/README.md (100%) rename {example/main => examples/mqtt}/Makefile (100%) rename {example => examples}/mqtt/conn/Makefile (100%) rename {example => examples}/mqtt/conn/conn.cpp (100%) rename {example => examples}/mqtt/pub/Makefile (100%) rename {example => examples}/mqtt/pub/pub.cpp (100%) rename {example => examples}/mqtt/sub/Makefile (100%) rename {example => examples}/mqtt/sub/sub.cpp (100%) rename {example/mqtt => examples/network}/Makefile (100%) rename {example => examples}/network/buffered_fd/Makefile (100%) rename {example => examples}/network/buffered_fd/io_echo.cpp (100%) rename {example => examples}/network/stdio_stream/01-stdin-out/Makefile (100%) rename {example => examples}/network/stdio_stream/01-stdin-out/main.cpp (100%) rename {example => examples}/network/stdio_stream/02-stdio/Makefile (100%) rename {example => examples}/network/stdio_stream/02-stdio/main.cpp (100%) rename {example/network => examples/network/stdio_stream}/Makefile (100%) rename {example/network/stdio_stream => examples/network/tcp_acceptor}/Makefile (100%) rename {example => examples}/network/tcp_acceptor/tcp_echo/Makefile (100%) rename {example => examples}/network/tcp_acceptor/tcp_echo/tcp_echo.cpp (100%) rename {example => examples}/network/tcp_acceptor/tcp_nc_server/Makefile (100%) rename {example => examples}/network/tcp_acceptor/tcp_nc_server/tcp_nc_server.cpp (100%) rename {example/network/tcp_acceptor => examples/network/tcp_client}/Makefile (100%) rename {example => examples}/network/tcp_client/tcp_echo/Makefile (100%) rename {example => examples}/network/tcp_client/tcp_echo/tcp_echo.cpp (100%) rename {example => examples}/network/tcp_client/tcp_hex_client/Makefile (100%) rename {example => examples}/network/tcp_client/tcp_hex_client/tcp_hex_client.cpp (100%) rename {example => examples}/network/tcp_client/tcp_nc_client/Makefile (100%) rename {example => examples}/network/tcp_client/tcp_nc_client/tcp_nc_client.cpp (100%) rename {example/network/tcp_client => examples/network/tcp_connector}/Makefile (100%) rename {example => examples}/network/tcp_connector/tcp_echo/Makefile (100%) rename {example => examples}/network/tcp_connector/tcp_echo/tcp_echo.cpp (100%) rename {example => examples}/network/tcp_connector/tcp_nc_client/Makefile (100%) rename {example => examples}/network/tcp_connector/tcp_nc_client/tcp_nc_client.cpp (100%) rename {example/network/tcp_connector => examples/network/tcp_server}/Makefile (100%) rename {example => examples}/network/tcp_server/tcp_echo/Makefile (100%) rename {example => examples}/network/tcp_server/tcp_echo/tcp_echo.cpp (100%) rename {example => examples}/network/tcp_server/tcp_nc_server/Makefile (100%) rename {example => examples}/network/tcp_server/tcp_nc_server/tcp_nc_server.cpp (100%) rename {example/network/tcp_server => examples/network/uart}/Makefile (100%) rename {example => examples}/network/uart/uart_to_uart/Makefile (100%) rename {example => examples}/network/uart/uart_to_uart/uart_to_uart.cpp (100%) rename {example => examples}/network/uart/uart_tool/Makefile (100%) rename {example => examples}/network/uart/uart_tool/uart_tool.cpp (100%) rename {example/network/uart => examples/network/udp_socket}/Makefile (100%) rename {example => examples}/network/udp_socket/ping_pong/Makefile (100%) rename {example => examples}/network/udp_socket/ping_pong/ping_pong.cpp (100%) rename {example => examples}/network/udp_socket/recv_only/Makefile (100%) rename {example => examples}/network/udp_socket/recv_only/recv_only.cpp (100%) rename {example => examples}/network/udp_socket/request/Makefile (100%) rename {example => examples}/network/udp_socket/request/request.cpp (100%) rename {example => examples}/network/udp_socket/respond/Makefile (100%) rename {example => examples}/network/udp_socket/respond/respond.cpp (100%) rename {example => examples}/network/udp_socket/send_only/Makefile (100%) rename {example => examples}/network/udp_socket/send_only/send_only.cpp (100%) rename {example/network/udp_socket => examples/terminal}/Makefile (100%) rename {example => examples}/terminal/tcp_rpc/Makefile (100%) rename {example => examples}/terminal/tcp_rpc/main.cpp (100%) rename {example => examples}/terminal/telnetd/Makefile (100%) rename {example => examples}/terminal/telnetd/main.cpp (100%) rename {example/terminal => examples/util}/Makefile (100%) rename {example => examples}/util/backtrace/Makefile (100%) rename {example => examples}/util/backtrace/sample.cpp (100%) create mode 100644 modules/Makefile rename {base => modules/base}/Makefile (92%) rename {base => modules/base}/cabinet.hpp (100%) rename {base => modules/base}/cabinet_test.cpp (100%) rename {base => modules/base}/cabinet_token.h (100%) rename {base => modules/base}/defines.h (100%) rename {base => modules/base}/json.hpp (100%) rename {base => modules/base}/json_fwd.h (100%) rename {base => modules/base}/json_test.cpp (100%) rename {base => modules/base}/log.h (100%) rename {base => modules/base}/log_imp.cpp (100%) rename {base => modules/base}/log_imp.h (100%) rename {base => modules/base}/log_output.cpp (100%) rename {base => modules/base}/log_output.h (100%) rename {base => modules/base}/log_output_test.cpp (100%) rename {base => modules/base}/memblock.h (100%) rename {base => modules/base}/scope_exit.hpp (100%) rename {base => modules/base}/scope_exit_test.cpp (100%) rename {coroutine => modules/coroutine}/Makefile (93%) rename {coroutine => modules/coroutine}/README.md (100%) rename {coroutine => modules/coroutine}/broadcast.hpp (100%) rename {coroutine => modules/coroutine}/broadcast_test.cpp (100%) rename {coroutine => modules/coroutine}/channel.hpp (100%) rename {coroutine => modules/coroutine}/channel_test.cpp (100%) rename {coroutine => modules/coroutine}/condition.hpp (100%) rename {coroutine => modules/coroutine}/condition_test.cpp (100%) rename {coroutine => modules/coroutine}/mutex.hpp (100%) rename {coroutine => modules/coroutine}/mutex_test.cpp (100%) rename {coroutine => modules/coroutine}/scheduler.cpp (100%) rename {coroutine => modules/coroutine}/scheduler.h (100%) rename {coroutine => modules/coroutine}/scheduler_test.cpp (100%) rename {coroutine => modules/coroutine}/semaphore.hpp (100%) rename {coroutine => modules/coroutine}/semaphore_test.cpp (100%) rename {event => modules/event}/Makefile (97%) rename {event => modules/event}/common_loop.cpp (100%) rename {event => modules/event}/common_loop.h (100%) rename {event => modules/event}/common_loop_run.cpp (100%) rename {event => modules/event}/common_loop_signal.cpp (100%) rename {event => modules/event}/common_loop_test.cpp (100%) rename {event => modules/event}/config.mk (100%) rename {event => modules/event}/engins/epoll/fd_event.cpp (100%) rename {event => modules/event}/engins/epoll/fd_event.h (100%) rename {event => modules/event}/engins/epoll/loop.cpp (100%) rename {event => modules/event}/engins/epoll/loop.h (100%) rename {event => modules/event}/engins/epoll/timer_event.cpp (100%) rename {event => modules/event}/engins/epoll/timer_event.h (100%) rename {event => modules/event}/engins/libev/fd_event.cpp (100%) rename {event => modules/event}/engins/libev/fd_event.h (100%) rename {event => modules/event}/engins/libev/loop.cpp (100%) rename {event => modules/event}/engins/libev/loop.h (100%) rename {event => modules/event}/engins/libev/timer_event.cpp (100%) rename {event => modules/event}/engins/libev/timer_event.h (100%) rename {event => modules/event}/engins/libevent/common.cpp (100%) rename {event => modules/event}/engins/libevent/common.h (100%) rename {event => modules/event}/engins/libevent/fd_event.cpp (100%) rename {event => modules/event}/engins/libevent/fd_event.h (100%) rename {event => modules/event}/engins/libevent/loop.cpp (100%) rename {event => modules/event}/engins/libevent/loop.h (100%) rename {event => modules/event}/engins/libevent/timer_event.cpp (100%) rename {event => modules/event}/engins/libevent/timer_event.h (100%) rename {event => modules/event}/event.h (100%) rename {event => modules/event}/fd_event.h (100%) rename {event => modules/event}/fd_event_test.cpp (100%) rename {event => modules/event}/forward.h (100%) rename {event => modules/event}/loop.cpp (100%) rename {event => modules/event}/loop.h (100%) rename {event => modules/event}/misc.cpp (100%) rename {event => modules/event}/misc.h (100%) rename {event => modules/event}/signal_event.h (100%) rename {event => modules/event}/signal_event_impl.cpp (100%) rename {event => modules/event}/signal_event_impl.h (100%) rename {event => modules/event}/signal_event_test.cpp (100%) rename {event => modules/event}/stat.cpp (100%) rename {event => modules/event}/stat.h (100%) rename {event => modules/event}/stat_test.cpp (100%) rename {event => modules/event}/timer_event.h (100%) rename {event => modules/event}/timer_event_test.cpp (100%) rename {event => modules/event}/version.cpp (100%) rename {event => modules/event}/version.h (100%) rename {eventx => modules/eventx}/Makefile (92%) rename {eventx => modules/eventx}/request_pool.hpp (100%) rename {eventx => modules/eventx}/request_pool_test.cpp (100%) rename {eventx => modules/eventx}/thread_pool.cpp (100%) rename {eventx => modules/eventx}/thread_pool.h (100%) rename {eventx => modules/eventx}/thread_pool_test.cpp (100%) rename {eventx => modules/eventx}/timeout_monitor.cpp (100%) rename {eventx => modules/eventx}/timeout_monitor.h (100%) rename {eventx => modules/eventx}/timeout_monitor_test.cpp (100%) rename {eventx => modules/eventx}/timer_pool.cpp (100%) rename {eventx => modules/eventx}/timer_pool.h (100%) rename {eventx => modules/eventx}/timer_pool_test.cpp (100%) rename {http => modules/http}/Makefile (95%) rename {http => modules/http}/README.md (100%) rename {http => modules/http}/client/client.cpp (100%) rename {http => modules/http}/client/client.h (100%) rename {http => modules/http}/common.cpp (100%) rename {http => modules/http}/common.h (100%) rename {http => modules/http}/common_test.cpp (100%) rename {http => modules/http}/request.cpp (100%) rename {http => modules/http}/request.h (100%) rename {http => modules/http}/request_test.cpp (100%) rename {http => modules/http}/respond.cpp (100%) rename {http => modules/http}/respond.h (100%) rename {http => modules/http}/respond_test.cpp (100%) rename {http => modules/http}/server/context.cpp (100%) rename {http => modules/http}/server/context.h (100%) rename {http => modules/http}/server/middleware.h (100%) rename {http => modules/http}/server/request_parser.cpp (100%) rename {http => modules/http}/server/request_parser.h (100%) rename {http => modules/http}/server/request_parser_test.cpp (100%) rename {http => modules/http}/server/router.cpp (100%) rename {http => modules/http}/server/router.h (100%) rename {http => modules/http}/server/server.cpp (100%) rename {http => modules/http}/server/server.h (100%) rename {http => modules/http}/server/server_imp.cpp (100%) rename {http => modules/http}/server/server_imp.h (100%) rename {http => modules/http}/server/types.h (100%) rename {http => modules/http}/url.cpp (100%) rename {http => modules/http}/url.h (100%) rename {http => modules/http}/url_test.cpp (100%) rename {log => modules/log}/Makefile (93%) rename {log => modules/log}/async_channel.cpp (100%) rename {log => modules/log}/async_channel.h (100%) rename {log => modules/log}/async_channel_test.cpp (100%) rename {log => modules/log}/channel.cpp (100%) rename {log => modules/log}/channel.h (100%) rename {log => modules/log}/file_async_channel.cpp (100%) rename {log => modules/log}/file_async_channel.h (100%) rename {log => modules/log}/file_async_channel_test.cpp (100%) rename {log => modules/log}/stdout_channel.cpp (100%) rename {log => modules/log}/stdout_channel.h (100%) rename {log => modules/log}/stdout_channel_test.cpp (100%) rename {log => modules/log}/syslog_channel.cpp (100%) rename {log => modules/log}/syslog_channel.h (100%) rename {log => modules/log}/syslog_channel_test.cpp (100%) rename {main => modules/main}/Makefile (92%) rename {main => modules/main}/README.md (100%) rename {main => modules/main}/args.cpp (100%) rename {main => modules/main}/args.h (100%) rename {main => modules/main}/context.h (100%) rename {main => modules/main}/context_imp.cpp (100%) rename {main => modules/main}/context_imp.h (100%) rename {main => modules/main}/log.cpp (100%) rename {main => modules/main}/log.h (100%) rename {main => modules/main}/main.cpp (100%) rename {main => modules/main}/main.h (100%) rename {main => modules/main}/misc.cpp (100%) rename {main => modules/main}/module.cpp (100%) rename {main => modules/main}/module.h (100%) rename {main => modules/main}/signal.cpp (100%) rename {mqtt => modules/mqtt}/Makefile (88%) rename {mqtt => modules/mqtt}/client.cpp (100%) rename {mqtt => modules/mqtt}/client.h (100%) rename {network => modules/network}/Makefile (95%) rename {network => modules/network}/README (100%) rename {network => modules/network}/buffer.cpp (100%) rename {network => modules/network}/buffer.h (100%) rename {network => modules/network}/buffer_test.cpp (100%) rename {network => modules/network}/buffered_fd.cpp (100%) rename {network => modules/network}/buffered_fd.h (100%) rename {network => modules/network}/buffered_fd_test.cpp (100%) rename {network => modules/network}/byte_stream.h (100%) rename {network => modules/network}/fd.cpp (100%) rename {network => modules/network}/fd.h (100%) rename {network => modules/network}/fd_test.cpp (100%) rename {network => modules/network}/ip_address.cpp (100%) rename {network => modules/network}/ip_address.h (100%) rename {network => modules/network}/ip_address_test.cpp (100%) rename {network => modules/network}/sockaddr.cpp (100%) rename {network => modules/network}/sockaddr.h (100%) rename {network => modules/network}/sockaddr_test.cpp (100%) rename {network => modules/network}/socket_fd.cpp (100%) rename {network => modules/network}/socket_fd.h (100%) rename {network => modules/network}/stdio_stream.cpp (100%) rename {network => modules/network}/stdio_stream.h (100%) rename {network => modules/network}/tcp_acceptor.cpp (100%) rename {network => modules/network}/tcp_acceptor.h (100%) rename {network => modules/network}/tcp_client.cpp (100%) rename {network => modules/network}/tcp_client.h (100%) rename {network => modules/network}/tcp_connection.cpp (100%) rename {network => modules/network}/tcp_connection.h (100%) rename {network => modules/network}/tcp_connector.cpp (100%) rename {network => modules/network}/tcp_connector.h (100%) rename {network => modules/network}/tcp_server.cpp (100%) rename {network => modules/network}/tcp_server.h (100%) rename {network => modules/network}/uart.cpp (100%) rename {network => modules/network}/uart.h (100%) rename {network => modules/network}/uart_test.cpp (100%) rename {network => modules/network}/udp_socket.cpp (100%) rename {network => modules/network}/udp_socket.h (100%) rename {network => modules/network}/udp_socket_test.cpp (100%) rename {terminal => modules/terminal}/Makefile (95%) rename {terminal => modules/terminal}/README.md (100%) rename {terminal => modules/terminal}/connection.h (100%) rename {terminal => modules/terminal}/impl/dir_node.cpp (100%) rename {terminal => modules/terminal}/impl/dir_node.h (100%) rename {terminal => modules/terminal}/impl/func_node.cpp (100%) rename {terminal => modules/terminal}/impl/func_node.h (100%) rename {terminal => modules/terminal}/impl/inner_types.h (100%) rename {terminal => modules/terminal}/impl/key_event_scanner.cpp (100%) rename {terminal => modules/terminal}/impl/key_event_scanner.h (100%) rename {terminal => modules/terminal}/impl/key_event_scanner_test.cpp (100%) rename {terminal => modules/terminal}/impl/node.h (100%) rename {terminal => modules/terminal}/impl/service/tcp_rpc.cpp (100%) rename {terminal => modules/terminal}/impl/service/tcp_rpc.h (100%) rename {terminal => modules/terminal}/impl/service/telnetd.cpp (100%) rename {terminal => modules/terminal}/impl/service/telnetd.h (100%) rename {terminal => modules/terminal}/impl/session_context.h (100%) rename {terminal => modules/terminal}/impl/terminal.cpp (100%) rename {terminal => modules/terminal}/impl/terminal.h (100%) rename {terminal => modules/terminal}/impl/terminal_commands.cpp (100%) rename {terminal => modules/terminal}/impl/terminal_key_events.cpp (100%) rename {terminal => modules/terminal}/impl/terminal_nodes.cpp (100%) rename {terminal => modules/terminal}/service/tcp_rpc.cpp (100%) rename {terminal => modules/terminal}/service/tcp_rpc.h (100%) rename {terminal => modules/terminal}/service/telnetd.cpp (100%) rename {terminal => modules/terminal}/service/telnetd.h (100%) rename {terminal => modules/terminal}/session.cpp (100%) rename {terminal => modules/terminal}/session.h (100%) rename {terminal => modules/terminal}/terminal.cpp (100%) rename {terminal => modules/terminal}/terminal.h (100%) rename {terminal => modules/terminal}/terminal_interact.h (100%) rename {terminal => modules/terminal}/terminal_nodes.h (100%) rename {terminal => modules/terminal}/types.h (100%) rename {util => modules/util}/Makefile (95%) rename {util => modules/util}/argument_parser.cpp (100%) rename {util => modules/util}/argument_parser.h (100%) rename {util => modules/util}/argument_parser_test.cpp (100%) rename {util => modules/util}/async_pipe.cpp (100%) rename {util => modules/util}/async_pipe.h (100%) rename {util => modules/util}/async_pipe_test.cpp (100%) rename {util => modules/util}/backtrace.cpp (100%) rename {util => modules/util}/backtrace.h (100%) rename {util => modules/util}/fs.cpp (100%) rename {util => modules/util}/fs.h (100%) rename {util => modules/util}/fs_test.cpp (100%) rename {util => modules/util}/pid_file.cpp (100%) rename {util => modules/util}/pid_file.h (100%) rename {util => modules/util}/pid_file_test.cpp (100%) rename {util => modules/util}/serializer.cpp (100%) rename {util => modules/util}/serializer.h (100%) rename {util => modules/util}/serializer_test.cpp (100%) rename {util => modules/util}/split_cmdline.cpp (100%) rename {util => modules/util}/split_cmdline.h (100%) rename {util => modules/util}/split_cmdline_test.cpp (100%) rename {util => modules/util}/state_machine.cpp (100%) rename {util => modules/util}/state_machine.h (100%) rename {util => modules/util}/state_machine_test.cpp (100%) rename {util => modules/util}/string.cpp (100%) rename {util => modules/util}/string.h (100%) rename {util => modules/util}/string_test.cpp (100%) rename {util => modules/util}/thread_wdog.cpp (100%) rename {util => modules/util}/thread_wdog.h (100%) rename {util => modules/util}/thread_wdog_test.cpp (100%) rename {util => modules/util}/time_counter.cpp (100%) rename {util => modules/util}/time_counter.h (100%) rename {util => modules/util}/time_counter_test.cpp (100%) diff --git a/Makefile b/Makefile index 2cafdd7..0da33ea 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ include build_env.mk -.PHONY: all clean distclean +.PHONY: all modules examples sample test clean distclean CCFLAGS := -Wall @@ -25,13 +25,17 @@ CFLAGS := $(CCFLAGS) $(CFLAGS) APPS_DIR := $(PWD) export CC CXX CFLAGS CXXFLAGS LDFLAGS APPS_DIR +export MODULES include config.mk -all test: - @for i in $(app_y); do \ - [ ! -d $$i ] || $(MAKE) -C $$i $@ || exit $$? ; \ - done +all: modules + +modules examples sample: + $(MAKE) -C $@ + +test: + $(MAKE) -C modules test clean: -rm -rf $(OUTPUT_DIR) diff --git a/config.mk b/config.mk index d493c0a..38a137d 100644 --- a/config.mk +++ b/config.mk @@ -1,13 +1,11 @@ -app_y += base -app_y += util -app_y += event -app_y += eventx -app_y += log -app_y += network -app_y += http -app_y += coroutine -app_y += mqtt -app_y += terminal -app_y += main -#app_y += sample -app_y += example +MODULES += base +MODULES += util +MODULES += event +MODULES += eventx +MODULES += log +MODULES += network +MODULES += http +MODULES += coroutine +MODULES += mqtt +MODULES += terminal +MODULES += main diff --git a/example/util/Makefile b/example/util/Makefile deleted file mode 100644 index 31374b4..0000000 --- a/example/util/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -all test clean distclean: - @for i in $(shell ls) ; do \ - if [ -d $$i ]; then \ - $(MAKE) -C $$i $@ || exit $$? ; \ - fi \ - done diff --git a/examples/Makefile b/examples/Makefile new file mode 100644 index 0000000..1b05fb4 --- /dev/null +++ b/examples/Makefile @@ -0,0 +1,4 @@ +all test: + @for i in $(MODULES); do \ + [ ! -d $$i ] || $(MAKE) -C $$i $@ || exit $$? ; \ + done diff --git a/example/event/01-io/Makefile b/examples/event/01-io/Makefile similarity index 100% rename from example/event/01-io/Makefile rename to examples/event/01-io/Makefile diff --git a/example/event/01-io/main.cpp b/examples/event/01-io/main.cpp similarity index 100% rename from example/event/01-io/main.cpp rename to examples/event/01-io/main.cpp diff --git a/example/event/02-timer/Makefile b/examples/event/02-timer/Makefile similarity index 100% rename from example/event/02-timer/Makefile rename to examples/event/02-timer/Makefile diff --git a/example/event/02-timer/main.cpp b/examples/event/02-timer/main.cpp similarity index 100% rename from example/event/02-timer/main.cpp rename to examples/event/02-timer/main.cpp diff --git a/example/event/03-signal/Makefile b/examples/event/03-signal/Makefile similarity index 100% rename from example/event/03-signal/Makefile rename to examples/event/03-signal/Makefile diff --git a/example/event/03-signal/main.cpp b/examples/event/03-signal/main.cpp similarity index 100% rename from example/event/03-signal/main.cpp rename to examples/event/03-signal/main.cpp diff --git a/example/event/04-run-in-loop/Makefile b/examples/event/04-run-in-loop/Makefile similarity index 100% rename from example/event/04-run-in-loop/Makefile rename to examples/event/04-run-in-loop/Makefile diff --git a/example/event/04-run-in-loop/main.cpp b/examples/event/04-run-in-loop/main.cpp similarity index 100% rename from example/event/04-run-in-loop/main.cpp rename to examples/event/04-run-in-loop/main.cpp diff --git a/example/event/05-run-next-seq/Makefile b/examples/event/05-run-next-seq/Makefile similarity index 100% rename from example/event/05-run-next-seq/Makefile rename to examples/event/05-run-next-seq/Makefile diff --git a/example/event/05-run-next-seq/main.cpp b/examples/event/05-run-next-seq/main.cpp similarity index 100% rename from example/event/05-run-next-seq/main.cpp rename to examples/event/05-run-next-seq/main.cpp diff --git a/example/event/06-stdin-timer-signal/Makefile b/examples/event/06-stdin-timer-signal/Makefile similarity index 100% rename from example/event/06-stdin-timer-signal/Makefile rename to examples/event/06-stdin-timer-signal/Makefile diff --git a/example/event/06-stdin-timer-signal/main.cpp b/examples/event/06-stdin-timer-signal/main.cpp similarity index 100% rename from example/event/06-stdin-timer-signal/main.cpp rename to examples/event/06-stdin-timer-signal/main.cpp diff --git a/example/event/07-delay-delete/Makefile b/examples/event/07-delay-delete/Makefile similarity index 100% rename from example/event/07-delay-delete/Makefile rename to examples/event/07-delay-delete/Makefile diff --git a/example/event/07-delay-delete/main.cpp b/examples/event/07-delay-delete/main.cpp similarity index 100% rename from example/event/07-delay-delete/main.cpp rename to examples/event/07-delay-delete/main.cpp diff --git a/example/event/08-calc-game/Makefile b/examples/event/08-calc-game/Makefile similarity index 100% rename from example/event/08-calc-game/Makefile rename to examples/event/08-calc-game/Makefile diff --git a/example/event/08-calc-game/game.cpp b/examples/event/08-calc-game/game.cpp similarity index 100% rename from example/event/08-calc-game/game.cpp rename to examples/event/08-calc-game/game.cpp diff --git a/example/event/08-calc-game/game.h b/examples/event/08-calc-game/game.h similarity index 100% rename from example/event/08-calc-game/game.h rename to examples/event/08-calc-game/game.h diff --git a/example/event/08-calc-game/game_lite.cpp b/examples/event/08-calc-game/game_lite.cpp similarity index 100% rename from example/event/08-calc-game/game_lite.cpp rename to examples/event/08-calc-game/game_lite.cpp diff --git a/example/event/08-calc-game/game_lite.h b/examples/event/08-calc-game/game_lite.h similarity index 100% rename from example/event/08-calc-game/game_lite.h rename to examples/event/08-calc-game/game_lite.h diff --git a/example/event/08-calc-game/main.cpp b/examples/event/08-calc-game/main.cpp similarity index 100% rename from example/event/08-calc-game/main.cpp rename to examples/event/08-calc-game/main.cpp diff --git a/example/Makefile b/examples/event/Makefile similarity index 100% rename from example/Makefile rename to examples/event/Makefile diff --git a/example/event/Makefile b/examples/eventx/Makefile similarity index 100% rename from example/event/Makefile rename to examples/eventx/Makefile diff --git a/example/eventx/thread-pool/Makefile b/examples/eventx/thread-pool/Makefile similarity index 100% rename from example/eventx/thread-pool/Makefile rename to examples/eventx/thread-pool/Makefile diff --git a/example/eventx/thread-pool/main.cpp b/examples/eventx/thread-pool/main.cpp similarity index 100% rename from example/eventx/thread-pool/main.cpp rename to examples/eventx/thread-pool/main.cpp diff --git a/example/eventx/Makefile b/examples/http/Makefile similarity index 100% rename from example/eventx/Makefile rename to examples/http/Makefile diff --git a/example/http/Makefile b/examples/http/server/Makefile similarity index 100% rename from example/http/Makefile rename to examples/http/server/Makefile diff --git a/example/http/server/async_respond/Makefile b/examples/http/server/async_respond/Makefile similarity index 100% rename from example/http/server/async_respond/Makefile rename to examples/http/server/async_respond/Makefile diff --git a/example/http/server/async_respond/async_respond.cpp b/examples/http/server/async_respond/async_respond.cpp similarity index 100% rename from example/http/server/async_respond/async_respond.cpp rename to examples/http/server/async_respond/async_respond.cpp diff --git a/example/http/server/router/Makefile b/examples/http/server/router/Makefile similarity index 100% rename from example/http/server/router/Makefile rename to examples/http/server/router/Makefile diff --git a/example/http/server/router/router.cpp b/examples/http/server/router/router.cpp similarity index 100% rename from example/http/server/router/router.cpp rename to examples/http/server/router/router.cpp diff --git a/example/http/server/simple/Makefile b/examples/http/server/simple/Makefile similarity index 100% rename from example/http/server/simple/Makefile rename to examples/http/server/simple/Makefile diff --git a/example/http/server/simple/simple.cpp b/examples/http/server/simple/simple.cpp similarity index 100% rename from example/http/server/simple/simple.cpp rename to examples/http/server/simple/simple.cpp diff --git a/example/main/00_empty/Makefile b/examples/main/00_empty/Makefile similarity index 100% rename from example/main/00_empty/Makefile rename to examples/main/00_empty/Makefile diff --git a/example/main/01_one_app/Makefile b/examples/main/01_one_app/Makefile similarity index 100% rename from example/main/01_one_app/Makefile rename to examples/main/01_one_app/Makefile diff --git a/example/main/01_one_app/app.cpp b/examples/main/01_one_app/app.cpp similarity index 100% rename from example/main/01_one_app/app.cpp rename to examples/main/01_one_app/app.cpp diff --git a/example/main/01_one_app/app.h b/examples/main/01_one_app/app.h similarity index 100% rename from example/main/01_one_app/app.h rename to examples/main/01_one_app/app.h diff --git a/example/main/01_one_app/main.cpp b/examples/main/01_one_app/main.cpp similarity index 100% rename from example/main/01_one_app/main.cpp rename to examples/main/01_one_app/main.cpp diff --git a/example/main/02_more_than_one_apps/Makefile b/examples/main/02_more_than_one_apps/Makefile similarity index 100% rename from example/main/02_more_than_one_apps/Makefile rename to examples/main/02_more_than_one_apps/Makefile diff --git a/example/main/02_more_than_one_apps/app1/app.cpp b/examples/main/02_more_than_one_apps/app1/app.cpp similarity index 100% rename from example/main/02_more_than_one_apps/app1/app.cpp rename to examples/main/02_more_than_one_apps/app1/app.cpp diff --git a/example/main/02_more_than_one_apps/app1/app.h b/examples/main/02_more_than_one_apps/app1/app.h similarity index 100% rename from example/main/02_more_than_one_apps/app1/app.h rename to examples/main/02_more_than_one_apps/app1/app.h diff --git a/example/main/02_more_than_one_apps/app1/app.mk b/examples/main/02_more_than_one_apps/app1/app.mk similarity index 100% rename from example/main/02_more_than_one_apps/app1/app.mk rename to examples/main/02_more_than_one_apps/app1/app.mk diff --git a/example/main/02_more_than_one_apps/app1/sub.cpp b/examples/main/02_more_than_one_apps/app1/sub.cpp similarity index 100% rename from example/main/02_more_than_one_apps/app1/sub.cpp rename to examples/main/02_more_than_one_apps/app1/sub.cpp diff --git a/example/main/02_more_than_one_apps/app1/sub.h b/examples/main/02_more_than_one_apps/app1/sub.h similarity index 100% rename from example/main/02_more_than_one_apps/app1/sub.h rename to examples/main/02_more_than_one_apps/app1/sub.h diff --git a/example/main/02_more_than_one_apps/app2/app.cpp b/examples/main/02_more_than_one_apps/app2/app.cpp similarity index 100% rename from example/main/02_more_than_one_apps/app2/app.cpp rename to examples/main/02_more_than_one_apps/app2/app.cpp diff --git a/example/main/02_more_than_one_apps/app2/app.h b/examples/main/02_more_than_one_apps/app2/app.h similarity index 100% rename from example/main/02_more_than_one_apps/app2/app.h rename to examples/main/02_more_than_one_apps/app2/app.h diff --git a/example/main/02_more_than_one_apps/app2/app.mk b/examples/main/02_more_than_one_apps/app2/app.mk similarity index 100% rename from example/main/02_more_than_one_apps/app2/app.mk rename to examples/main/02_more_than_one_apps/app2/app.mk diff --git a/example/main/02_more_than_one_apps/app3/app.cpp b/examples/main/02_more_than_one_apps/app3/app.cpp similarity index 100% rename from example/main/02_more_than_one_apps/app3/app.cpp rename to examples/main/02_more_than_one_apps/app3/app.cpp diff --git a/example/main/02_more_than_one_apps/app3/app.h b/examples/main/02_more_than_one_apps/app3/app.h similarity index 100% rename from example/main/02_more_than_one_apps/app3/app.h rename to examples/main/02_more_than_one_apps/app3/app.h diff --git a/example/main/02_more_than_one_apps/app3/app.mk b/examples/main/02_more_than_one_apps/app3/app.mk similarity index 100% rename from example/main/02_more_than_one_apps/app3/app.mk rename to examples/main/02_more_than_one_apps/app3/app.mk diff --git a/example/main/02_more_than_one_apps/main.cpp b/examples/main/02_more_than_one_apps/main.cpp similarity index 100% rename from example/main/02_more_than_one_apps/main.cpp rename to examples/main/02_more_than_one_apps/main.cpp diff --git a/example/main/03_nc_client_and_echo_server/Makefile b/examples/main/03_nc_client_and_echo_server/Makefile similarity index 100% rename from example/main/03_nc_client_and_echo_server/Makefile rename to examples/main/03_nc_client_and_echo_server/Makefile diff --git a/example/main/03_nc_client_and_echo_server/README.md b/examples/main/03_nc_client_and_echo_server/README.md similarity index 100% rename from example/main/03_nc_client_and_echo_server/README.md rename to examples/main/03_nc_client_and_echo_server/README.md diff --git a/example/main/03_nc_client_and_echo_server/echo_server/app.cpp b/examples/main/03_nc_client_and_echo_server/echo_server/app.cpp similarity index 100% rename from example/main/03_nc_client_and_echo_server/echo_server/app.cpp rename to examples/main/03_nc_client_and_echo_server/echo_server/app.cpp diff --git a/example/main/03_nc_client_and_echo_server/echo_server/app.h b/examples/main/03_nc_client_and_echo_server/echo_server/app.h similarity index 100% rename from example/main/03_nc_client_and_echo_server/echo_server/app.h rename to examples/main/03_nc_client_and_echo_server/echo_server/app.h diff --git a/example/main/03_nc_client_and_echo_server/echo_server/app.mk b/examples/main/03_nc_client_and_echo_server/echo_server/app.mk similarity index 100% rename from example/main/03_nc_client_and_echo_server/echo_server/app.mk rename to examples/main/03_nc_client_and_echo_server/echo_server/app.mk diff --git a/example/main/03_nc_client_and_echo_server/main.cpp b/examples/main/03_nc_client_and_echo_server/main.cpp similarity index 100% rename from example/main/03_nc_client_and_echo_server/main.cpp rename to examples/main/03_nc_client_and_echo_server/main.cpp diff --git a/example/main/03_nc_client_and_echo_server/nc_client/app.cpp b/examples/main/03_nc_client_and_echo_server/nc_client/app.cpp similarity index 100% rename from example/main/03_nc_client_and_echo_server/nc_client/app.cpp rename to examples/main/03_nc_client_and_echo_server/nc_client/app.cpp diff --git a/example/main/03_nc_client_and_echo_server/nc_client/app.h b/examples/main/03_nc_client_and_echo_server/nc_client/app.h similarity index 100% rename from example/main/03_nc_client_and_echo_server/nc_client/app.h rename to examples/main/03_nc_client_and_echo_server/nc_client/app.h diff --git a/example/main/03_nc_client_and_echo_server/nc_client/app.mk b/examples/main/03_nc_client_and_echo_server/nc_client/app.mk similarity index 100% rename from example/main/03_nc_client_and_echo_server/nc_client/app.mk rename to examples/main/03_nc_client_and_echo_server/nc_client/app.mk diff --git a/example/main/04_initiate_runtime_error/Makefile b/examples/main/04_initiate_runtime_error/Makefile similarity index 100% rename from example/main/04_initiate_runtime_error/Makefile rename to examples/main/04_initiate_runtime_error/Makefile diff --git a/example/main/04_initiate_runtime_error/README.txt b/examples/main/04_initiate_runtime_error/README.txt similarity index 100% rename from example/main/04_initiate_runtime_error/README.txt rename to examples/main/04_initiate_runtime_error/README.txt diff --git a/example/main/04_initiate_runtime_error/main.cpp b/examples/main/04_initiate_runtime_error/main.cpp similarity index 100% rename from example/main/04_initiate_runtime_error/main.cpp rename to examples/main/04_initiate_runtime_error/main.cpp diff --git a/example/http/server/Makefile b/examples/main/Makefile similarity index 100% rename from example/http/server/Makefile rename to examples/main/Makefile diff --git a/example/main/README.md b/examples/main/README.md similarity index 100% rename from example/main/README.md rename to examples/main/README.md diff --git a/example/main/Makefile b/examples/mqtt/Makefile similarity index 100% rename from example/main/Makefile rename to examples/mqtt/Makefile diff --git a/example/mqtt/conn/Makefile b/examples/mqtt/conn/Makefile similarity index 100% rename from example/mqtt/conn/Makefile rename to examples/mqtt/conn/Makefile diff --git a/example/mqtt/conn/conn.cpp b/examples/mqtt/conn/conn.cpp similarity index 100% rename from example/mqtt/conn/conn.cpp rename to examples/mqtt/conn/conn.cpp diff --git a/example/mqtt/pub/Makefile b/examples/mqtt/pub/Makefile similarity index 100% rename from example/mqtt/pub/Makefile rename to examples/mqtt/pub/Makefile diff --git a/example/mqtt/pub/pub.cpp b/examples/mqtt/pub/pub.cpp similarity index 100% rename from example/mqtt/pub/pub.cpp rename to examples/mqtt/pub/pub.cpp diff --git a/example/mqtt/sub/Makefile b/examples/mqtt/sub/Makefile similarity index 100% rename from example/mqtt/sub/Makefile rename to examples/mqtt/sub/Makefile diff --git a/example/mqtt/sub/sub.cpp b/examples/mqtt/sub/sub.cpp similarity index 100% rename from example/mqtt/sub/sub.cpp rename to examples/mqtt/sub/sub.cpp diff --git a/example/mqtt/Makefile b/examples/network/Makefile similarity index 100% rename from example/mqtt/Makefile rename to examples/network/Makefile diff --git a/example/network/buffered_fd/Makefile b/examples/network/buffered_fd/Makefile similarity index 100% rename from example/network/buffered_fd/Makefile rename to examples/network/buffered_fd/Makefile diff --git a/example/network/buffered_fd/io_echo.cpp b/examples/network/buffered_fd/io_echo.cpp similarity index 100% rename from example/network/buffered_fd/io_echo.cpp rename to examples/network/buffered_fd/io_echo.cpp diff --git a/example/network/stdio_stream/01-stdin-out/Makefile b/examples/network/stdio_stream/01-stdin-out/Makefile similarity index 100% rename from example/network/stdio_stream/01-stdin-out/Makefile rename to examples/network/stdio_stream/01-stdin-out/Makefile diff --git a/example/network/stdio_stream/01-stdin-out/main.cpp b/examples/network/stdio_stream/01-stdin-out/main.cpp similarity index 100% rename from example/network/stdio_stream/01-stdin-out/main.cpp rename to examples/network/stdio_stream/01-stdin-out/main.cpp diff --git a/example/network/stdio_stream/02-stdio/Makefile b/examples/network/stdio_stream/02-stdio/Makefile similarity index 100% rename from example/network/stdio_stream/02-stdio/Makefile rename to examples/network/stdio_stream/02-stdio/Makefile diff --git a/example/network/stdio_stream/02-stdio/main.cpp b/examples/network/stdio_stream/02-stdio/main.cpp similarity index 100% rename from example/network/stdio_stream/02-stdio/main.cpp rename to examples/network/stdio_stream/02-stdio/main.cpp diff --git a/example/network/Makefile b/examples/network/stdio_stream/Makefile similarity index 100% rename from example/network/Makefile rename to examples/network/stdio_stream/Makefile diff --git a/example/network/stdio_stream/Makefile b/examples/network/tcp_acceptor/Makefile similarity index 100% rename from example/network/stdio_stream/Makefile rename to examples/network/tcp_acceptor/Makefile diff --git a/example/network/tcp_acceptor/tcp_echo/Makefile b/examples/network/tcp_acceptor/tcp_echo/Makefile similarity index 100% rename from example/network/tcp_acceptor/tcp_echo/Makefile rename to examples/network/tcp_acceptor/tcp_echo/Makefile diff --git a/example/network/tcp_acceptor/tcp_echo/tcp_echo.cpp b/examples/network/tcp_acceptor/tcp_echo/tcp_echo.cpp similarity index 100% rename from example/network/tcp_acceptor/tcp_echo/tcp_echo.cpp rename to examples/network/tcp_acceptor/tcp_echo/tcp_echo.cpp diff --git a/example/network/tcp_acceptor/tcp_nc_server/Makefile b/examples/network/tcp_acceptor/tcp_nc_server/Makefile similarity index 100% rename from example/network/tcp_acceptor/tcp_nc_server/Makefile rename to examples/network/tcp_acceptor/tcp_nc_server/Makefile diff --git a/example/network/tcp_acceptor/tcp_nc_server/tcp_nc_server.cpp b/examples/network/tcp_acceptor/tcp_nc_server/tcp_nc_server.cpp similarity index 100% rename from example/network/tcp_acceptor/tcp_nc_server/tcp_nc_server.cpp rename to examples/network/tcp_acceptor/tcp_nc_server/tcp_nc_server.cpp diff --git a/example/network/tcp_acceptor/Makefile b/examples/network/tcp_client/Makefile similarity index 100% rename from example/network/tcp_acceptor/Makefile rename to examples/network/tcp_client/Makefile diff --git a/example/network/tcp_client/tcp_echo/Makefile b/examples/network/tcp_client/tcp_echo/Makefile similarity index 100% rename from example/network/tcp_client/tcp_echo/Makefile rename to examples/network/tcp_client/tcp_echo/Makefile diff --git a/example/network/tcp_client/tcp_echo/tcp_echo.cpp b/examples/network/tcp_client/tcp_echo/tcp_echo.cpp similarity index 100% rename from example/network/tcp_client/tcp_echo/tcp_echo.cpp rename to examples/network/tcp_client/tcp_echo/tcp_echo.cpp diff --git a/example/network/tcp_client/tcp_hex_client/Makefile b/examples/network/tcp_client/tcp_hex_client/Makefile similarity index 100% rename from example/network/tcp_client/tcp_hex_client/Makefile rename to examples/network/tcp_client/tcp_hex_client/Makefile diff --git a/example/network/tcp_client/tcp_hex_client/tcp_hex_client.cpp b/examples/network/tcp_client/tcp_hex_client/tcp_hex_client.cpp similarity index 100% rename from example/network/tcp_client/tcp_hex_client/tcp_hex_client.cpp rename to examples/network/tcp_client/tcp_hex_client/tcp_hex_client.cpp diff --git a/example/network/tcp_client/tcp_nc_client/Makefile b/examples/network/tcp_client/tcp_nc_client/Makefile similarity index 100% rename from example/network/tcp_client/tcp_nc_client/Makefile rename to examples/network/tcp_client/tcp_nc_client/Makefile diff --git a/example/network/tcp_client/tcp_nc_client/tcp_nc_client.cpp b/examples/network/tcp_client/tcp_nc_client/tcp_nc_client.cpp similarity index 100% rename from example/network/tcp_client/tcp_nc_client/tcp_nc_client.cpp rename to examples/network/tcp_client/tcp_nc_client/tcp_nc_client.cpp diff --git a/example/network/tcp_client/Makefile b/examples/network/tcp_connector/Makefile similarity index 100% rename from example/network/tcp_client/Makefile rename to examples/network/tcp_connector/Makefile diff --git a/example/network/tcp_connector/tcp_echo/Makefile b/examples/network/tcp_connector/tcp_echo/Makefile similarity index 100% rename from example/network/tcp_connector/tcp_echo/Makefile rename to examples/network/tcp_connector/tcp_echo/Makefile diff --git a/example/network/tcp_connector/tcp_echo/tcp_echo.cpp b/examples/network/tcp_connector/tcp_echo/tcp_echo.cpp similarity index 100% rename from example/network/tcp_connector/tcp_echo/tcp_echo.cpp rename to examples/network/tcp_connector/tcp_echo/tcp_echo.cpp diff --git a/example/network/tcp_connector/tcp_nc_client/Makefile b/examples/network/tcp_connector/tcp_nc_client/Makefile similarity index 100% rename from example/network/tcp_connector/tcp_nc_client/Makefile rename to examples/network/tcp_connector/tcp_nc_client/Makefile diff --git a/example/network/tcp_connector/tcp_nc_client/tcp_nc_client.cpp b/examples/network/tcp_connector/tcp_nc_client/tcp_nc_client.cpp similarity index 100% rename from example/network/tcp_connector/tcp_nc_client/tcp_nc_client.cpp rename to examples/network/tcp_connector/tcp_nc_client/tcp_nc_client.cpp diff --git a/example/network/tcp_connector/Makefile b/examples/network/tcp_server/Makefile similarity index 100% rename from example/network/tcp_connector/Makefile rename to examples/network/tcp_server/Makefile diff --git a/example/network/tcp_server/tcp_echo/Makefile b/examples/network/tcp_server/tcp_echo/Makefile similarity index 100% rename from example/network/tcp_server/tcp_echo/Makefile rename to examples/network/tcp_server/tcp_echo/Makefile diff --git a/example/network/tcp_server/tcp_echo/tcp_echo.cpp b/examples/network/tcp_server/tcp_echo/tcp_echo.cpp similarity index 100% rename from example/network/tcp_server/tcp_echo/tcp_echo.cpp rename to examples/network/tcp_server/tcp_echo/tcp_echo.cpp diff --git a/example/network/tcp_server/tcp_nc_server/Makefile b/examples/network/tcp_server/tcp_nc_server/Makefile similarity index 100% rename from example/network/tcp_server/tcp_nc_server/Makefile rename to examples/network/tcp_server/tcp_nc_server/Makefile diff --git a/example/network/tcp_server/tcp_nc_server/tcp_nc_server.cpp b/examples/network/tcp_server/tcp_nc_server/tcp_nc_server.cpp similarity index 100% rename from example/network/tcp_server/tcp_nc_server/tcp_nc_server.cpp rename to examples/network/tcp_server/tcp_nc_server/tcp_nc_server.cpp diff --git a/example/network/tcp_server/Makefile b/examples/network/uart/Makefile similarity index 100% rename from example/network/tcp_server/Makefile rename to examples/network/uart/Makefile diff --git a/example/network/uart/uart_to_uart/Makefile b/examples/network/uart/uart_to_uart/Makefile similarity index 100% rename from example/network/uart/uart_to_uart/Makefile rename to examples/network/uart/uart_to_uart/Makefile diff --git a/example/network/uart/uart_to_uart/uart_to_uart.cpp b/examples/network/uart/uart_to_uart/uart_to_uart.cpp similarity index 100% rename from example/network/uart/uart_to_uart/uart_to_uart.cpp rename to examples/network/uart/uart_to_uart/uart_to_uart.cpp diff --git a/example/network/uart/uart_tool/Makefile b/examples/network/uart/uart_tool/Makefile similarity index 100% rename from example/network/uart/uart_tool/Makefile rename to examples/network/uart/uart_tool/Makefile diff --git a/example/network/uart/uart_tool/uart_tool.cpp b/examples/network/uart/uart_tool/uart_tool.cpp similarity index 100% rename from example/network/uart/uart_tool/uart_tool.cpp rename to examples/network/uart/uart_tool/uart_tool.cpp diff --git a/example/network/uart/Makefile b/examples/network/udp_socket/Makefile similarity index 100% rename from example/network/uart/Makefile rename to examples/network/udp_socket/Makefile diff --git a/example/network/udp_socket/ping_pong/Makefile b/examples/network/udp_socket/ping_pong/Makefile similarity index 100% rename from example/network/udp_socket/ping_pong/Makefile rename to examples/network/udp_socket/ping_pong/Makefile diff --git a/example/network/udp_socket/ping_pong/ping_pong.cpp b/examples/network/udp_socket/ping_pong/ping_pong.cpp similarity index 100% rename from example/network/udp_socket/ping_pong/ping_pong.cpp rename to examples/network/udp_socket/ping_pong/ping_pong.cpp diff --git a/example/network/udp_socket/recv_only/Makefile b/examples/network/udp_socket/recv_only/Makefile similarity index 100% rename from example/network/udp_socket/recv_only/Makefile rename to examples/network/udp_socket/recv_only/Makefile diff --git a/example/network/udp_socket/recv_only/recv_only.cpp b/examples/network/udp_socket/recv_only/recv_only.cpp similarity index 100% rename from example/network/udp_socket/recv_only/recv_only.cpp rename to examples/network/udp_socket/recv_only/recv_only.cpp diff --git a/example/network/udp_socket/request/Makefile b/examples/network/udp_socket/request/Makefile similarity index 100% rename from example/network/udp_socket/request/Makefile rename to examples/network/udp_socket/request/Makefile diff --git a/example/network/udp_socket/request/request.cpp b/examples/network/udp_socket/request/request.cpp similarity index 100% rename from example/network/udp_socket/request/request.cpp rename to examples/network/udp_socket/request/request.cpp diff --git a/example/network/udp_socket/respond/Makefile b/examples/network/udp_socket/respond/Makefile similarity index 100% rename from example/network/udp_socket/respond/Makefile rename to examples/network/udp_socket/respond/Makefile diff --git a/example/network/udp_socket/respond/respond.cpp b/examples/network/udp_socket/respond/respond.cpp similarity index 100% rename from example/network/udp_socket/respond/respond.cpp rename to examples/network/udp_socket/respond/respond.cpp diff --git a/example/network/udp_socket/send_only/Makefile b/examples/network/udp_socket/send_only/Makefile similarity index 100% rename from example/network/udp_socket/send_only/Makefile rename to examples/network/udp_socket/send_only/Makefile diff --git a/example/network/udp_socket/send_only/send_only.cpp b/examples/network/udp_socket/send_only/send_only.cpp similarity index 100% rename from example/network/udp_socket/send_only/send_only.cpp rename to examples/network/udp_socket/send_only/send_only.cpp diff --git a/example/network/udp_socket/Makefile b/examples/terminal/Makefile similarity index 100% rename from example/network/udp_socket/Makefile rename to examples/terminal/Makefile diff --git a/example/terminal/tcp_rpc/Makefile b/examples/terminal/tcp_rpc/Makefile similarity index 100% rename from example/terminal/tcp_rpc/Makefile rename to examples/terminal/tcp_rpc/Makefile diff --git a/example/terminal/tcp_rpc/main.cpp b/examples/terminal/tcp_rpc/main.cpp similarity index 100% rename from example/terminal/tcp_rpc/main.cpp rename to examples/terminal/tcp_rpc/main.cpp diff --git a/example/terminal/telnetd/Makefile b/examples/terminal/telnetd/Makefile similarity index 100% rename from example/terminal/telnetd/Makefile rename to examples/terminal/telnetd/Makefile diff --git a/example/terminal/telnetd/main.cpp b/examples/terminal/telnetd/main.cpp similarity index 100% rename from example/terminal/telnetd/main.cpp rename to examples/terminal/telnetd/main.cpp diff --git a/example/terminal/Makefile b/examples/util/Makefile similarity index 100% rename from example/terminal/Makefile rename to examples/util/Makefile diff --git a/example/util/backtrace/Makefile b/examples/util/backtrace/Makefile similarity index 100% rename from example/util/backtrace/Makefile rename to examples/util/backtrace/Makefile diff --git a/example/util/backtrace/sample.cpp b/examples/util/backtrace/sample.cpp similarity index 100% rename from example/util/backtrace/sample.cpp rename to examples/util/backtrace/sample.cpp diff --git a/modules/Makefile b/modules/Makefile new file mode 100644 index 0000000..1b05fb4 --- /dev/null +++ b/modules/Makefile @@ -0,0 +1,4 @@ +all test: + @for i in $(MODULES); do \ + [ ! -d $$i ] || $(MAKE) -C $$i $@ || exit $$? ; \ + done diff --git a/base/Makefile b/modules/base/Makefile similarity index 92% rename from base/Makefile rename to modules/base/Makefile index 5b2264a..b81565b 100644 --- a/base/Makefile +++ b/modules/base/Makefile @@ -33,4 +33,4 @@ TEST_LDFLAGS := $(LDFLAGS) ENABLE_SHARED_LIB = no -include ../tools/lib_common.mk +include $(TOP_DIR)/tools/lib_common.mk diff --git a/base/cabinet.hpp b/modules/base/cabinet.hpp similarity index 100% rename from base/cabinet.hpp rename to modules/base/cabinet.hpp diff --git a/base/cabinet_test.cpp b/modules/base/cabinet_test.cpp similarity index 100% rename from base/cabinet_test.cpp rename to modules/base/cabinet_test.cpp diff --git a/base/cabinet_token.h b/modules/base/cabinet_token.h similarity index 100% rename from base/cabinet_token.h rename to modules/base/cabinet_token.h diff --git a/base/defines.h b/modules/base/defines.h similarity index 100% rename from base/defines.h rename to modules/base/defines.h diff --git a/base/json.hpp b/modules/base/json.hpp similarity index 100% rename from base/json.hpp rename to modules/base/json.hpp diff --git a/base/json_fwd.h b/modules/base/json_fwd.h similarity index 100% rename from base/json_fwd.h rename to modules/base/json_fwd.h diff --git a/base/json_test.cpp b/modules/base/json_test.cpp similarity index 100% rename from base/json_test.cpp rename to modules/base/json_test.cpp diff --git a/base/log.h b/modules/base/log.h similarity index 100% rename from base/log.h rename to modules/base/log.h diff --git a/base/log_imp.cpp b/modules/base/log_imp.cpp similarity index 100% rename from base/log_imp.cpp rename to modules/base/log_imp.cpp diff --git a/base/log_imp.h b/modules/base/log_imp.h similarity index 100% rename from base/log_imp.h rename to modules/base/log_imp.h diff --git a/base/log_output.cpp b/modules/base/log_output.cpp similarity index 100% rename from base/log_output.cpp rename to modules/base/log_output.cpp diff --git a/base/log_output.h b/modules/base/log_output.h similarity index 100% rename from base/log_output.h rename to modules/base/log_output.h diff --git a/base/log_output_test.cpp b/modules/base/log_output_test.cpp similarity index 100% rename from base/log_output_test.cpp rename to modules/base/log_output_test.cpp diff --git a/base/memblock.h b/modules/base/memblock.h similarity index 100% rename from base/memblock.h rename to modules/base/memblock.h diff --git a/base/scope_exit.hpp b/modules/base/scope_exit.hpp similarity index 100% rename from base/scope_exit.hpp rename to modules/base/scope_exit.hpp diff --git a/base/scope_exit_test.cpp b/modules/base/scope_exit_test.cpp similarity index 100% rename from base/scope_exit_test.cpp rename to modules/base/scope_exit_test.cpp diff --git a/coroutine/Makefile b/modules/coroutine/Makefile similarity index 93% rename from coroutine/Makefile rename to modules/coroutine/Makefile index cd24929..0eb2f88 100644 --- a/coroutine/Makefile +++ b/modules/coroutine/Makefile @@ -28,4 +28,4 @@ TEST_LDFLAGS := $(LDFLAGS) -ltbox_event -ltbox_base -levent_core -lev ENABLE_SHARED_LIB = no -include ../tools/lib_common.mk +include $(TOP_DIR)/tools/lib_common.mk diff --git a/coroutine/README.md b/modules/coroutine/README.md similarity index 100% rename from coroutine/README.md rename to modules/coroutine/README.md diff --git a/coroutine/broadcast.hpp b/modules/coroutine/broadcast.hpp similarity index 100% rename from coroutine/broadcast.hpp rename to modules/coroutine/broadcast.hpp diff --git a/coroutine/broadcast_test.cpp b/modules/coroutine/broadcast_test.cpp similarity index 100% rename from coroutine/broadcast_test.cpp rename to modules/coroutine/broadcast_test.cpp diff --git a/coroutine/channel.hpp b/modules/coroutine/channel.hpp similarity index 100% rename from coroutine/channel.hpp rename to modules/coroutine/channel.hpp diff --git a/coroutine/channel_test.cpp b/modules/coroutine/channel_test.cpp similarity index 100% rename from coroutine/channel_test.cpp rename to modules/coroutine/channel_test.cpp diff --git a/coroutine/condition.hpp b/modules/coroutine/condition.hpp similarity index 100% rename from coroutine/condition.hpp rename to modules/coroutine/condition.hpp diff --git a/coroutine/condition_test.cpp b/modules/coroutine/condition_test.cpp similarity index 100% rename from coroutine/condition_test.cpp rename to modules/coroutine/condition_test.cpp diff --git a/coroutine/mutex.hpp b/modules/coroutine/mutex.hpp similarity index 100% rename from coroutine/mutex.hpp rename to modules/coroutine/mutex.hpp diff --git a/coroutine/mutex_test.cpp b/modules/coroutine/mutex_test.cpp similarity index 100% rename from coroutine/mutex_test.cpp rename to modules/coroutine/mutex_test.cpp diff --git a/coroutine/scheduler.cpp b/modules/coroutine/scheduler.cpp similarity index 100% rename from coroutine/scheduler.cpp rename to modules/coroutine/scheduler.cpp diff --git a/coroutine/scheduler.h b/modules/coroutine/scheduler.h similarity index 100% rename from coroutine/scheduler.h rename to modules/coroutine/scheduler.h diff --git a/coroutine/scheduler_test.cpp b/modules/coroutine/scheduler_test.cpp similarity index 100% rename from coroutine/scheduler_test.cpp rename to modules/coroutine/scheduler_test.cpp diff --git a/coroutine/semaphore.hpp b/modules/coroutine/semaphore.hpp similarity index 100% rename from coroutine/semaphore.hpp rename to modules/coroutine/semaphore.hpp diff --git a/coroutine/semaphore_test.cpp b/modules/coroutine/semaphore_test.cpp similarity index 100% rename from coroutine/semaphore_test.cpp rename to modules/coroutine/semaphore_test.cpp diff --git a/event/Makefile b/modules/event/Makefile similarity index 97% rename from event/Makefile rename to modules/event/Makefile index c5e7bb0..c20161c 100644 --- a/event/Makefile +++ b/modules/event/Makefile @@ -70,4 +70,4 @@ endif ENABLE_SHARED_LIB = no -include ../tools/lib_common.mk +include $(TOP_DIR)/tools/lib_common.mk diff --git a/event/common_loop.cpp b/modules/event/common_loop.cpp similarity index 100% rename from event/common_loop.cpp rename to modules/event/common_loop.cpp diff --git a/event/common_loop.h b/modules/event/common_loop.h similarity index 100% rename from event/common_loop.h rename to modules/event/common_loop.h diff --git a/event/common_loop_run.cpp b/modules/event/common_loop_run.cpp similarity index 100% rename from event/common_loop_run.cpp rename to modules/event/common_loop_run.cpp diff --git a/event/common_loop_signal.cpp b/modules/event/common_loop_signal.cpp similarity index 100% rename from event/common_loop_signal.cpp rename to modules/event/common_loop_signal.cpp diff --git a/event/common_loop_test.cpp b/modules/event/common_loop_test.cpp similarity index 100% rename from event/common_loop_test.cpp rename to modules/event/common_loop_test.cpp diff --git a/event/config.mk b/modules/event/config.mk similarity index 100% rename from event/config.mk rename to modules/event/config.mk diff --git a/event/engins/epoll/fd_event.cpp b/modules/event/engins/epoll/fd_event.cpp similarity index 100% rename from event/engins/epoll/fd_event.cpp rename to modules/event/engins/epoll/fd_event.cpp diff --git a/event/engins/epoll/fd_event.h b/modules/event/engins/epoll/fd_event.h similarity index 100% rename from event/engins/epoll/fd_event.h rename to modules/event/engins/epoll/fd_event.h diff --git a/event/engins/epoll/loop.cpp b/modules/event/engins/epoll/loop.cpp similarity index 100% rename from event/engins/epoll/loop.cpp rename to modules/event/engins/epoll/loop.cpp diff --git a/event/engins/epoll/loop.h b/modules/event/engins/epoll/loop.h similarity index 100% rename from event/engins/epoll/loop.h rename to modules/event/engins/epoll/loop.h diff --git a/event/engins/epoll/timer_event.cpp b/modules/event/engins/epoll/timer_event.cpp similarity index 100% rename from event/engins/epoll/timer_event.cpp rename to modules/event/engins/epoll/timer_event.cpp diff --git a/event/engins/epoll/timer_event.h b/modules/event/engins/epoll/timer_event.h similarity index 100% rename from event/engins/epoll/timer_event.h rename to modules/event/engins/epoll/timer_event.h diff --git a/event/engins/libev/fd_event.cpp b/modules/event/engins/libev/fd_event.cpp similarity index 100% rename from event/engins/libev/fd_event.cpp rename to modules/event/engins/libev/fd_event.cpp diff --git a/event/engins/libev/fd_event.h b/modules/event/engins/libev/fd_event.h similarity index 100% rename from event/engins/libev/fd_event.h rename to modules/event/engins/libev/fd_event.h diff --git a/event/engins/libev/loop.cpp b/modules/event/engins/libev/loop.cpp similarity index 100% rename from event/engins/libev/loop.cpp rename to modules/event/engins/libev/loop.cpp diff --git a/event/engins/libev/loop.h b/modules/event/engins/libev/loop.h similarity index 100% rename from event/engins/libev/loop.h rename to modules/event/engins/libev/loop.h diff --git a/event/engins/libev/timer_event.cpp b/modules/event/engins/libev/timer_event.cpp similarity index 100% rename from event/engins/libev/timer_event.cpp rename to modules/event/engins/libev/timer_event.cpp diff --git a/event/engins/libev/timer_event.h b/modules/event/engins/libev/timer_event.h similarity index 100% rename from event/engins/libev/timer_event.h rename to modules/event/engins/libev/timer_event.h diff --git a/event/engins/libevent/common.cpp b/modules/event/engins/libevent/common.cpp similarity index 100% rename from event/engins/libevent/common.cpp rename to modules/event/engins/libevent/common.cpp diff --git a/event/engins/libevent/common.h b/modules/event/engins/libevent/common.h similarity index 100% rename from event/engins/libevent/common.h rename to modules/event/engins/libevent/common.h diff --git a/event/engins/libevent/fd_event.cpp b/modules/event/engins/libevent/fd_event.cpp similarity index 100% rename from event/engins/libevent/fd_event.cpp rename to modules/event/engins/libevent/fd_event.cpp diff --git a/event/engins/libevent/fd_event.h b/modules/event/engins/libevent/fd_event.h similarity index 100% rename from event/engins/libevent/fd_event.h rename to modules/event/engins/libevent/fd_event.h diff --git a/event/engins/libevent/loop.cpp b/modules/event/engins/libevent/loop.cpp similarity index 100% rename from event/engins/libevent/loop.cpp rename to modules/event/engins/libevent/loop.cpp diff --git a/event/engins/libevent/loop.h b/modules/event/engins/libevent/loop.h similarity index 100% rename from event/engins/libevent/loop.h rename to modules/event/engins/libevent/loop.h diff --git a/event/engins/libevent/timer_event.cpp b/modules/event/engins/libevent/timer_event.cpp similarity index 100% rename from event/engins/libevent/timer_event.cpp rename to modules/event/engins/libevent/timer_event.cpp diff --git a/event/engins/libevent/timer_event.h b/modules/event/engins/libevent/timer_event.h similarity index 100% rename from event/engins/libevent/timer_event.h rename to modules/event/engins/libevent/timer_event.h diff --git a/event/event.h b/modules/event/event.h similarity index 100% rename from event/event.h rename to modules/event/event.h diff --git a/event/fd_event.h b/modules/event/fd_event.h similarity index 100% rename from event/fd_event.h rename to modules/event/fd_event.h diff --git a/event/fd_event_test.cpp b/modules/event/fd_event_test.cpp similarity index 100% rename from event/fd_event_test.cpp rename to modules/event/fd_event_test.cpp diff --git a/event/forward.h b/modules/event/forward.h similarity index 100% rename from event/forward.h rename to modules/event/forward.h diff --git a/event/loop.cpp b/modules/event/loop.cpp similarity index 100% rename from event/loop.cpp rename to modules/event/loop.cpp diff --git a/event/loop.h b/modules/event/loop.h similarity index 100% rename from event/loop.h rename to modules/event/loop.h diff --git a/event/misc.cpp b/modules/event/misc.cpp similarity index 100% rename from event/misc.cpp rename to modules/event/misc.cpp diff --git a/event/misc.h b/modules/event/misc.h similarity index 100% rename from event/misc.h rename to modules/event/misc.h diff --git a/event/signal_event.h b/modules/event/signal_event.h similarity index 100% rename from event/signal_event.h rename to modules/event/signal_event.h diff --git a/event/signal_event_impl.cpp b/modules/event/signal_event_impl.cpp similarity index 100% rename from event/signal_event_impl.cpp rename to modules/event/signal_event_impl.cpp diff --git a/event/signal_event_impl.h b/modules/event/signal_event_impl.h similarity index 100% rename from event/signal_event_impl.h rename to modules/event/signal_event_impl.h diff --git a/event/signal_event_test.cpp b/modules/event/signal_event_test.cpp similarity index 100% rename from event/signal_event_test.cpp rename to modules/event/signal_event_test.cpp diff --git a/event/stat.cpp b/modules/event/stat.cpp similarity index 100% rename from event/stat.cpp rename to modules/event/stat.cpp diff --git a/event/stat.h b/modules/event/stat.h similarity index 100% rename from event/stat.h rename to modules/event/stat.h diff --git a/event/stat_test.cpp b/modules/event/stat_test.cpp similarity index 100% rename from event/stat_test.cpp rename to modules/event/stat_test.cpp diff --git a/event/timer_event.h b/modules/event/timer_event.h similarity index 100% rename from event/timer_event.h rename to modules/event/timer_event.h diff --git a/event/timer_event_test.cpp b/modules/event/timer_event_test.cpp similarity index 100% rename from event/timer_event_test.cpp rename to modules/event/timer_event_test.cpp diff --git a/event/version.cpp b/modules/event/version.cpp similarity index 100% rename from event/version.cpp rename to modules/event/version.cpp diff --git a/event/version.h b/modules/event/version.h similarity index 100% rename from event/version.h rename to modules/event/version.h diff --git a/eventx/Makefile b/modules/eventx/Makefile similarity index 92% rename from eventx/Makefile rename to modules/eventx/Makefile index 0980962..02eb500 100644 --- a/eventx/Makefile +++ b/modules/eventx/Makefile @@ -25,4 +25,4 @@ TEST_CPP_SRC_FILES = \ TEST_LDFLAGS := $(LDFLAGS) -ltbox_event -ltbox_base -levent_core -lev ENABLE_SHARED_LIB = no -include ../tools/lib_common.mk +include $(TOP_DIR)/tools/lib_common.mk diff --git a/eventx/request_pool.hpp b/modules/eventx/request_pool.hpp similarity index 100% rename from eventx/request_pool.hpp rename to modules/eventx/request_pool.hpp diff --git a/eventx/request_pool_test.cpp b/modules/eventx/request_pool_test.cpp similarity index 100% rename from eventx/request_pool_test.cpp rename to modules/eventx/request_pool_test.cpp diff --git a/eventx/thread_pool.cpp b/modules/eventx/thread_pool.cpp similarity index 100% rename from eventx/thread_pool.cpp rename to modules/eventx/thread_pool.cpp diff --git a/eventx/thread_pool.h b/modules/eventx/thread_pool.h similarity index 100% rename from eventx/thread_pool.h rename to modules/eventx/thread_pool.h diff --git a/eventx/thread_pool_test.cpp b/modules/eventx/thread_pool_test.cpp similarity index 100% rename from eventx/thread_pool_test.cpp rename to modules/eventx/thread_pool_test.cpp diff --git a/eventx/timeout_monitor.cpp b/modules/eventx/timeout_monitor.cpp similarity index 100% rename from eventx/timeout_monitor.cpp rename to modules/eventx/timeout_monitor.cpp diff --git a/eventx/timeout_monitor.h b/modules/eventx/timeout_monitor.h similarity index 100% rename from eventx/timeout_monitor.h rename to modules/eventx/timeout_monitor.h diff --git a/eventx/timeout_monitor_test.cpp b/modules/eventx/timeout_monitor_test.cpp similarity index 100% rename from eventx/timeout_monitor_test.cpp rename to modules/eventx/timeout_monitor_test.cpp diff --git a/eventx/timer_pool.cpp b/modules/eventx/timer_pool.cpp similarity index 100% rename from eventx/timer_pool.cpp rename to modules/eventx/timer_pool.cpp diff --git a/eventx/timer_pool.h b/modules/eventx/timer_pool.h similarity index 100% rename from eventx/timer_pool.h rename to modules/eventx/timer_pool.h diff --git a/eventx/timer_pool_test.cpp b/modules/eventx/timer_pool_test.cpp similarity index 100% rename from eventx/timer_pool_test.cpp rename to modules/eventx/timer_pool_test.cpp diff --git a/http/Makefile b/modules/http/Makefile similarity index 95% rename from http/Makefile rename to modules/http/Makefile index 0199b4b..035a338 100644 --- a/http/Makefile +++ b/modules/http/Makefile @@ -40,4 +40,4 @@ TEST_LDFLAGS := $(LDFLAGS) -ltbox_network -ltbox_log -ltbox_event -ltbox_util -l ENABLE_SHARED_LIB = no -include ../tools/lib_common.mk +include $(TOP_DIR)/tools/lib_common.mk diff --git a/http/README.md b/modules/http/README.md similarity index 100% rename from http/README.md rename to modules/http/README.md diff --git a/http/client/client.cpp b/modules/http/client/client.cpp similarity index 100% rename from http/client/client.cpp rename to modules/http/client/client.cpp diff --git a/http/client/client.h b/modules/http/client/client.h similarity index 100% rename from http/client/client.h rename to modules/http/client/client.h diff --git a/http/common.cpp b/modules/http/common.cpp similarity index 100% rename from http/common.cpp rename to modules/http/common.cpp diff --git a/http/common.h b/modules/http/common.h similarity index 100% rename from http/common.h rename to modules/http/common.h diff --git a/http/common_test.cpp b/modules/http/common_test.cpp similarity index 100% rename from http/common_test.cpp rename to modules/http/common_test.cpp diff --git a/http/request.cpp b/modules/http/request.cpp similarity index 100% rename from http/request.cpp rename to modules/http/request.cpp diff --git a/http/request.h b/modules/http/request.h similarity index 100% rename from http/request.h rename to modules/http/request.h diff --git a/http/request_test.cpp b/modules/http/request_test.cpp similarity index 100% rename from http/request_test.cpp rename to modules/http/request_test.cpp diff --git a/http/respond.cpp b/modules/http/respond.cpp similarity index 100% rename from http/respond.cpp rename to modules/http/respond.cpp diff --git a/http/respond.h b/modules/http/respond.h similarity index 100% rename from http/respond.h rename to modules/http/respond.h diff --git a/http/respond_test.cpp b/modules/http/respond_test.cpp similarity index 100% rename from http/respond_test.cpp rename to modules/http/respond_test.cpp diff --git a/http/server/context.cpp b/modules/http/server/context.cpp similarity index 100% rename from http/server/context.cpp rename to modules/http/server/context.cpp diff --git a/http/server/context.h b/modules/http/server/context.h similarity index 100% rename from http/server/context.h rename to modules/http/server/context.h diff --git a/http/server/middleware.h b/modules/http/server/middleware.h similarity index 100% rename from http/server/middleware.h rename to modules/http/server/middleware.h diff --git a/http/server/request_parser.cpp b/modules/http/server/request_parser.cpp similarity index 100% rename from http/server/request_parser.cpp rename to modules/http/server/request_parser.cpp diff --git a/http/server/request_parser.h b/modules/http/server/request_parser.h similarity index 100% rename from http/server/request_parser.h rename to modules/http/server/request_parser.h diff --git a/http/server/request_parser_test.cpp b/modules/http/server/request_parser_test.cpp similarity index 100% rename from http/server/request_parser_test.cpp rename to modules/http/server/request_parser_test.cpp diff --git a/http/server/router.cpp b/modules/http/server/router.cpp similarity index 100% rename from http/server/router.cpp rename to modules/http/server/router.cpp diff --git a/http/server/router.h b/modules/http/server/router.h similarity index 100% rename from http/server/router.h rename to modules/http/server/router.h diff --git a/http/server/server.cpp b/modules/http/server/server.cpp similarity index 100% rename from http/server/server.cpp rename to modules/http/server/server.cpp diff --git a/http/server/server.h b/modules/http/server/server.h similarity index 100% rename from http/server/server.h rename to modules/http/server/server.h diff --git a/http/server/server_imp.cpp b/modules/http/server/server_imp.cpp similarity index 100% rename from http/server/server_imp.cpp rename to modules/http/server/server_imp.cpp diff --git a/http/server/server_imp.h b/modules/http/server/server_imp.h similarity index 100% rename from http/server/server_imp.h rename to modules/http/server/server_imp.h diff --git a/http/server/types.h b/modules/http/server/types.h similarity index 100% rename from http/server/types.h rename to modules/http/server/types.h diff --git a/http/url.cpp b/modules/http/url.cpp similarity index 100% rename from http/url.cpp rename to modules/http/url.cpp diff --git a/http/url.h b/modules/http/url.h similarity index 100% rename from http/url.h rename to modules/http/url.h diff --git a/http/url_test.cpp b/modules/http/url_test.cpp similarity index 100% rename from http/url_test.cpp rename to modules/http/url_test.cpp diff --git a/log/Makefile b/modules/log/Makefile similarity index 93% rename from log/Makefile rename to modules/log/Makefile index 5f7ba95..46bc045 100644 --- a/log/Makefile +++ b/modules/log/Makefile @@ -28,4 +28,4 @@ TEST_CPP_SRC_FILES = \ TEST_LDFLAGS := $(LDFLAGS) -ltbox_util -ltbox_event -ltbox_base ENABLE_SHARED_LIB = no -include ../tools/lib_common.mk +include $(TOP_DIR)/tools/lib_common.mk diff --git a/log/async_channel.cpp b/modules/log/async_channel.cpp similarity index 100% rename from log/async_channel.cpp rename to modules/log/async_channel.cpp diff --git a/log/async_channel.h b/modules/log/async_channel.h similarity index 100% rename from log/async_channel.h rename to modules/log/async_channel.h diff --git a/log/async_channel_test.cpp b/modules/log/async_channel_test.cpp similarity index 100% rename from log/async_channel_test.cpp rename to modules/log/async_channel_test.cpp diff --git a/log/channel.cpp b/modules/log/channel.cpp similarity index 100% rename from log/channel.cpp rename to modules/log/channel.cpp diff --git a/log/channel.h b/modules/log/channel.h similarity index 100% rename from log/channel.h rename to modules/log/channel.h diff --git a/log/file_async_channel.cpp b/modules/log/file_async_channel.cpp similarity index 100% rename from log/file_async_channel.cpp rename to modules/log/file_async_channel.cpp diff --git a/log/file_async_channel.h b/modules/log/file_async_channel.h similarity index 100% rename from log/file_async_channel.h rename to modules/log/file_async_channel.h diff --git a/log/file_async_channel_test.cpp b/modules/log/file_async_channel_test.cpp similarity index 100% rename from log/file_async_channel_test.cpp rename to modules/log/file_async_channel_test.cpp diff --git a/log/stdout_channel.cpp b/modules/log/stdout_channel.cpp similarity index 100% rename from log/stdout_channel.cpp rename to modules/log/stdout_channel.cpp diff --git a/log/stdout_channel.h b/modules/log/stdout_channel.h similarity index 100% rename from log/stdout_channel.h rename to modules/log/stdout_channel.h diff --git a/log/stdout_channel_test.cpp b/modules/log/stdout_channel_test.cpp similarity index 100% rename from log/stdout_channel_test.cpp rename to modules/log/stdout_channel_test.cpp diff --git a/log/syslog_channel.cpp b/modules/log/syslog_channel.cpp similarity index 100% rename from log/syslog_channel.cpp rename to modules/log/syslog_channel.cpp diff --git a/log/syslog_channel.h b/modules/log/syslog_channel.h similarity index 100% rename from log/syslog_channel.h rename to modules/log/syslog_channel.h diff --git a/log/syslog_channel_test.cpp b/modules/log/syslog_channel_test.cpp similarity index 100% rename from log/syslog_channel_test.cpp rename to modules/log/syslog_channel_test.cpp diff --git a/main/Makefile b/modules/main/Makefile similarity index 92% rename from main/Makefile rename to modules/main/Makefile index f07ab87..cd612a3 100644 --- a/main/Makefile +++ b/modules/main/Makefile @@ -33,4 +33,4 @@ TEST_LDFLAGS := $(LDFLAGS) \ ENABLE_SHARED_LIB = no -include ../tools/lib_common.mk +include $(TOP_DIR)/tools/lib_common.mk diff --git a/main/README.md b/modules/main/README.md similarity index 100% rename from main/README.md rename to modules/main/README.md diff --git a/main/args.cpp b/modules/main/args.cpp similarity index 100% rename from main/args.cpp rename to modules/main/args.cpp diff --git a/main/args.h b/modules/main/args.h similarity index 100% rename from main/args.h rename to modules/main/args.h diff --git a/main/context.h b/modules/main/context.h similarity index 100% rename from main/context.h rename to modules/main/context.h diff --git a/main/context_imp.cpp b/modules/main/context_imp.cpp similarity index 100% rename from main/context_imp.cpp rename to modules/main/context_imp.cpp diff --git a/main/context_imp.h b/modules/main/context_imp.h similarity index 100% rename from main/context_imp.h rename to modules/main/context_imp.h diff --git a/main/log.cpp b/modules/main/log.cpp similarity index 100% rename from main/log.cpp rename to modules/main/log.cpp diff --git a/main/log.h b/modules/main/log.h similarity index 100% rename from main/log.h rename to modules/main/log.h diff --git a/main/main.cpp b/modules/main/main.cpp similarity index 100% rename from main/main.cpp rename to modules/main/main.cpp diff --git a/main/main.h b/modules/main/main.h similarity index 100% rename from main/main.h rename to modules/main/main.h diff --git a/main/misc.cpp b/modules/main/misc.cpp similarity index 100% rename from main/misc.cpp rename to modules/main/misc.cpp diff --git a/main/module.cpp b/modules/main/module.cpp similarity index 100% rename from main/module.cpp rename to modules/main/module.cpp diff --git a/main/module.h b/modules/main/module.h similarity index 100% rename from main/module.h rename to modules/main/module.h diff --git a/main/signal.cpp b/modules/main/signal.cpp similarity index 100% rename from main/signal.cpp rename to modules/main/signal.cpp diff --git a/mqtt/Makefile b/modules/mqtt/Makefile similarity index 88% rename from mqtt/Makefile rename to modules/mqtt/Makefile index 8efb1eb..a63747f 100644 --- a/mqtt/Makefile +++ b/modules/mqtt/Makefile @@ -15,4 +15,4 @@ TEST_LDFLAGS := $(LDFLAGS) -ltbox_event -ltbox_base -lmosquitto -levent_core -le ENABLE_SHARED_LIB = no -include ../tools/lib_common.mk +include $(TOP_DIR)/tools/lib_common.mk diff --git a/mqtt/client.cpp b/modules/mqtt/client.cpp similarity index 100% rename from mqtt/client.cpp rename to modules/mqtt/client.cpp diff --git a/mqtt/client.h b/modules/mqtt/client.h similarity index 100% rename from mqtt/client.h rename to modules/mqtt/client.h diff --git a/network/Makefile b/modules/network/Makefile similarity index 95% rename from network/Makefile rename to modules/network/Makefile index 0e4267c..939411f 100644 --- a/network/Makefile +++ b/modules/network/Makefile @@ -51,4 +51,4 @@ TEST_LDFLAGS := $(LDFLAGS) -ltbox_event -ltbox_base ENABLE_SHARED_LIB = no -include ../tools/lib_common.mk +include $(TOP_DIR)/tools/lib_common.mk diff --git a/network/README b/modules/network/README similarity index 100% rename from network/README rename to modules/network/README diff --git a/network/buffer.cpp b/modules/network/buffer.cpp similarity index 100% rename from network/buffer.cpp rename to modules/network/buffer.cpp diff --git a/network/buffer.h b/modules/network/buffer.h similarity index 100% rename from network/buffer.h rename to modules/network/buffer.h diff --git a/network/buffer_test.cpp b/modules/network/buffer_test.cpp similarity index 100% rename from network/buffer_test.cpp rename to modules/network/buffer_test.cpp diff --git a/network/buffered_fd.cpp b/modules/network/buffered_fd.cpp similarity index 100% rename from network/buffered_fd.cpp rename to modules/network/buffered_fd.cpp diff --git a/network/buffered_fd.h b/modules/network/buffered_fd.h similarity index 100% rename from network/buffered_fd.h rename to modules/network/buffered_fd.h diff --git a/network/buffered_fd_test.cpp b/modules/network/buffered_fd_test.cpp similarity index 100% rename from network/buffered_fd_test.cpp rename to modules/network/buffered_fd_test.cpp diff --git a/network/byte_stream.h b/modules/network/byte_stream.h similarity index 100% rename from network/byte_stream.h rename to modules/network/byte_stream.h diff --git a/network/fd.cpp b/modules/network/fd.cpp similarity index 100% rename from network/fd.cpp rename to modules/network/fd.cpp diff --git a/network/fd.h b/modules/network/fd.h similarity index 100% rename from network/fd.h rename to modules/network/fd.h diff --git a/network/fd_test.cpp b/modules/network/fd_test.cpp similarity index 100% rename from network/fd_test.cpp rename to modules/network/fd_test.cpp diff --git a/network/ip_address.cpp b/modules/network/ip_address.cpp similarity index 100% rename from network/ip_address.cpp rename to modules/network/ip_address.cpp diff --git a/network/ip_address.h b/modules/network/ip_address.h similarity index 100% rename from network/ip_address.h rename to modules/network/ip_address.h diff --git a/network/ip_address_test.cpp b/modules/network/ip_address_test.cpp similarity index 100% rename from network/ip_address_test.cpp rename to modules/network/ip_address_test.cpp diff --git a/network/sockaddr.cpp b/modules/network/sockaddr.cpp similarity index 100% rename from network/sockaddr.cpp rename to modules/network/sockaddr.cpp diff --git a/network/sockaddr.h b/modules/network/sockaddr.h similarity index 100% rename from network/sockaddr.h rename to modules/network/sockaddr.h diff --git a/network/sockaddr_test.cpp b/modules/network/sockaddr_test.cpp similarity index 100% rename from network/sockaddr_test.cpp rename to modules/network/sockaddr_test.cpp diff --git a/network/socket_fd.cpp b/modules/network/socket_fd.cpp similarity index 100% rename from network/socket_fd.cpp rename to modules/network/socket_fd.cpp diff --git a/network/socket_fd.h b/modules/network/socket_fd.h similarity index 100% rename from network/socket_fd.h rename to modules/network/socket_fd.h diff --git a/network/stdio_stream.cpp b/modules/network/stdio_stream.cpp similarity index 100% rename from network/stdio_stream.cpp rename to modules/network/stdio_stream.cpp diff --git a/network/stdio_stream.h b/modules/network/stdio_stream.h similarity index 100% rename from network/stdio_stream.h rename to modules/network/stdio_stream.h diff --git a/network/tcp_acceptor.cpp b/modules/network/tcp_acceptor.cpp similarity index 100% rename from network/tcp_acceptor.cpp rename to modules/network/tcp_acceptor.cpp diff --git a/network/tcp_acceptor.h b/modules/network/tcp_acceptor.h similarity index 100% rename from network/tcp_acceptor.h rename to modules/network/tcp_acceptor.h diff --git a/network/tcp_client.cpp b/modules/network/tcp_client.cpp similarity index 100% rename from network/tcp_client.cpp rename to modules/network/tcp_client.cpp diff --git a/network/tcp_client.h b/modules/network/tcp_client.h similarity index 100% rename from network/tcp_client.h rename to modules/network/tcp_client.h diff --git a/network/tcp_connection.cpp b/modules/network/tcp_connection.cpp similarity index 100% rename from network/tcp_connection.cpp rename to modules/network/tcp_connection.cpp diff --git a/network/tcp_connection.h b/modules/network/tcp_connection.h similarity index 100% rename from network/tcp_connection.h rename to modules/network/tcp_connection.h diff --git a/network/tcp_connector.cpp b/modules/network/tcp_connector.cpp similarity index 100% rename from network/tcp_connector.cpp rename to modules/network/tcp_connector.cpp diff --git a/network/tcp_connector.h b/modules/network/tcp_connector.h similarity index 100% rename from network/tcp_connector.h rename to modules/network/tcp_connector.h diff --git a/network/tcp_server.cpp b/modules/network/tcp_server.cpp similarity index 100% rename from network/tcp_server.cpp rename to modules/network/tcp_server.cpp diff --git a/network/tcp_server.h b/modules/network/tcp_server.h similarity index 100% rename from network/tcp_server.h rename to modules/network/tcp_server.h diff --git a/network/uart.cpp b/modules/network/uart.cpp similarity index 100% rename from network/uart.cpp rename to modules/network/uart.cpp diff --git a/network/uart.h b/modules/network/uart.h similarity index 100% rename from network/uart.h rename to modules/network/uart.h diff --git a/network/uart_test.cpp b/modules/network/uart_test.cpp similarity index 100% rename from network/uart_test.cpp rename to modules/network/uart_test.cpp diff --git a/network/udp_socket.cpp b/modules/network/udp_socket.cpp similarity index 100% rename from network/udp_socket.cpp rename to modules/network/udp_socket.cpp diff --git a/network/udp_socket.h b/modules/network/udp_socket.h similarity index 100% rename from network/udp_socket.h rename to modules/network/udp_socket.h diff --git a/network/udp_socket_test.cpp b/modules/network/udp_socket_test.cpp similarity index 100% rename from network/udp_socket_test.cpp rename to modules/network/udp_socket_test.cpp diff --git a/terminal/Makefile b/modules/terminal/Makefile similarity index 95% rename from terminal/Makefile rename to modules/terminal/Makefile index b80a700..60ea789 100644 --- a/terminal/Makefile +++ b/modules/terminal/Makefile @@ -36,4 +36,4 @@ TEST_CPP_SRC_FILES = \ TEST_LDFLAGS := $(LDFLAGS) -ltbox_network -ltbox_event -ltbox_util -ltbox_base -levent_core -lev ENABLE_SHARED_LIB = no -include ../tools/lib_common.mk +include $(TOP_DIR)/tools/lib_common.mk diff --git a/terminal/README.md b/modules/terminal/README.md similarity index 100% rename from terminal/README.md rename to modules/terminal/README.md diff --git a/terminal/connection.h b/modules/terminal/connection.h similarity index 100% rename from terminal/connection.h rename to modules/terminal/connection.h diff --git a/terminal/impl/dir_node.cpp b/modules/terminal/impl/dir_node.cpp similarity index 100% rename from terminal/impl/dir_node.cpp rename to modules/terminal/impl/dir_node.cpp diff --git a/terminal/impl/dir_node.h b/modules/terminal/impl/dir_node.h similarity index 100% rename from terminal/impl/dir_node.h rename to modules/terminal/impl/dir_node.h diff --git a/terminal/impl/func_node.cpp b/modules/terminal/impl/func_node.cpp similarity index 100% rename from terminal/impl/func_node.cpp rename to modules/terminal/impl/func_node.cpp diff --git a/terminal/impl/func_node.h b/modules/terminal/impl/func_node.h similarity index 100% rename from terminal/impl/func_node.h rename to modules/terminal/impl/func_node.h diff --git a/terminal/impl/inner_types.h b/modules/terminal/impl/inner_types.h similarity index 100% rename from terminal/impl/inner_types.h rename to modules/terminal/impl/inner_types.h diff --git a/terminal/impl/key_event_scanner.cpp b/modules/terminal/impl/key_event_scanner.cpp similarity index 100% rename from terminal/impl/key_event_scanner.cpp rename to modules/terminal/impl/key_event_scanner.cpp diff --git a/terminal/impl/key_event_scanner.h b/modules/terminal/impl/key_event_scanner.h similarity index 100% rename from terminal/impl/key_event_scanner.h rename to modules/terminal/impl/key_event_scanner.h diff --git a/terminal/impl/key_event_scanner_test.cpp b/modules/terminal/impl/key_event_scanner_test.cpp similarity index 100% rename from terminal/impl/key_event_scanner_test.cpp rename to modules/terminal/impl/key_event_scanner_test.cpp diff --git a/terminal/impl/node.h b/modules/terminal/impl/node.h similarity index 100% rename from terminal/impl/node.h rename to modules/terminal/impl/node.h diff --git a/terminal/impl/service/tcp_rpc.cpp b/modules/terminal/impl/service/tcp_rpc.cpp similarity index 100% rename from terminal/impl/service/tcp_rpc.cpp rename to modules/terminal/impl/service/tcp_rpc.cpp diff --git a/terminal/impl/service/tcp_rpc.h b/modules/terminal/impl/service/tcp_rpc.h similarity index 100% rename from terminal/impl/service/tcp_rpc.h rename to modules/terminal/impl/service/tcp_rpc.h diff --git a/terminal/impl/service/telnetd.cpp b/modules/terminal/impl/service/telnetd.cpp similarity index 100% rename from terminal/impl/service/telnetd.cpp rename to modules/terminal/impl/service/telnetd.cpp diff --git a/terminal/impl/service/telnetd.h b/modules/terminal/impl/service/telnetd.h similarity index 100% rename from terminal/impl/service/telnetd.h rename to modules/terminal/impl/service/telnetd.h diff --git a/terminal/impl/session_context.h b/modules/terminal/impl/session_context.h similarity index 100% rename from terminal/impl/session_context.h rename to modules/terminal/impl/session_context.h diff --git a/terminal/impl/terminal.cpp b/modules/terminal/impl/terminal.cpp similarity index 100% rename from terminal/impl/terminal.cpp rename to modules/terminal/impl/terminal.cpp diff --git a/terminal/impl/terminal.h b/modules/terminal/impl/terminal.h similarity index 100% rename from terminal/impl/terminal.h rename to modules/terminal/impl/terminal.h diff --git a/terminal/impl/terminal_commands.cpp b/modules/terminal/impl/terminal_commands.cpp similarity index 100% rename from terminal/impl/terminal_commands.cpp rename to modules/terminal/impl/terminal_commands.cpp diff --git a/terminal/impl/terminal_key_events.cpp b/modules/terminal/impl/terminal_key_events.cpp similarity index 100% rename from terminal/impl/terminal_key_events.cpp rename to modules/terminal/impl/terminal_key_events.cpp diff --git a/terminal/impl/terminal_nodes.cpp b/modules/terminal/impl/terminal_nodes.cpp similarity index 100% rename from terminal/impl/terminal_nodes.cpp rename to modules/terminal/impl/terminal_nodes.cpp diff --git a/terminal/service/tcp_rpc.cpp b/modules/terminal/service/tcp_rpc.cpp similarity index 100% rename from terminal/service/tcp_rpc.cpp rename to modules/terminal/service/tcp_rpc.cpp diff --git a/terminal/service/tcp_rpc.h b/modules/terminal/service/tcp_rpc.h similarity index 100% rename from terminal/service/tcp_rpc.h rename to modules/terminal/service/tcp_rpc.h diff --git a/terminal/service/telnetd.cpp b/modules/terminal/service/telnetd.cpp similarity index 100% rename from terminal/service/telnetd.cpp rename to modules/terminal/service/telnetd.cpp diff --git a/terminal/service/telnetd.h b/modules/terminal/service/telnetd.h similarity index 100% rename from terminal/service/telnetd.h rename to modules/terminal/service/telnetd.h diff --git a/terminal/session.cpp b/modules/terminal/session.cpp similarity index 100% rename from terminal/session.cpp rename to modules/terminal/session.cpp diff --git a/terminal/session.h b/modules/terminal/session.h similarity index 100% rename from terminal/session.h rename to modules/terminal/session.h diff --git a/terminal/terminal.cpp b/modules/terminal/terminal.cpp similarity index 100% rename from terminal/terminal.cpp rename to modules/terminal/terminal.cpp diff --git a/terminal/terminal.h b/modules/terminal/terminal.h similarity index 100% rename from terminal/terminal.h rename to modules/terminal/terminal.h diff --git a/terminal/terminal_interact.h b/modules/terminal/terminal_interact.h similarity index 100% rename from terminal/terminal_interact.h rename to modules/terminal/terminal_interact.h diff --git a/terminal/terminal_nodes.h b/modules/terminal/terminal_nodes.h similarity index 100% rename from terminal/terminal_nodes.h rename to modules/terminal/terminal_nodes.h diff --git a/terminal/types.h b/modules/terminal/types.h similarity index 100% rename from terminal/types.h rename to modules/terminal/types.h diff --git a/util/Makefile b/modules/util/Makefile similarity index 95% rename from util/Makefile rename to modules/util/Makefile index 7a12104..22563a6 100644 --- a/util/Makefile +++ b/modules/util/Makefile @@ -47,4 +47,4 @@ TEST_LDFLAGS := $(LDFLAGS) -ltbox_base -ldl ENABLE_SHARED_LIB = no -include ../tools/lib_common.mk +include $(TOP_DIR)/tools/lib_common.mk diff --git a/util/argument_parser.cpp b/modules/util/argument_parser.cpp similarity index 100% rename from util/argument_parser.cpp rename to modules/util/argument_parser.cpp diff --git a/util/argument_parser.h b/modules/util/argument_parser.h similarity index 100% rename from util/argument_parser.h rename to modules/util/argument_parser.h diff --git a/util/argument_parser_test.cpp b/modules/util/argument_parser_test.cpp similarity index 100% rename from util/argument_parser_test.cpp rename to modules/util/argument_parser_test.cpp diff --git a/util/async_pipe.cpp b/modules/util/async_pipe.cpp similarity index 100% rename from util/async_pipe.cpp rename to modules/util/async_pipe.cpp diff --git a/util/async_pipe.h b/modules/util/async_pipe.h similarity index 100% rename from util/async_pipe.h rename to modules/util/async_pipe.h diff --git a/util/async_pipe_test.cpp b/modules/util/async_pipe_test.cpp similarity index 100% rename from util/async_pipe_test.cpp rename to modules/util/async_pipe_test.cpp diff --git a/util/backtrace.cpp b/modules/util/backtrace.cpp similarity index 100% rename from util/backtrace.cpp rename to modules/util/backtrace.cpp diff --git a/util/backtrace.h b/modules/util/backtrace.h similarity index 100% rename from util/backtrace.h rename to modules/util/backtrace.h diff --git a/util/fs.cpp b/modules/util/fs.cpp similarity index 100% rename from util/fs.cpp rename to modules/util/fs.cpp diff --git a/util/fs.h b/modules/util/fs.h similarity index 100% rename from util/fs.h rename to modules/util/fs.h diff --git a/util/fs_test.cpp b/modules/util/fs_test.cpp similarity index 100% rename from util/fs_test.cpp rename to modules/util/fs_test.cpp diff --git a/util/pid_file.cpp b/modules/util/pid_file.cpp similarity index 100% rename from util/pid_file.cpp rename to modules/util/pid_file.cpp diff --git a/util/pid_file.h b/modules/util/pid_file.h similarity index 100% rename from util/pid_file.h rename to modules/util/pid_file.h diff --git a/util/pid_file_test.cpp b/modules/util/pid_file_test.cpp similarity index 100% rename from util/pid_file_test.cpp rename to modules/util/pid_file_test.cpp diff --git a/util/serializer.cpp b/modules/util/serializer.cpp similarity index 100% rename from util/serializer.cpp rename to modules/util/serializer.cpp diff --git a/util/serializer.h b/modules/util/serializer.h similarity index 100% rename from util/serializer.h rename to modules/util/serializer.h diff --git a/util/serializer_test.cpp b/modules/util/serializer_test.cpp similarity index 100% rename from util/serializer_test.cpp rename to modules/util/serializer_test.cpp diff --git a/util/split_cmdline.cpp b/modules/util/split_cmdline.cpp similarity index 100% rename from util/split_cmdline.cpp rename to modules/util/split_cmdline.cpp diff --git a/util/split_cmdline.h b/modules/util/split_cmdline.h similarity index 100% rename from util/split_cmdline.h rename to modules/util/split_cmdline.h diff --git a/util/split_cmdline_test.cpp b/modules/util/split_cmdline_test.cpp similarity index 100% rename from util/split_cmdline_test.cpp rename to modules/util/split_cmdline_test.cpp diff --git a/util/state_machine.cpp b/modules/util/state_machine.cpp similarity index 100% rename from util/state_machine.cpp rename to modules/util/state_machine.cpp diff --git a/util/state_machine.h b/modules/util/state_machine.h similarity index 100% rename from util/state_machine.h rename to modules/util/state_machine.h diff --git a/util/state_machine_test.cpp b/modules/util/state_machine_test.cpp similarity index 100% rename from util/state_machine_test.cpp rename to modules/util/state_machine_test.cpp diff --git a/util/string.cpp b/modules/util/string.cpp similarity index 100% rename from util/string.cpp rename to modules/util/string.cpp diff --git a/util/string.h b/modules/util/string.h similarity index 100% rename from util/string.h rename to modules/util/string.h diff --git a/util/string_test.cpp b/modules/util/string_test.cpp similarity index 100% rename from util/string_test.cpp rename to modules/util/string_test.cpp diff --git a/util/thread_wdog.cpp b/modules/util/thread_wdog.cpp similarity index 100% rename from util/thread_wdog.cpp rename to modules/util/thread_wdog.cpp diff --git a/util/thread_wdog.h b/modules/util/thread_wdog.h similarity index 100% rename from util/thread_wdog.h rename to modules/util/thread_wdog.h diff --git a/util/thread_wdog_test.cpp b/modules/util/thread_wdog_test.cpp similarity index 100% rename from util/thread_wdog_test.cpp rename to modules/util/thread_wdog_test.cpp diff --git a/util/time_counter.cpp b/modules/util/time_counter.cpp similarity index 100% rename from util/time_counter.cpp rename to modules/util/time_counter.cpp diff --git a/util/time_counter.h b/modules/util/time_counter.h similarity index 100% rename from util/time_counter.h rename to modules/util/time_counter.h diff --git a/util/time_counter_test.cpp b/modules/util/time_counter_test.cpp similarity index 100% rename from util/time_counter_test.cpp rename to modules/util/time_counter_test.cpp -- Gitee From bfb02ff586474f20921d32b4496eecfc5aefcb7f Mon Sep 17 00:00:00 2001 From: Hevake Date: Wed, 17 Aug 2022 01:19:30 +0800 Subject: [PATCH 23/24] =?UTF-8?q?=E5=B0=86sample=E7=A7=BB=E5=85=A5?= =?UTF-8?q?=E5=88=B0examples/main/=E7=9B=AE=E5=BD=95=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 4 ++-- {sample => examples/main/sample}/Makefile | 0 {sample => examples/main/sample}/README.md | 0 {sample => examples/main/sample}/app1/app.cpp | 0 {sample => examples/main/sample}/app1/app.h | 0 {sample => examples/main/sample}/app1/app.mk | 0 {sample => examples/main/sample}/app2/app.cpp | 0 {sample => examples/main/sample}/app2/app.h | 0 {sample => examples/main/sample}/app2/app.mk | 0 {sample => examples/main/sample}/app_main.cpp | 0 {sample => examples/main/sample}/build_time.cpp | 0 {sample => examples/main/sample}/default.conf | 0 12 files changed, 2 insertions(+), 2 deletions(-) rename {sample => examples/main/sample}/Makefile (100%) rename {sample => examples/main/sample}/README.md (100%) rename {sample => examples/main/sample}/app1/app.cpp (100%) rename {sample => examples/main/sample}/app1/app.h (100%) rename {sample => examples/main/sample}/app1/app.mk (100%) rename {sample => examples/main/sample}/app2/app.cpp (100%) rename {sample => examples/main/sample}/app2/app.h (100%) rename {sample => examples/main/sample}/app2/app.mk (100%) rename {sample => examples/main/sample}/app_main.cpp (100%) rename {sample => examples/main/sample}/build_time.cpp (100%) rename {sample => examples/main/sample}/default.conf (100%) diff --git a/Makefile b/Makefile index 0da33ea..c9d328b 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ include build_env.mk -.PHONY: all modules examples sample test clean distclean +.PHONY: all modules examples test clean distclean CCFLAGS := -Wall @@ -31,7 +31,7 @@ include config.mk all: modules -modules examples sample: +modules examples: $(MAKE) -C $@ test: diff --git a/sample/Makefile b/examples/main/sample/Makefile similarity index 100% rename from sample/Makefile rename to examples/main/sample/Makefile diff --git a/sample/README.md b/examples/main/sample/README.md similarity index 100% rename from sample/README.md rename to examples/main/sample/README.md diff --git a/sample/app1/app.cpp b/examples/main/sample/app1/app.cpp similarity index 100% rename from sample/app1/app.cpp rename to examples/main/sample/app1/app.cpp diff --git a/sample/app1/app.h b/examples/main/sample/app1/app.h similarity index 100% rename from sample/app1/app.h rename to examples/main/sample/app1/app.h diff --git a/sample/app1/app.mk b/examples/main/sample/app1/app.mk similarity index 100% rename from sample/app1/app.mk rename to examples/main/sample/app1/app.mk diff --git a/sample/app2/app.cpp b/examples/main/sample/app2/app.cpp similarity index 100% rename from sample/app2/app.cpp rename to examples/main/sample/app2/app.cpp diff --git a/sample/app2/app.h b/examples/main/sample/app2/app.h similarity index 100% rename from sample/app2/app.h rename to examples/main/sample/app2/app.h diff --git a/sample/app2/app.mk b/examples/main/sample/app2/app.mk similarity index 100% rename from sample/app2/app.mk rename to examples/main/sample/app2/app.mk diff --git a/sample/app_main.cpp b/examples/main/sample/app_main.cpp similarity index 100% rename from sample/app_main.cpp rename to examples/main/sample/app_main.cpp diff --git a/sample/build_time.cpp b/examples/main/sample/build_time.cpp similarity index 100% rename from sample/build_time.cpp rename to examples/main/sample/build_time.cpp diff --git a/sample/default.conf b/examples/main/sample/default.conf similarity index 100% rename from sample/default.conf rename to examples/main/sample/default.conf -- Gitee From 218a534ecbd6d33fe6bc59041462ffdfc9bbbdf7 Mon Sep 17 00:00:00 2001 From: hevake_lcj Date: Wed, 17 Aug 2022 11:07:38 +0800 Subject: [PATCH 24/24] =?UTF-8?q?fixbug:=20=E8=A7=A3=E5=86=B3event/engins/?= =?UTF-8?q?epoll=E4=B8=ADTimerEvent=E5=9C=A8Oneshot=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E4=B8=8B=E8=A7=A6=E5=8F=91=E5=90=8EisEnabled()=E4=BE=9D?= =?UTF-8?q?=E6=97=A7=E4=B8=BAtrue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- event/engins/epoll/fd_event.cpp | 7 +++---- event/engins/epoll/timer_event.cpp | 5 +++++ event/timer_event_test.cpp | 2 ++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/event/engins/epoll/fd_event.cpp b/event/engins/epoll/fd_event.cpp index 58ff0ed..d1c21e3 100644 --- a/event/engins/epoll/fd_event.cpp +++ b/event/engins/epoll/fd_event.cpp @@ -141,14 +141,13 @@ void EpollFdEvent::onEvent(short events) { wp_loop_->beginEventProcess(); - if (cb_) { + if (is_stop_after_trigger_) + disable(); + if (cb_) { ++cb_level_; cb_(events); --cb_level_; - - if (is_stop_after_trigger_) - disable(); } wp_loop_->endEventProcess(); diff --git a/event/engins/epoll/timer_event.cpp b/event/engins/epoll/timer_event.cpp index 908a4bb..81d6ae0 100644 --- a/event/engins/epoll/timer_event.cpp +++ b/event/engins/epoll/timer_event.cpp @@ -80,6 +80,11 @@ void EpollTimerEvent::onEvent() { wp_loop_->beginEventProcess(); + if (mode_ == Mode::kOneshot) { + is_enabled_ = false; + token_.reset(); + } + if (cb_) { ++cb_level_; cb_(); diff --git a/event/timer_event_test.cpp b/event/timer_event_test.cpp index 776e329..610893f 100644 --- a/event/timer_event_test.cpp +++ b/event/timer_event_test.cpp @@ -27,6 +27,7 @@ TEST(TimerEvent, Oneshot) sp_loop->runLoop(); EXPECT_EQ(run_time, 1); + EXPECT_FALSE(timer_event->isEnabled()); delete timer_event; delete sp_loop; @@ -50,6 +51,7 @@ TEST(TimerEvent, Persist) sp_loop->runLoop(); EXPECT_EQ(run_time, 10); + EXPECT_TRUE(timer_event->isEnabled()); delete timer_event; delete sp_loop; -- Gitee