/[LeafOK_CVS]/lbbs/src/bbs_net.c
ViewVC logotype

Diff of /lbbs/src/bbs_net.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.97 by sysadm, Thu Dec 18 07:58:23 2025 UTC Revision 1.103 by sysadm, Thu Dec 18 11:18:29 2025 UTC
# Line 140  static int load_bbsnet_conf(const char * Line 140  static int load_bbsnet_conf(const char *
140                  port = strtol(t4, &endptr, 10);                  port = strtol(t4, &endptr, 10);
141                  if (*endptr != '\0' || port <= 0 || port > 65535)                  if (*endptr != '\0' || port <= 0 || port > 65535)
142                  {                  {
143                          log_error("Invalid port value %d of menu item %d\n", port, menu_item_id);                          log_error("Invalid port value %ld of menu item %d\n", port, menu_item_id);
144                          fclose(fp);                          fclose(fp);
145                          unload_bbsnet_conf();                          unload_bbsnet_conf();
146                          return -3;                          return -3;
# Line 212  static void progress_bar(int percent, in Line 212  static void progress_bar(int percent, in
212          char buf2[LINE_BUFFER_LEN];          char buf2[LINE_BUFFER_LEN];
213          int pos;          int pos;
214    
215          if (len <= 0)          if (len < 4)
216          {          {
217                  len = 1;                  len = 4;
218          }          }
219          else if (len > LINE_BUFFER_LEN)          else if (len + 2 > LINE_BUFFER_LEN)
220          {          {
221                  len = LINE_BUFFER_LEN - 1;                  len = LINE_BUFFER_LEN - 3;
222          }          }
223          if (percent < 0)          if (percent < 0)
224          {          {
# Line 531  static int bbsnet_connect(int n) Line 531  static int bbsnet_connect(int n)
531          }          }
532          ts_now = ts_begin;          ts_now = ts_begin;
533    
534          while ((ts_now.tv_sec - ts_begin.tv_sec) +          while ((ts_now.tv_sec - ts_begin.tv_sec) * 1000 +
535                                     (ts_now.tv_nsec - ts_begin.tv_nsec) / 1000 / 1000 / 1000 <                                     (ts_now.tv_nsec - ts_begin.tv_nsec) / 1000 / 1000 <
536                             REMOTE_CONNECT_TIMEOUT &&                             REMOTE_CONNECT_TIMEOUT * 1000 &&
537                     !sock_connected && !SYS_server_exit)                     !sock_connected && !SYS_server_exit)
538          {          {
539  #ifdef HAVE_SYS_EPOLL_H  #ifdef HAVE_SYS_EPOLL_H
# Line 573  static int bbsnet_connect(int n) Line 573  static int bbsnet_connect(int n)
573                                                           (ts_now.tv_nsec - ts_begin.tv_nsec) / 1000 / 1000) /                                                           (ts_now.tv_nsec - ts_begin.tv_nsec) / 1000 / 1000) /
574                                                     REMOTE_CONNECT_TIMEOUT / 10 +                                                     REMOTE_CONNECT_TIMEOUT / 10 +
575                                             1;                                             1;
576                            if (progress < 0)
577                            {
578                                    progress = 0;
579                            }
580                            if (progress > 100)
581                            {
582                                    progress = 100;
583                            }
584    
585                          if (progress > progress_last)                          if (progress > progress_last)
586                          {                          {
# Line 956  static int bbsnet_connect(int n) Line 964  static int bbsnet_connect(int n)
964                  {                  {
965                          if (time(NULL) - BBS_last_access_tm >= BBS_max_user_idle_time)                          if (time(NULL) - BBS_last_access_tm >= BBS_max_user_idle_time)
966                          {                          {
967                                    log_debug("User input timeout\n");
968                                  break;                                  break;
969                          }                          }
970                  }                  }
# Line 1313  static int bbsnet_connect(int n) Line 1322  static int bbsnet_connect(int n)
1322          ret = 1; // Normal disconnect          ret = 1; // Normal disconnect
1323          BBS_last_access_tm = time(NULL);          BBS_last_access_tm = time(NULL);
1324          t_used = BBS_last_access_tm - t_begin;          t_used = BBS_last_access_tm - t_begin;
1325          log_common("BBSNET disconnect, %d days %d hours %d minutes %d seconds used\n",          log_common("BBSNET disconnect, %ld days %ld hours %ld minutes %ld seconds used\n",
1326                             t_used / 86400, t_used % 86400 / 3600, t_used % 3600 / 60, t_used % 60);                             t_used / 86400, t_used % 86400 / 3600, t_used % 3600 / 60, t_used % 60);
1327    
1328  cleanup:  cleanup:
# Line 1364  cleanup: Line 1373  cleanup:
1373    
1374          if (sock != -1 && close(sock) == -1)          if (sock != -1 && close(sock) == -1)
1375          {          {
1376                  log_error("Close socket failed\n");                  log_error("close(socket) error (%d)\n", errno);
1377          }          }
1378    
1379          if (res)          if (res)
# Line 1425  static int bbsnet_selchange() Line 1434  static int bbsnet_selchange()
1434    
1435  int bbs_net()  int bbs_net()
1436  {  {
1437          int ch, i;          int ch;
1438    
1439          if (load_bbsnet_conf(CONF_BBSNET) < 0)          if (load_bbsnet_conf(CONF_BBSNET) < 0)
1440          {          {
# Line 1457  int bbs_net() Line 1466  int bbs_net()
1466                  case KEY_TIMEOUT:                  case KEY_TIMEOUT:
1467                          if (time(NULL) - BBS_last_access_tm >= BBS_max_user_idle_time)                          if (time(NULL) - BBS_last_access_tm >= BBS_max_user_idle_time)
1468                          {                          {
1469                                  log_error("User input timeout\n");                                  log_debug("User input timeout\n");
1470                                  goto cleanup;                                  goto cleanup;
1471                          }                          }
1472                          continue;                          continue;
# Line 1465  int bbs_net() Line 1474  int bbs_net()
1474                  case Ctrl('C'): // user cancel                  case Ctrl('C'): // user cancel
1475                          goto cleanup;                          goto cleanup;
1476                  case CR:                  case CR:
1477                          bbsnet_connect(bbsnet_menu.menu_item_pos[0]);                          if (bbsnet_connect(bbsnet_menu.menu_item_pos[0]) < 0)
1478                            {
1479                                    log_debug("bbsnet_connect() error\n");
1480                            }
1481                          // Force cleanup anything remaining in the output buffer                          // Force cleanup anything remaining in the output buffer
1482                          clearscr();                          clearscr();
1483                          iflush();                          iflush();
# Line 1475  int bbs_net() Line 1487  int bbs_net()
1487                          bbsnet_selchange();                          bbsnet_selchange();
1488                          break;                          break;
1489                  case KEY_UP:                  case KEY_UP:
1490                          for (i = 0; i < STATION_PER_LINE; i++)                          for (int i = 0; i < STATION_PER_LINE; i++)
1491                          {                          {
1492                                  menu_control(&bbsnet_menu, KEY_UP);                                  menu_control(&bbsnet_menu, KEY_UP);
1493                          }                          }
1494                          bbsnet_selchange();                          bbsnet_selchange();
1495                          break;                          break;
1496                  case KEY_DOWN:                  case KEY_DOWN:
1497                          for (i = 0; i < STATION_PER_LINE; i++)                          for (int i = 0; i < STATION_PER_LINE; i++)
1498                          {                          {
1499                                  menu_control(&bbsnet_menu, KEY_DOWN);                                  menu_control(&bbsnet_menu, KEY_DOWN);
1500                          }                          }


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1