├── .github └── workflows │ ├── cmake.yml │ └── make.yml ├── .gitignore ├── 3rd-party ├── Makefile └── nlohmann │ ├── CMakeLists.txt │ ├── LICENSE.MIT │ ├── Makefile │ ├── json.hpp │ └── json_fwd.hpp ├── CMakeLists.txt ├── CONTRIBUTING.md ├── CONTRIBUTORS.md ├── Config.cmake.in ├── LICENSE ├── Makefile ├── README.md ├── README_CN.md ├── build_env.mk ├── config.mk ├── documents ├── images │ ├── 0000-terminal-show.gif │ ├── 0001-set-log-level.gif │ ├── 0001-tbox-loop.jpg │ ├── 0002-exit-friendly.gif │ ├── 0002-log-show.png │ ├── 0003-run-in-loop.png │ ├── 0004-run-thread-pool.png │ ├── 0005-arguments.png │ ├── 0006-error-dump.png │ ├── 0008-main-framework.png │ ├── 0009-demo-app.png │ ├── 0010-action-tree-graph.jpg │ ├── 0010-state-machine-graph.png │ ├── 0011-trace-view.png │ ├── README.md │ ├── logo-with-slogan.png │ ├── logo.png │ └── modules-dependence.png └── logo.txt ├── examples ├── Makefile ├── alarm │ ├── Makefile │ ├── cron_alarm │ │ ├── Makefile │ │ └── main.cpp │ ├── oneshot_alarm │ │ ├── Makefile │ │ └── main.cpp │ └── weekly_alarm │ │ ├── Makefile │ │ └── main.cpp ├── base │ ├── Makefile │ ├── assert │ │ ├── Makefile │ │ └── main.cpp │ ├── object_pool │ │ ├── Makefile │ │ └── main.cpp │ └── print_log │ │ ├── Makefile │ │ ├── main.cpp │ │ └── other.c ├── dbus │ ├── 00-loop │ │ ├── Makefile │ │ └── main.cpp │ └── Makefile ├── event │ ├── 01_io │ │ ├── Makefile │ │ └── main.cpp │ ├── 02_timer │ │ ├── Makefile │ │ └── main.cpp │ ├── 03_signal │ │ ├── Makefile │ │ └── main.cpp │ ├── 04_run_in_loop │ │ ├── Makefile │ │ └── main.cpp │ ├── 05_run_next_seq │ │ ├── Makefile │ │ └── main.cpp │ ├── 06_stdin_timer_signal │ │ ├── Makefile │ │ └── main.cpp │ ├── 07_delay_delete │ │ ├── Makefile │ │ └── main.cpp │ ├── 08_calc_game │ │ ├── Makefile │ │ ├── game.cpp │ │ ├── game.h │ │ ├── game_lite.cpp │ │ ├── game_lite.h │ │ └── main.cpp │ ├── 09_named_pipe │ │ ├── Makefile │ │ └── main.cpp │ └── Makefile ├── eventx │ ├── Makefile │ ├── thread_pool │ │ ├── Makefile │ │ └── main.cpp │ └── timer_fd │ │ ├── Makefile │ │ └── main.cpp ├── http │ ├── Makefile │ └── server │ │ ├── Makefile │ │ ├── async_respond │ │ ├── Makefile │ │ └── async_respond.cpp │ │ ├── file_download │ │ ├── Makefile │ │ └── file_download.cpp │ │ ├── form_data │ │ ├── Makefile │ │ └── file_upload.cpp │ │ ├── router │ │ ├── Makefile │ │ ├── router.cpp │ │ └── webpage.cpp │ │ └── simple │ │ ├── Makefile │ │ └── simple.cpp ├── jsonrpc │ ├── Makefile │ ├── message │ │ ├── Makefile │ │ ├── ping │ │ │ ├── Makefile │ │ │ └── ping.cpp │ │ └── pong │ │ │ ├── Makefile │ │ │ └── pong.cpp │ └── req_rsp │ │ ├── Makefile │ │ ├── ping │ │ ├── Makefile │ │ └── ping.cpp │ │ └── pong │ │ ├── Makefile │ │ └── pong.cpp ├── main │ ├── 00_empty │ │ └── Makefile │ ├── 01_one_app │ │ ├── Makefile │ │ ├── app.cpp │ │ ├── app.h │ │ └── main.cpp │ ├── 02_more_than_one_apps │ │ ├── Makefile │ │ ├── app1 │ │ │ ├── app.cpp │ │ │ ├── app.h │ │ │ ├── app.mk │ │ │ ├── sub.cpp │ │ │ └── sub.h │ │ ├── app2 │ │ │ ├── app.cpp │ │ │ ├── app.h │ │ │ └── app.mk │ │ ├── app3 │ │ │ ├── app.cpp │ │ │ ├── app.h │ │ │ └── app.mk │ │ └── main.cpp │ ├── 03_nc_client_and_echo_server │ │ ├── Makefile │ │ ├── README.md │ │ ├── echo_server │ │ │ ├── app.cpp │ │ │ ├── app.h │ │ │ └── app.mk │ │ ├── main.cpp │ │ └── nc_client │ │ │ ├── app.cpp │ │ │ ├── app.h │ │ │ └── app.mk │ ├── 04_runtime_error │ │ ├── Makefile │ │ ├── README.txt │ │ └── main.cpp │ ├── 06_run_in_backend │ │ ├── Makefile │ │ ├── app.cpp │ │ ├── app.h │ │ ├── app_main.cpp │ │ └── main.cpp │ ├── Makefile │ ├── README.md │ └── sample │ │ ├── Makefile │ │ ├── README.md │ │ ├── app1 │ │ ├── app.cpp │ │ ├── app.h │ │ └── app.mk │ │ ├── app2 │ │ ├── app.cpp │ │ ├── app.h │ │ └── app.mk │ │ ├── app_main.cpp │ │ ├── build_time.cpp │ │ └── default.conf ├── mqtt │ ├── Makefile │ ├── conn │ │ ├── Makefile │ │ └── conn.cpp │ ├── pub │ │ ├── Makefile │ │ └── pub.cpp │ └── sub │ │ ├── Makefile │ │ └── sub.cpp ├── network │ ├── Makefile │ ├── buffered_fd │ │ ├── Makefile │ │ └── io_echo.cpp │ ├── stdio_stream │ │ ├── 01_stdin_out │ │ │ ├── Makefile │ │ │ └── main.cpp │ │ ├── 02_stdio │ │ │ ├── Makefile │ │ │ └── main.cpp │ │ └── Makefile │ ├── tcp_acceptor │ │ ├── Makefile │ │ ├── tcp_echo │ │ │ ├── Makefile │ │ │ └── tcp_echo.cpp │ │ └── tcp_nc_server │ │ │ ├── Makefile │ │ │ └── tcp_nc_server.cpp │ ├── tcp_client │ │ ├── Makefile │ │ ├── tcp_echo │ │ │ ├── Makefile │ │ │ └── tcp_echo.cpp │ │ ├── tcp_hex_client │ │ │ ├── Makefile │ │ │ └── tcp_hex_client.cpp │ │ └── tcp_nc_client │ │ │ ├── Makefile │ │ │ └── tcp_nc_client.cpp │ ├── tcp_connector │ │ ├── Makefile │ │ ├── tcp_echo │ │ │ ├── Makefile │ │ │ └── tcp_echo.cpp │ │ └── tcp_nc_client │ │ │ ├── Makefile │ │ │ └── tcp_nc_client.cpp │ ├── tcp_server │ │ ├── Makefile │ │ ├── tcp_echo │ │ │ ├── Makefile │ │ │ └── tcp_echo.cpp │ │ └── tcp_nc_server │ │ │ ├── Makefile │ │ │ └── tcp_nc_server.cpp │ ├── uart │ │ ├── Makefile │ │ ├── uart_to_uart │ │ │ ├── Makefile │ │ │ └── uart_to_uart.cpp │ │ └── uart_tool │ │ │ ├── Makefile │ │ │ └── uart_tool.cpp │ └── udp_socket │ │ ├── Makefile │ │ ├── ping_pong │ │ ├── Makefile │ │ └── ping_pong.cpp │ │ ├── recv_only │ │ ├── Makefile │ │ └── recv_only.cpp │ │ ├── request │ │ ├── Makefile │ │ └── request.cpp │ │ ├── respond │ │ ├── Makefile │ │ └── respond.cpp │ │ └── send_only │ │ ├── Makefile │ │ └── send_only.cpp ├── run │ ├── Makefile │ ├── echo_server │ │ ├── Makefile │ │ ├── echo_server.cpp │ │ └── echo_server.h │ ├── nc_client │ │ ├── Makefile │ │ ├── nc_client.cpp │ │ └── nc_client.h │ └── timer_event │ │ ├── Makefile │ │ └── timer_event.cpp ├── terminal │ ├── Makefile │ ├── build_nodes.cpp │ ├── stdio │ │ ├── Makefile │ │ └── main.cpp │ ├── tcp_rpc │ │ ├── Makefile │ │ └── main.cpp │ └── telnetd │ │ ├── Makefile │ │ └── main.cpp ├── trace │ ├── 01_demo │ │ ├── Makefile │ │ └── main.cpp │ ├── 02_multi_threads │ │ ├── Makefile │ │ └── main.cpp │ └── Makefile └── util │ ├── Makefile │ └── json_deep_loader │ ├── Makefile │ ├── config │ ├── common.json │ ├── main.json │ ├── sub │ │ ├── sub1.json │ │ └── sub2.json │ └── sub3.json │ └── main.cpp ├── mk ├── exe_common.mk ├── lib_common.mk ├── lib_header_only_common.mk └── lib_tbox_common.mk ├── modules ├── Makefile ├── alarm │ ├── 3rd-party │ │ ├── ccronexpr.cpp │ │ └── ccronexpr.h │ ├── CMakeLists.txt │ ├── Makefile │ ├── alarm.cpp │ ├── alarm.h │ ├── cron_alarm.cpp │ ├── cron_alarm.h │ ├── oneshot_alarm.cpp │ ├── oneshot_alarm.h │ ├── weekly_alarm.cpp │ ├── weekly_alarm.h │ ├── workday_alarm.cpp │ ├── workday_alarm.h │ ├── workday_calendar.cpp │ ├── workday_calendar.h │ └── workday_calendar_test.cpp ├── base │ ├── CMakeLists.txt │ ├── Makefile │ ├── assert.h │ ├── backtrace.cpp │ ├── backtrace.h │ ├── backtrace_test.cpp │ ├── cabinet.hpp │ ├── cabinet_test.cpp │ ├── cabinet_token.h │ ├── cabinet_token_test.cpp │ ├── catch_throw.cpp │ ├── catch_throw.h │ ├── catch_throw_test.cpp │ ├── defines.h │ ├── func_types.h │ ├── json.hpp │ ├── json_fwd.h │ ├── json_test.cpp │ ├── lifetime_tag.hpp │ ├── lifetime_tag_test.cpp │ ├── log.h │ ├── log_impl.cpp │ ├── log_impl.h │ ├── log_output.cpp │ ├── log_output.h │ ├── log_output_test.cpp │ ├── memblock.h │ ├── object_pool.hpp │ ├── object_pool_test.cpp │ ├── recorder.cpp │ ├── recorder.h │ ├── recorder_test.cpp │ ├── scope_exit.hpp │ ├── scope_exit_test.cpp │ ├── version.cpp │ ├── version.h │ └── wrapped_recorder.h ├── coroutine │ ├── CMakeLists.txt │ ├── Makefile │ ├── README.md │ ├── broadcast.hpp │ ├── broadcast_test.cpp │ ├── channel.hpp │ ├── channel_test.cpp │ ├── condition.hpp │ ├── condition_test.cpp │ ├── mutex.hpp │ ├── mutex_test.cpp │ ├── scheduler.cpp │ ├── scheduler.h │ ├── scheduler_test.cpp │ ├── semaphore.hpp │ └── semaphore_test.cpp ├── crypto │ ├── CMakeLists.txt │ ├── Makefile │ ├── aes.cpp │ ├── aes.h │ ├── aes_test.cpp │ ├── md5.cpp │ ├── md5.h │ └── md5_test.cpp ├── dbus │ ├── CMakeLists.txt │ ├── Makefile │ ├── connection.cpp │ ├── connection.h │ ├── loop.cpp │ └── loop.h ├── event │ ├── CMakeLists.txt │ ├── Makefile │ ├── common_loop.cpp │ ├── common_loop.h │ ├── common_loop_run.cpp │ ├── common_loop_signal.cpp │ ├── common_loop_test.cpp │ ├── common_loop_timer.cpp │ ├── engines │ │ ├── epoll │ │ │ ├── fd_event.cpp │ │ │ ├── fd_event.h │ │ │ ├── loop.cpp │ │ │ ├── loop.h │ │ │ └── types.h │ │ └── select │ │ │ ├── fd_event.cpp │ │ │ ├── fd_event.h │ │ │ ├── loop.cpp │ │ │ ├── loop.h │ │ │ └── types.h │ ├── event.h │ ├── fd_event.h │ ├── fd_event_test.cpp │ ├── forward.h │ ├── loop.cpp │ ├── loop.h │ ├── misc.cpp │ ├── misc.h │ ├── signal_event.h │ ├── signal_event_impl.cpp │ ├── signal_event_impl.h │ ├── signal_event_test.cpp │ ├── stat.cpp │ ├── stat.h │ ├── stat_test.cpp │ ├── timer_event.h │ ├── timer_event_impl.cpp │ ├── timer_event_impl.h │ └── timer_event_test.cpp ├── eventx │ ├── CMakeLists.txt │ ├── Makefile │ ├── async.cpp │ ├── async.h │ ├── async_test.cpp │ ├── loop_thread.cpp │ ├── loop_thread.h │ ├── loop_thread_test.cpp │ ├── loop_wdog.cpp │ ├── loop_wdog.h │ ├── loop_wdog_test.cpp │ ├── request_pool.hpp │ ├── request_pool_test.cpp │ ├── thread_pool.cpp │ ├── thread_pool.h │ ├── thread_pool_test.cpp │ ├── timeout_monitor.hpp │ ├── timeout_monitor_impl.hpp │ ├── timeout_monitor_test.cpp │ ├── timer_fd.cpp │ ├── timer_fd.h │ ├── timer_fd_test.cpp │ ├── timer_pool.cpp │ ├── timer_pool.h │ ├── timer_pool_test.cpp │ ├── work_thread.cpp │ ├── work_thread.h │ └── work_thread_test.cpp ├── flow │ ├── CMakeLists.txt │ ├── Makefile │ ├── action.cpp │ ├── action.h │ ├── action_executor.cpp │ ├── action_executor.h │ ├── action_executor_test.cpp │ ├── action_reason.h │ ├── action_test.cpp │ ├── actions │ │ ├── assemble_action.cpp │ │ ├── assemble_action.h │ │ ├── assemble_action_test.cpp │ │ ├── composite_action.cpp │ │ ├── composite_action.h │ │ ├── composite_action_test.cpp │ │ ├── dummy_action.cpp │ │ ├── dummy_action.h │ │ ├── event_action.cpp │ │ ├── event_action.h │ │ ├── function_action.cpp │ │ ├── function_action.h │ │ ├── function_action_test.cpp │ │ ├── if_else_action.cpp │ │ ├── if_else_action.h │ │ ├── if_else_action_test.cpp │ │ ├── if_then_action.cpp │ │ ├── if_then_action.h │ │ ├── if_then_action_test.cpp │ │ ├── loop_action.cpp │ │ ├── loop_action.h │ │ ├── loop_action_test.cpp │ │ ├── loop_if_action.cpp │ │ ├── loop_if_action.h │ │ ├── loop_if_action_test.cpp │ │ ├── parallel_action.cpp │ │ ├── parallel_action.h │ │ ├── parallel_action_test.cpp │ │ ├── repeat_action.cpp │ │ ├── repeat_action.h │ │ ├── repeat_action_test.cpp │ │ ├── sequence_action.cpp │ │ ├── sequence_action.h │ │ ├── sequence_action_test.cpp │ │ ├── sleep_action.cpp │ │ ├── sleep_action.h │ │ ├── sleep_action_test.cpp │ │ ├── succ_fail_action.h │ │ ├── succ_fail_action_test.cpp │ │ ├── switch_action.cpp │ │ ├── switch_action.h │ │ ├── switch_action_test.cpp │ │ ├── wrapper_action.cpp │ │ ├── wrapper_action.h │ │ └── wrapper_action_test.cpp │ ├── event.h │ ├── event_publisher.h │ ├── event_publisher_impl.cpp │ ├── event_publisher_impl.h │ ├── event_publisher_impl_test.cpp │ ├── event_subscriber.h │ ├── state_machine.cpp │ ├── state_machine.h │ ├── state_machine_test.cpp │ ├── to_graphviz.cpp │ ├── to_graphviz.h │ └── to_graphviz_test.cpp ├── http │ ├── CMakeLists.txt │ ├── Makefile │ ├── README.md │ ├── client │ │ ├── client.cpp │ │ └── client.h │ ├── common.cpp │ ├── common.h │ ├── common_test.cpp │ ├── request.cpp │ ├── request.h │ ├── request_test.cpp │ ├── respond.cpp │ ├── respond.h │ ├── respond_test.cpp │ ├── server │ │ ├── context.cpp │ │ ├── context.h │ │ ├── middleware.h │ │ ├── middlewares │ │ │ ├── file_downloader_middleware.cpp │ │ │ ├── file_downloader_middleware.h │ │ │ ├── form_data.cpp │ │ │ ├── form_data.h │ │ │ ├── form_data_middleware.cpp │ │ │ ├── form_data_middleware.h │ │ │ ├── route_key.h │ │ │ ├── router_middleware.cpp │ │ │ └── router_middleware.h │ │ ├── request_parser.cpp │ │ ├── request_parser.h │ │ ├── request_parser_test.cpp │ │ ├── server.cpp │ │ ├── server.h │ │ ├── server_imp.cpp │ │ ├── server_imp.h │ │ └── types.h │ ├── url.cpp │ ├── url.h │ └── url_test.cpp ├── jsonrpc │ ├── CMakeLists.txt │ ├── Makefile │ ├── inner_types.h │ ├── proto.cpp │ ├── proto.h │ ├── protos │ │ ├── header_stream_proto.cpp │ │ ├── header_stream_proto.h │ │ ├── header_stream_proto_test.cpp │ │ ├── packet_proto.cpp │ │ ├── packet_proto.h │ │ ├── packet_proto_test.cpp │ │ ├── raw_stream_proto.cpp │ │ ├── raw_stream_proto.h │ │ └── raw_stream_proto_test.cpp │ ├── rpc.cpp │ ├── rpc.h │ └── rpc_test.cpp ├── log │ ├── CMakeLists.txt │ ├── Makefile │ ├── async_file_sink.cpp │ ├── async_file_sink.h │ ├── async_file_sink_test.cpp │ ├── async_sink.cpp │ ├── async_sink.h │ ├── async_sink_test.cpp │ ├── async_stdout_sink.cpp │ ├── async_stdout_sink.h │ ├── async_stdout_sink_test.cpp │ ├── async_syslog_sink.cpp │ ├── async_syslog_sink.h │ ├── async_syslog_sink_test.cpp │ ├── sink.cpp │ ├── sink.h │ ├── sync_stdout_sink.cpp │ ├── sync_stdout_sink.h │ └── sync_stdout_sink_test.cpp ├── main │ ├── CMakeLists.txt │ ├── Makefile │ ├── README.md │ ├── args.cpp │ ├── args.h │ ├── context.h │ ├── context_imp.cpp │ ├── context_imp.h │ ├── error_signals.cpp │ ├── log.cpp │ ├── log.h │ ├── main.h │ ├── misc.cpp │ ├── module.cpp │ ├── module.h │ ├── run_in_backend.cpp │ ├── run_in_frontend.cpp │ ├── terminate.cpp │ ├── trace.cpp │ └── trace.h ├── mqtt │ ├── CMakeLists.txt │ ├── Makefile │ ├── client.cpp │ └── client.h ├── network │ ├── CMakeLists.txt │ ├── Makefile │ ├── README │ ├── buffered_fd.cpp │ ├── buffered_fd.h │ ├── buffered_fd_test.cpp │ ├── byte_stream.h │ ├── dns_request.cpp │ ├── dns_request.h │ ├── dns_request_test.cpp │ ├── domain_name.h │ ├── ip_address.cpp │ ├── ip_address.h │ ├── ip_address_test.cpp │ ├── net_if.cpp │ ├── net_if.h │ ├── net_if_test.cpp │ ├── sockaddr.cpp │ ├── sockaddr.h │ ├── sockaddr_test.cpp │ ├── socket_fd.cpp │ ├── socket_fd.h │ ├── stdio_stream.cpp │ ├── stdio_stream.h │ ├── tcp_acceptor.cpp │ ├── tcp_acceptor.h │ ├── tcp_client.cpp │ ├── tcp_client.h │ ├── tcp_connection.cpp │ ├── tcp_connection.h │ ├── tcp_connector.cpp │ ├── tcp_connector.h │ ├── tcp_server.cpp │ ├── tcp_server.h │ ├── uart.cpp │ ├── uart.h │ ├── uart_test.cpp │ ├── udp_socket.cpp │ ├── udp_socket.h │ └── udp_socket_test.cpp ├── run │ ├── Makefile │ └── main.cpp ├── tbox ├── terminal │ ├── CMakeLists.txt │ ├── Makefile │ ├── README.md │ ├── connection.h │ ├── helper.cpp │ ├── helper.h │ ├── impl │ │ ├── dir_node.cpp │ │ ├── dir_node.h │ │ ├── func_node.cpp │ │ ├── func_node.h │ │ ├── inner_types.h │ │ ├── key_event_scanner.cpp │ │ ├── key_event_scanner.h │ │ ├── key_event_scanner_test.cpp │ │ ├── node.h │ │ ├── service │ │ │ ├── stdio.cpp │ │ │ ├── stdio.h │ │ │ ├── tcp_rpc.cpp │ │ │ ├── tcp_rpc.h │ │ │ ├── telnetd.cpp │ │ │ └── telnetd.h │ │ ├── session_context.h │ │ ├── terminal.cpp │ │ ├── terminal.h │ │ ├── terminal_commands.cpp │ │ ├── terminal_key_events.cpp │ │ └── terminal_nodes.cpp │ ├── service │ │ ├── stdio.cpp │ │ ├── stdio.h │ │ ├── tcp_rpc.cpp │ │ ├── tcp_rpc.h │ │ ├── telnetd.cpp │ │ └── telnetd.h │ ├── session.cpp │ ├── session.h │ ├── terminal.cpp │ ├── terminal.h │ ├── terminal_interact.h │ ├── terminal_nodes.h │ └── types.h ├── trace │ ├── CMakeLists.txt │ ├── Makefile │ ├── sink.cpp │ ├── sink.h │ └── sink_test.cpp └── util │ ├── CMakeLists.txt │ ├── Makefile │ ├── argument_parser.cpp │ ├── argument_parser.h │ ├── argument_parser_test.cpp │ ├── async_pipe.cpp │ ├── async_pipe.h │ ├── async_pipe_test.cpp │ ├── base64.cpp │ ├── base64.h │ ├── base64_test.cpp │ ├── buffer.cpp │ ├── buffer.h │ ├── buffer_test.cpp │ ├── checksum.cpp │ ├── checksum.h │ ├── checksum_test.cpp │ ├── crc.cpp │ ├── crc.h │ ├── crc_test.cpp │ ├── execute_cmd.cpp │ ├── execute_cmd.h │ ├── execute_cmd_test.cpp │ ├── fd.cpp │ ├── fd.h │ ├── fd_test.cpp │ ├── fs.cpp │ ├── fs.h │ ├── fs_test.cpp │ ├── json.cpp │ ├── json.h │ ├── json_deep_loader.cpp │ ├── json_deep_loader.h │ ├── json_test.cpp │ ├── pid_file.cpp │ ├── pid_file.h │ ├── pid_file_test.cpp │ ├── scalable_integer.cpp │ ├── scalable_integer.h │ ├── scalable_integer_test.cpp │ ├── serializer.cpp │ ├── serializer.h │ ├── serializer_test.cpp │ ├── split_cmdline.cpp │ ├── split_cmdline.h │ ├── split_cmdline_test.cpp │ ├── string.cpp │ ├── string.h │ ├── string_test.cpp │ ├── timestamp.cpp │ ├── timestamp.h │ ├── timestamp_test.cpp │ ├── variables.cpp │ ├── variables.h │ └── variables_test.cpp ├── tools ├── Makefile ├── check_and_archive_log_files.sh ├── graphviz_render │ ├── .gitignore │ ├── README_cn.md │ ├── requirements.txt │ └── src │ │ ├── data_processing.py │ │ ├── data_source.py │ │ ├── main.py │ │ ├── signal_handler.py │ │ ├── transform │ │ ├── __init__.py │ │ ├── zoomable.py │ │ └── zoomable_cpu.py │ │ └── ui │ │ ├── __init__.py │ │ └── viewer.py └── trace │ ├── Makefile │ └── analyzer │ ├── Makefile │ ├── main.cpp │ ├── writer.cpp │ └── writer.h └── version.mk /.github/workflows/cmake.yml: -------------------------------------------------------------------------------- 1 | name: CMake Build and Test 2 | 3 | on: 4 | push: 5 | branches: [ master, develop ] 6 | pull_request: 7 | branches: [ master, develop ] 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Setup 14 | run: | 15 | sudo apt update 16 | sudo apt install build-essential cmake 17 | sudo apt install libgtest-dev libgmock-dev 18 | sudo apt install libmosquitto-dev 19 | sudo apt install libdbus-1-dev 20 | - uses: actions/checkout@v3 21 | - name: Build 22 | run: cmake -B build && cmake --build build 23 | - name: Test 24 | run: find ./build -name *_test -exec {} \; 25 | -------------------------------------------------------------------------------- /.github/workflows/make.yml: -------------------------------------------------------------------------------- 1 | name: Make Build and Test 2 | 3 | on: 4 | push: 5 | branches: [ master, develop ] 6 | pull_request: 7 | branches: [ master, develop ] 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Setup 14 | run: | 15 | sudo apt update 16 | sudo apt install build-essential 17 | sudo apt install libgtest-dev libgmock-dev 18 | sudo apt install libmosquitto-dev 19 | sudo apt install libdbus-1-dev 20 | - uses: actions/checkout@v3 21 | - name: Build 22 | run: make 23 | - name: Test 24 | run: find .build -name test -exec {} \; 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Clion 2 | .idea/ 3 | cmake-build-*/ 4 | 5 | # others 6 | tags 7 | test 8 | cscope.* 9 | *.o 10 | lib*.a 11 | lib*.so* 12 | /.staging 13 | /.install 14 | /.build 15 | /build 16 | -------------------------------------------------------------------------------- /3rd-party/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | all test: 22 | @for i in $(THIRDPARTY); do \ 23 | [ ! -d $$i ] || $(MAKE) -C $$i $@ || exit $$? ; \ 24 | done 25 | -------------------------------------------------------------------------------- /3rd-party/nlohmann/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | cmake_minimum_required(VERSION 3.15) 22 | 23 | project(nlohmann) 24 | 25 | set(TBOX_JSON_HEADERS 26 | json.hpp 27 | json_fwd.hpp) 28 | 29 | install(FILES ${TBOX_JSON_HEADERS} DESTINATION include/nlohmann) 30 | -------------------------------------------------------------------------------- /3rd-party/nlohmann/LICENSE.MIT: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2013-2022 Niels Lohmann 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /3rd-party/nlohmann/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | LIB_NAME = nlohmann 22 | 23 | HEAD_FILES = \ 24 | json.hpp \ 25 | json_fwd.hpp \ 26 | 27 | include $(TOP_DIR)/mk/lib_header_only_common.mk 28 | -------------------------------------------------------------------------------- /CONTRIBUTORS.md: -------------------------------------------------------------------------------- 1 | _If we have forgotten your name, please contact us_ 2 | 3 | ## cpp-tbox Contributors 4 | 5 | * Hevake Lee 6 | * Lucas Law 7 | * Sky Hou 8 | * DuanYH 9 | * Gwill 10 | * MacroModel 11 | -------------------------------------------------------------------------------- /Config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | set(_cpp_tbox_supported_components "@TBOX_COMPONENTS@") 4 | 5 | foreach(_comp ${tbox_FIND_COMPONENTS}) 6 | if (NOT _comp IN_LIST _cpp_tbox_supported_components) 7 | set(tbox_FOUND False) 8 | set(tbox_NOT_FOUND_MESSAGE "Unsupported component: ${_comp}, supported list: ${_cpp_tbox_supported_components}") 9 | endif() 10 | include("${CMAKE_CURRENT_LIST_DIR}/tbox_${_comp}_targets.cmake") 11 | endforeach() 12 | -------------------------------------------------------------------------------- /config.mk: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | # 核心模块 22 | MODULES += base 23 | MODULES += util 24 | MODULES += event 25 | MODULES += eventx 26 | MODULES += log 27 | MODULES += network 28 | MODULES += terminal 29 | MODULES += trace 30 | MODULES += coroutine 31 | MODULES += main 32 | MODULES += run 33 | 34 | ## 非核心模块,请根据需要选择 35 | MODULES += http 36 | MODULES += mqtt 37 | MODULES += flow 38 | MODULES += alarm 39 | MODULES += crypto 40 | MODULES += dbus 41 | MODULES += jsonrpc 42 | 43 | ## 第三方库依赖 44 | THIRDPARTY += nlohmann 45 | 46 | ## 编译配置 47 | CCFLAGS += -DENABLE_TRACE_RECORDER=1 48 | -------------------------------------------------------------------------------- /documents/images/0000-terminal-show.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cpp-main/cpp-tbox/94e39c3ee72a20c9dd068c9fa8fdc2818dfbc55b/documents/images/0000-terminal-show.gif -------------------------------------------------------------------------------- /documents/images/0001-set-log-level.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cpp-main/cpp-tbox/94e39c3ee72a20c9dd068c9fa8fdc2818dfbc55b/documents/images/0001-set-log-level.gif -------------------------------------------------------------------------------- /documents/images/0001-tbox-loop.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cpp-main/cpp-tbox/94e39c3ee72a20c9dd068c9fa8fdc2818dfbc55b/documents/images/0001-tbox-loop.jpg -------------------------------------------------------------------------------- /documents/images/0002-exit-friendly.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cpp-main/cpp-tbox/94e39c3ee72a20c9dd068c9fa8fdc2818dfbc55b/documents/images/0002-exit-friendly.gif -------------------------------------------------------------------------------- /documents/images/0002-log-show.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cpp-main/cpp-tbox/94e39c3ee72a20c9dd068c9fa8fdc2818dfbc55b/documents/images/0002-log-show.png -------------------------------------------------------------------------------- /documents/images/0003-run-in-loop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cpp-main/cpp-tbox/94e39c3ee72a20c9dd068c9fa8fdc2818dfbc55b/documents/images/0003-run-in-loop.png -------------------------------------------------------------------------------- /documents/images/0004-run-thread-pool.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cpp-main/cpp-tbox/94e39c3ee72a20c9dd068c9fa8fdc2818dfbc55b/documents/images/0004-run-thread-pool.png -------------------------------------------------------------------------------- /documents/images/0005-arguments.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cpp-main/cpp-tbox/94e39c3ee72a20c9dd068c9fa8fdc2818dfbc55b/documents/images/0005-arguments.png -------------------------------------------------------------------------------- /documents/images/0006-error-dump.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cpp-main/cpp-tbox/94e39c3ee72a20c9dd068c9fa8fdc2818dfbc55b/documents/images/0006-error-dump.png -------------------------------------------------------------------------------- /documents/images/0008-main-framework.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cpp-main/cpp-tbox/94e39c3ee72a20c9dd068c9fa8fdc2818dfbc55b/documents/images/0008-main-framework.png -------------------------------------------------------------------------------- /documents/images/0009-demo-app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cpp-main/cpp-tbox/94e39c3ee72a20c9dd068c9fa8fdc2818dfbc55b/documents/images/0009-demo-app.png -------------------------------------------------------------------------------- /documents/images/0010-action-tree-graph.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cpp-main/cpp-tbox/94e39c3ee72a20c9dd068c9fa8fdc2818dfbc55b/documents/images/0010-action-tree-graph.jpg -------------------------------------------------------------------------------- /documents/images/0010-state-machine-graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cpp-main/cpp-tbox/94e39c3ee72a20c9dd068c9fa8fdc2818dfbc55b/documents/images/0010-state-machine-graph.png -------------------------------------------------------------------------------- /documents/images/0011-trace-view.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cpp-main/cpp-tbox/94e39c3ee72a20c9dd068c9fa8fdc2818dfbc55b/documents/images/0011-trace-view.png -------------------------------------------------------------------------------- /documents/images/README.md: -------------------------------------------------------------------------------- 1 | 这里存放文档照片 2 | -------------------------------------------------------------------------------- /documents/images/logo-with-slogan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cpp-main/cpp-tbox/94e39c3ee72a20c9dd068c9fa8fdc2818dfbc55b/documents/images/logo-with-slogan.png -------------------------------------------------------------------------------- /documents/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cpp-main/cpp-tbox/94e39c3ee72a20c9dd068c9fa8fdc2818dfbc55b/documents/images/logo.png -------------------------------------------------------------------------------- /documents/images/modules-dependence.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cpp-main/cpp-tbox/94e39c3ee72a20c9dd068c9fa8fdc2818dfbc55b/documents/images/modules-dependence.png -------------------------------------------------------------------------------- /documents/logo.txt: -------------------------------------------------------------------------------- 1 | .============. 2 | // M A K E / \ 3 | // C++ DEV / \ 4 | // E A S Y / \/ \ 5 | ++ ----------. \/\ . 6 | \\ \ \ /\ / 7 | \\ \ \ / 8 | \\ \ \ / 9 | -============' 10 | -------------------------------------------------------------------------------- /examples/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | all test: 22 | @for i in $(MODULES); do \ 23 | [ ! -d $$i ] || $(MAKE) -C $$i $@ || exit $$? ; \ 24 | done 25 | -------------------------------------------------------------------------------- /examples/alarm/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | all test clean distclean: 22 | @for i in $(shell ls) ; do \ 23 | if [ -d $$i ]; then \ 24 | $(MAKE) -C $$i $@ || exit $$? ; \ 25 | fi \ 26 | done 27 | -------------------------------------------------------------------------------- /examples/alarm/cron_alarm/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/alarm/cron_alarm 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := main.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_alarm \ 29 | -ltbox_event \ 30 | -ltbox_base \ 31 | -ldl 32 | 33 | include $(TOP_DIR)/mk/exe_common.mk 34 | -------------------------------------------------------------------------------- /examples/alarm/oneshot_alarm/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/alarm/oneshot_alarm 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := main.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_alarm \ 29 | -ltbox_event \ 30 | -ltbox_base \ 31 | -ldl 32 | 33 | include $(TOP_DIR)/mk/exe_common.mk 34 | -------------------------------------------------------------------------------- /examples/alarm/weekly_alarm/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/alarm/weekly_alarm 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := main.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_alarm \ 29 | -ltbox_event \ 30 | -ltbox_base \ 31 | -ldl 32 | 33 | include $(TOP_DIR)/mk/exe_common.mk 34 | -------------------------------------------------------------------------------- /examples/base/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | all test clean distclean: 22 | @for i in $(shell ls) ; do \ 23 | if [ -d $$i ]; then \ 24 | $(MAKE) -C $$i $@ || exit $$? ; \ 25 | fi \ 26 | done 27 | -------------------------------------------------------------------------------- /examples/base/assert/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/base/assert 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := main.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += -ltbox_base -ldl 28 | 29 | include $(TOP_DIR)/mk/exe_common.mk 30 | -------------------------------------------------------------------------------- /examples/base/assert/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #include 21 | #include 22 | #include 23 | 24 | int main() { 25 | LogOutput_Enable(); 26 | TBOX_ASSERT(12 > 0); 27 | TBOX_ASSERT(12 < 0); 28 | LogOutput_Disable(); 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /examples/base/object_pool/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/base/object_pool 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := main.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += -ltbox_base -ldl 28 | 29 | include $(TOP_DIR)/mk/exe_common.mk 30 | -------------------------------------------------------------------------------- /examples/base/print_log/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2023 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/base/print_log 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := main.cpp 25 | C_SRC_FILES := other.c 26 | 27 | CXXFLAGS += -DMODULE_ID='"demo"' 28 | CFLAGS += -DMODULE_ID='"demo"' 29 | 30 | LDFLAGS += -ltbox_base -ldl 31 | 32 | include $(TOP_DIR)/mk/exe_common.mk 33 | -------------------------------------------------------------------------------- /examples/base/print_log/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2023 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #include 21 | #include 22 | 23 | extern "C" void DoSomeThing(); 24 | 25 | int main() { 26 | LogOutput_Enable(); 27 | 28 | LogInfo("this log print in C++ file"); 29 | DoSomeThing(); 30 | 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /examples/base/print_log/other.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void DoSomeThing() 4 | { 5 | LogInfo("This log print in C file"); 6 | } 7 | -------------------------------------------------------------------------------- /examples/dbus/00-loop/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/dbus/00-loop 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := main.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | CXXFLAGS += $(shell pkg-config --cflags dbus-1) 28 | LDFLAGS += $(shell pkg-config --libs dbus-1) 29 | LDFLAGS += \ 30 | -ltbox_dbus \ 31 | -ltbox_event \ 32 | -ltbox_base \ 33 | -ldl 34 | 35 | include $(TOP_DIR)/mk/exe_common.mk 36 | -------------------------------------------------------------------------------- /examples/dbus/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | all test clean distclean: 22 | @for i in $(shell ls) ; do \ 23 | if [ -d $$i ]; then \ 24 | $(MAKE) -C $$i $@ || exit $$? ; \ 25 | fi \ 26 | done 27 | -------------------------------------------------------------------------------- /examples/event/01_io/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/event/01_io 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := main.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_event \ 29 | -ltbox_base \ 30 | -ldl 31 | 32 | include $(TOP_DIR)/mk/exe_common.mk 33 | -------------------------------------------------------------------------------- /examples/event/02_timer/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/event/02_timer 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := main.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_event \ 29 | -ltbox_base \ 30 | -ldl 31 | 32 | include $(TOP_DIR)/mk/exe_common.mk 33 | -------------------------------------------------------------------------------- /examples/event/03_signal/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/event/03_signal 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := main.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_event \ 29 | -ltbox_base \ 30 | -ldl 31 | 32 | include $(TOP_DIR)/mk/exe_common.mk 33 | -------------------------------------------------------------------------------- /examples/event/04_run_in_loop/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/event/04_run_in_loop 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := main.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_event \ 29 | -ltbox_base \ 30 | -lpthread \ 31 | -ldl 32 | 33 | include $(TOP_DIR)/mk/exe_common.mk 34 | -------------------------------------------------------------------------------- /examples/event/05_run_next_seq/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/event/05_run_next_seq 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := main.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_event \ 29 | -ltbox_base \ 30 | -ldl 31 | 32 | include $(TOP_DIR)/mk/exe_common.mk 33 | -------------------------------------------------------------------------------- /examples/event/06_stdin_timer_signal/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/event/06_stdin_timer_signal 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := main.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_event \ 29 | -ltbox_base \ 30 | -ldl 31 | 32 | include $(TOP_DIR)/mk/exe_common.mk 33 | -------------------------------------------------------------------------------- /examples/event/07_delay_delete/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/event/07_delay_delete 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := main.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_event \ 29 | -ltbox_base \ 30 | -ldl 31 | 32 | include $(TOP_DIR)/mk/exe_common.mk 33 | -------------------------------------------------------------------------------- /examples/event/08_calc_game/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/event/08_calc_game 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := \ 25 | main.cpp \ 26 | game.cpp \ 27 | 28 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 29 | LDFLAGS += \ 30 | -ltbox_event \ 31 | -ltbox_base \ 32 | -ldl 33 | 34 | include $(TOP_DIR)/mk/exe_common.mk 35 | -------------------------------------------------------------------------------- /examples/event/09_named_pipe/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2024 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/event/09_named_pipe 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := main.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_event \ 29 | -ltbox_base \ 30 | -ldl 31 | 32 | include $(TOP_DIR)/mk/exe_common.mk 33 | -------------------------------------------------------------------------------- /examples/event/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | all test clean distclean: 22 | @for i in $(shell ls) ; do \ 23 | if [ -d $$i ]; then \ 24 | $(MAKE) -C $$i $@ || exit $$? ; \ 25 | fi \ 26 | done 27 | -------------------------------------------------------------------------------- /examples/eventx/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | all test clean distclean: 22 | @for i in $(shell ls) ; do \ 23 | if [ -d $$i ]; then \ 24 | $(MAKE) -C $$i $@ || exit $$? ; \ 25 | fi \ 26 | done 27 | -------------------------------------------------------------------------------- /examples/eventx/thread_pool/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/eventx/thread_pool 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := main.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_eventx \ 29 | -ltbox_event \ 30 | -ltbox_base \ 31 | -lpthread \ 32 | -ldl 33 | 34 | include $(TOP_DIR)/mk/exe_common.mk 35 | -------------------------------------------------------------------------------- /examples/eventx/timer_fd/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/eventx/timer_fd 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := main.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_eventx \ 29 | -ltbox_event \ 30 | -ltbox_base \ 31 | -ldl 32 | 33 | include $(TOP_DIR)/mk/exe_common.mk 34 | -------------------------------------------------------------------------------- /examples/http/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | all test clean distclean: 22 | @for i in $(shell ls) ; do \ 23 | if [ -d $$i ]; then \ 24 | $(MAKE) -C $$i $@ || exit $$? ; \ 25 | fi \ 26 | done 27 | -------------------------------------------------------------------------------- /examples/http/server/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | all test clean distclean: 22 | @for i in $(shell ls) ; do \ 23 | if [ -d $$i ]; then \ 24 | $(MAKE) -C $$i $@ || exit $$? ; \ 25 | fi \ 26 | done 27 | -------------------------------------------------------------------------------- /examples/http/server/async_respond/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/http/server/async_respond 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := async_respond.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_http \ 29 | -ltbox_network \ 30 | -ltbox_eventx \ 31 | -ltbox_event \ 32 | -ltbox_log \ 33 | -ltbox_util \ 34 | -ltbox_base \ 35 | -lpthread -ldl 36 | 37 | include $(TOP_DIR)/mk/exe_common.mk 38 | -------------------------------------------------------------------------------- /examples/http/server/file_download/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2025 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/http/server/file_download 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := file_download.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' -std=c++17 $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_http \ 29 | -ltbox_network \ 30 | -ltbox_eventx \ 31 | -ltbox_event \ 32 | -ltbox_trace \ 33 | -ltbox_log \ 34 | -ltbox_util \ 35 | -ltbox_base \ 36 | -lstdc++fs \ 37 | -lpthread -ldl 38 | 39 | include $(TOP_DIR)/mk/exe_common.mk 40 | -------------------------------------------------------------------------------- /examples/http/server/form_data/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2025 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/http/server/file_upload 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := file_upload.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_http \ 29 | -ltbox_network \ 30 | -ltbox_eventx \ 31 | -ltbox_event \ 32 | -ltbox_log \ 33 | -ltbox_util \ 34 | -ltbox_base \ 35 | -lpthread -ldl 36 | 37 | include $(TOP_DIR)/mk/exe_common.mk 38 | -------------------------------------------------------------------------------- /examples/http/server/router/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2025 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/http/server/router 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := router.cpp webpage.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_http \ 29 | -ltbox_network \ 30 | -ltbox_eventx \ 31 | -ltbox_event \ 32 | -ltbox_log \ 33 | -ltbox_util \ 34 | -ltbox_base \ 35 | -lpthread -ldl 36 | 37 | include $(TOP_DIR)/mk/exe_common.mk 38 | -------------------------------------------------------------------------------- /examples/http/server/simple/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/http/server/simple 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := simple.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_http \ 29 | -ltbox_network \ 30 | -ltbox_eventx \ 31 | -ltbox_event \ 32 | -ltbox_log \ 33 | -ltbox_util \ 34 | -ltbox_base \ 35 | -lpthread -ldl 36 | 37 | include $(TOP_DIR)/mk/exe_common.mk 38 | -------------------------------------------------------------------------------- /examples/jsonrpc/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | all test clean distclean: 22 | @for i in $(shell ls) ; do \ 23 | if [ -d $$i ]; then \ 24 | $(MAKE) -C $$i $@ || exit $$? ; \ 25 | fi \ 26 | done 27 | -------------------------------------------------------------------------------- /examples/jsonrpc/message/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | all test clean distclean: 22 | @for i in $(shell ls) ; do \ 23 | if [ -d $$i ]; then \ 24 | $(MAKE) -C $$i $@ || exit $$? ; \ 25 | fi \ 26 | done 27 | -------------------------------------------------------------------------------- /examples/jsonrpc/message/ping/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/jsonrpc/message/ping 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := ping.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_jsonrpc \ 29 | -ltbox_network \ 30 | -ltbox_eventx \ 31 | -ltbox_event \ 32 | -ltbox_util \ 33 | -ltbox_base \ 34 | -lpthread -ldl 35 | 36 | include $(TOP_DIR)/mk/exe_common.mk 37 | -------------------------------------------------------------------------------- /examples/jsonrpc/message/pong/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/jsonrpc/message/pong 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := pong.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_jsonrpc \ 29 | -ltbox_network \ 30 | -ltbox_eventx \ 31 | -ltbox_event \ 32 | -ltbox_util \ 33 | -ltbox_base \ 34 | -lpthread -ldl 35 | 36 | include $(TOP_DIR)/mk/exe_common.mk 37 | -------------------------------------------------------------------------------- /examples/jsonrpc/req_rsp/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | all test clean distclean: 22 | @for i in $(shell ls) ; do \ 23 | if [ -d $$i ]; then \ 24 | $(MAKE) -C $$i $@ || exit $$? ; \ 25 | fi \ 26 | done 27 | -------------------------------------------------------------------------------- /examples/jsonrpc/req_rsp/ping/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/jsonrpc/req_rsp/ping 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := ping.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_jsonrpc \ 29 | -ltbox_network \ 30 | -ltbox_eventx \ 31 | -ltbox_event \ 32 | -ltbox_util \ 33 | -ltbox_base \ 34 | -lpthread -ldl 35 | 36 | include $(TOP_DIR)/mk/exe_common.mk 37 | -------------------------------------------------------------------------------- /examples/jsonrpc/req_rsp/pong/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/jsonrpc/req_rsp/pong 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := pong.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_jsonrpc \ 29 | -ltbox_network \ 30 | -ltbox_eventx \ 31 | -ltbox_event \ 32 | -ltbox_util \ 33 | -ltbox_base \ 34 | -lpthread -ldl 35 | 36 | include $(TOP_DIR)/mk/exe_common.mk 37 | -------------------------------------------------------------------------------- /examples/main/00_empty/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/main/00_empty 22 | EXE_NAME := ${PROJECT} 23 | 24 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 25 | LDFLAGS += \ 26 | -ltbox_main \ 27 | -ltbox_coroutine \ 28 | -ltbox_trace \ 29 | -ltbox_terminal \ 30 | -ltbox_network \ 31 | -ltbox_eventx \ 32 | -ltbox_eventx \ 33 | -ltbox_event \ 34 | -ltbox_log \ 35 | -ltbox_util \ 36 | -ltbox_base \ 37 | -lpthread \ 38 | -ldl \ 39 | -rdynamic 40 | 41 | include $(TOP_DIR)/mk/exe_common.mk 42 | -------------------------------------------------------------------------------- /examples/main/01_one_app/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/main/01_one_app 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES = \ 25 | app.cpp \ 26 | main.cpp \ 27 | 28 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 29 | LDFLAGS += \ 30 | -ltbox_main \ 31 | -ltbox_coroutine \ 32 | -ltbox_trace \ 33 | -ltbox_terminal \ 34 | -ltbox_network \ 35 | -ltbox_eventx \ 36 | -ltbox_eventx \ 37 | -ltbox_event \ 38 | -ltbox_log \ 39 | -ltbox_util \ 40 | -ltbox_base \ 41 | -lpthread \ 42 | -ldl \ 43 | -rdynamic 44 | 45 | include $(TOP_DIR)/mk/exe_common.mk 46 | -------------------------------------------------------------------------------- /examples/main/01_one_app/app.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #include "app.h" 21 | #include 22 | 23 | App::App(tbox::main::Context &ctx) : 24 | Module("app", ctx) 25 | { 26 | LogTag(); 27 | } 28 | 29 | App::~App() 30 | { 31 | LogTag(); 32 | } 33 | 34 | bool App::onInit(const tbox::Json &cfg) 35 | { 36 | LogTag(); 37 | return true; 38 | } 39 | 40 | bool App::onStart() 41 | { 42 | LogTag(); 43 | return true; 44 | } 45 | 46 | void App::onStop() 47 | { 48 | LogTag(); 49 | } 50 | 51 | void App::onCleanup() 52 | { 53 | LogTag(); 54 | } 55 | -------------------------------------------------------------------------------- /examples/main/01_one_app/app.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_MAIN_EXAMPLE_SAMPLE_H_20211226 21 | #define TBOX_MAIN_EXAMPLE_SAMPLE_H_20211226 22 | 23 | #include 24 | 25 | class App : public tbox::main::Module 26 | { 27 | public: 28 | App(tbox::main::Context &ctx); 29 | ~App(); 30 | protected: 31 | virtual bool onInit(const tbox::Json &cfg) override; 32 | virtual bool onStart() override; 33 | virtual void onStop() override; 34 | virtual void onCleanup() override; 35 | }; 36 | 37 | #endif //TBOX_MAIN_EXAMPLE_SAMPLE_H_20211226 38 | -------------------------------------------------------------------------------- /examples/main/01_one_app/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #include 21 | #include "app.h" 22 | 23 | namespace tbox { 24 | namespace main { 25 | 26 | void RegisterApps(Module &apps, Context &ctx) 27 | { 28 | apps.add(new ::App(ctx)); 29 | } 30 | 31 | std::string GetAppDescribe() 32 | { 33 | return "One app sample"; 34 | } 35 | 36 | std::string GetAppBuildTime() 37 | { 38 | return __DATE__ " " __TIME__; 39 | } 40 | 41 | void GetAppVersion(int &major, int &minor, int &rev, int &build) 42 | { 43 | major = 0; 44 | minor = 0; 45 | rev = 1; 46 | build = 0; 47 | } 48 | 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /examples/main/02_more_than_one_apps/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/main/02_more_than_one_apps 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES = \ 25 | main.cpp \ 26 | 27 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 28 | LDFLAGS += \ 29 | -ltbox_main \ 30 | -ltbox_coroutine \ 31 | -ltbox_trace \ 32 | -ltbox_terminal \ 33 | -ltbox_network \ 34 | -ltbox_eventx \ 35 | -ltbox_eventx \ 36 | -ltbox_event \ 37 | -ltbox_log \ 38 | -ltbox_util \ 39 | -ltbox_base \ 40 | -lpthread \ 41 | -ldl \ 42 | -rdynamic 43 | 44 | include app1/app.mk 45 | include app2/app.mk 46 | include app3/app.mk 47 | 48 | include $(TOP_DIR)/mk/exe_common.mk 49 | -------------------------------------------------------------------------------- /examples/main/02_more_than_one_apps/app1/app.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #include "app.h" 21 | #include 22 | #include "sub.h" 23 | 24 | namespace app1 { 25 | 26 | App::App(tbox::main::Context &ctx) : 27 | Module("app1", ctx) 28 | { 29 | add(new Sub(ctx)); 30 | LogTag(); 31 | } 32 | 33 | App::~App() 34 | { 35 | LogTag(); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /examples/main/02_more_than_one_apps/app1/app.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_MAIN_EXAMPLE_APP1_H_20211226 21 | #define TBOX_MAIN_EXAMPLE_APP1_H_20211226 22 | 23 | #include 24 | 25 | namespace app1 { 26 | 27 | class App : public tbox::main::Module 28 | { 29 | public: 30 | App(tbox::main::Context &ctx); 31 | ~App(); 32 | }; 33 | 34 | } 35 | 36 | #endif //TBOX_MAIN_EXAMPLE_APP1_H_20211226 37 | -------------------------------------------------------------------------------- /examples/main/02_more_than_one_apps/app1/app.mk: -------------------------------------------------------------------------------- 1 | CPP_SRC_FILES += \ 2 | app1/app.cpp \ 3 | app1/sub.cpp \ 4 | -------------------------------------------------------------------------------- /examples/main/02_more_than_one_apps/app1/sub.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #include "sub.h" 21 | #include 22 | 23 | namespace app1 { 24 | 25 | Sub::Sub(tbox::main::Context &ctx) : 26 | Module("sub", ctx) 27 | { 28 | LogTag(); 29 | } 30 | 31 | Sub::~Sub() 32 | { 33 | LogTag(); 34 | } 35 | 36 | bool Sub::onInit(const tbox::Json &cfg) 37 | { 38 | LogTag(); 39 | return true; 40 | } 41 | 42 | bool Sub::onStart() 43 | { 44 | LogTag(); 45 | return true; 46 | } 47 | 48 | void Sub::onStop() 49 | { 50 | LogTag(); 51 | } 52 | 53 | void Sub::onCleanup() 54 | { 55 | LogTag(); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /examples/main/02_more_than_one_apps/app1/sub.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_MAIN_EXAMPLE_SUBMODULE_H_20220329 21 | #define TBOX_MAIN_EXAMPLE_SUBMODULE_H_20220329 22 | 23 | #include 24 | 25 | namespace app1 { 26 | 27 | class Sub : public tbox::main::Module 28 | { 29 | public: 30 | Sub(tbox::main::Context &ctx); 31 | ~Sub(); 32 | 33 | protected: 34 | virtual bool onInit(const tbox::Json &cfg) override; 35 | virtual bool onStart() override; 36 | virtual void onStop() override; 37 | virtual void onCleanup() override; 38 | }; 39 | 40 | } 41 | 42 | #endif //TBOX_MAIN_EXAMPLE_SUBMODULE_H_20220329 43 | -------------------------------------------------------------------------------- /examples/main/02_more_than_one_apps/app2/app.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_MAIN_EXAMPLE_APP2_H_20211226 21 | #define TBOX_MAIN_EXAMPLE_APP2_H_20211226 22 | 23 | #include 24 | 25 | namespace app2 { 26 | 27 | class App : public tbox::main::Module 28 | { 29 | public: 30 | App(tbox::main::Context &ctx); 31 | ~App(); 32 | 33 | protected: 34 | virtual void onFillDefaultConfig(tbox::Json &cfg) override; 35 | virtual bool onInit(const tbox::Json &cfg) override; 36 | virtual bool onStart() override; 37 | virtual void onStop() override; 38 | virtual void onCleanup() override; 39 | }; 40 | 41 | } 42 | 43 | #endif //TBOX_MAIN_EXAMPLE_APP2_H_20211226 44 | -------------------------------------------------------------------------------- /examples/main/02_more_than_one_apps/app2/app.mk: -------------------------------------------------------------------------------- 1 | CPP_SRC_FILES += \ 2 | app2/app.cpp \ 3 | -------------------------------------------------------------------------------- /examples/main/02_more_than_one_apps/app3/app.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #include "app.h" 21 | #include 22 | 23 | namespace app3 { 24 | 25 | App::App(tbox::main::Context &ctx) : 26 | Module("app3", ctx) 27 | { 28 | LogTag(); 29 | } 30 | 31 | App::~App() 32 | { 33 | LogTag(); 34 | } 35 | 36 | bool App::onInit(const tbox::Json &cfg) 37 | { 38 | LogTag(); 39 | return true; 40 | } 41 | 42 | bool App::onStart() 43 | { 44 | LogTag(); 45 | return true; 46 | } 47 | 48 | void App::onStop() 49 | { 50 | LogTag(); 51 | } 52 | 53 | void App::onCleanup() 54 | { 55 | LogTag(); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /examples/main/02_more_than_one_apps/app3/app.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_MAIN_EXAMPLE_APP3_H_20211226 21 | #define TBOX_MAIN_EXAMPLE_APP3_H_20211226 22 | 23 | #include 24 | 25 | namespace app3 { 26 | 27 | class App : public tbox::main::Module 28 | { 29 | public: 30 | App(tbox::main::Context &ctx); 31 | ~App(); 32 | protected: 33 | virtual bool onInit(const tbox::Json &cfg) override; 34 | virtual bool onStart() override; 35 | virtual void onStop() override; 36 | virtual void onCleanup() override; 37 | }; 38 | 39 | } 40 | 41 | #endif //TBOX_MAIN_EXAMPLE_APP3_H_20211226 42 | -------------------------------------------------------------------------------- /examples/main/02_more_than_one_apps/app3/app.mk: -------------------------------------------------------------------------------- 1 | CPP_SRC_FILES += \ 2 | app3/app.cpp \ 3 | -------------------------------------------------------------------------------- /examples/main/03_nc_client_and_echo_server/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/main/03_nc_client_and_echo_server 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES = \ 25 | main.cpp \ 26 | 27 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 28 | LDFLAGS += \ 29 | -ltbox_main \ 30 | -ltbox_coroutine \ 31 | -ltbox_trace \ 32 | -ltbox_terminal \ 33 | -ltbox_network \ 34 | -ltbox_eventx \ 35 | -ltbox_eventx \ 36 | -ltbox_event \ 37 | -ltbox_log \ 38 | -ltbox_util \ 39 | -ltbox_base \ 40 | -lpthread \ 41 | -ldl \ 42 | -rdynamic 43 | 44 | include echo_server/app.mk 45 | include nc_client/app.mk 46 | 47 | include $(TOP_DIR)/mk/exe_common.mk 48 | -------------------------------------------------------------------------------- /examples/main/03_nc_client_and_echo_server/README.md: -------------------------------------------------------------------------------- 1 | 这是一个单进程,多应用的示例。它有两个应用: 2 | 3 | - echo\_server,创建 127.0.0.1:12345 的TCP服务,接受客户端的连接。将客户端发来的内容,原封不动回复过去。 4 | - nc\_client,创建一个TCP的客户端,去连接 127.0.0.1:12345 服务器。将终端接收到的内容发送给服务器,同时将服务器回复的内容输出到终端。 5 | 6 | 两个应用虽运行在同一个进程里,但两者的代码分别在各自的子目录下,独立逻辑,不相干扰。 7 | -------------------------------------------------------------------------------- /examples/main/03_nc_client_and_echo_server/echo_server/app.mk: -------------------------------------------------------------------------------- 1 | CPP_SRC_FILES += echo_server/app.cpp 2 | LDFLAGS += -ltbox_network 3 | -------------------------------------------------------------------------------- /examples/main/03_nc_client_and_echo_server/nc_client/app.mk: -------------------------------------------------------------------------------- 1 | CPP_SRC_FILES += nc_client/app.cpp 2 | LDFLAGS += -ltbox_network 3 | -------------------------------------------------------------------------------- /examples/main/04_runtime_error/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/main/04_runtime_error 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES = \ 25 | main.cpp \ 26 | 27 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 28 | LDFLAGS += \ 29 | -ltbox_main \ 30 | -ltbox_coroutine \ 31 | -ltbox_trace \ 32 | -ltbox_terminal \ 33 | -ltbox_network \ 34 | -ltbox_eventx \ 35 | -ltbox_eventx \ 36 | -ltbox_event \ 37 | -ltbox_log \ 38 | -ltbox_util \ 39 | -ltbox_base \ 40 | -lpthread \ 41 | -ldl \ 42 | -rdynamic 43 | 44 | include $(TOP_DIR)/mk/exe_common.mk 45 | -------------------------------------------------------------------------------- /examples/main/04_runtime_error/README.txt: -------------------------------------------------------------------------------- 1 | 本示例模拟程序出现异常,使程序打印调用栈 2 | -------------------------------------------------------------------------------- /examples/main/06_run_in_backend/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/main/06_run_in_backend 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES = \ 25 | app.cpp \ 26 | app_main.cpp \ 27 | main.cpp \ 28 | 29 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 30 | LDFLAGS += \ 31 | -ltbox_main \ 32 | -ltbox_coroutine \ 33 | -ltbox_trace \ 34 | -ltbox_terminal \ 35 | -ltbox_network \ 36 | -ltbox_eventx \ 37 | -ltbox_eventx \ 38 | -ltbox_event \ 39 | -ltbox_log \ 40 | -ltbox_util \ 41 | -ltbox_base \ 42 | -lpthread \ 43 | -ldl \ 44 | -rdynamic 45 | 46 | include $(TOP_DIR)/mk/exe_common.mk 47 | -------------------------------------------------------------------------------- /examples/main/06_run_in_backend/app.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_MAIN_EXAMPLE_SAMPLE_H_20211226 21 | #define TBOX_MAIN_EXAMPLE_SAMPLE_H_20211226 22 | 23 | #include 24 | #include 25 | 26 | class App : public tbox::main::Module 27 | { 28 | public: 29 | App(tbox::main::Context &ctx); 30 | ~App(); 31 | protected: 32 | virtual bool onInit(const tbox::Json &cfg) override; 33 | virtual bool onStart() override; 34 | virtual void onStop() override; 35 | virtual void onCleanup() override; 36 | 37 | private: 38 | tbox::event::TimerEvent *timer_; 39 | }; 40 | 41 | #endif //TBOX_MAIN_EXAMPLE_SAMPLE_H_20211226 42 | -------------------------------------------------------------------------------- /examples/main/06_run_in_backend/app_main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #include 21 | #include "app.h" 22 | 23 | namespace tbox { 24 | namespace main { 25 | 26 | void RegisterApps(Module &apps, Context &ctx) 27 | { 28 | apps.add(new ::App(ctx)); 29 | } 30 | 31 | std::string GetAppDescribe() 32 | { 33 | return "One app sample"; 34 | } 35 | 36 | std::string GetAppBuildTime() 37 | { 38 | return __DATE__ " " __TIME__; 39 | } 40 | 41 | void GetAppVersion(int &major, int &minor, int &rev, int &build) 42 | { 43 | major = 0; 44 | minor = 0; 45 | rev = 1; 46 | build = 0; 47 | } 48 | 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /examples/main/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | all test clean distclean: 22 | @for i in $(shell ls) ; do \ 23 | if [ -d $$i ]; then \ 24 | $(MAKE) -C $$i $@ || exit $$? ; \ 25 | fi \ 26 | done 27 | -------------------------------------------------------------------------------- /examples/main/README.md: -------------------------------------------------------------------------------- 1 | 示例说明: 2 | 3 | - 01\_one\_app,单应用模板 4 | - 02\_more\_than\_one\_apps,多应用模板 5 | - 03\_nc\_client\_and\_echo\_server,基于多应用示例,tcp\_client与tcp\_echo\_server 6 | 7 | -------------------------------------------------------------------------------- /examples/main/sample/README.md: -------------------------------------------------------------------------------- 1 | 这是一个单进程,多应用的示例。它有两个应用。 2 | 两个应用虽运行在同一个进程里,但两者的代码分别在各自的子目录下,独立逻辑,不相干扰。 3 | -------------------------------------------------------------------------------- /examples/main/sample/app1/app.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #include "app.h" 21 | #include 22 | 23 | namespace app1 { 24 | 25 | App::App(tbox::main::Context &ctx) : 26 | Module("app1", ctx) 27 | { 28 | LogTag(); 29 | } 30 | 31 | App::~App() 32 | { 33 | LogTag(); 34 | } 35 | 36 | bool App::onInit(const tbox::Json &cfg) 37 | { 38 | LogTag(); 39 | return true; 40 | } 41 | 42 | bool App::onStart() 43 | { 44 | LogTag(); 45 | return true; 46 | } 47 | 48 | void App::onStop() 49 | { 50 | LogTag(); 51 | } 52 | 53 | void App::onCleanup() 54 | { 55 | LogTag(); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /examples/main/sample/app1/app.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_MAIN_EXAMPLE_APP1_H_20211226 21 | #define TBOX_MAIN_EXAMPLE_APP1_H_20211226 22 | 23 | #include 24 | 25 | namespace app1 { 26 | 27 | class App : public tbox::main::Module 28 | { 29 | public: 30 | App(tbox::main::Context &ctx); 31 | ~App(); 32 | 33 | protected: 34 | virtual bool onInit(const tbox::Json &cfg) override; 35 | virtual bool onStart() override; 36 | virtual void onStop() override; 37 | virtual void onCleanup() override; 38 | }; 39 | 40 | } 41 | 42 | #endif //TBOX_MAIN_EXAMPLE_APP1_H_20211226 43 | -------------------------------------------------------------------------------- /examples/main/sample/app1/app.mk: -------------------------------------------------------------------------------- 1 | CPP_SRC_FILES += app1/app.cpp 2 | CC_SRC_FILES += 3 | C_SRC_FILES += 4 | LDFLAGS += 5 | 6 | TEST_CPP_SRC_FILES += 7 | TEST_LDFLAGS += 8 | -------------------------------------------------------------------------------- /examples/main/sample/app2/app.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #include "app.h" 21 | #include 22 | 23 | namespace app2 { 24 | 25 | App::App(tbox::main::Context &ctx) : 26 | Module("app2", ctx) 27 | { 28 | LogTag(); 29 | } 30 | 31 | App::~App() 32 | { 33 | LogTag(); 34 | } 35 | 36 | bool App::onInit(const tbox::Json &cfg) 37 | { 38 | LogTag(); 39 | return true; 40 | } 41 | 42 | bool App::onStart() 43 | { 44 | LogTag(); 45 | return true; 46 | } 47 | 48 | void App::onStop() 49 | { 50 | LogTag(); 51 | } 52 | 53 | void App::onCleanup() 54 | { 55 | LogTag(); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /examples/main/sample/app2/app.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_MAIN_EXAMPLE_APP2_H_20211226 21 | #define TBOX_MAIN_EXAMPLE_APP2_H_20211226 22 | 23 | #include 24 | 25 | namespace app2 { 26 | 27 | class App : public tbox::main::Module 28 | { 29 | public: 30 | App(tbox::main::Context &ctx); 31 | ~App(); 32 | 33 | protected: 34 | virtual bool onInit(const tbox::Json &cfg) override; 35 | virtual bool onStart() override; 36 | virtual void onStop() override; 37 | virtual void onCleanup() override; 38 | }; 39 | 40 | } 41 | 42 | #endif //TBOX_MAIN_EXAMPLE_APP2_H_20211226 43 | -------------------------------------------------------------------------------- /examples/main/sample/app2/app.mk: -------------------------------------------------------------------------------- 1 | CPP_SRC_FILES += app2/app.cpp 2 | CC_SRC_FILES += 3 | C_SRC_FILES += 4 | LDFLAGS += 5 | 6 | TEST_CPP_SRC_FILES += 7 | TEST_LDFLAGS += 8 | -------------------------------------------------------------------------------- /examples/main/sample/app_main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #include 21 | 22 | #include "app1/app.h" 23 | #include "app2/app.h" 24 | 25 | namespace tbox { 26 | namespace main { 27 | 28 | void RegisterApps(Module &apps, Context &ctx) 29 | { 30 | apps.add(new app1::App(ctx)); 31 | apps.add(new app2::App(ctx)); 32 | } 33 | 34 | std::string GetAppDescribe() 35 | { 36 | return "This is a sample within two apps."; 37 | } 38 | 39 | void GetAppVersion(int &major, int &minor, int &rev, int &build) 40 | { 41 | major = 1; 42 | minor = 0; 43 | rev = 0; 44 | build = 0; 45 | } 46 | 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /examples/main/sample/build_time.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #include 21 | 22 | namespace tbox { 23 | namespace main { 24 | 25 | std::string GetAppBuildTime() 26 | { 27 | return __DATE__ " " __TIME__; 28 | } 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /examples/main/sample/default.conf: -------------------------------------------------------------------------------- 1 | { 2 | "pid_file": "/tmp/sample.pid", 3 | "thread_pool": { 4 | "max": 5, 5 | "min": 1 6 | }, 7 | "telnetd": { 8 | "bind": "/tmp/sample-telnetd.sock" 9 | }, 10 | "tcp_rpc": { 11 | "bind": "/tmp/sample-rpc.sock" 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /examples/mqtt/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | all test clean distclean: 22 | @for i in $(shell ls) ; do \ 23 | if [ -d $$i ]; then \ 24 | $(MAKE) -C $$i $@ || exit $$? ; \ 25 | fi \ 26 | done 27 | -------------------------------------------------------------------------------- /examples/mqtt/conn/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/mqtt/conn 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := conn.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_mqtt \ 29 | -ltbox_event \ 30 | -ltbox_base \ 31 | -lmosquitto \ 32 | -lpthread \ 33 | -ldl 34 | 35 | include $(TOP_DIR)/mk/exe_common.mk 36 | -------------------------------------------------------------------------------- /examples/mqtt/pub/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/mqtt/pub 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := pub.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_mqtt \ 29 | -ltbox_event \ 30 | -ltbox_base \ 31 | -lmosquitto \ 32 | -lpthread \ 33 | -ldl 34 | 35 | include $(TOP_DIR)/mk/exe_common.mk 36 | -------------------------------------------------------------------------------- /examples/mqtt/sub/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/mqtt/sub 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := sub.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_mqtt \ 29 | -ltbox_event \ 30 | -ltbox_base \ 31 | -lmosquitto \ 32 | -lpthread \ 33 | -ldl 34 | 35 | include $(TOP_DIR)/mk/exe_common.mk 36 | -------------------------------------------------------------------------------- /examples/network/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | all test clean distclean: 22 | @for i in $(shell ls) ; do \ 23 | if [ -d $$i ]; then \ 24 | $(MAKE) -C $$i $@ || exit $$? ; \ 25 | fi \ 26 | done 27 | -------------------------------------------------------------------------------- /examples/network/buffered_fd/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/network/buffered_fd/01-io-echo 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := io_echo.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_network \ 29 | -ltbox_event \ 30 | -ltbox_util \ 31 | -ltbox_base \ 32 | -ldl 33 | 34 | include $(TOP_DIR)/mk/exe_common.mk 35 | -------------------------------------------------------------------------------- /examples/network/stdio_stream/01_stdin_out/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/network/stdio_stream/01_stdin_out 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := main.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_network \ 29 | -ltbox_event \ 30 | -ltbox_util \ 31 | -ltbox_base \ 32 | -ldl 33 | 34 | include $(TOP_DIR)/mk/exe_common.mk 35 | -------------------------------------------------------------------------------- /examples/network/stdio_stream/02_stdio/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/network/stdio_stream/02_stdio 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := main.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_network \ 29 | -ltbox_event \ 30 | -ltbox_util \ 31 | -ltbox_base \ 32 | -ldl 33 | 34 | include $(TOP_DIR)/mk/exe_common.mk 35 | -------------------------------------------------------------------------------- /examples/network/stdio_stream/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | all test clean distclean: 22 | @for i in $(shell ls) ; do \ 23 | if [ -d $$i ]; then \ 24 | $(MAKE) -C $$i $@ || exit $$? ; \ 25 | fi \ 26 | done 27 | -------------------------------------------------------------------------------- /examples/network/tcp_acceptor/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | all test clean distclean: 22 | @for i in $(shell ls) ; do \ 23 | if [ -d $$i ]; then \ 24 | $(MAKE) -C $$i $@ || exit $$? ; \ 25 | fi \ 26 | done 27 | -------------------------------------------------------------------------------- /examples/network/tcp_acceptor/tcp_echo/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/network/tcp_acceptor/tcp_echo 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := tcp_echo.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_network \ 29 | -ltbox_event \ 30 | -ltbox_util \ 31 | -ltbox_base \ 32 | -ldl 33 | 34 | include $(TOP_DIR)/mk/exe_common.mk 35 | -------------------------------------------------------------------------------- /examples/network/tcp_acceptor/tcp_nc_server/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/network/tcp_acceptor/tcp_nc_server 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := tcp_nc_server.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_network \ 29 | -ltbox_event \ 30 | -ltbox_util \ 31 | -ltbox_base \ 32 | -ldl 33 | 34 | include $(TOP_DIR)/mk/exe_common.mk 35 | -------------------------------------------------------------------------------- /examples/network/tcp_client/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | all test clean distclean: 22 | @for i in $(shell ls) ; do \ 23 | if [ -d $$i ]; then \ 24 | $(MAKE) -C $$i $@ || exit $$? ; \ 25 | fi \ 26 | done 27 | -------------------------------------------------------------------------------- /examples/network/tcp_client/tcp_echo/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/network/tcp_client/tcp_echo 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := tcp_echo.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_network \ 29 | -ltbox_event \ 30 | -ltbox_util \ 31 | -ltbox_base \ 32 | -ldl 33 | 34 | include $(TOP_DIR)/mk/exe_common.mk 35 | -------------------------------------------------------------------------------- /examples/network/tcp_client/tcp_hex_client/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/network/tcp_client/tcp_hex_client 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := tcp_hex_client.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_network \ 29 | -ltbox_event \ 30 | -ltbox_util \ 31 | -ltbox_base \ 32 | -ldl 33 | 34 | include $(TOP_DIR)/mk/exe_common.mk 35 | -------------------------------------------------------------------------------- /examples/network/tcp_client/tcp_nc_client/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/network/tcp_client/tcp_nc_client 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := tcp_nc_client.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_network \ 29 | -ltbox_event \ 30 | -ltbox_util \ 31 | -ltbox_base \ 32 | -ldl 33 | 34 | include $(TOP_DIR)/mk/exe_common.mk 35 | -------------------------------------------------------------------------------- /examples/network/tcp_connector/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | all test clean distclean: 22 | @for i in $(shell ls) ; do \ 23 | if [ -d $$i ]; then \ 24 | $(MAKE) -C $$i $@ || exit $$? ; \ 25 | fi \ 26 | done 27 | -------------------------------------------------------------------------------- /examples/network/tcp_connector/tcp_echo/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/network/tcp_connector/tcp_echo 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := tcp_echo.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_network \ 29 | -ltbox_event \ 30 | -ltbox_util \ 31 | -ltbox_base \ 32 | -ldl 33 | 34 | include $(TOP_DIR)/mk/exe_common.mk 35 | -------------------------------------------------------------------------------- /examples/network/tcp_connector/tcp_nc_client/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/network/tcp_connector/tcp_nc_client 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := tcp_nc_client.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_network \ 29 | -ltbox_event \ 30 | -ltbox_util \ 31 | -ltbox_base \ 32 | -ldl 33 | 34 | include $(TOP_DIR)/mk/exe_common.mk 35 | -------------------------------------------------------------------------------- /examples/network/tcp_server/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | all test clean distclean: 22 | @for i in $(shell ls) ; do \ 23 | if [ -d $$i ]; then \ 24 | $(MAKE) -C $$i $@ || exit $$? ; \ 25 | fi \ 26 | done 27 | -------------------------------------------------------------------------------- /examples/network/tcp_server/tcp_echo/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/network/tcp_server/tcp_echo 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := tcp_echo.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_network \ 29 | -ltbox_event \ 30 | -ltbox_util \ 31 | -ltbox_base \ 32 | -ldl 33 | 34 | include $(TOP_DIR)/mk/exe_common.mk 35 | -------------------------------------------------------------------------------- /examples/network/tcp_server/tcp_nc_server/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/network/tcp_server/tcp_nc_server 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := tcp_nc_server.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_network \ 29 | -ltbox_event \ 30 | -ltbox_util \ 31 | -ltbox_base \ 32 | -ldl 33 | 34 | include $(TOP_DIR)/mk/exe_common.mk 35 | -------------------------------------------------------------------------------- /examples/network/uart/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | all test clean distclean: 22 | @for i in $(shell ls) ; do \ 23 | if [ -d $$i ]; then \ 24 | $(MAKE) -C $$i $@ || exit $$? ; \ 25 | fi \ 26 | done 27 | -------------------------------------------------------------------------------- /examples/network/uart/uart_to_uart/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/network/uart/uart_to_uart 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := uart_to_uart.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_network \ 29 | -ltbox_event \ 30 | -ltbox_util \ 31 | -ltbox_base \ 32 | -ldl 33 | 34 | include $(TOP_DIR)/mk/exe_common.mk 35 | -------------------------------------------------------------------------------- /examples/network/uart/uart_tool/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/network/uart/uart_tool 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := uart_tool.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_network \ 29 | -ltbox_event \ 30 | -ltbox_util \ 31 | -ltbox_base \ 32 | -ldl 33 | 34 | include $(TOP_DIR)/mk/exe_common.mk 35 | -------------------------------------------------------------------------------- /examples/network/udp_socket/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | all test clean distclean: 22 | @for i in $(shell ls) ; do \ 23 | if [ -d $$i ]; then \ 24 | $(MAKE) -C $$i $@ || exit $$? ; \ 25 | fi \ 26 | done 27 | -------------------------------------------------------------------------------- /examples/network/udp_socket/ping_pong/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/network/udp_socket/ping_pong 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := ping_pong.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_network \ 29 | -ltbox_event \ 30 | -ltbox_util \ 31 | -ltbox_base \ 32 | -ldl 33 | 34 | include $(TOP_DIR)/mk/exe_common.mk 35 | -------------------------------------------------------------------------------- /examples/network/udp_socket/recv_only/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/network/udp_socket/recv_only 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := recv_only.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_network \ 29 | -ltbox_event \ 30 | -ltbox_util \ 31 | -ltbox_base \ 32 | -ldl 33 | 34 | include $(TOP_DIR)/mk/exe_common.mk 35 | -------------------------------------------------------------------------------- /examples/network/udp_socket/request/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/network/udp_socket/request 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := request.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_network \ 29 | -ltbox_event \ 30 | -ltbox_util \ 31 | -ltbox_base \ 32 | -ldl 33 | 34 | include $(TOP_DIR)/mk/exe_common.mk 35 | -------------------------------------------------------------------------------- /examples/network/udp_socket/respond/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/network/udp_socket/respond 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := respond.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_network \ 29 | -ltbox_event \ 30 | -ltbox_util \ 31 | -ltbox_base \ 32 | -ldl 33 | 34 | include $(TOP_DIR)/mk/exe_common.mk 35 | -------------------------------------------------------------------------------- /examples/network/udp_socket/send_only/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/network/udp_socket/send_only 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := send_only.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_network \ 29 | -ltbox_event \ 30 | -ltbox_util \ 31 | -ltbox_base \ 32 | -ldl 33 | 34 | include $(TOP_DIR)/mk/exe_common.mk 35 | -------------------------------------------------------------------------------- /examples/network/udp_socket/send_only/send_only.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #include 21 | #include 22 | 23 | using namespace std; 24 | using namespace tbox::network; 25 | 26 | int main() 27 | { 28 | UdpSocket().send("hello", 6, SockAddr::FromString("127.0.0.1:6666")); 29 | cout << "done" << endl; 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /examples/run/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | all test clean distclean: 22 | @for i in $(shell ls) ; do \ 23 | if [ -d $$i ]; then \ 24 | $(MAKE) -C $$i $@ || exit $$? ; \ 25 | fi \ 26 | done 27 | -------------------------------------------------------------------------------- /examples/run/echo_server/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT = examples/run/echo_server 22 | 23 | LIB_NAME = echo_server 24 | LIB_VERSION_X = 0 25 | LIB_VERSION_Y = 0 26 | LIB_VERSION_Z = 1 27 | 28 | CPP_SRC_FILES = echo_server.cpp 29 | 30 | CXXFLAGS := -DMODULE_ID='"$(LIB_NAME)"' $(CXXFLAGS) 31 | 32 | ENABLE_STATIC_LIB = no 33 | ENABLE_SHARED_LIB = yes 34 | 35 | include $(TOP_DIR)/mk/lib_common.mk 36 | -------------------------------------------------------------------------------- /examples/run/nc_client/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT = examples/run/nc_client 22 | 23 | LIB_NAME = nc_client 24 | LIB_VERSION_X = 0 25 | LIB_VERSION_Y = 0 26 | LIB_VERSION_Z = 1 27 | 28 | CPP_SRC_FILES = nc_client.cpp 29 | 30 | CXXFLAGS := -DMODULE_ID='"$(LIB_NAME)"' $(CXXFLAGS) 31 | LDFLAGS += -ltbox_network 32 | 33 | ENABLE_STATIC_LIB = no 34 | ENABLE_SHARED_LIB = yes 35 | 36 | include $(TOP_DIR)/mk/lib_common.mk 37 | -------------------------------------------------------------------------------- /examples/run/timer_event/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT = examples/run/timer_event 22 | 23 | LIB_NAME = timer_event 24 | LIB_VERSION_X = 0 25 | LIB_VERSION_Y = 0 26 | LIB_VERSION_Z = 1 27 | 28 | CPP_SRC_FILES = timer_event.cpp 29 | 30 | CXXFLAGS := -DMODULE_ID='"$(LIB_NAME)"' $(CXXFLAGS) 31 | 32 | ENABLE_STATIC_LIB = no 33 | ENABLE_SHARED_LIB = yes 34 | 35 | include $(TOP_DIR)/mk/lib_common.mk 36 | -------------------------------------------------------------------------------- /examples/terminal/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | all test clean distclean: 22 | @for i in $(shell ls) ; do \ 23 | if [ -d $$i ]; then \ 24 | $(MAKE) -C $$i $@ || exit $$? ; \ 25 | fi \ 26 | done 27 | -------------------------------------------------------------------------------- /examples/terminal/stdio/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/terminal/stdio 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := main.cpp ../build_nodes.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_terminal \ 29 | -ltbox_network \ 30 | -ltbox_event \ 31 | -ltbox_util \ 32 | -ltbox_base \ 33 | -ldl 34 | 35 | include $(TOP_DIR)/mk/exe_common.mk 36 | -------------------------------------------------------------------------------- /examples/terminal/tcp_rpc/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/terminal/tcp_rpc 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := main.cpp ../build_nodes.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_terminal \ 29 | -ltbox_network \ 30 | -ltbox_event \ 31 | -ltbox_util \ 32 | -ltbox_base \ 33 | -ldl 34 | 35 | include $(TOP_DIR)/mk/exe_common.mk 36 | -------------------------------------------------------------------------------- /examples/terminal/telnetd/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/terminal/telnetd 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := main.cpp ../build_nodes.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_terminal \ 29 | -ltbox_network \ 30 | -ltbox_event \ 31 | -ltbox_util \ 32 | -ltbox_base \ 33 | -ldl 34 | 35 | include $(TOP_DIR)/mk/exe_common.mk 36 | -------------------------------------------------------------------------------- /examples/trace/01_demo/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2024 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/trace/01_demo 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := main.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_trace \ 29 | -ltbox_util \ 30 | -ltbox_base \ 31 | -lpthread -ldl 32 | 33 | include $(TOP_DIR)/mk/exe_common.mk 34 | -------------------------------------------------------------------------------- /examples/trace/02_multi_threads/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2024 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/trace/02_multi_threads 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := main.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_trace \ 29 | -ltbox_util \ 30 | -ltbox_base \ 31 | -lpthread -ldl 32 | 33 | include $(TOP_DIR)/mk/exe_common.mk 34 | -------------------------------------------------------------------------------- /examples/trace/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | all test clean distclean: 22 | @for i in $(shell ls) ; do \ 23 | if [ -d $$i ]; then \ 24 | $(MAKE) -C $$i $@ || exit $$? ; \ 25 | fi \ 26 | done 27 | -------------------------------------------------------------------------------- /examples/util/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | all test clean distclean: 22 | @for i in $(shell ls) ; do \ 23 | if [ -d $$i ]; then \ 24 | $(MAKE) -C $$i $@ || exit $$? ; \ 25 | fi \ 26 | done 27 | -------------------------------------------------------------------------------- /examples/util/json_deep_loader/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := examples/util/json_deep_loader 22 | EXE_NAME := ${PROJECT} 23 | 24 | CPP_SRC_FILES := main.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_util \ 29 | -ltbox_base \ 30 | -ldl \ 31 | 32 | include $(TOP_DIR)/mk/exe_common.mk 33 | -------------------------------------------------------------------------------- /examples/util/json_deep_loader/config/common.json: -------------------------------------------------------------------------------- 1 | { 2 | "common.a": 2 3 | } 4 | -------------------------------------------------------------------------------- /examples/util/json_deep_loader/config/main.json: -------------------------------------------------------------------------------- 1 | { 2 | "main.a": 1, 3 | "__include__":["sub/sub1.json => sub1", "common.json"] 4 | } 5 | -------------------------------------------------------------------------------- /examples/util/json_deep_loader/config/sub/sub1.json: -------------------------------------------------------------------------------- 1 | { 2 | "sub1.a": 1, 3 | "__include__": "sub2.json => sub2" 4 | } 5 | -------------------------------------------------------------------------------- /examples/util/json_deep_loader/config/sub/sub2.json: -------------------------------------------------------------------------------- 1 | [1, 2, 3, { "__include__": "../sub3.json"} ] 2 | -------------------------------------------------------------------------------- /examples/util/json_deep_loader/config/sub3.json: -------------------------------------------------------------------------------- 1 | { 2 | "sub3.a": 4 3 | } 4 | -------------------------------------------------------------------------------- /mk/lib_header_only_common.mk: -------------------------------------------------------------------------------- 1 | ################################################################ 2 | # ABOUT: 3 | # This C++ library project Makefile's common part, which can be included 4 | # into project's Makefile, to make Makefile is easy to maintain. 5 | # 6 | # HOW TO USE: 7 | # before include this file. those variables need be specified. 8 | # LIB_NAME, STAGING_DIR, HEAD_FILES 9 | ################################################################ 10 | 11 | .PHONY: all install uninstall 12 | 13 | SRC_HEAD_TO_INSTALL_HEAD = $(addprefix $(STAGING_DIR)/include/$(LIB_NAME)/,$(1)) 14 | 15 | define CREATE_INSTALL_HEAD_TARGET 16 | $(call SRC_HEAD_TO_INSTALL_HEAD,$(1)) : $(1) 17 | @install -Dm 640 $$^ $$@ 18 | endef 19 | 20 | $(foreach src,$(HEAD_FILES),$(eval $(call CREATE_INSTALL_HEAD_TARGET,$(src)))) 21 | 22 | INSTALL_HEADS := $(foreach src,$(HEAD_FILES),$(call SRC_HEAD_TO_INSTALL_HEAD,$(src))) 23 | 24 | all : install 25 | 26 | install: $(INSTALL_HEADS) 27 | 28 | uninstall: 29 | rm -rf $(STAGING_DIR)/include/$(LIB_NAME) 30 | 31 | clean: 32 | 33 | -------------------------------------------------------------------------------- /modules/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | all test: 22 | @for i in $(MODULES); do \ 23 | [ ! -d $$i ] || $(MAKE) -C $$i $@ || exit $$? ; \ 24 | done 25 | -------------------------------------------------------------------------------- /modules/base/assert.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | /** 21 | * 定义宏 TBOX_ASSERT(), 令其它错误信息打印到Log日志上 22 | */ 23 | #ifndef TBOX_BASE_ASSERT_H_20221026 24 | #define TBOX_BASE_ASSERT_H_20221026 25 | 26 | #include 27 | #include "log.h" 28 | 29 | //! WARN: Don't use this in log related module 30 | 31 | #ifdef NDEBUG //! 在非调试模式下,什么都不用做 32 | # define TBOX_ASSERT(expr) void(0) 33 | #else //! 在调试模式下,要在日志中打印错误并退出 34 | # define TBOX_ASSERT(expr) \ 35 | if (!(expr)) { \ 36 | LogFatal("TBOX_ASSERT(%s)", #expr); \ 37 | std::abort(); \ 38 | } 39 | #endif 40 | 41 | #endif //TBOX_BASE_ASSERT_H_20221026 42 | -------------------------------------------------------------------------------- /modules/base/backtrace.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_BACKTRACE_H_20220708 21 | #define TBOX_BACKTRACE_H_20220708 22 | 23 | #include 24 | #include "log.h" 25 | 26 | namespace tbox { 27 | 28 | /// 导出调用栈 29 | std::string DumpBacktrace(const unsigned int max_frames = 64); 30 | 31 | } 32 | 33 | #define LogBacktrace(level) LogPrintf((level), "call stack:\n%s", tbox::DumpBacktrace().c_str()) 34 | 35 | #endif // TBOX_BACKTRACE_H_20220708 36 | -------------------------------------------------------------------------------- /modules/base/backtrace_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #include "backtrace.h" 21 | #include 22 | 23 | #include "log_output.h" 24 | 25 | namespace tbox { 26 | 27 | TEST(Backtrace, _) 28 | { 29 | LogOutput_Enable(); 30 | LogBacktrace(LOG_LEVEL_TRACE); 31 | LogOutput_Disable(); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /modules/base/func_types.h: -------------------------------------------------------------------------------- 1 | #ifndef TBOX_BASE_FUNC_TYPES_H_20240107 2 | #define TBOX_BASE_FUNC_TYPES_H_20240107 3 | 4 | #include 5 | 6 | //! 定义最常用的std::function类型 7 | 8 | namespace tbox { 9 | 10 | using VoidFunc = std::function; 11 | using BoolFunc = std::function; 12 | 13 | } 14 | 15 | #endif //TBOX_BASE_FUNC_TYPES_H_20240107 16 | -------------------------------------------------------------------------------- /modules/base/json.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2023 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_BASE_JSON_IMP_H_20211227 21 | #define TBOX_BASE_JSON_IMP_H_20211227 22 | 23 | #include "json_fwd.h" 24 | 25 | #include 26 | //! 如果找到不该文件,则从 github 下载: 27 | //! https://github.com/nlohmann/json/blob/v3.10.4/single_include/nlohmann/json.hpp 28 | //! 下载链接:https://raw.githubusercontent.com/nlohmann/json/v3.10.4/single_include/nlohmann/json.hpp 29 | //! 放置到 /usr/local/include/nlohmann/ 目录下 30 | 31 | #endif //TBOX_BASE_JSON_IMP_H_20211227 32 | -------------------------------------------------------------------------------- /modules/base/json_fwd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_BASE_JSON_H_20211227 21 | #define TBOX_BASE_JSON_H_20211227 22 | 23 | #include 24 | 25 | //! 如果找到不该文件,则从 github 下载: 26 | //! https://github.com/nlohmann/json/blob/v3.10.4/include/nlohmann/json_fwd.hpp 27 | //! 下载链接:https://raw.githubusercontent.com/nlohmann/json/v3.10.4/include/nlohmann/json_fwd.hpp 28 | //! 放置到 /usr/local/include/nlohmann/ 目录下 29 | 30 | namespace tbox { 31 | 32 | using Json = nlohmann::json; 33 | using OrderedJson = nlohmann::ordered_json; 34 | 35 | } 36 | 37 | #endif //TBOX_BASE_JSON_H_20211227 38 | -------------------------------------------------------------------------------- /modules/base/log_output.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef LOG_OUTPUT_H 21 | #define LOG_OUTPUT_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /// 开启日志输出 28 | void LogOutput_Enable(); 29 | 30 | /// 关闭日志输出 31 | void LogOutput_Disable(); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif //LOG_OUTPUT_H 38 | -------------------------------------------------------------------------------- /modules/base/memblock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_BASE_MEMBLOCK_H_20200817 21 | #define TBOX_BASE_MEMBLOCK_H_20200817 22 | 23 | #include 24 | 25 | namespace tbox { 26 | using Memblock = std::vector; 27 | } 28 | 29 | #endif //TBOX_BASE_MEMBLOCK_H_20200817 30 | -------------------------------------------------------------------------------- /modules/base/recorder_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2024 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #include 21 | #include "recorder.h" 22 | 23 | namespace tbox { 24 | namespace trace { 25 | 26 | TEST(Recorder, Scope) { 27 | RECORD_SCOPE(); 28 | if (true) { 29 | RECORD_SCOPE(); 30 | } 31 | } 32 | 33 | TEST(Recorder, Event) { 34 | RECORD_EVENT(); 35 | RECORD_EVENT(); 36 | } 37 | 38 | TEST(Recorder, Named) { 39 | RECORD_DEFINE(a); 40 | RECORD_DEFINE(b); 41 | 42 | RECORD_START(a); 43 | RECORD_START(b); 44 | 45 | RECORD_STOP(a); 46 | RECORD_STOP(b); 47 | } 48 | 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /modules/base/version.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | namespace tbox { 21 | 22 | void GetTboxVersion(int &major, int &minor, int &rev) 23 | { 24 | major = TBOX_VERSION_MAJOR; 25 | minor = TBOX_VERSION_MINOR; 26 | rev = TBOX_VERSION_REVISION; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /modules/base/version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_BASE_VERSION_H 21 | #define TBOX_BASE_VERSION_H 22 | 23 | namespace tbox { 24 | 25 | void GetTboxVersion(int &major, int &minor, int &rev); 26 | 27 | } 28 | #endif //TBOX_BASE_VERSION_H 29 | -------------------------------------------------------------------------------- /modules/base/wrapped_recorder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2024 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | /** 21 | * 在 recorder.h 的基础上加 ENABLE_TRACE_RECORDER 宏开关 22 | * 使 recorder 功能可以在编译期间被关彻底关闭 23 | */ 24 | #ifndef TBOX_TRACE_WRAPPED_RECORDER_H_20240610 25 | #define TBOX_TRACE_WRAPPED_RECORDER_H_20240610 26 | 27 | #if ENABLE_TRACE_RECORDER 28 | #include "recorder.h" 29 | #else 30 | #define RECORD_SCOPE() 31 | #define RECORD_DEFINE(name) 32 | #define RECORD_START(name) 33 | #define RECORD_STOP(name) 34 | #define RECORD_EVENT() 35 | #endif 36 | 37 | #endif //TBOX_TRACE_WRAPPED_RECORDER_H_20240610 38 | -------------------------------------------------------------------------------- /modules/crypto/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT = crypto 22 | LIB_NAME = crypto 23 | LIB_VERSION_X = 0 24 | LIB_VERSION_Y = 0 25 | LIB_VERSION_Z = 1 26 | 27 | HEAD_FILES = \ 28 | md5.h \ 29 | aes.h \ 30 | 31 | CPP_SRC_FILES = \ 32 | md5.cpp \ 33 | aes.cpp \ 34 | 35 | CXXFLAGS := -DMODULE_ID='"tbox.crypto"' $(CXXFLAGS) 36 | 37 | TEST_CPP_SRC_FILES = \ 38 | $(CPP_SRC_FILES) \ 39 | md5_test.cpp \ 40 | aes_test.cpp \ 41 | 42 | TEST_LDFLAGS := $(LDFLAGS) -ltbox_util -ltbox_base -ldl 43 | 44 | ENABLE_SHARED_LIB = no 45 | 46 | include $(TOP_DIR)/mk/lib_tbox_common.mk 47 | -------------------------------------------------------------------------------- /modules/crypto/aes_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #include 21 | #include "aes.h" 22 | 23 | namespace tbox { 24 | namespace crypto { 25 | 26 | //! 加密解密之后结果一致 27 | TEST(AES, CipherAndInvCipher) { 28 | uint8_t plaintext[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; 29 | uint8_t key[16] = {0x12, 0x33, 0x34, 0x55, 0x43}; //! Any 30 | 31 | AES aes(key); 32 | uint8_t ciphertext[16] = {0}; 33 | aes.cipher(plaintext, ciphertext); 34 | 35 | uint8_t invciphertext[16] = {0}; 36 | aes.invcipher(ciphertext, invciphertext); 37 | EXPECT_EQ(memcmp(plaintext, invciphertext, 16), 0); 38 | } 39 | 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /modules/dbus/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT = dbus 22 | LIB_NAME = dbus 23 | 24 | LIB_VERSION_X = 0 25 | LIB_VERSION_Y = 0 26 | LIB_VERSION_Z = 1 27 | 28 | HEAD_FILES = \ 29 | loop.h \ 30 | connection.h 31 | 32 | CPP_SRC_FILES = \ 33 | loop.cpp \ 34 | connection.cpp 35 | 36 | CXXFLAGS += -DMODULE_ID='"tbox.dbus"' 37 | CXXFLAGS += $(shell pkg-config --cflags dbus-1) 38 | LDFLAGS += $(shell pkg-config --libs dbus-1) 39 | 40 | TEST_CPP_SRC_FILES = \ 41 | 42 | TEST_LDFLAGS := $(LDFLAGS) -ltbox_event -ltbox_base -ldl 43 | ENABLE_SHARED_LIB = no 44 | 45 | include $(TOP_DIR)/mk/lib_tbox_common.mk 46 | -------------------------------------------------------------------------------- /modules/event/engines/select/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2024 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_EVENT_SELECT_TYPES_H_20240619 21 | #define TBOX_EVENT_SELECT_TYPES_H_20240619 22 | 23 | #include 24 | 25 | namespace tbox { 26 | namespace event { 27 | 28 | class SelectFdEvent; 29 | 30 | //! 同一个fd共享的数据 31 | struct SelectFdSharedData { 32 | int fd = 0; //!< 文件描述符 33 | int ref = 0; //!< 引用计数 34 | 35 | int read_event_num = 0; //!< 监听可读事件的FdEvent个数 36 | int write_event_num = 0; //!< 监听可写事件的FdEvent个数 37 | int except_event_num = 0; //!< 监听异常事件的FdEvent个数 38 | 39 | std::vector fd_events; 40 | }; 41 | 42 | } 43 | } 44 | 45 | #endif //TBOX_EVENT_SELECT_TYPES_H_20240619 46 | -------------------------------------------------------------------------------- /modules/event/forward.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_EVENT_FORWARD_H_20170627 21 | #define TBOX_EVENT_FORWARD_H_20170627 22 | 23 | namespace tbox{ 24 | namespace event { 25 | 26 | class Loop; 27 | class FdEvent; 28 | class TimerEvent; 29 | class SignalEvent; 30 | 31 | } 32 | } 33 | 34 | #endif //TBOX_EVENT_FORWARD_H_20170627 35 | -------------------------------------------------------------------------------- /modules/event/misc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_EVENT_MISC_H_20220303 21 | #define TBOX_EVENT_MISC_H_20220303 22 | 23 | namespace tbox { 24 | namespace event { 25 | 26 | bool CreateFdPair(int &read_fd, int &write_fd); 27 | int CreateEventFd(); 28 | 29 | } 30 | } 31 | 32 | #endif //TBOX_EVENT_MISC_H_20220303 33 | -------------------------------------------------------------------------------- /modules/event/stat_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #include 21 | #include "stat.h" 22 | #include 23 | 24 | namespace tbox { 25 | namespace event { 26 | 27 | using namespace std; 28 | 29 | TEST(Stat, Stream) 30 | { 31 | const char *target_str = R"(stat_time: 10000 us 32 | time_cost: 60 us 33 | max_time_cost: 50 us 34 | event_count: 2 35 | avg_cost: 30 us 36 | cpu: 0.6 % 37 | )"; 38 | 39 | Stat stat; 40 | stat.event_count = 2; 41 | stat.peak_cost_us = 50; 42 | stat.time_cost_us = 60; 43 | stat.stat_time_us = 10000; 44 | 45 | ostringstream oss; 46 | oss << stat; 47 | 48 | EXPECT_EQ(oss.str(), target_str); 49 | } 50 | 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /modules/event/timer_event.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_EVENT_TIMER_ITEM_H_20170627 21 | #define TBOX_EVENT_TIMER_ITEM_H_20170627 22 | 23 | #include 24 | #include 25 | 26 | #include "event.h" 27 | 28 | namespace tbox { 29 | namespace event { 30 | 31 | class TimerEvent : public Event { 32 | public: 33 | using Event::Event; 34 | 35 | virtual bool initialize(const std::chrono::milliseconds &time_span, Mode mode) = 0; 36 | 37 | using CallbackFunc = std::function; 38 | virtual void setCallback(CallbackFunc &&cb) = 0; 39 | 40 | public: 41 | virtual ~TimerEvent() { } 42 | }; 43 | 44 | } 45 | } 46 | 47 | #endif //TBOX_EVENT_TIMER_ITEM_H_20170627 48 | -------------------------------------------------------------------------------- /modules/eventx/loop_thread_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #include "loop_thread.h" 21 | 22 | #include 23 | 24 | namespace tbox { 25 | namespace eventx { 26 | namespace { 27 | 28 | TEST(LoopThread, runNow) { 29 | bool tag = false; 30 | { 31 | LoopThread lp; 32 | lp.loop()->runInLoop([&] { tag = true; }); 33 | } 34 | EXPECT_TRUE(tag); 35 | } 36 | 37 | TEST(LoopThread, runLater) { 38 | bool tag = false; 39 | LoopThread lp(false); 40 | lp.loop()->runInLoop([&] { tag = true; }); 41 | lp.start(); 42 | lp.stop(); 43 | EXPECT_TRUE(tag); 44 | } 45 | 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /modules/flow/event.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_FLOW_EVENT_H_20221022 21 | #define TBOX_FLOW_EVENT_H_20221022 22 | 23 | namespace tbox { 24 | namespace flow { 25 | 26 | struct Event { 27 | using ID = int; 28 | 29 | ID id = 0; 30 | const void *extra = nullptr; 31 | 32 | Event() { } 33 | 34 | template 35 | Event(ET e) : id(static_cast(e)) { } 36 | 37 | template 38 | Event(ET e, DT *p) : id(static_cast(e)), extra(p) { } 39 | }; 40 | 41 | } 42 | } 43 | 44 | #endif //TBOX_FLOW_EVENT_H_20221022 45 | -------------------------------------------------------------------------------- /modules/flow/event_publisher.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_FLOW_EVENT_PUBLISHER_H_20221001 21 | #define TBOX_FLOW_EVENT_PUBLISHER_H_20221001 22 | 23 | #include "event.h" 24 | 25 | namespace tbox { 26 | namespace flow { 27 | 28 | class EventSubscriber; 29 | 30 | class EventPublisher { 31 | public: 32 | virtual void subscribe(EventSubscriber *subscriber) = 0; 33 | virtual void unsubscribe(EventSubscriber *subscriber) = 0; 34 | virtual void publish(Event event) = 0; 35 | 36 | protected: 37 | virtual ~EventPublisher() { } 38 | }; 39 | 40 | } 41 | } 42 | 43 | #endif //TBOX_FLOW_EVENT_PUBLISHER_H_20221001 44 | -------------------------------------------------------------------------------- /modules/flow/event_publisher_impl_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | 21 | -------------------------------------------------------------------------------- /modules/flow/event_subscriber.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_FLOW_EVENT_SUBSCRIBER_H_20221001 21 | #define TBOX_FLOW_EVENT_SUBSCRIBER_H_20221001 22 | 23 | #include "event.h" 24 | 25 | namespace tbox { 26 | namespace flow { 27 | 28 | class EventSubscriber { 29 | public: 30 | virtual bool onEvent(Event event) = 0; 31 | 32 | protected: 33 | virtual ~EventSubscriber() { } 34 | }; 35 | 36 | } 37 | } 38 | 39 | #endif //TBOX_FLOW_EVENT_SUBSCRIBER_H_20221001 40 | -------------------------------------------------------------------------------- /modules/http/README.md: -------------------------------------------------------------------------------- 1 | # HTTP 模块 2 | 3 | 本模块的设计初宗并非为了取代 Apache, Nginx 这类已非常成熟的 HTTP 服务器,而是为了补全 4 | 我们服务程序中无法对外提供RESTfull API的缺口。 5 | 6 | 本模块在设计时参考了 node.js 中 Express 的中间件设计思想。接口简洁,使用方便。 7 | 8 | 示例: 9 | ```c++ 10 | 11 | using namespace tbox; 12 | using namespace tbox::event; 13 | using namespace tbox::network; 14 | using namespace tbox::http; 15 | using namespace tbox::http::server; 16 | 17 | //! 假设已存在Loop的实例指针 sp_loop 18 | 19 | Server srv(sp_loop); 20 | if (!srv.initialize(network::SockAddr::FromString(bind_addr), 1)) { 21 | LogErr("init srv fail"); 22 | return 0; 23 | } 24 | 25 | srv.start(); 26 | 27 | //! 添加请求处理 28 | srv.use( 29 | [&](ContextSptr ctx, const NextFunc &next) { 30 | ctx->res().status_code = StatusCode::k200_OK; 31 | ctx->res().body = "Hello!"; 32 | } 33 | ); 34 | 35 | //! 其它杂项,比如:设置退出中断信号 36 | 37 | sp_loop->runLoop(); 38 | srv.cleanup(); 39 | 40 | ``` 41 | 42 | 具体使用,请参考 example/ 下的示例。 43 | -------------------------------------------------------------------------------- /modules/http/client/client.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #include "client.h" 21 | 22 | namespace tbox { 23 | namespace http { 24 | namespace client { 25 | 26 | using namespace event; 27 | using namespace network; 28 | 29 | Client::Client(Loop *wp_loop) 30 | { 31 | (void)wp_loop; 32 | } 33 | 34 | Client::~Client() 35 | { } 36 | 37 | bool Client::initialize(const SockAddr &server_addr) 38 | { 39 | (void)server_addr; 40 | return false; 41 | } 42 | 43 | void Client::request(const Request &req, const RespondCallback &cb) 44 | { 45 | (void)req; 46 | (void)cb; 47 | } 48 | 49 | void Client::cleanup() 50 | { } 51 | 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /modules/http/request.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_HTTP_REQUEST_H_20220501 21 | #define TBOX_HTTP_REQUEST_H_20220501 22 | 23 | #include "common.h" 24 | #include "url.h" 25 | 26 | namespace tbox { 27 | namespace http { 28 | 29 | //! 请求 30 | struct Request { 31 | Method method = Method::kUnset; 32 | HttpVer http_ver = HttpVer::kUnset; 33 | Url::Path url; 34 | Headers headers; 35 | std::string body; 36 | 37 | bool isValid() const; 38 | std::string toString() const; 39 | }; 40 | 41 | } 42 | } 43 | 44 | #endif //TBOX_HTTP_REQUEST_H_20220501 45 | -------------------------------------------------------------------------------- /modules/http/respond.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_HTTP_RESPOND_H_20220501 21 | #define TBOX_HTTP_RESPOND_H_20220501 22 | 23 | #include "common.h" 24 | 25 | namespace tbox { 26 | namespace http { 27 | 28 | //! 回复 29 | struct Respond { 30 | HttpVer http_ver = HttpVer::kUnset; 31 | StatusCode status_code = StatusCode::kUnset; 32 | Headers headers; 33 | std::string body; 34 | 35 | bool isValid() const; 36 | std::string toString() const; 37 | }; 38 | 39 | } 40 | } 41 | 42 | #endif //TBOX_HTTP_RESPOND_H_20220501 43 | -------------------------------------------------------------------------------- /modules/http/server/middleware.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_HTTP_MIDDLEWARE_H_20220501 21 | #define TBOX_HTTP_MIDDLEWARE_H_20220501 22 | 23 | #include "types.h" 24 | 25 | namespace tbox { 26 | namespace http { 27 | namespace server { 28 | 29 | //! 中间件 30 | class Middleware { 31 | public: 32 | ~Middleware() { } 33 | 34 | public: 35 | virtual void handle(ContextSptr sp_ctx, const NextFunc &next) = 0; 36 | }; 37 | 38 | } 39 | } 40 | } 41 | 42 | #endif //TBOX_HTTP_MIDDLEWARE_H_20220501 43 | -------------------------------------------------------------------------------- /modules/http/server/middlewares/route_key.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2025 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_HTTP_SERVER_ROUTE_KEY_H_20250419 21 | #define TBOX_HTTP_SERVER_ROUTE_KEY_H_20250419 22 | 23 | #include "../../common.h" 24 | 25 | namespace tbox { 26 | namespace http { 27 | namespace server { 28 | 29 | //! 用于存储处理函数的映射 30 | struct RouteKey { 31 | Method method; 32 | std::string path; 33 | 34 | bool operator<(const RouteKey& other) const { 35 | if (method != other.method) 36 | return method < other.method; 37 | return path < other.path; 38 | } 39 | }; 40 | 41 | } 42 | } 43 | } 44 | 45 | #endif // TBOX_HTTP_SERVER_ROUTE_KEY_H_20250419 46 | -------------------------------------------------------------------------------- /modules/http/server/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_HTTP_SERVER_TYPES_H_20220503 21 | #define TBOX_HTTP_SERVER_TYPES_H_20220503 22 | 23 | #include 24 | #include 25 | 26 | namespace tbox { 27 | namespace http { 28 | namespace server { 29 | 30 | class Context; 31 | using ContextSptr = std::shared_ptr; 32 | using NextFunc = std::function; 33 | using RequestHandler = std::function; 34 | 35 | } 36 | } 37 | } 38 | 39 | #endif //TBOX_HTTP_SERVER_TYPES_H_20220503 40 | -------------------------------------------------------------------------------- /modules/jsonrpc/inner_types.h: -------------------------------------------------------------------------------- 1 | #ifndef TBOX_JSONRPC_INNER_TYPES_H_20230813 2 | #define TBOX_JSONRPC_INNER_TYPES_H_20230813 3 | 4 | namespace tbox { 5 | namespace jsonrpc { 6 | 7 | enum ErrorCode { 8 | kParseError = -32700, 9 | kInvalidRequest = -32600, 10 | kMethodNotFound = -32601, 11 | kInvalidParams = -32602, 12 | kInternalError = -32603, 13 | kRequestTimeout = -32000, 14 | }; 15 | 16 | } 17 | } 18 | 19 | #endif //TBOX_JSONRPC_INNER_TYPES_H_20230813 20 | -------------------------------------------------------------------------------- /modules/jsonrpc/protos/packet_proto.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2023 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_JSONRPC_PACKET_PROTO_H_20230831 21 | #define TBOX_JSONRPC_PACKET_PROTO_H_20230831 22 | 23 | #include "../proto.h" 24 | 25 | namespace tbox { 26 | namespace jsonrpc { 27 | 28 | /** 29 | * 分包协议 30 | * 31 | * 约定onRecvData()中指定的内容都是一个完整的JSON字串 32 | * 适用于已经有分包机制的传输协议,如:UDP, MQTT, HTTP 33 | */ 34 | class PacketProto : public Proto { 35 | public: 36 | virtual ssize_t onRecvData(const void *data_ptr, size_t data_size) override; 37 | 38 | protected: 39 | virtual void sendJson(const Json &js) override; 40 | }; 41 | 42 | } 43 | } 44 | 45 | #endif //TBOX_JSONRPC_PACKET_PROTO_H_20230831 46 | -------------------------------------------------------------------------------- /modules/log/async_stdout_sink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_LOG_ASYNC_STDOUT_SINK_H_20220408 21 | #define TBOX_LOG_ASYNC_STDOUT_SINK_H_20220408 22 | 23 | #include "async_sink.h" 24 | 25 | #include 26 | 27 | namespace tbox { 28 | namespace log { 29 | 30 | class AsyncStdoutSink : public AsyncSink { 31 | public: 32 | AsyncStdoutSink(); 33 | 34 | protected: 35 | virtual void endline() override; 36 | virtual void flush() override; 37 | 38 | private: 39 | std::vector buffer_; 40 | }; 41 | 42 | } 43 | } 44 | 45 | #endif //TBOX_LOG_ASYNC_STDOUT_SINK_H_20220408 46 | -------------------------------------------------------------------------------- /modules/log/async_syslog_sink.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #include 21 | #include "async_syslog_sink.h" 22 | 23 | namespace tbox { 24 | namespace log { 25 | 26 | AsyncSyslogSink::AsyncSyslogSink() 27 | { 28 | AsyncSink::Config cfg; 29 | cfg.buff_size = 10240; 30 | cfg.buff_min_num = 2; 31 | cfg.buff_max_num = 20; 32 | cfg.interval = 100; 33 | 34 | setConfig(cfg); 35 | } 36 | 37 | void AsyncSyslogSink::endline() 38 | { 39 | cache_.push_back('\0'); 40 | ::syslog(LOG_INFO, "%s", cache_.data()); 41 | 42 | cache_.clear(); 43 | } 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /modules/log/async_syslog_sink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_LOG_ASYNC_SYSLOG_SINK_H_20220408 21 | #define TBOX_LOG_ASYNC_SYSLOG_SINK_H_20220408 22 | 23 | #include "async_sink.h" 24 | 25 | namespace tbox { 26 | namespace log { 27 | 28 | class AsyncSyslogSink : public AsyncSink { 29 | public: 30 | AsyncSyslogSink(); 31 | 32 | protected: 33 | virtual void endline() override; 34 | virtual void flush() override { } 35 | }; 36 | 37 | } 38 | } 39 | 40 | #endif //TBOX_LOG_ASYNC_SYSLOG_SINK_H_20220408 41 | -------------------------------------------------------------------------------- /modules/log/sync_stdout_sink.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2023 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_LOG_SYNC_STDOUT_SINK_H_20231006 21 | #define TBOX_LOG_SYNC_STDOUT_SINK_H_20231006 22 | 23 | #include "sink.h" 24 | 25 | namespace tbox { 26 | namespace log { 27 | 28 | class SyncStdoutSink : public Sink { 29 | protected: 30 | virtual void onLogFrontEnd(const LogContent *content) override; 31 | }; 32 | 33 | } 34 | } 35 | 36 | #endif //TBOX_LOG_SYNC_STDOUT_SINK_H_20231006 37 | -------------------------------------------------------------------------------- /modules/main/trace.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2024 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_MAIN_TRACE_H_20240607 21 | #define TBOX_MAIN_TRACE_H_20240607 22 | 23 | #include 24 | #include "context.h" 25 | 26 | namespace tbox { 27 | namespace main { 28 | 29 | class Trace { 30 | public: 31 | void fillDefaultConfig(Json &cfg) const; 32 | bool initialize(Context &ctx, const Json &cfg); 33 | 34 | protected: 35 | void initShell(terminal::TerminalNodes &term); 36 | }; 37 | 38 | } 39 | } 40 | 41 | #endif //TBOX_MAIN_TRACE_H_20240607 42 | -------------------------------------------------------------------------------- /modules/mqtt/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT = mqtt 22 | LIB_NAME = mqtt 23 | LIB_VERSION_X = 0 24 | LIB_VERSION_Y = 0 25 | LIB_VERSION_Z = 1 26 | 27 | HEAD_FILES = client.h 28 | 29 | CPP_SRC_FILES = client.cpp 30 | 31 | CXXFLAGS := -DMODULE_ID='"tbox.mqtt"' $(CXXFLAGS) 32 | 33 | TEST_CPP_SRC_FILES = \ 34 | 35 | TEST_LDFLAGS := $(LDFLAGS) -ltbox_event -ltbox_base -lmosquitto -ldl 36 | 37 | ENABLE_SHARED_LIB = no 38 | 39 | include $(TOP_DIR)/mk/lib_tbox_common.mk 40 | -------------------------------------------------------------------------------- /modules/network/README: -------------------------------------------------------------------------------- 1 | 通信模块 2 | 包含:串口、TCP、UDP 等 3 | -------------------------------------------------------------------------------- /modules/network/net_if.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_NETWORK_NET_IF_H_20221226 21 | #define TBOX_NETWORK_NET_IF_H_20221226 22 | 23 | #include 24 | #include 25 | 26 | #include "ip_address.h" 27 | 28 | namespace tbox { 29 | namespace network { 30 | 31 | struct NetIF { 32 | std::string name; 33 | IPAddress ip; 34 | IPAddress mask; 35 | uint32_t flags = 0; 36 | }; 37 | 38 | bool GetNetIF(std::vector &net_if_vec); 39 | bool GetNetIF(const std::string &name, std::vector &net_if_vec); 40 | 41 | } 42 | } 43 | 44 | #endif //TBOX_NETWORK_NET_IF_H_20221226 45 | -------------------------------------------------------------------------------- /modules/run/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := run 22 | EXE_NAME := run 23 | 24 | CPP_SRC_FILES = main.cpp 25 | 26 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 27 | LDFLAGS += \ 28 | -ltbox_main \ 29 | -ltbox_coroutine \ 30 | -ltbox_trace \ 31 | -ltbox_terminal \ 32 | -ltbox_network \ 33 | -ltbox_eventx \ 34 | -ltbox_event \ 35 | -ltbox_log \ 36 | -ltbox_util \ 37 | -ltbox_base \ 38 | -lpthread \ 39 | -ldl \ 40 | -rdynamic 41 | 42 | include $(TOP_DIR)/mk/exe_common.mk 43 | -------------------------------------------------------------------------------- /modules/tbox: -------------------------------------------------------------------------------- 1 | ../modules -------------------------------------------------------------------------------- /modules/terminal/README.md: -------------------------------------------------------------------------------- 1 | # 是什么? 2 | 3 | terminal 是一个提供与运行中程序类似shell交互命令终端的模块。 4 | 5 | # 为什么需要它? 6 | 7 | 在服务程序运行时,通常只会通过日志输出程序的执行过程。开发或运维人员无法与它进行直接的交互。 8 | 比如以下场景: 9 | 10 | * 在开发过程中,工程师还没有来得及实现完整的界面交互,但又想让程序模块执行某个动作; 11 | * 当程序运行异常的时候,工程师非常希望能打印关键的信息方便排查; 12 | * 在程序遇到突发状态时,运维人员希望在不停止服务的前提下,调整运行参数。 13 | 14 | 有了 terminal,开发或运维工程师可直接与程序通过命令的形式进行交互。 15 | 只需要 telnet 登陆进去,通过命令的方式让它执行指定的函数,即可满足上述场景的需求。 16 | 从而减少工程师的调试与运维工程量。 17 | 18 | terminal 的设计模仿 Bash。 19 | 命令的组织非常类似文件系统的目录树: 20 | 21 | ``` 22 | # tree 23 | |-- dir1 24 | | |-- dir1_1 25 | | | |-- async* 26 | | | `-- root(R) 27 | | `-- dir1_2 28 | | `-- sync* 29 | |-- dir2 30 | `-- sync* 31 | ``` 32 | 33 | 支持 cd, ls, tree, pwd, history, !n, !-n, !! 等常用命令; 34 | 还支持常用的按键动作 UP, DOWN, LEFT, RIGHT, DELETE, HOME, END。 35 | 36 | # 目前有哪里 telnet 客户端通过了测试? 37 | 38 | * Windows 自带 telnet 命令 39 | * Linux 终端 telnet 命令 40 | * Putty telnet 连接 41 | * XShell telnet 连接 42 | * Tabby telnet profile (注意:Input mode 要设置为 Normal) 43 | 44 | -------------------------------------------------------------------------------- /modules/terminal/impl/func_node.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #include "func_node.h" 21 | 22 | namespace tbox { 23 | namespace terminal { 24 | 25 | FuncNode::FuncNode(const Func &func, const std::string &help) : 26 | Node(help), func_(func) 27 | { } 28 | 29 | void FuncNode::execute(const Session &s, const Args &a) const 30 | { 31 | if (func_) 32 | func_(s, a); 33 | } 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /modules/terminal/impl/func_node.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_TERMINAL_FUNC_NODE_H_20220207 21 | #define TBOX_TERMINAL_FUNC_NODE_H_20220207 22 | 23 | #include "node.h" 24 | #include 25 | 26 | namespace tbox { 27 | namespace terminal { 28 | 29 | class FuncNode : public Node { 30 | public: 31 | FuncNode(const Func &func, const std::string &help); 32 | 33 | virtual NodeType type() const override { return NodeType::kFunc; } 34 | void execute(const Session &s, const Args &a) const; 35 | 36 | private: 37 | Func func_; 38 | }; 39 | 40 | } 41 | } 42 | 43 | #endif //TBOX_TERMINAL_FUNC_NODE_H_20220207 44 | -------------------------------------------------------------------------------- /modules/terminal/impl/inner_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_TERMINAL_INNER_TYPES_H_20220214 21 | #define TBOX_TERMINAL_INNER_TYPES_H_20220214 22 | 23 | #include "../types.h" 24 | 25 | namespace tbox { 26 | namespace terminal { 27 | 28 | enum class NodeType { kFunc, kDir }; 29 | 30 | struct NodeInfo { 31 | std::string name; 32 | NodeToken token; 33 | 34 | NodeInfo(const std::string &n, const NodeToken &t) : 35 | name(n), token(t) { } 36 | }; 37 | 38 | using PathItem = std::pair; 39 | using Path = std::vector; 40 | 41 | } 42 | } 43 | 44 | #endif //TBOX_TERMINAL_INNER_TYPES_H_20220214 45 | -------------------------------------------------------------------------------- /modules/terminal/impl/node.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_TERMINAL_NODE_H_20220207 21 | #define TBOX_TERMINAL_NODE_H_20220207 22 | 23 | #include "inner_types.h" 24 | 25 | namespace tbox { 26 | namespace terminal { 27 | 28 | class Node { 29 | public: 30 | explicit Node(const std::string &help) : help_(help) { } 31 | virtual ~Node() { } 32 | 33 | virtual NodeType type() const = 0; 34 | std::string help() const { return help_; } 35 | 36 | private: 37 | std::string help_; 38 | }; 39 | 40 | } 41 | } 42 | 43 | #endif //TBOX_TERMINAL_NODE_H_20220207 44 | -------------------------------------------------------------------------------- /modules/terminal/service/stdio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2025 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_TERMINAL_STDIO_H_20250325 21 | #define TBOX_TERMINAL_STDIO_H_20250325 22 | 23 | #include 24 | 25 | namespace tbox { 26 | namespace terminal { 27 | 28 | class TerminalInteract; 29 | 30 | class Stdio { 31 | public: 32 | Stdio(event::Loop *wp_loop, TerminalInteract *wp_terminal); 33 | ~Stdio(); 34 | 35 | public: 36 | bool initialize(); 37 | bool start(); 38 | void stop(); 39 | void cleanup(); 40 | 41 | private: 42 | class Impl; 43 | Impl *impl_ = nullptr; 44 | }; 45 | 46 | } 47 | } 48 | 49 | #endif //TBOX_TERMINAL_STDIO_H_20250325 50 | -------------------------------------------------------------------------------- /modules/terminal/service/tcp_rpc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_TERMINAL_TCP_RPC_H_20220306 21 | #define TBOX_TERMINAL_TCP_RPC_H_20220306 22 | 23 | #include 24 | 25 | namespace tbox { 26 | namespace terminal { 27 | 28 | class TerminalInteract; 29 | 30 | class TcpRpc { 31 | public: 32 | TcpRpc(event::Loop *wp_loop, TerminalInteract *wp_terminal); 33 | ~TcpRpc(); 34 | 35 | public: 36 | bool initialize(const std::string &bind_addr); 37 | bool start(); 38 | void stop(); 39 | void cleanup(); 40 | 41 | private: 42 | class Impl; 43 | Impl *impl_ = nullptr; 44 | }; 45 | 46 | } 47 | } 48 | 49 | #endif //TBOX_TERMINAL_TCP_RPC_H_20220306 50 | -------------------------------------------------------------------------------- /modules/terminal/service/telnetd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_TERMINAL_TELNETD_H_20220127 21 | #define TBOX_TERMINAL_TELNETD_H_20220127 22 | 23 | #include 24 | 25 | namespace tbox { 26 | namespace terminal { 27 | 28 | class TerminalInteract; 29 | 30 | class Telnetd { 31 | public: 32 | Telnetd(event::Loop *wp_loop, TerminalInteract *wp_terminal); 33 | ~Telnetd(); 34 | 35 | public: 36 | bool initialize(const std::string &bind_addr); 37 | bool start(); 38 | void stop(); 39 | void cleanup(); 40 | 41 | private: 42 | class Impl; 43 | Impl *impl_ = nullptr; 44 | }; 45 | 46 | } 47 | } 48 | 49 | #endif //TBOX_TERMINAL_TELNETD_H_20220127 50 | -------------------------------------------------------------------------------- /modules/terminal/session.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_TERMINAL_SESSION_H_20220214 21 | #define TBOX_TERMINAL_SESSION_H_20220214 22 | 23 | #include "types.h" 24 | 25 | namespace tbox { 26 | namespace terminal { 27 | 28 | class Connection; 29 | 30 | class Session { 31 | public: 32 | Session(Connection *wp_conn, const SessionToken &st); 33 | 34 | bool send(char ch) const; 35 | bool send(const std::string &str) const; 36 | bool endSession() const; 37 | bool isValid() const; 38 | 39 | private: 40 | Connection *wp_conn_; 41 | const SessionToken st_; 42 | }; 43 | 44 | } 45 | } 46 | 47 | #endif //TBOX_TERMINAL_SESSION_H_20220214 48 | -------------------------------------------------------------------------------- /modules/terminal/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_TERMINAL_TYPES_H_20220128 21 | #define TBOX_TERMINAL_TYPES_H_20220128 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | namespace tbox { 30 | namespace terminal { 31 | 32 | class Session; 33 | 34 | using SessionToken = cabinet::Token; 35 | using NodeToken = cabinet::Token; 36 | 37 | using Args = std::vector; 38 | using Func = std::function; 39 | 40 | } 41 | } 42 | 43 | #endif //TBOX_TERMINAL_TYPES_H_20220128 44 | -------------------------------------------------------------------------------- /modules/trace/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2024 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT = trace 22 | LIB_NAME = trace 23 | LIB_VERSION_X = 0 24 | LIB_VERSION_Y = 1 25 | LIB_VERSION_Z = 0 26 | 27 | HEAD_FILES = sink.h 28 | 29 | CPP_SRC_FILES = sink.cpp 30 | 31 | CXXFLAGS := -DMODULE_ID='"tbox.trace"' $(CXXFLAGS) 32 | 33 | TEST_CPP_SRC_FILES = \ 34 | $(CPP_SRC_FILES) \ 35 | sink_test.cpp \ 36 | 37 | TEST_LDFLAGS := $(LDFLAGS) -ltbox_util -ltbox_base -ldl 38 | 39 | ENABLE_SHARED_LIB = no 40 | 41 | include $(TOP_DIR)/mk/lib_tbox_common.mk 42 | -------------------------------------------------------------------------------- /modules/util/crc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_UTIL_CRC_H_20230104 21 | #define TBOX_UTIL_CRC_H_20230104 22 | 23 | #include 24 | #include 25 | 26 | namespace tbox { 27 | namespace util { 28 | 29 | uint16_t CalcCrc16(const void *data_ptr, size_t data_size, uint16_t init_seed = 0xffff); 30 | uint32_t CalcCrc32(const void *data_ptr, size_t data_size, uint32_t init_seed = 0xffffffff); 31 | 32 | } 33 | } 34 | 35 | #endif //TBOX_UTIL_CRC_H_20230104 36 | -------------------------------------------------------------------------------- /modules/util/crc_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #include 21 | #include "crc.h" 22 | 23 | namespace tbox { 24 | namespace util { 25 | 26 | TEST(Crc, CalcCrc16) { 27 | uint8_t tmp_data[] = {0x02, 0x0A, 0x00, 0x03, 0xE6, 0x02, 0x08, 0x03}; 28 | uint16_t crc = CalcCrc16(tmp_data, sizeof(tmp_data)); 29 | EXPECT_EQ(crc, 0xD7DD); 30 | } 31 | 32 | TEST(Crc, CalcCrc32) { 33 | uint8_t tmp_data[] = {'h', 'e', 'l', 'l', 'o', ' ', 'c', 'r', 'c', ' ', '!'}; 34 | uint32_t crc = CalcCrc32(tmp_data, sizeof(tmp_data)); 35 | EXPECT_EQ(crc, 0x7DC7D3D4); 36 | } 37 | 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /modules/util/execute_cmd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #include 21 | 22 | namespace tbox { 23 | namespace util { 24 | 25 | bool ExecuteCmd(const std::string &cmd); 26 | bool ExecuteCmd(const std::string &cmd, int &ret); 27 | 28 | bool ExecuteCmd(const std::string &cmd, std::string &result); 29 | bool ExecuteCmd(const std::string &cmd, std::string &result, int &ret); 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /modules/util/pid_file_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #include 21 | #include 22 | #include "pid_file.h" 23 | 24 | using namespace tbox::util; 25 | 26 | TEST(PidFile, base) 27 | { 28 | const char *pid_file = "/tmp/test.pid"; 29 | ::unlink(pid_file); 30 | { 31 | PidFile pid; 32 | ASSERT_TRUE(pid.lock(pid_file)); 33 | 34 | EXPECT_EQ(::access(pid_file, R_OK), 0); //! 文件应该存在 35 | } 36 | 37 | EXPECT_EQ(::access(pid_file, R_OK), -1); //! 文件应该打不开,因为已经删除了 38 | EXPECT_EQ(errno, ENOENT); 39 | } 40 | -------------------------------------------------------------------------------- /modules/util/split_cmdline.h: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #ifndef TBOX_UTIL_SPLIT_CMDLINE_H_20220207 21 | #define TBOX_UTIL_SPLIT_CMDLINE_H_20220207 22 | 23 | #include 24 | #include 25 | 26 | namespace tbox { 27 | namespace util { 28 | 29 | bool SplitCmdline(const std::string &cmd, std::vector &args); 30 | 31 | } 32 | } 33 | 34 | #endif //TBOX_UTIL_SPLIT_CMDLINE_H_20220207 35 | -------------------------------------------------------------------------------- /modules/util/timestamp_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * .============. 3 | * // M A K E / \ 4 | * // C++ DEV / \ 5 | * // E A S Y / \/ \ 6 | * ++ ----------. \/\ . 7 | * \\ \ \ /\ / 8 | * \\ \ \ / 9 | * \\ \ \ / 10 | * -============' 11 | * 12 | * Copyright (c) 2024 Hevake and contributors, all rights reserved. 13 | * 14 | * This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | * Use of this source code is governed by MIT license that can be found 16 | * in the LICENSE file in the root of the source tree. All contributing 17 | * project authors may be found in the CONTRIBUTORS.md file in the root 18 | * of the source tree. 19 | */ 20 | #include 21 | 22 | #include "timestamp.h" 23 | 24 | namespace tbox { 25 | namespace util { 26 | 27 | TEST(Timestamp, GetUtcTimeString) 28 | { 29 | EXPECT_EQ(GetUtcTimeString(0), "1970-01-01 00:00:00"); 30 | } 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /tools/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | all test: 22 | @for i in $(MODULES); do \ 23 | [ ! -d $$i ] || $(MAKE) -C $$i $@ || exit $$? ; \ 24 | done 25 | -------------------------------------------------------------------------------- /tools/graphviz_render/.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__ 2 | -------------------------------------------------------------------------------- /tools/graphviz_render/README_cn.md: -------------------------------------------------------------------------------- 1 | 第一步:安装python3及以上 2 | 3 | 第二步:安装依赖 4 | `pip3 install -r requirements.txt` 5 | 6 | 第三步:运行工具 7 | `python3 ./src/main.py /tmp/gviz` (备注: /tmp/gviz是管道名,可自定义) 8 | 如果运行报以下错误 9 | ![](images/image.png) 10 | 11 | 请安装: 12 | `sudo apt-get install libxcb-cursor0 libxcb-xinerama0 libxcb-randr0 libxcb-util0-dev` 13 | 14 | 第四步:往管道文件写数据 15 | 示例:`echo "diagraph{ A->B; B->C; A->C }" > /tmp/gviz` 16 | -------------------------------------------------------------------------------- /tools/graphviz_render/requirements.txt: -------------------------------------------------------------------------------- 1 | Pillow==9.0.0 2 | Pillow==7.0.0 3 | Pillow==11.1.0 4 | PyQt5==5.15.11 5 | -------------------------------------------------------------------------------- /tools/graphviz_render/src/signal_handler.py: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2025 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | import signal 22 | from PyQt5.QtCore import QObject, pyqtSignal, QTimer 23 | 24 | class SignalHandler(QObject): 25 | sig_interrupt = pyqtSignal() 26 | 27 | def __init__(self): 28 | super().__init__() 29 | # 注册系统信号到Qt信号转发 30 | signal.signal(signal.SIGINT, self.handle_signal) 31 | 32 | def handle_signal(self, signum, _): 33 | print(f"捕获到信号 {signum}") 34 | self.sig_interrupt.emit() # 通过Qt信号触发主线程退出 35 | -------------------------------------------------------------------------------- /tools/graphviz_render/src/transform/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2025 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | from .zoomable import ZoomableGraphicsView 22 | -------------------------------------------------------------------------------- /tools/graphviz_render/src/ui/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2025 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | from .viewer import GraphvizViewer 22 | -------------------------------------------------------------------------------- /tools/trace/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | all test clean distclean: 22 | @for i in $(shell ls) ; do \ 23 | if [ -d $$i ]; then \ 24 | $(MAKE) -C $$i $@ || exit $$? ; \ 25 | fi \ 26 | done 27 | -------------------------------------------------------------------------------- /tools/trace/analyzer/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | PROJECT := tools/trace/analyzer 22 | EXE_NAME := $(PROJECT) 23 | 24 | CPP_SRC_FILES := \ 25 | main.cpp \ 26 | writer.cpp \ 27 | 28 | CXXFLAGS := -DMODULE_ID='"$(EXE_NAME)"' $(CXXFLAGS) 29 | LDFLAGS += \ 30 | -ltbox_trace \ 31 | -ltbox_util \ 32 | -ltbox_base \ 33 | -ldl 34 | 35 | include $(TOP_DIR)/mk/exe_common.mk 36 | -------------------------------------------------------------------------------- /version.mk: -------------------------------------------------------------------------------- 1 | # 2 | # .============. 3 | # // M A K E / \ 4 | # // C++ DEV / \ 5 | # // E A S Y / \/ \ 6 | # ++ ----------. \/\ . 7 | # \\ \ \ /\ / 8 | # \\ \ \ / 9 | # \\ \ \ / 10 | # -============' 11 | # 12 | # Copyright (c) 2018 Hevake and contributors, all rights reserved. 13 | # 14 | # This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox) 15 | # Use of this source code is governed by MIT license that can be found 16 | # in the LICENSE file in the root of the source tree. All contributing 17 | # project authors may be found in the CONTRIBUTORS.md file in the root 18 | # of the source tree. 19 | # 20 | 21 | # TBOX版本号 22 | TBOX_VERSION_MAJOR := 1 23 | TBOX_VERSION_MINOR := 12 24 | TBOX_VERSION_REVISION := 9 25 | --------------------------------------------------------------------------------