/[LeafOK_CVS]/lbbs/src/bbs_main.c
ViewVC logotype

Diff of /lbbs/src/bbs_main.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.96 by sysadm, Sun Nov 2 08:13:50 2025 UTC Revision 1.103 by sysadm, Sat Nov 8 08:21:31 2025 UTC
# Line 1  Line 1 
1  /***************************************************************************  /* SPDX-License-Identifier: GPL-3.0-or-later */
2                                                    bbs_main.c  -  description  /*
3                                                           -------------------   * bbs_main
4          Copyright            : (C) 2004-2025 by Leaflet   *   - entry and major procedures of user interactive access
5          Email                : leaflet@leafok.com   *
6   ***************************************************************************/   * Copyright (C) 2004-2025  Leaflet <leaflet@leafok.com>
7     */
 /***************************************************************************  
  *                                                                         *  
  *   This program is free software; you can redistribute it and/or modify  *  
  *   it under the terms of the GNU General Public License as published by  *  
  *   the Free Software Foundation; either version 3 of the License, or     *  
  *   (at your option) any later version.                                   *  
  *                                                                         *  
  ***************************************************************************/  
8    
9  #include "article_favor.h"  #include "article_favor.h"
10  #include "article_view_log.h"  #include "article_view_log.h"
11  #include "bbs.h"  #include "bbs.h"
12  #include "bbs_cmd.h"  #include "bbs_cmd.h"
13  #include "bbs_main.h"  #include "bbs_main.h"
14    #include "bwf.h"
15  #include "common.h"  #include "common.h"
16  #include "database.h"  #include "database.h"
17  #include "editor.h"  #include "editor.h"
# Line 29  Line 22 
22  #include "screen.h"  #include "screen.h"
23  #include "section_list.h"  #include "section_list.h"
24  #include "section_list_display.h"  #include "section_list_display.h"
25    #include "str_process.h"
26  #include "trie_dict.h"  #include "trie_dict.h"
27  #include "user_list.h"  #include "user_list.h"
28  #include "user_priv.h"  #include "user_priv.h"
# Line 146  int bbs_center() Line 140  int bbs_center()
140                  if (ch != KEY_NULL && ch != KEY_TIMEOUT)                  if (ch != KEY_NULL && ch != KEY_TIMEOUT)
141                  {                  {
142                          BBS_last_access_tm = time(NULL);                          BBS_last_access_tm = time(NULL);
143    #ifdef _DEBUG
144                            log_error("Debug: BBS_last_access_tm is updated\n");
145    #endif
146                  }                  }
147    
148                  if (bbs_menu.choose_step == 0 && time(NULL) - t_last_action >= 10)                  if (bbs_menu.choose_step == 0 && time(NULL) - t_last_action >= 10)
# Line 169  int bbs_center() Line 166  int bbs_center()
166                          log_error("KEY_NULL\n");                          log_error("KEY_NULL\n");
167                          return 0;                          return 0;
168                  case KEY_TIMEOUT:                  case KEY_TIMEOUT:
169                          if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME)                          if (time(NULL) - BBS_last_access_tm >= BBS_max_user_idle_time)
170                          {                          {
171                                  log_error("User input timeout\n");                                  log_error("User input timeout\n");
172                                  return 0;                                  return 0;
# Line 208  int bbs_charset_select() Line 205  int bbs_charset_select()
205          int ch;          int ch;
206    
207          snprintf(msg, sizeof(msg),          snprintf(msg, sizeof(msg),
208                           "\rChoose character set in 5 seconds [UTF-8, GBK]: [U/g]");                           "\rChoose character set in 3 seconds [UTF-8, GBK]: [U/g]");
209    
210          while (!SYS_server_exit)          while (!SYS_server_exit)
211          {          {
212                  ch = press_any_key_ex(msg, 5);                  ch = press_any_key_ex(msg, 3);
213                  switch (ch)                  switch (toupper(ch))
214                  {                  {
215                  case KEY_NULL:                  case KEY_NULL:
216                          return -1;                          return -1;
217                  case KEY_TIMEOUT:                  case KEY_TIMEOUT:
218                  case CR:                  case CR:
                 case 'u':  
219                  case 'U':                  case 'U':
220                          return 0;                          break;
                 case 'g':  
221                  case 'G':                  case 'G':
222                          if (io_conv_init("GBK") < 0)                          if (io_conv_init("GBK") < 0)
223                          {                          {
224                                  log_error("io_conv_init(%s) error\n", "GBK");                                  log_error("io_conv_init(%s) error\n", "GBK");
225                                  return -1;                                  return -1;
226                          }                          }
227                          return 0;                          break;
228                  default:                  default:
229                          continue;                          continue;
230                  }                  }
231    
232                    break;
233            }
234    
235            snprintf(msg, sizeof(msg),
236                             "\rChoose wide-character display in 3 seconds [Fixed, Dynamic]: [F/d]");
237    
238            while (!SYS_server_exit)
239            {
240                    ch = press_any_key_ex(msg, 3);
241                    switch (toupper(ch))
242                    {
243                    case KEY_NULL:
244                            return -1;
245                    case KEY_TIMEOUT:
246                    case CR:
247                    case 'F':
248                            UTF8_fixed_width = 1;
249                            break;
250                    case 'D':
251                            UTF8_fixed_width = 0;
252                            break;
253                    default:
254                            continue;
255                    }
256    
257                    break;
258          }          }
259    
260          return 0;          return 0;
# Line 282  int bbs_main() Line 304  int bbs_main()
304          }          }
305    
306          // Set default charset          // Set default charset
307          if (io_conv_init(BBS_DEFAULT_CHARSET) < 0)          if (io_conv_init(BBS_default_charset) < 0)
308          {          {
309                  log_error("io_conv_init(%s) error\n", BBS_DEFAULT_CHARSET);                  log_error("io_conv_init(%s) error\n", BBS_default_charset);
310                  goto cleanup;                  goto cleanup;
311          }          }
312    
# Line 323  int bbs_main() Line 345  int bbs_main()
345                  log_error("article_view_log_load() error\n");                  log_error("article_view_log_load() error\n");
346                  goto cleanup;                  goto cleanup;
347          }          }
348            
349          // Load article view log          // Load article view log
350          if (article_view_log_load(BBS_priv.uid, &BBS_article_view_log, 0) < 0)          if (article_view_log_load(BBS_priv.uid, &BBS_article_view_log, 0) < 0)
351          {          {
# Line 397  cleanup: Line 419  cleanup:
419          detach_article_block_shm();          detach_article_block_shm();
420          detach_trie_dict_shm();          detach_trie_dict_shm();
421    
422            // Cleanup BWF
423            bwf_unload();
424    
425          return 0;          return 0;
426  }  }


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

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