/[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.48 by sysadm, Thu Jun 5 08:36:02 2025 UTC Revision 1.53 by sysadm, Wed Jun 18 05:11:19 2025 UTC
# Line 20  Line 20 
20  #include "io.h"  #include "io.h"
21  #include "screen.h"  #include "screen.h"
22  #include "menu.h"  #include "menu.h"
23    #include "login.h"
24  #include <stdio.h>  #include <stdio.h>
25  #include <stdarg.h>  #include <stdarg.h>
26  #include <errno.h>  #include <errno.h>
# Line 216  int bbsnet_connect(int n) Line 217  int bbsnet_connect(int n)
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);
# Line 252  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 406  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)
# Line 431  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                          }                          }
# Line 498  int bbsnet_connect(int n) Line 504  int bbsnet_connect(int n)
504                                          else                                          else
505                                          {                                          {
506                                                  input_buf_len += ret;                                                  input_buf_len += ret;
507                                                  BBS_last_access_tm = time(0);                                                  BBS_last_access_tm = time(NULL);
508                                                  continue;                                                  continue;
509                                          }                                          }
510                                  }                                  }
# Line 575  int bbsnet_connect(int n) Line 581  int bbsnet_connect(int n)
581                                          }                                          }
582                                          else if (ret == 0) // broken pipe                                          else if (ret == 0) // broken pipe
583                                          {                                          {
584                                                  log_common("read(socket) EOF\n");  #ifdef _DEBUG
585                                                    log_error("read(socket) EOF\n");
586    #endif
587                                                  sock_read_wait = 0;                                                  sock_read_wait = 0;
588                                                  loop = 0;                                                  loop = 0;
589                                                  break;                                                  break;
# Line 627  int bbsnet_connect(int n) Line 635  int bbsnet_connect(int n)
635                                          }                                          }
636                                          else if (ret == 0) // broken pipe                                          else if (ret == 0) // broken pipe
637                                          {                                          {
638                                                  log_common("write(STDOUT) EOF\n");  #ifdef _DEBUG
639                                                    log_error("write(STDOUT) EOF\n");
640    #endif
641                                                  stdout_write_wait = 0;                                                  stdout_write_wait = 0;
642                                                  loop = 0;                                                  loop = 0;
643                                                  break;                                                  break;
# Line 666  cleanup: Line 676  cleanup:
676                  log_error("Close socket failed\n");                  log_error("Close socket failed\n");
677          }          }
678    
679          t_used = time(0) - t_used;          t_used = time(NULL) - t_used;
680          tm_used = gmtime(&t_used);          tm_used = gmtime(&t_used);
681    
682          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",
# Line 732  int bbs_net() Line 742  int bbs_net()
742    
743          load_bbsnet_conf(CONF_BBSNET);          load_bbsnet_conf(CONF_BBSNET);
744    
745          BBS_last_access_tm = time(0);          BBS_last_access_tm = time(NULL);
746    
747          clearscr();          clearscr();
748          bbsnet_refresh();          bbsnet_refresh();
# Line 742  int bbs_net() Line 752  int bbs_net()
752          while (!SYS_server_exit)          while (!SYS_server_exit)
753          {          {
754                  ch = igetch(100);                  ch = igetch(100);
755    
756                  switch (ch)                  switch (ch)
757                  {                  {
758                  case KEY_NULL: // broken pipe                  case KEY_NULL: // broken pipe
# Line 749  int bbs_net() Line 760  int bbs_net()
760                  case Ctrl('C'): // user cancel                  case Ctrl('C'): // user cancel
761                          goto cleanup;                          goto cleanup;
762                  case KEY_TIMEOUT:                  case KEY_TIMEOUT:
763                          if (time(0) - BBS_last_access_tm >= MAX_DELAY_TIME)                          if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME)
764                          {                          {
765                                  goto cleanup;                                  goto cleanup;
766                          }                          }
# Line 798  int bbs_net() Line 809  int bbs_net()
809                          bbsnet_selchange();                          bbsnet_selchange();
810                          break;                          break;
811                  }                  }
812                  BBS_last_access_tm = time(0);                  BBS_last_access_tm = time(NULL);
813          }          }
814    
815  cleanup:  cleanup:


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

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