/[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.46 by sysadm, Wed Jun 4 13:42:53 2025 UTC Revision 1.59 by sysadm, Sat Oct 4 10:11:44 2025 UTC
# Line 16  Line 16 
16    
17  #include "bbs.h"  #include "bbs.h"
18  #include "common.h"  #include "common.h"
 #include "log.h"  
19  #include "io.h"  #include "io.h"
20  #include "screen.h"  #include "log.h"
21    #include "login.h"
22  #include "menu.h"  #include "menu.h"
23  #include <stdio.h>  #include "screen.h"
 #include <stdarg.h>  
24  #include <errno.h>  #include <errno.h>
 #include <string.h>  
 #include <stdlib.h>  
25  #include <fcntl.h>  #include <fcntl.h>
26    #include <netdb.h>
27    #include <stdarg.h>
28    #include <stdio.h>
29    #include <stdlib.h>
30    #include <string.h>
31  #include <time.h>  #include <time.h>
32  #include <unistd.h>  #include <unistd.h>
33  #include <netdb.h>  #include <arpa/inet.h>
34    #include <libssh/libssh.h>
35    #include <libssh/server.h>
36    #include <libssh/callbacks.h>
37    #include <netinet/in.h>
38    #include <netinet/ip.h>
39  #include <sys/select.h>  #include <sys/select.h>
40  #include <sys/ioctl.h>  #include <sys/ioctl.h>
41  #include <sys/socket.h>  #include <sys/socket.h>
42  #include <sys/epoll.h>  #include <sys/epoll.h>
 #include <netinet/in.h>  
 #include <netinet/ip.h>  
 #include <arpa/inet.h>  
43    
44  #define MENU_CONF_DELIM " \t\r\n"  #define MENU_CONF_DELIM " \t\r\n"
45    
# Line 209  int bbsnet_connect(int n) Line 213  int bbsnet_connect(int n)
213          int tos;          int tos;
214          char remote_addr[IP_ADDR_LEN];          char remote_addr[IP_ADDR_LEN];
215          int remote_port;          int remote_port;
216          time_t t_used;          time_t t_used = time(NULL);
217          struct tm *tm_used;          struct tm *tm_used;
218          int ch;          int ch;
219    
220            if (user_online_update("BBS_NET") < 0)
221            {
222                    log_error("user_online_update(BBS_NET) error\n");
223            }
224    
225          clearscr();          clearscr();
226    
227          moveto(0, 0);          moveto(0, 0);
228          prints("\033[1;32m正在测试往 %s (%s) 的连接,请稍候... \033[m\r\n",          prints("\033[1;32m姝e湪娴嬭瘯寰 %s (%s) 鐨勮繛鎺ワ紝璇风◢鍊... \033[m\r\n",
229                     bbsnet_conf[n].host1, bbsnet_conf[n].ip);                     bbsnet_conf[n].host1, bbsnet_conf[n].ip);
230          iflush();          iflush();
231    
# Line 224  int bbsnet_connect(int n) Line 233  int bbsnet_connect(int n)
233    
234          if (p_host == NULL)          if (p_host == NULL)
235          {          {
236                  prints("\033[1;31m查找主机名失败!\033[m\r\n");                  prints("\033[1;31m鏌ユ壘涓绘満鍚嶅け璐ワ紒\033[m\r\n");
237                  press_any_key();                  press_any_key();
238                  return -1;                  return -1;
239          }          }
# Line 233  int bbsnet_connect(int n) Line 242  int bbsnet_connect(int n)
242    
243          if (sock < 0)          if (sock < 0)
244          {          {
245                  prints("\033[1;31m无法创建socket!\033[m\r\n");                  prints("\033[1;31m鏃犳硶鍒涘缓socket锛乗033[m\r\n");
246                  press_any_key();                  press_any_key();
247                  return -1;                  return -1;
248          }          }
249    
250          sin.sin_family = AF_INET;          sin.sin_family = AF_INET;
251          sin.sin_addr.s_addr = (hostaddr_server[0] != '\0' ? inet_addr(hostaddr_server) : INADDR_ANY);          sin.sin_addr.s_addr = (BBS_address[0] != '\0' ? inet_addr(BBS_address) : INADDR_ANY);
252          sin.sin_port = 0;          sin.sin_port = 0;
253    
254          if (bind(sock, (struct sockaddr *)&sin, sizeof(sin)) < 0)          if (bind(sock, (struct sockaddr *)&sin, sizeof(sin)) < 0)
# Line 249  int bbsnet_connect(int n) Line 258  int bbsnet_connect(int n)
258                  return -2;                  return -2;
259          }          }
260    
261          bzero(&sin, sizeof(sin));          memset(&sin, 0, sizeof(sin));
262          sin.sin_family = AF_INET;          sin.sin_family = AF_INET;
263          sin.sin_addr = *(struct in_addr *)p_host->h_addr_list[0];          sin.sin_addr = *(struct in_addr *)p_host->h_addr_list[0];
264          sin.sin_port = htons(bbsnet_conf[n].port);          sin.sin_port = htons(bbsnet_conf[n].port);
# Line 258  int bbsnet_connect(int n) Line 267  int bbsnet_connect(int n)
267          remote_addr[sizeof(remote_addr) - 1] = '\0';          remote_addr[sizeof(remote_addr) - 1] = '\0';
268          remote_port = ntohs(sin.sin_port);          remote_port = ntohs(sin.sin_port);
269    
270          prints("\033[1;32m穿梭进度条提示您当前已使用的时间,按\033[1;33mCtrl+C\033[1;32m中断。\033[m\r\n");          prints("\033[1;32m绌挎杩涘害鏉℃彁绀烘偍褰撳墠宸蹭娇鐢ㄧ殑鏃堕棿锛屾寜\033[1;33mCtrl+C\033[1;32m涓柇銆俓033[m\r\n");
271          process_bar(0, MAX_PROCESS_BAR_LEN);          process_bar(0, MAX_PROCESS_BAR_LEN);
272    
273          // Set socket as non-blocking          // Set socket as non-blocking
# Line 278  int bbsnet_connect(int n) Line 287  int bbsnet_connect(int n)
287                  return -1;                  return -1;
288          }          }
289    
290          ev.events = EPOLLOUT;          ev.events = EPOLLOUT | EPOLLET;
291          ev.data.fd = sock;          ev.data.fd = sock;
292          if (epoll_ctl(epollfd, EPOLL_CTL_ADD, sock, &ev) == -1)          if (epoll_ctl(epollfd, EPOLL_CTL_ADD, sock, &ev) == -1)
293          {          {
# Line 286  int bbsnet_connect(int n) Line 295  int bbsnet_connect(int n)
295                  goto cleanup;                  goto cleanup;
296          }          }
297    
298          ev.events = EPOLLIN;          ev.events = EPOLLIN | EPOLLET;
299          ev.data.fd = STDIN_FILENO;          ev.data.fd = STDIN_FILENO;
300          if (epoll_ctl(epollfd, EPOLL_CTL_ADD, STDIN_FILENO, &ev) == -1)          if (epoll_ctl(epollfd, EPOLL_CTL_ADD, STDIN_FILENO, &ev) == -1)
301          {          {
# Line 313  int bbsnet_connect(int n) Line 322  int bbsnet_connect(int n)
322                          {                          {
323                                  log_error("connect(socket) error (%d)\n", errno);                                  log_error("connect(socket) error (%d)\n", errno);
324    
325                                  prints("\033[1;31m连接失败!\033[m\r\n");                                  prints("\033[1;31m杩炴帴澶辫触锛乗033[m\r\n");
326                                  press_any_key();                                  press_any_key();
327    
328                                  goto cleanup;                                  goto cleanup;
# Line 371  int bbsnet_connect(int n) Line 380  int bbsnet_connect(int n)
380          }          }
381          if (!sock_connected)          if (!sock_connected)
382          {          {
383                  prints("\033[1;31m连接失败!\033[m\r\n");                  prints("\033[1;31m杩炴帴澶辫触锛乗033[m\r\n");
384                  press_any_key();                  press_any_key();
385    
386                  goto cleanup;                  goto cleanup;
# Line 383  int bbsnet_connect(int n) Line 392  int bbsnet_connect(int n)
392                  log_error("setsockopt IP_TOS=%d error (%d)\n", tos, errno);                  log_error("setsockopt IP_TOS=%d error (%d)\n", tos, errno);
393          }          }
394    
395          prints("\033[1;31m连接成功!\033[m\r\n");          prints("\033[1;31m杩炴帴鎴愬姛锛乗033[m\r\n");
396          iflush();          iflush();
397          log_common("BBSNET connect to %s:%d\n", remote_addr, remote_port);          log_common("BBSNET connect to %s:%d\n", remote_addr, remote_port);
398    
# Line 395  int bbsnet_connect(int n) Line 404  int bbsnet_connect(int n)
404                  goto cleanup;                  goto cleanup;
405          }          }
406    
407          ev.events = EPOLLOUT;          ev.events = EPOLLOUT | EPOLLET;
408          ev.data.fd = STDOUT_FILENO;          ev.data.fd = STDOUT_FILENO;
409          if (epoll_ctl(epollfd, EPOLL_CTL_ADD, STDOUT_FILENO, &ev) == -1)          if (epoll_ctl(epollfd, EPOLL_CTL_ADD, STDOUT_FILENO, &ev) == -1)
410          {          {
# Line 403  int bbsnet_connect(int n) Line 412  int bbsnet_connect(int n)
412                  goto cleanup;                  goto cleanup;
413          }          }
414    
415          BBS_last_access_tm = t_used = time(0);          BBS_last_access_tm = t_used = time(NULL);
416          loop = 1;          loop = 1;
417    
418          while (loop && !SYS_server_exit)          while (loop && !SYS_server_exit)
419          {          {
420                    if (SSH_v2 && ssh_channel_is_closed(SSH_channel))
421                    {
422                            log_error("SSH channel is closed\n");
423                            loop = 0;
424                            break;
425                    }
426    
427                  nfds = epoll_wait(epollfd, events, MAX_EVENTS, 100); // 0.1 second                  nfds = epoll_wait(epollfd, events, MAX_EVENTS, 100); // 0.1 second
428    
429                  if (nfds < 0)                  if (nfds < 0)
# Line 421  int bbsnet_connect(int n) Line 437  int bbsnet_connect(int n)
437                  }                  }
438                  else if (nfds == 0) // timeout                  else if (nfds == 0) // timeout
439                  {                  {
440                          if (time(0) - BBS_last_access_tm >= MAX_DELAY_TIME)                          if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME)
441                          {                          {
442                                  break;                                  break;
443                          }                          }
                         continue;  
444                  }                  }
445    
446                  for (int i = 0; i < nfds; i++)                  for (int i = 0; i < nfds; i++)
447                  {                  {
448                          if (events[i].data.fd == STDIN_FILENO || stdin_read_wait)                          if (events[i].data.fd == STDIN_FILENO)
449                          {                          {
450                                  stdin_read_wait = 1;                                  stdin_read_wait = 1;
451                                  while (input_buf_len < sizeof(input_buf) && !SYS_server_exit)                          }
452    
453                            if (events[i].data.fd == sock)
454                            {
455                                    if (events[i].events & EPOLLIN)
456                                  {                                  {
457                                          ret = (int)read(STDIN_FILENO, input_buf + input_buf_len, sizeof(input_buf) - (size_t)input_buf_len);                                          sock_read_wait = 1;
458                                          if (ret < 0)                                  }
459                                    if (events[i].events & EPOLLOUT)
460                                    {
461                                            sock_write_wait = 1;
462                                    }
463                            }
464    
465                            if (events[i].data.fd == STDOUT_FILENO)
466                            {
467                                    stdout_write_wait = 1;
468                            }
469                    }
470    
471                    if (stdin_read_wait)
472                    {
473                            while (input_buf_len < sizeof(input_buf) && !SYS_server_exit)
474                            {
475                                    if (SSH_v2)
476                                    {
477                                            ret = ssh_channel_read_nonblocking(SSH_channel, input_buf + input_buf_len, sizeof(input_buf) - (uint32_t)input_buf_len, 0);
478                                            if (ret == SSH_ERROR)
479                                          {                                          {
480                                                  if (errno == EAGAIN || errno == EWOULDBLOCK)                                                  log_error("ssh_channel_read_nonblocking() error: %s\n", ssh_get_error(SSH_session));
481                                                  {                                                  loop = 0;
482                                                          stdin_read_wait = 0;                                                  break;
                                                         break;  
                                                 }  
                                                 else if (errno == EINTR)  
                                                 {  
                                                         continue;  
                                                 }  
                                                 else  
                                                 {  
                                                         log_error("read(STDIN) error (%d)\n", errno);  
                                                         loop = 0;  
                                                         break;  
                                                 }  
483                                          }                                          }
484                                          else if (ret == 0) // broken pipe                                          else if (ret == SSH_EOF)
485                                          {                                          {
                                                 log_common("read(STDIN) EOF\n");  
486                                                  stdin_read_wait = 0;                                                  stdin_read_wait = 0;
487                                                  loop = 0;                                                  loop = 0;
488                                                  break;                                                  break;
489                                          }                                          }
490                                          else                                          else if (ret == 0)
491                                            {
492                                                    stdin_read_wait = 0;
493                                                    break; // Check whether channel is still open
494                                            }
495                                    }
496                                    else
497                                    {
498                                            ret = (int)read(STDIN_FILENO, input_buf + input_buf_len, sizeof(input_buf) - (size_t)input_buf_len);
499                                    }
500                                    if (ret < 0)
501                                    {
502                                            if (errno == EAGAIN || errno == EWOULDBLOCK)
503                                            {
504                                                    stdin_read_wait = 0;
505                                                    break;
506                                            }
507                                            else if (errno == EINTR)
508                                          {                                          {
                                                 input_buf_len += ret;  
                                                 BBS_last_access_tm = time(0);  
509                                                  continue;                                                  continue;
510                                          }                                          }
511                                            else
512                                            {
513                                                    log_error("read(STDIN) error (%d)\n", errno);
514                                                    loop = 0;
515                                                    break;
516                                            }
517                                    }
518                                    else if (ret == 0) // broken pipe
519                                    {
520    #ifdef _DEBUG
521                                            log_error("read(STDIN) EOF\n");
522    #endif
523                                            stdin_read_wait = 0;
524                                            loop = 0;
525                                            break;
526                                    }
527                                    else
528                                    {
529                                            input_buf_len += ret;
530                                            BBS_last_access_tm = time(NULL);
531    
532                                            // Refresh current action while user input
533                                            if (user_online_update("BBS_NET") < 0)
534                                            {
535                                                    log_error("user_online_update(BBS_NET) error\n");
536                                            }
537    
538                                            continue;
539                                  }                                  }
540                          }                          }
541                    }
542    
543                          if (events[i].data.fd == sock || sock_write_wait) // EPOLLOUT                  if (sock_write_wait)
544                    {
545                            while (input_buf_offset < input_buf_len && !SYS_server_exit)
546                          {                          {
547                                  sock_write_wait = 1;                                  ret = (int)write(sock, input_buf + input_buf_offset, (size_t)(input_buf_len - input_buf_offset));
548                                  while (input_buf_offset < input_buf_len && !SYS_server_exit)                                  if (ret < 0)
549                                  {                                  {
550                                          ret = (int)write(sock, input_buf + input_buf_offset, (size_t)(input_buf_len - input_buf_offset));                                          if (errno == EAGAIN || errno == EWOULDBLOCK)
                                         if (ret < 0)  
551                                          {                                          {
552                                                  if (errno == EAGAIN || errno == EWOULDBLOCK)                                                  sock_write_wait = 0;
553                                                  {                                                  break;
                                                         sock_write_wait = 0;  
                                                         break;  
                                                 }  
                                                 else if (errno == EINTR)  
                                                 {  
                                                         continue;  
                                                 }  
                                                 else  
                                                 {  
                                                         log_error("write(socket) error (%d)\n", errno);  
                                                         loop = 0;  
                                                         break;  
                                                 }  
554                                          }                                          }
555                                          else if (ret == 0) // broken pipe                                          else if (errno == EINTR)
556                                          {                                          {
557                                                  log_common("write(socket) EOF\n");                                                  continue;
558                                                  sock_write_wait = 0;                                          }
559                                            else
560                                            {
561                                                    log_error("write(socket) error (%d)\n", errno);
562                                                  loop = 0;                                                  loop = 0;
563                                                  break;                                                  break;
564                                          }                                          }
565                                          else                                  }
566                                    else if (ret == 0) // broken pipe
567                                    {
568    #ifdef _DEBUG
569                                            log_error("write(socket) EOF\n");
570    #endif
571                                            sock_write_wait = 0;
572                                            loop = 0;
573                                            break;
574                                    }
575                                    else
576                                    {
577                                            input_buf_offset += ret;
578                                            if (input_buf_offset >= input_buf_len) // Output buffer complete
579                                          {                                          {
580                                                  input_buf_offset += ret;                                                  input_buf_offset = 0;
581                                                  if (input_buf_offset >= input_buf_len) // Output buffer complete                                                  input_buf_len = 0;
582                                                  {                                                  break;
                                                         input_buf_offset = 0;  
                                                         input_buf_len = 0;  
                                                         break;  
                                                 }  
                                                 continue;  
583                                          }                                          }
584                                            continue;
585                                  }                                  }
586                          }                          }
587                    }
588    
589                          if (events[i].data.fd == sock || sock_read_wait) // EPOLLIN                  if (sock_read_wait)
590                    {
591                            while (output_buf_len < sizeof(output_buf) && !SYS_server_exit)
592                          {                          {
593                                  sock_read_wait = 1;                                  ret = (int)read(sock, output_buf + output_buf_len, sizeof(output_buf) - (size_t)output_buf_len);
594                                  while (output_buf_len < sizeof(output_buf) && !SYS_server_exit)                                  if (ret < 0)
595                                  {                                  {
596                                          ret = (int)read(sock, output_buf + output_buf_len, sizeof(output_buf) - (size_t)output_buf_len);                                          if (errno == EAGAIN || errno == EWOULDBLOCK)
                                         if (ret < 0)  
                                         {  
                                                 if (errno == EAGAIN || errno == EWOULDBLOCK)  
                                                 {  
                                                         sock_read_wait = 0;  
                                                         break;  
                                                 }  
                                                 else if (errno == EINTR)  
                                                 {  
                                                         continue;  
                                                 }  
                                                 else  
                                                 {  
                                                         log_error("read(socket) error (%d)\n", errno);  
                                                         loop = 0;  
                                                         break;  
                                                 }  
                                         }  
                                         else if (ret == 0) // broken pipe  
597                                          {                                          {
                                                 log_common("read(socket) EOF\n");  
598                                                  sock_read_wait = 0;                                                  sock_read_wait = 0;
                                                 loop = 0;  
599                                                  break;                                                  break;
600                                          }                                          }
601                                          else                                          else if (errno == EINTR)
602                                          {                                          {
                                                 output_buf_len += ret;  
603                                                  continue;                                                  continue;
604                                          }                                          }
605                                            else
606                                            {
607                                                    log_error("read(socket) error (%d)\n", errno);
608                                                    loop = 0;
609                                                    break;
610                                            }
611                                    }
612                                    else if (ret == 0) // broken pipe
613                                    {
614    #ifdef _DEBUG
615                                            log_error("read(socket) EOF\n");
616    #endif
617                                            sock_read_wait = 0;
618                                            loop = 0;
619                                            break;
620                                    }
621                                    else
622                                    {
623                                            output_buf_len += ret;
624                                            continue;
625                                  }                                  }
626                          }                          }
627                    }
628    
629                          if (events[i].data.fd == STDOUT_FILENO || stdout_write_wait)                  if (stdout_write_wait)
630                    {
631                            while (output_buf_offset < output_buf_len && !SYS_server_exit)
632                          {                          {
633                                  stdout_write_wait = 1;                                  if (SSH_v2)
                                 while (output_buf_offset < output_buf_len && !SYS_server_exit)  
634                                  {                                  {
635                                          ret = (int)write(STDOUT_FILENO, output_buf + output_buf_offset, (size_t)(output_buf_len - output_buf_offset));                                          ret = ssh_channel_write(SSH_channel, output_buf + output_buf_offset, (uint32_t)(output_buf_len - output_buf_offset));
636                                          if (ret < 0)                                          if (ret == SSH_ERROR)
637                                          {                                          {
638                                                  if (errno == EAGAIN || errno == EWOULDBLOCK)                                                  log_error("ssh_channel_write() error: %s\n", ssh_get_error(SSH_session));
639                                                  {                                                  loop = 0;
640                                                          stdout_write_wait = 0;                                                  break;
                                                         break;  
                                                 }  
                                                 else if (errno == EINTR)  
                                                 {  
                                                         continue;  
                                                 }  
                                                 else  
                                                 {  
                                                         log_error("write(STDOUT) error (%d)\n", errno);  
                                                         loop = 0;  
                                                         break;  
                                                 }  
641                                          }                                          }
642                                          else if (ret == 0) // broken pipe                                  }
643                                    else
644                                    {
645                                            ret = (int)write(STDOUT_FILENO, output_buf + output_buf_offset, (size_t)(output_buf_len - output_buf_offset));
646                                    }
647                                    if (ret < 0)
648                                    {
649                                            if (errno == EAGAIN || errno == EWOULDBLOCK)
650                                          {                                          {
                                                 log_common("write(STDOUT) EOF\n");  
651                                                  stdout_write_wait = 0;                                                  stdout_write_wait = 0;
                                                 loop = 0;  
652                                                  break;                                                  break;
653                                          }                                          }
654                                          else                                          else if (errno == EINTR)
655                                          {                                          {
                                                 output_buf_offset += ret;  
                                                 if (output_buf_offset >= output_buf_len) // Output buffer complete  
                                                 {  
                                                         output_buf_offset = 0;  
                                                         output_buf_len = 0;  
                                                         break;  
                                                 }  
656                                                  continue;                                                  continue;
657                                          }                                          }
658                                            else
659                                            {
660                                                    log_error("write(STDOUT) error (%d)\n", errno);
661                                                    loop = 0;
662                                                    break;
663                                            }
664                                    }
665                                    else if (ret == 0) // broken pipe
666                                    {
667    #ifdef _DEBUG
668                                            log_error("write(STDOUT) EOF\n");
669    #endif
670                                            stdout_write_wait = 0;
671                                            loop = 0;
672                                            break;
673                                    }
674                                    else
675                                    {
676                                            output_buf_offset += ret;
677                                            if (output_buf_offset >= output_buf_len) // Output buffer complete
678                                            {
679                                                    output_buf_offset = 0;
680                                                    output_buf_len = 0;
681                                                    break;
682                                            }
683                                            continue;
684                                  }                                  }
685                          }                          }
686                  }                  }
# Line 619  cleanup: Line 704  cleanup:
704                  log_error("Close socket failed\n");                  log_error("Close socket failed\n");
705          }          }
706    
707          t_used = time(0) - t_used;          t_used = time(NULL) - t_used;
708          tm_used = gmtime(&t_used);          tm_used = gmtime(&t_used);
709    
710          log_common("BBSNET disconnect, %d days %d hours %d minutes %d seconds used\n",          log_common("BBSNET disconnect, %d days %d hours %d minutes %d seconds used\n",
711                          tm_used->tm_mday - 1, tm_used->tm_hour, tm_used->tm_min,                             tm_used->tm_mday - 1, tm_used->tm_hour, tm_used->tm_min,
712                          tm_used->tm_sec);                             tm_used->tm_sec);
713    
714          return 0;          return 0;
715  }  }
# Line 647  bbsnet_refresh() Line 732  bbsnet_refresh()
732          moveto(22, 0);          moveto(22, 0);
733          prints(" ----------------------------------------------------------------------------- ");          prints(" ----------------------------------------------------------------------------- ");
734          moveto(23, 0);          moveto(23, 0);
735          prints(" [\x1b[1;32mCtrl+C\x1b[m]退出");          prints(" [\x1b[1;32mCtrl+C\x1b[m]閫鍑");
736    
737          iflush();          iflush();
738    
# Line 660  int bbsnet_selchange() Line 745  int bbsnet_selchange()
745    
746          moveto(20, 0);          moveto(20, 0);
747          clrtoeol();          clrtoeol();
748          prints("|\x1b[1m单位:\x1b[1;33m%-18s\x1b[m  站名:\x1b[1;33m%s\x1b[m",          prints("|\x1b[1m鍗曚綅:\x1b[1;33m%-18s\x1b[m  绔欏悕:\x1b[1;33m%s\x1b[m",
749                     bbsnet_conf[i].host2, bbsnet_conf[i].host1);                     bbsnet_conf[i].host2, bbsnet_conf[i].host1);
750          moveto(20, 79);          moveto(20, 79);
751          prints("|");          prints("|");
752          moveto(21, 0);          moveto(21, 0);
753          clrtoeol();          clrtoeol();
754          prints("|\x1b[1m连往:\x1b[1;33m%-20s", bbsnet_conf[i].ip);          prints("|\x1b[1m杩炲線:\x1b[1;33m%-20s", bbsnet_conf[i].ip);
755          if (bbsnet_conf[i].port != 23)          if (bbsnet_conf[i].port != 23)
756          {          {
757                  prints("  %d", bbsnet_conf[i].port);                  prints("  %d", bbsnet_conf[i].port);
# Line 685  int bbs_net() Line 770  int bbs_net()
770    
771          load_bbsnet_conf(CONF_BBSNET);          load_bbsnet_conf(CONF_BBSNET);
772    
773          BBS_last_access_tm = time(0);          BBS_last_access_tm = time(NULL);
774    
775          clearscr();          clearscr();
776          bbsnet_refresh();          bbsnet_refresh();
# Line 695  int bbs_net() Line 780  int bbs_net()
780          while (!SYS_server_exit)          while (!SYS_server_exit)
781          {          {
782                  ch = igetch(100);                  ch = igetch(100);
783    
784                  switch (ch)                  switch (ch)
785                  {                  {
786                  case KEY_NULL:  // broken pipe                  case KEY_NULL: // broken pipe
787                  case KEY_ESC:                  case KEY_ESC:
788                  case Ctrl('C'): // user cancel                  case Ctrl('C'): // user cancel
789                          goto cleanup;                          goto cleanup;
790                  case KEY_TIMEOUT:                  case KEY_TIMEOUT:
791                          if (time(0) - BBS_last_access_tm >= MAX_DELAY_TIME)                          if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME)
792                          {                          {
793                                  goto cleanup;                                  goto cleanup;
794                          }                          }
# Line 751  int bbs_net() Line 837  int bbs_net()
837                          bbsnet_selchange();                          bbsnet_selchange();
838                          break;                          break;
839                  }                  }
840                  BBS_last_access_tm = time(0);                  BBS_last_access_tm = time(NULL);
841          }          }
842    
843  cleanup:  cleanup:


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

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