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

Diff of /lbbs/src/section_list.c

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

Revision 1.35 by sysadm, Mon Jun 23 08:38:01 2025 UTC Revision 1.43 by sysadm, Tue Oct 14 05:28:15 2025 UTC
# Line 75  typedef struct article_block_pool_t ARTI Line 75  typedef struct article_block_pool_t ARTI
75    
76  static ARTICLE_BLOCK_POOL *p_article_block_pool = NULL;  static ARTICLE_BLOCK_POOL *p_article_block_pool = NULL;
77    
78  struct section_list_pool_t  SECTION_LIST_POOL *p_section_list_pool = NULL;
 {  
         int shmid;  
         SECTION_LIST sections[BBS_max_section];  
         int section_count;  
         int semid;  
         TRIE_NODE *p_trie_dict_section_by_name;  
         TRIE_NODE *p_trie_dict_section_by_sid;  
 };  
 typedef struct section_list_pool_t SECTION_LIST_POOL;  
   
 static SECTION_LIST_POOL *p_section_list_pool = NULL;  
79    
80  int article_block_init(const char *filename, int block_count)  int article_block_init(const char *filename, int block_count)
81  {  {
# Line 630  SECTION_LIST *section_list_create(int32_ Line 619  SECTION_LIST *section_list_create(int32_
619          p_section = p_section_list_pool->sections + p_section_list_pool->section_count;          p_section = p_section_list_pool->sections + p_section_list_pool->section_count;
620    
621          p_section->sid = sid;          p_section->sid = sid;
622            p_section->ex_menu_tm = 0;
623    
624          strncpy(p_section->sname, sname, sizeof(p_section->sname) - 1);          strncpy(p_section->sname, sname, sizeof(p_section->sname) - 1);
625          p_section->sname[sizeof(p_section->sname) - 1] = '\0';          p_section->sname[sizeof(p_section->sname) - 1] = '\0';
# Line 659  SECTION_LIST *section_list_create(int32_ Line 649  SECTION_LIST *section_list_create(int32_
649          return p_section;          return p_section;
650  }  }
651    
652    int section_list_update(SECTION_LIST *p_section, const char *sname, const char *stitle, const char *master_list)
653    {
654            if (p_section == NULL || sname == NULL || stitle == NULL || master_list == NULL)
655            {
656                    log_error("NULL pointer error\n");
657                    return -1;
658            }
659    
660            strncpy(p_section->sname, sname, sizeof(p_section->sname) - 1);
661            p_section->sname[sizeof(p_section->sname) - 1] = '\0';
662    
663            strncpy(p_section->stitle, stitle, sizeof(p_section->stitle) - 1);
664            p_section->stitle[sizeof(p_section->stitle) - 1] = '\0';
665    
666            strncpy(p_section->master_list, master_list, sizeof(p_section->master_list) - 1);
667            p_section->master_list[sizeof(p_section->master_list) - 1] = '\0';
668    
669            if (trie_dict_set(p_section_list_pool->p_trie_dict_section_by_name, sname, p_section_list_pool->section_count) != 1)
670            {
671                    log_error("trie_dict_set(section, %s, %d) error\n", sname, p_section_list_pool->section_count);
672                    return -2;
673            }
674    
675            return 0;
676    }
677    
678  void section_list_reset_articles(SECTION_LIST *p_section)  void section_list_reset_articles(SECTION_LIST *p_section)
679  {  {
680          p_section->article_count = 0;          p_section->article_count = 0;
# Line 737  int section_list_append_article(SECTION_ Line 753  int section_list_append_article(SECTION_
753    
754          if (p_section == NULL || p_article_src == NULL)          if (p_section == NULL || p_article_src == NULL)
755          {          {
756                  log_error("section_list_append_article() NULL pointer error\n");                  log_error("NULL pointer error\n");
757                  return -1;                  return -1;
758          }          }
759    
# Line 1033  int section_list_page_count_with_ontop(S Line 1049  int section_list_page_count_with_ontop(S
1049                  return -1;                  return -1;
1050          }          }
1051    
1052          page_count = p_section->page_count - 1 +          page_count = p_section->page_count - (p_section->last_page_visible_article_count > 0 ? 1 : 0) +
1053                                   (p_section->last_page_visible_article_count + p_section->ontop_article_count) / BBS_article_limit_per_page +                                   (p_section->last_page_visible_article_count + p_section->ontop_article_count) / BBS_article_limit_per_page +
1054                                   ((p_section->last_page_visible_article_count + p_section->ontop_article_count) % BBS_article_limit_per_page == 0 ? 0 : 1);                                   ((p_section->last_page_visible_article_count + p_section->ontop_article_count) % BBS_article_limit_per_page == 0 ? 0 : 1);
1055    
# Line 1072  ARTICLE *section_list_find_article_with_ Line 1088  ARTICLE *section_list_find_article_with_
1088    
1089          if (p_section == NULL)          if (p_section == NULL)
1090          {          {
1091                  log_error("section_list_find_article_with_offset() NULL pointer error\n");                  log_error("NULL pointer error\n");
1092                  return NULL;                  return NULL;
1093          }          }
1094    
# Line 1164  int section_list_calculate_page(SECTION_ Line 1180  int section_list_calculate_page(SECTION_
1180    
1181          if (p_section == NULL)          if (p_section == NULL)
1182          {          {
1183                  log_error("section_list_calculate_page() NULL pointer error\n");                  log_error("NULL pointer error\n");
1184                  return -1;                  return -1;
1185          }          }
1186    
# Line 1323  int section_list_move_topic(SECTION_LIST Line 1339  int section_list_move_topic(SECTION_LIST
1339    
1340          if (p_section_src == NULL || p_section_dest == NULL)          if (p_section_src == NULL || p_section_dest == NULL)
1341          {          {
1342                  log_error("section_list_move_topic() NULL pointer error\n");                  log_error("NULL pointer error\n");
1343                  return -1;                  return -1;
1344          }          }
1345    
# Line 1695  int section_list_rd_lock(SECTION_LIST *p Line 1711  int section_list_rd_lock(SECTION_LIST *p
1711                          timer++;                          timer++;
1712                          if (timer % SECTION_TRY_LOCK_TIMES == 0)                          if (timer % SECTION_TRY_LOCK_TIMES == 0)
1713                          {                          {
1714                                  log_error("section_list_rd_lock() tried %d times on section %d\n", sid, timer);                                  log_error("section_list_try_rd_lock() tried %d times on section %d\n", sid, timer);
1715                          }                          }
1716                  }                  }
1717                  else // failed                  else // failed
1718                  {                  {
1719                          log_error("section_list_rd_lock() failed on section %d\n", sid);                          log_error("section_list_try_rd_lock() failed on section %d\n", sid);
1720                          break;                          break;
1721                  }                  }
1722          }          }
# Line 1726  int section_list_rw_lock(SECTION_LIST *p Line 1742  int section_list_rw_lock(SECTION_LIST *p
1742                          timer++;                          timer++;
1743                          if (timer % SECTION_TRY_LOCK_TIMES == 0)                          if (timer % SECTION_TRY_LOCK_TIMES == 0)
1744                          {                          {
1745                                  log_error("acquire_section_rw_lock() tried %d times on section %d\n", sid, timer);                                  log_error("section_list_try_rw_lock() tried %d times on section %d\n", sid, timer);
1746                          }                          }
1747                  }                  }
1748                  else // failed                  else // failed
1749                  {                  {
1750                          log_error("acquire_section_rw_lock() failed on section %d\n", sid);                          log_error("section_list_try_rw_lock() failed on section %d\n", sid);
1751                          break;                          break;
1752                  }                  }
1753          }          }


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

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