/[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.72 by sysadm, Mon Oct 20 03:38:23 2025 UTC Revision 1.81 by sysadm, Tue Nov 11 00:28:05 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     */
8  /***************************************************************************  
9   *                                                                         *  #ifdef HAVE_CONFIG_H
10   *   This program is free software; you can redistribute it and/or modify  *  #include "config.h"
11   *   it under the terms of the GNU General Public License as published by  *  #endif
  *   the Free Software Foundation; either version 3 of the License, or     *  
  *   (at your option) any later version.                                   *  
  *                                                                         *  
  ***************************************************************************/  
12    
13  #include "bbs.h"  #include "bbs.h"
14  #include "common.h"  #include "common.h"
# Line 41  Line 37 
37  #include <sys/socket.h>  #include <sys/socket.h>
38  #include <sys/epoll.h>  #include <sys/epoll.h>
39    
40  #define MENU_CONF_DELIM " \t\r\n"  static const char MENU_CONF_DELIM[] = " \t\r\n";
41    
42  #define MAX_PROCESS_BAR_LEN 30  enum _bbs_net_constant_t
43  #define MAXSTATION 26 * 2  {
44  #define STATION_PER_LINE 4          MAX_PROCESS_BAR_LEN = 30,
45            MAXSTATION = 26 * 2,
46            STATION_PER_LINE = 4,
47    };
48    
49  struct _bbsnet_conf  struct _bbsnet_conf
50  {  {
# Line 53  struct _bbsnet_conf Line 52  struct _bbsnet_conf
52          char host2[40];          char host2[40];
53          char ip[40];          char ip[40];
54          in_port_t port;          in_port_t port;
55          char charset[20];          char charset[CHARSET_MAX_LEN + 1];
56  } bbsnet_conf[MAXSTATION];  } bbsnet_conf[MAXSTATION];
57    
58  MENU_SET bbsnet_menu;  static MENU_SET bbsnet_menu;
59    
60  int load_bbsnet_conf(const char *file_config)  static int load_bbsnet_conf(const char *file_config)
61  {  {
62          FILE *fp;          FILE *fp;
63          MENU *p_menu;          MENU *p_menu;
# Line 153  int load_bbsnet_conf(const char *file_co Line 152  int load_bbsnet_conf(const char *file_co
152          return 0;          return 0;
153  }  }
154    
155  void unload_bbsnet_conf(void)  static void unload_bbsnet_conf(void)
156  {  {
157          bbsnet_menu.menu_count = 0;          bbsnet_menu.menu_count = 0;
158          bbsnet_menu.menu_item_count = 0;          bbsnet_menu.menu_item_count = 0;
# Line 164  void unload_bbsnet_conf(void) Line 163  void unload_bbsnet_conf(void)
163          bbsnet_menu.p_menu_item_pool = NULL;          bbsnet_menu.p_menu_item_pool = NULL;
164  }  }
165    
166  void process_bar(int n, int len)  static void process_bar(int n, int len)
167  {  {
168          char buf[LINE_BUFFER_LEN];          char buf[LINE_BUFFER_LEN];
169          char buf2[LINE_BUFFER_LEN];          char buf2[LINE_BUFFER_LEN];
# Line 185  void process_bar(int n, int len) Line 184  void process_bar(int n, int len)
184          moveto(4, 0);          moveto(4, 0);
185          prints(" ------------------------------ \r\n");          prints(" ------------------------------ \r\n");
186          snprintf(buf, sizeof(buf), "            %3d%%              ", n * 100 / len);          snprintf(buf, sizeof(buf), "            %3d%%              ", n * 100 / len);
187          strncpy(buf2, buf, (size_t)n);          memcpy(buf2, buf, (size_t)n);
188          buf2[n] = '\0';          buf2[n] = '\0';
189          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);
190          prints(" ------------------------------ \r\n");          prints(" ------------------------------ \r\n");
191          iflush();          iflush();
192  }  }
193    
194  int bbsnet_connect(int n)  static int bbsnet_connect(int n)
195  {  {
196          int sock, ret, loop, error;          int sock, ret, loop, error;
197          int sock_connected = 0;          int sock_connected = 0;
# Line 484  int bbsnet_connect(int n) Line 483  int bbsnet_connect(int n)
483                  }                  }
484                  else if (nfds == 0) // timeout                  else if (nfds == 0) // timeout
485                  {                  {
486                          if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME)                          if (time(NULL) - BBS_last_access_tm >= BBS_max_user_idle_time)
487                          {                          {
488                                  break;                                  break;
489                          }                          }
# Line 539  int bbsnet_connect(int n) Line 538  int bbsnet_connect(int n)
538                                                  // Send NO-OP to remote server                                                  // Send NO-OP to remote server
539                                                  input_buf[input_buf_len] = '\0';                                                  input_buf[input_buf_len] = '\0';
540                                                  input_buf_len++;                                                  input_buf_len++;
541                                                    BBS_last_access_tm = time(NULL);
542    
543                                                  stdin_read_wait = 0;                                                  stdin_read_wait = 0;
544                                                  break; // Check whether channel is still open                                                  break; // Check whether channel is still open
# Line 806  cleanup: Line 806  cleanup:
806          return 0;          return 0;
807  }  }
808    
809  static int  static int bbsnet_refresh()
 bbsnet_refresh()  
810  {  {
811          clearscr();          clearscr();
812          moveto(1, 0);          moveto(1, 0);
# Line 831  bbsnet_refresh() Line 830  bbsnet_refresh()
830          return 0;          return 0;
831  }  }
832    
833  int bbsnet_selchange()  static int bbsnet_selchange()
834  {  {
835          int i = bbsnet_menu.menu_item_pos[0];          int i = bbsnet_menu.menu_item_pos[0];
836    
# Line 856  int bbsnet_selchange() Line 855  int bbsnet_selchange()
855          return 0;          return 0;
856  }  }
857    
858  int bbs_net()  extern int bbs_net()
859  {  {
860          int ch, i;          int ch, i;
861    
# Line 882  int bbs_net() Line 881  int bbs_net()
881                          log_error("KEY_NULL\n");                          log_error("KEY_NULL\n");
882                          goto cleanup;                          goto cleanup;
883                  case KEY_TIMEOUT:                  case KEY_TIMEOUT:
884                          if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME)                          if (time(NULL) - BBS_last_access_tm >= BBS_max_user_idle_time)
885                          {                          {
886                                  log_error("User input timeout\n");                                  log_error("User input timeout\n");
887                                  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