A little code cleanup
This commit is contained in:
@@ -120,7 +120,7 @@ public:
|
|||||||
int last_write_nbytes;
|
int last_write_nbytes;
|
||||||
};
|
};
|
||||||
|
|
||||||
DrivenEngine *driven_;
|
UniqueDrivenEngine driven_;
|
||||||
std::vector<ChanInfo> chans_;
|
std::vector<ChanInfo> chans_;
|
||||||
std::map<int, SOCKET> listen_sockets_;
|
std::map<int, SOCKET> listen_sockets_;
|
||||||
bool read_console_recently_;
|
bool read_console_recently_;
|
||||||
@@ -478,8 +478,18 @@ public:
|
|||||||
cleanup_channels();
|
cleanup_channels();
|
||||||
}
|
}
|
||||||
|
|
||||||
void drive(DrivenEngine *de, int argc, char *argv[]) {
|
void drive(int argc, char *argv[]) {
|
||||||
driven_ = de;
|
if (argc < 2) {
|
||||||
|
DrivenEngine::print_usage(std::cerr, argv[0]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
driven_ = DrivenEngine::make(argv[1]);
|
||||||
|
if (driven_ == nullptr) {
|
||||||
|
DrivenEngine::print_usage(std::cerr, argv[0]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
DrivenEngine::set(driven_.get());
|
||||||
|
|
||||||
read_console_recently_ = false;
|
read_console_recently_ = false;
|
||||||
|
|
||||||
ssl_ctx_with_root_certs_ = new_ssl_context(false, true, "");
|
ssl_ctx_with_root_certs_ = new_ssl_context(false, true, "");
|
||||||
@@ -496,19 +506,18 @@ public:
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
DrivenEngine::set(de);
|
|
||||||
handle_lua_source();
|
handle_lua_source();
|
||||||
driven_->drv_invoke_event_init(argc, argv);
|
driven_->drv_invoke_event_init(argc, argv);
|
||||||
handle_listen_ports();
|
handle_listen_ports();
|
||||||
|
|
||||||
while (!de->drv_get_stop_driver()) {
|
while (!driven_->drv_get_stop_driver()) {
|
||||||
handle_lua_source();
|
handle_lua_source();
|
||||||
handle_console_output();
|
handle_console_output();
|
||||||
handle_new_outgoing_sockets();
|
handle_new_outgoing_sockets();
|
||||||
handle_socket_input_output();
|
handle_socket_input_output();
|
||||||
handle_console_input();
|
handle_console_input();
|
||||||
handle_console_output();
|
handle_console_output();
|
||||||
de->drv_invoke_event_update(monoclock.get());
|
driven_->drv_invoke_event_update(monoclock.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ChanInfo &chan : chans_) {
|
for (ChanInfo &chan : chans_) {
|
||||||
@@ -522,17 +531,3 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void driver_drive(int argc, char *argv[]) {
|
|
||||||
Driver driver;
|
|
||||||
if (argc < 2) {
|
|
||||||
DrivenEngine::print_usage(std::cerr, argv[0]);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
UniqueDrivenEngine engine = DrivenEngine::make(argv[1]);
|
|
||||||
if (engine == nullptr) {
|
|
||||||
DrivenEngine::print_usage(std::cerr, argv[0]);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
driver.drive(engine.get(), argc, argv);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -268,6 +268,7 @@ int main(int argc, char **argv)
|
|||||||
enable_tty_raw();
|
enable_tty_raw();
|
||||||
OPENSSL_init_ssl(0, NULL);
|
OPENSSL_init_ssl(0, NULL);
|
||||||
SourceDB::register_lua_builtins();
|
SourceDB::register_lua_builtins();
|
||||||
driver_drive(argc, argv);
|
Driver driver;
|
||||||
|
driver.drive(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -273,6 +273,7 @@ int main(int argc, char **argv)
|
|||||||
init_winsock();
|
init_winsock();
|
||||||
OPENSSL_init_ssl(0, NULL);
|
OPENSSL_init_ssl(0, NULL);
|
||||||
SourceDB::register_lua_builtins();
|
SourceDB::register_lua_builtins();
|
||||||
driver_drive(argc, argv);
|
Driver driver;
|
||||||
|
driver.drive(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user