/[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.73 by sysadm, Mon Oct 20 04:17:36 2025 UTC Revision 1.80 by sysadm, Wed Nov 5 04:19:21 2025 UTC
# Line 1  Line 1 
1  /***************************************************************************  /* SPDX-License-Identifier: GPL-3.0-or-later */
2                                                    bbs_net.c  -  description  /*
3                                                           -------------------   * bbs_net
4          Copyright            : (C) 2004-2025 by Leaflet   *   - user interactive feature of site shuttle
5          Email                : leaflet@leafok.com   *
6   ***************************************************************************/   * Copyright (C) 2004-2025  Leaflet <leaflet@leafok.com>
7     */
 /***************************************************************************  
  *                                                                         *  
  *   This program is free software; you can redistribute it and/or modify  *  
  *   it under the terms of the GNU General Public License as published by  *  
  *   the Free Software Foundation; either version 3 of the License, or     *  
  *   (at your option) any later version.                                   *  
  *                                                                         *  
  ***************************************************************************/  
8    
9  #include "bbs.h"  #include "bbs.h"
10  #include "common.h"  #include "common.h"
# Line 41  Line 33 
33  #include <sys/socket.h>  #include <sys/socket.h>
34  #include <sys/epoll.h>  #include <sys/epoll.h>
35    
36  #define MENU_CONF_DELIM " \t\r\n"  static const char MENU_CONF_DELIM[] = " \t\r\n";
37    
38  #define MAX_PROCESS_BAR_LEN 30  enum _bbs_net_constant_t
39  #define MAXSTATION 26 * 2  {
40  #define STATION_PER_LINE 4          MAX_PROCESS_BAR_LEN = 30,
41            MAXSTATION = 26 * 2,
42            STATION_PER_LINE = 4,
43    };
44    
45  struct _bbsnet_conf  struct _bbsnet_conf
46  {  {
# Line 53  struct _bbsnet_conf Line 48  struct _bbsnet_conf
48          char host2[40];          char host2[40];
49          char ip[40];          char ip[40];
50          in_port_t port;          in_port_t port;
51          char charset[20];          char charset[CHARSET_MAX_LEN + 1];
52  } bbsnet_conf[MAXSTATION];  } bbsnet_conf[MAXSTATION];
53    
54  MENU_SET bbsnet_menu;  static MENU_SET bbsnet_menu;
55    
56  int load_bbsnet_conf(const char *file_config)  static int load_bbsnet_conf(const char *file_config)
57  {  {
58          FILE *fp;          FILE *fp;
59          MENU *p_menu;          MENU *p_menu;
# Line 153  int load_bbsnet_conf(const char *file_co Line 148  int load_bbsnet_conf(const char *file_co
148          return 0;          return 0;
149  }  }
150    
151  void unload_bbsnet_conf(void)  static void unload_bbsnet_conf(void)
152  {  {
153          bbsnet_menu.menu_count = 0;          bbsnet_menu.menu_count = 0;
154          bbsnet_menu.menu_item_count = 0;          bbsnet_menu.menu_item_count = 0;
# Line 164  void unload_bbsnet_conf(void) Line 159  void unload_bbsnet_conf(void)
159          bbsnet_menu.p_menu_item_pool = NULL;          bbsnet_menu.p_menu_item_pool = NULL;
160  }  }
161    
162  void process_bar(int n, int len)  static void process_bar(int n, int len)
163  {  {
164          char buf[LINE_BUFFER_LEN];          char buf[LINE_BUFFER_LEN];
165          char buf2[LINE_BUFFER_LEN];          char buf2[LINE_BUFFER_LEN];
# Line 185  void process_bar(int n, int len) Line 180  void process_bar(int n, int len)
180          moveto(4, 0);          moveto(4, 0);
181          prints(" ------------------------------ \r\n");          prints(" ------------------------------ \r\n");
182          snprintf(buf, sizeof(buf), "            %3d%%              ", n * 100 / len);          snprintf(buf, sizeof(buf), "            %3d%%              ", n * 100 / len);
183          strncpy(buf2, buf, (size_t)n);          memcpy(buf2, buf, (size_t)n);
184          buf2[n] = '\0';          buf2[n] = '\0';
185          prints("|\033[46m%s\033[44m%s\033[m|\r\n", buf2, buf + n);          prints("|\033[46m%s\033[44m%s\033[m|\r\n", buf2, buf + n);
186          prints(" ------------------------------ \r\n");          prints(" ------------------------------ \r\n");
187          iflush();          iflush();
188  }  }
189    
190  int bbsnet_connect(int n)  static int bbsnet_connect(int n)
191  {  {
192          int sock, ret, loop, error;          int sock, ret, loop, error;
193          int sock_connected = 0;          int sock_connected = 0;
# Line 484  int bbsnet_connect(int n) Line 479  int bbsnet_connect(int n)
479                  }                  }
480                  else if (nfds == 0) // timeout                  else if (nfds == 0) // timeout
481                  {                  {
482                          if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME)                          if (time(NULL) - BBS_last_access_tm >= BBS_max_user_idle_time)
483                          {                          {
484                                  break;                                  break;
485                          }                          }
# Line 807  cleanup: Line 802  cleanup:
802          return 0;          return 0;
803  }  }
804    
805  static int  static int bbsnet_refresh()
 bbsnet_refresh()  
806  {  {
807          clearscr();          clearscr();
808          moveto(1, 0);          moveto(1, 0);
# Line 832  bbsnet_refresh() Line 826  bbsnet_refresh()
826          return 0;          return 0;
827  }  }
828    
829  int bbsnet_selchange()  static int bbsnet_selchange()
830  {  {
831          int i = bbsnet_menu.menu_item_pos[0];          int i = bbsnet_menu.menu_item_pos[0];
832    
# Line 857  int bbsnet_selchange() Line 851  int bbsnet_selchange()
851          return 0;          return 0;
852  }  }
853    
854  int bbs_net()  extern int bbs_net()
855  {  {
856          int ch, i;          int ch, i;
857    
# Line 883  int bbs_net() Line 877  int bbs_net()
877                          log_error("KEY_NULL\n");                          log_error("KEY_NULL\n");
878                          goto cleanup;                          goto cleanup;
879                  case KEY_TIMEOUT:                  case KEY_TIMEOUT:
880                          if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME)                          if (time(NULL) - BBS_last_access_tm >= BBS_max_user_idle_time)
881                          {                          {
882                                  log_error("User input timeout\n");                                  log_error("User input timeout\n");
883                                  goto cleanup;                                  goto cleanup;


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

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