/[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.49 by sysadm, Mon Jun 16 14:30:44 2025 UTC Revision 1.52 by sysadm, Wed Jun 18 04:38:20 2025 UTC
# Line 14  Line 14 
14   *                                                                         *   *                                                                         *
15   ***************************************************************************/   ***************************************************************************/
16    
 #define _POSIX_C_SOURCE 200809L  
   
17  #include "bbs.h"  #include "bbs.h"
18  #include "common.h"  #include "common.h"
19  #include "log.h"  #include "log.h"
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 408  int bbsnet_connect(int n) Line 407  int bbsnet_connect(int n)
407                  goto cleanup;                  goto cleanup;
408          }          }
409    
410          BBS_last_access_tm = t_used = time(0);          BBS_last_access_tm = t_used = time(NULL);
411          loop = 1;          loop = 1;
412    
413          while (loop && !SYS_server_exit)          while (loop && !SYS_server_exit)
# Line 433  int bbsnet_connect(int n) Line 432  int bbsnet_connect(int n)
432                  }                  }
433                  else if (nfds == 0) // timeout                  else if (nfds == 0) // timeout
434                  {                  {
435                          if (time(0) - BBS_last_access_tm >= MAX_DELAY_TIME)                          if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME)
436                          {                          {
437                                  break;                                  break;
438                          }                          }
# Line 500  int bbsnet_connect(int n) Line 499  int bbsnet_connect(int n)
499                                          else                                          else
500                                          {                                          {
501                                                  input_buf_len += ret;                                                  input_buf_len += ret;
502                                                  BBS_last_access_tm = time(0);                                                  BBS_last_access_tm = time(NULL);
503                                                  continue;                                                  continue;
504                                          }                                          }
505                                  }                                  }
# Line 577  int bbsnet_connect(int n) Line 576  int bbsnet_connect(int n)
576                                          }                                          }
577                                          else if (ret == 0) // broken pipe                                          else if (ret == 0) // broken pipe
578                                          {                                          {
579                                                  log_common("read(socket) EOF\n");  #ifdef _DEBUG
580                                                    log_error("read(socket) EOF\n");
581    #endif
582                                                  sock_read_wait = 0;                                                  sock_read_wait = 0;
583                                                  loop = 0;                                                  loop = 0;
584                                                  break;                                                  break;
# Line 629  int bbsnet_connect(int n) Line 630  int bbsnet_connect(int n)
630                                          }                                          }
631                                          else if (ret == 0) // broken pipe                                          else if (ret == 0) // broken pipe
632                                          {                                          {
633                                                  log_common("write(STDOUT) EOF\n");  #ifdef _DEBUG
634                                                    log_error("write(STDOUT) EOF\n");
635    #endif
636                                                  stdout_write_wait = 0;                                                  stdout_write_wait = 0;
637                                                  loop = 0;                                                  loop = 0;
638                                                  break;                                                  break;
# Line 668  cleanup: Line 671  cleanup:
671                  log_error("Close socket failed\n");                  log_error("Close socket failed\n");
672          }          }
673    
674          t_used = time(0) - t_used;          t_used = time(NULL) - t_used;
675          tm_used = gmtime(&t_used);          tm_used = gmtime(&t_used);
676    
677          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 734  int bbs_net() Line 737  int bbs_net()
737    
738          load_bbsnet_conf(CONF_BBSNET);          load_bbsnet_conf(CONF_BBSNET);
739    
740          BBS_last_access_tm = time(0);          BBS_last_access_tm = time(NULL);
741    
742          clearscr();          clearscr();
743          bbsnet_refresh();          bbsnet_refresh();
# Line 744  int bbs_net() Line 747  int bbs_net()
747          while (!SYS_server_exit)          while (!SYS_server_exit)
748          {          {
749                  ch = igetch(100);                  ch = igetch(100);
750    
751                    if (user_online_update("BBS_NET") < 0)
752                    {
753                            log_error("user_online_update(BBS_NET) error\n");
754                    }
755    
756                  switch (ch)                  switch (ch)
757                  {                  {
758                  case KEY_NULL: // broken pipe                  case KEY_NULL: // broken pipe
# Line 751  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 800  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