/[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.20 by sysadm, Mon May 5 09:30:22 2025 UTC Revision 1.21 by sysadm, Mon May 5 11:11:06 2025 UTC
# Line 62  int load_bbsnet_conf(const char *file_co Line 62  int load_bbsnet_conf(const char *file_co
62          }          }
63    
64          p_menu = bbsnet_menu.p_menu[0] = malloc(sizeof(MENU));          p_menu = bbsnet_menu.p_menu[0] = malloc(sizeof(MENU));
65          strcpy(p_menu->name, "BBSNET");          strncpy(p_menu->name, "BBSNET", sizeof(p_menu->name) - 1);
66            p_menu->name[sizeof(p_menu->name) - 1] = '\0';
67          p_menu->title.show = 0;          p_menu->title.show = 0;
68          p_menu->screen.show = 0;          p_menu->screen.show = 0;
69    
# Line 78  int load_bbsnet_conf(const char *file_co Line 79  int load_bbsnet_conf(const char *file_co
79                          continue;                          continue;
80                  }                  }
81    
82                  strncpy(bbsnet_conf[item_count].host1, t2, sizeof(bbsnet_conf[item_count].host1));                  strncpy(bbsnet_conf[item_count].host1, t2, sizeof(bbsnet_conf[item_count].host1) - 1);
83                  strncpy(bbsnet_conf[item_count].host2, t1, sizeof(bbsnet_conf[item_count].host2));                  bbsnet_conf[item_count].host1[sizeof(bbsnet_conf[item_count].host1) - 1] = '\0';
84                  strncpy(bbsnet_conf[item_count].ip, t3, sizeof(bbsnet_conf[item_count].ip));                  strncpy(bbsnet_conf[item_count].host2, t1, sizeof(bbsnet_conf[item_count].host2) - 1);
85                    bbsnet_conf[item_count].host2[sizeof(bbsnet_conf[item_count].host2) - 1] = '\0';
86                    strncpy(bbsnet_conf[item_count].ip, t3, sizeof(bbsnet_conf[item_count].ip) - 1);
87                    bbsnet_conf[item_count].ip[sizeof(bbsnet_conf[item_count].ip) - 1] = '\0';
88                  bbsnet_conf[item_count].port = t4 ? atoi(t4) : 23;                  bbsnet_conf[item_count].port = t4 ? atoi(t4) : 23;
89    
90                  p_menuitem = p_menu->items[item_count] = malloc(sizeof(MENU_ITEM));                  p_menuitem = p_menu->items[item_count] = malloc(sizeof(MENU_ITEM));
# Line 95  int load_bbsnet_conf(const char *file_co Line 99  int load_bbsnet_conf(const char *file_co
99                          (item_count < MAXSTATION / 2 ? 'A' + item_count : 'a' + item_count);                          (item_count < MAXSTATION / 2 ? 'A' + item_count : 'a' + item_count);
100                  p_menuitem->name[1] = '\0';                  p_menuitem->name[1] = '\0';
101                  snprintf(p_menuitem->text, sizeof(p_menuitem->text), "%c. %s",                  snprintf(p_menuitem->text, sizeof(p_menuitem->text), "%c. %s",
102                                   p_menuitem->name[0], t2);                                   p_menuitem->name[0], bbsnet_conf[item_count].host1);
103    
104                  item_count++;                  item_count++;
105          }          }
# Line 183  int bbsnet_connect(int n) Line 187  int bbsnet_connect(int n)
187    
188          sin.sin_family = AF_INET;          sin.sin_family = AF_INET;
189          sin.sin_addr.s_addr =          sin.sin_addr.s_addr =
190                  (strlen(hostaddr_server) > 0 ? inet_addr(hostaddr_server) : INADDR_ANY);                  (strnlen(hostaddr_server, sizeof(hostaddr_server)) > 0 ? inet_addr(hostaddr_server) : INADDR_ANY);
191          sin.sin_port = 0;          sin.sin_port = 0;
192    
193          if (bind(sock, (struct sockaddr *)&sin, sizeof(sin)) < 0)          if (bind(sock, (struct sockaddr *)&sin, sizeof(sin)) < 0)
# Line 198  int bbsnet_connect(int n) Line 202  int bbsnet_connect(int n)
202          sin.sin_addr = *(struct in_addr *)pHost->h_addr_list[0];          sin.sin_addr = *(struct in_addr *)pHost->h_addr_list[0];
203          sin.sin_port = htons(bbsnet_conf[n].port);          sin.sin_port = htons(bbsnet_conf[n].port);
204    
205          strcpy(remote_addr, inet_ntoa(sin.sin_addr));          strncpy(remote_addr, inet_ntoa(sin.sin_addr), sizeof(remote_addr) - 1);
206            remote_addr[sizeof(remote_addr) - 1] = '\0';
207          remote_port = ntohs(sin.sin_port);          remote_port = ntohs(sin.sin_port);
208    
209          prints("\033[1;32m穿梭进度条提示您当前已使用的时间。\033[m\r\n");          prints("\033[1;32m穿梭进度条提示您当前已使用的时间。\033[m\r\n");


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

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