--- lbbs/src/bbs_net.c 2025/06/05 08:36:02 1.48 +++ lbbs/src/bbs_net.c 2025/06/20 12:01:54 1.54 @@ -20,6 +20,7 @@ #include "io.h" #include "screen.h" #include "menu.h" +#include "login.h" #include #include #include @@ -216,6 +217,11 @@ int bbsnet_connect(int n) struct tm *tm_used; int ch; + if (user_online_update("BBS_NET") < 0) + { + log_error("user_online_update(BBS_NET) error\n"); + } + clearscr(); moveto(0, 0); @@ -252,7 +258,7 @@ int bbsnet_connect(int n) return -2; } - bzero(&sin, sizeof(sin)); + memset(&sin, 0, sizeof(sin)); sin.sin_family = AF_INET; sin.sin_addr = *(struct in_addr *)p_host->h_addr_list[0]; sin.sin_port = htons(bbsnet_conf[n].port); @@ -406,7 +412,7 @@ int bbsnet_connect(int n) goto cleanup; } - BBS_last_access_tm = t_used = time(0); + BBS_last_access_tm = t_used = time(NULL); loop = 1; while (loop && !SYS_server_exit) @@ -431,7 +437,7 @@ int bbsnet_connect(int n) } else if (nfds == 0) // timeout { - if (time(0) - BBS_last_access_tm >= MAX_DELAY_TIME) + if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME) { break; } @@ -490,7 +496,9 @@ int bbsnet_connect(int n) } else if (ret == 0) // broken pipe { - log_common("read(STDIN) EOF\n"); +#ifdef _DEBUG + log_error("read(STDIN) EOF\n"); +#endif stdin_read_wait = 0; loop = 0; break; @@ -498,7 +506,7 @@ int bbsnet_connect(int n) else { input_buf_len += ret; - BBS_last_access_tm = time(0); + BBS_last_access_tm = time(NULL); continue; } } @@ -530,7 +538,9 @@ int bbsnet_connect(int n) } else if (ret == 0) // broken pipe { - log_common("write(socket) EOF\n"); +#ifdef _DEBUG + log_error("write(socket) EOF\n"); +#endif sock_write_wait = 0; loop = 0; break; @@ -575,7 +585,9 @@ int bbsnet_connect(int n) } else if (ret == 0) // broken pipe { - log_common("read(socket) EOF\n"); +#ifdef _DEBUG + log_error("read(socket) EOF\n"); +#endif sock_read_wait = 0; loop = 0; break; @@ -627,7 +639,9 @@ int bbsnet_connect(int n) } else if (ret == 0) // broken pipe { - log_common("write(STDOUT) EOF\n"); +#ifdef _DEBUG + log_error("write(STDOUT) EOF\n"); +#endif stdout_write_wait = 0; loop = 0; break; @@ -666,7 +680,7 @@ cleanup: log_error("Close socket failed\n"); } - t_used = time(0) - t_used; + t_used = time(NULL) - t_used; tm_used = gmtime(&t_used); log_common("BBSNET disconnect, %d days %d hours %d minutes %d seconds used\n", @@ -732,7 +746,7 @@ int bbs_net() load_bbsnet_conf(CONF_BBSNET); - BBS_last_access_tm = time(0); + BBS_last_access_tm = time(NULL); clearscr(); bbsnet_refresh(); @@ -742,6 +756,7 @@ int bbs_net() while (!SYS_server_exit) { ch = igetch(100); + switch (ch) { case KEY_NULL: // broken pipe @@ -749,7 +764,7 @@ int bbs_net() case Ctrl('C'): // user cancel goto cleanup; case KEY_TIMEOUT: - if (time(0) - BBS_last_access_tm >= MAX_DELAY_TIME) + if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME) { goto cleanup; } @@ -798,7 +813,7 @@ int bbs_net() bbsnet_selchange(); break; } - BBS_last_access_tm = time(0); + BBS_last_access_tm = time(NULL); } cleanup: