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

Diff of /lbbs/src/section_list_display.c

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

Revision 1.69 by sysadm, Tue Nov 4 13:49:51 2025 UTC Revision 1.80 by sysadm, Wed Dec 3 14:04:02 2025 UTC
# Line 3  Line 3 
3   * section_list_display   * section_list_display
4   *   - user interactive feature of section articles list   *   - user interactive feature of section articles list
5   *   *
6   * Copyright (C) 2004-2025 by Leaflet <leaflet@leafok.com>   * Copyright (C) 2004-2025  Leaflet <leaflet@leafok.com>
7   */   */
8    
9    #ifdef HAVE_CONFIG_H
10    #include "config.h"
11    #endif
12    
13  #include "article_cache.h"  #include "article_cache.h"
14  #include "article_favor.h"  #include "article_favor.h"
15  #include "article_op.h"  #include "article_op.h"
# Line 31  Line 35 
35  #include <time.h>  #include <time.h>
36  #include <sys/param.h>  #include <sys/param.h>
37    
38  #define TITLE_SEARCH_MAX_LEN 60  enum _section_list_display_constant_t
39    {
40            TITLE_SEARCH_MAX_LEN = 60,
41    };
42    
43  static int32_t section_aid_locations[BBS_max_section] = {0};  static int32_t section_aid_locations[BBS_max_section] = {0};
44  static int section_topic_view_mode = 0;  static int section_topic_view_mode = 0;
# Line 64  enum select_cmd_t Line 71  enum select_cmd_t
71          SEARCH_USER,          SEARCH_USER,
72  };  };
73    
74  static int section_list_draw_items(int page_id, ARTICLE *p_articles[], int article_count, int display_nickname, int ontop_start_offset)  static int section_list_draw_items(int page_id, const ARTICLE *p_articles[], int article_count, int display_nickname, int ontop_start_offset)
75  {  {
76          char str_time[LINE_BUFFER_LEN];          char str_time[LINE_BUFFER_LEN];
77          struct tm tm_sub;          struct tm tm_sub;
# Line 218  static int section_list_draw_screen(cons Line 225  static int section_list_draw_screen(cons
225    
226          if (master_list[0] != '\0')          if (master_list[0] != '\0')
227          {          {
228                  snprintf(str_section_master, sizeof(str_section_master), "版主:%s", master_list);                  snprintf(str_section_master, sizeof(str_section_master), "版主: %s", master_list);
229          }          }
230          snprintf(str_section_name, sizeof(str_section_name), "讨论区 [%s]", sname);          snprintf(str_section_name, sizeof(str_section_name), "讨论区 [%s]", sname);
231    
# Line 263  static enum select_cmd_t section_list_se Line 270  static enum select_cmd_t section_list_se
270                  if (ch != KEY_NULL && ch != KEY_TIMEOUT)                  if (ch != KEY_NULL && ch != KEY_TIMEOUT)
271                  {                  {
272                          BBS_last_access_tm = time(NULL);                          BBS_last_access_tm = time(NULL);
273    
274                            // Refresh current action
275                            if (user_online_update(NULL) < 0)
276                            {
277                                    log_error("user_online_update(NULL) error\n");
278                            }
279                  }                  }
280    
281                  switch (ch)                  switch (ch)
# Line 271  static enum select_cmd_t section_list_se Line 284  static enum select_cmd_t section_list_se
284                          log_error("KEY_NULL\n");                          log_error("KEY_NULL\n");
285                          return EXIT_SECTION;                          return EXIT_SECTION;
286                  case KEY_TIMEOUT:                  case KEY_TIMEOUT:
287                          if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME)                          if (time(NULL) - BBS_last_access_tm >= BBS_max_user_idle_time)
288                          {                          {
289                                  log_error("User input timeout\n");                                  log_error("User input timeout\n");
290                                  return EXIT_SECTION;                                  return EXIT_SECTION;
# Line 577  int section_list_display(const char *sna Line 590  int section_list_display(const char *sna
590          char stitle[BBS_section_title_max_len + 1];          char stitle[BBS_section_title_max_len + 1];
591          char master_list[(BBS_username_max_len + 1) * 3 + 1];          char master_list[(BBS_username_max_len + 1) * 3 + 1];
592          char page_info_str[LINE_BUFFER_LEN];          char page_info_str[LINE_BUFFER_LEN];
593          ARTICLE *p_articles[BBS_article_limit_per_page];          const ARTICLE *p_articles[BBS_article_limit_per_page];
594          int article_count;          int article_count;
595          int page_count;          int page_count;
596          int ontop_start_offset;          int ontop_start_offset;
# Line 705  int section_list_display(const char *sna Line 718  int section_list_display(const char *sna
718                  {                  {
719                  case EXIT_SECTION:                  case EXIT_SECTION:
720                          // Update current aid location                          // Update current aid location
721                          if (p_articles[selected_index] != NULL)                          if (selected_index < article_count && p_articles[selected_index] != NULL)
722                          {                          {
723                                  if (selected_index >= ontop_start_offset)                                  if (selected_index >= ontop_start_offset)
724                                  {                                  {
# Line 1173  int section_list_display(const char *sna Line 1186  int section_list_display(const char *sna
1186                          moveto(SCREEN_ROWS, 1);                          moveto(SCREEN_ROWS, 1);
1187                          clrtoeol();                          clrtoeol();
1188                          get_data(SCREEN_ROWS, 1,                          get_data(SCREEN_ROWS, 1,
1189                                           (direction == 1 ? "向下搜寻作者: " : "向上搜寻作者: "),                                           (direction == 1 ? "↓搜寻作者: " : "↑搜寻作者: "),
1190                                           username, sizeof(username), BBS_username_max_len);                                           username, sizeof(username), BBS_username_max_len);
1191    
1192                          if (username[0] == '\0')                          if (username[0] == '\0')
# Line 1184  int section_list_display(const char *sna Line 1197  int section_list_display(const char *sna
1197                          // Verify format                          // Verify format
1198                          for (i = 0, ok = 1; ok && username[i] != '\0'; i++)                          for (i = 0, ok = 1; ok && username[i] != '\0'; i++)
1199                          {                          {
1200                                  if (!(isalpha(username[i]) || (i > 0 && (isdigit(username[i]) || username[i] == '_'))))                                  if (!(isalpha((int)username[i]) || (i > 0 && (isdigit((int)username[i]) || username[i] == '_'))))
1201                                  {                                  {
1202                                          ok = 0;                                          ok = 0;
1203                                  }                                  }
# Line 1262  int section_list_display(const char *sna Line 1275  int section_list_display(const char *sna
1275                          moveto(SCREEN_ROWS, 1);                          moveto(SCREEN_ROWS, 1);
1276                          clrtoeol();                          clrtoeol();
1277                          get_data(SCREEN_ROWS, 1,                          get_data(SCREEN_ROWS, 1,
1278                                           (direction == 1 ? "向下搜寻标题: " : "向上搜寻标题: "),                                           (direction == 1 ? "↓搜寻标题: " : "↑搜寻标题: "),
1279                                           title, sizeof(title), TITLE_SEARCH_MAX_LEN);                                           title, sizeof(title), TITLE_SEARCH_MAX_LEN);
1280    
1281                          if (title[0] == '\0')                          if (title[0] == '\0')
# Line 1350  int section_list_ex_dir_display(SECTION_ Line 1363  int section_list_ex_dir_display(SECTION_
1363  {  {
1364          MENU_SET ex_menu_set;          MENU_SET ex_menu_set;
1365          int ch = 0;          int ch = 0;
1366            int loop;
1367    
1368          if (p_section == NULL)          if (p_section == NULL)
1369          {          {
# Line 1382  int section_list_ex_dir_display(SECTION_ Line 1396  int section_list_ex_dir_display(SECTION_
1396    
1397          if (display_menu(&ex_menu_set) == 0)          if (display_menu(&ex_menu_set) == 0)
1398          {          {
1399                  while (!SYS_server_exit)                  for (loop = 1; !SYS_server_exit && loop;)
1400                  {                  {
1401                          iflush();                          iflush();
1402                          ch = igetch(100);                          ch = igetch(100);
# Line 1390  int section_list_ex_dir_display(SECTION_ Line 1404  int section_list_ex_dir_display(SECTION_
1404                          if (ch != KEY_NULL && ch != KEY_TIMEOUT)                          if (ch != KEY_NULL && ch != KEY_TIMEOUT)
1405                          {                          {
1406                                  BBS_last_access_tm = time(NULL);                                  BBS_last_access_tm = time(NULL);
1407    
1408                                    // Refresh current action
1409                                    if (user_online_update(NULL) < 0)
1410                                    {
1411                                            log_error("user_online_update(NULL) error\n");
1412                                    }
1413                          }                          }
1414    
1415                          switch (ch)                          switch (ch)
1416                          {                          {
1417                          case KEY_NULL: // broken pipe                          case KEY_NULL: // broken pipe
1418                                  log_error("KEY_NULL\n");                                  log_error("KEY_NULL\n");
1419                                  return 0;                                  loop = 0;
1420                                    break;
1421                          case KEY_TIMEOUT:                          case KEY_TIMEOUT:
1422                                  if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME)                                  if (time(NULL) - BBS_last_access_tm >= BBS_max_user_idle_time)
1423                                  {                                  {
1424                                          log_error("User input timeout\n");                                          log_error("User input timeout\n");
1425                                          return 0;                                          loop = 0;
1426                                            break;
1427                                  }                                  }
1428                                  continue;                                  continue;
1429                          case CR:                          case CR:
# Line 1409  int section_list_ex_dir_display(SECTION_ Line 1431  int section_list_ex_dir_display(SECTION_
1431                                  switch (menu_control(&ex_menu_set, ch))                                  switch (menu_control(&ex_menu_set, ch))
1432                                  {                                  {
1433                                  case EXITMENU:                                  case EXITMENU:
1434                                          ch = EXITMENU;                                          loop = 0;
1435                                          break;                                          break;
1436                                  case REDRAW:                                  case REDRAW:
1437                                          clearscr();                                          clearscr();
# Line 1422  int section_list_ex_dir_display(SECTION_ Line 1444  int section_list_ex_dir_display(SECTION_
1444                                          break;                                          break;
1445                                  }                                  }
1446                          }                          }
   
                         if (ch == EXITMENU)  
                         {  
                                 break;  
                         }  
1447                  }                  }
1448          }          }
1449    


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

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