/[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.36 by sysadm, Tue Jun 24 10:01:24 2025 UTC Revision 1.44 by sysadm, Tue Oct 14 05:52:29 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 555  void section_list_cleanup(void) Line 544  void section_list_cleanup(void)
544          p_section_list_pool = NULL;          p_section_list_pool = NULL;
545  }  }
546    
 void section_list_ex_menu_set_cleanup(void)  
 {  
         int i;  
   
         for (i = 0; i < p_section_list_pool->section_count; i++)  
         {  
                 if (p_section_list_pool->sections[i].ex_menu_tm > 0)  
                 {  
                         unload_menu(&(p_section_list_pool->sections[i].ex_menu_set));  
                 }  
         }  
 }  
   
547  int set_section_list_shm_readonly(void)  int set_section_list_shm_readonly(void)
548  {  {
549          int shmid;          int shmid;
# Line 673  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            int64_t index;
655    
656            if (p_section == NULL || sname == NULL || stitle == NULL || master_list == NULL)
657            {
658                    log_error("NULL pointer error\n");
659                    return -1;
660            }
661    
662            index = get_section_index(p_section);
663    
664            strncpy(p_section->sname, sname, sizeof(p_section->sname) - 1);
665            p_section->sname[sizeof(p_section->sname) - 1] = '\0';
666    
667            strncpy(p_section->stitle, stitle, sizeof(p_section->stitle) - 1);
668            p_section->stitle[sizeof(p_section->stitle) - 1] = '\0';
669    
670            strncpy(p_section->master_list, master_list, sizeof(p_section->master_list) - 1);
671            p_section->master_list[sizeof(p_section->master_list) - 1] = '\0';
672    
673            if (trie_dict_set(p_section_list_pool->p_trie_dict_section_by_name, sname, index) < 0)
674            {
675                    log_error("trie_dict_set(section, %s, %d) error\n", sname, index);
676                    return -2;
677            }
678    
679            return 0;
680    }
681    
682  void section_list_reset_articles(SECTION_LIST *p_section)  void section_list_reset_articles(SECTION_LIST *p_section)
683  {  {
684          p_section->article_count = 0;          p_section->article_count = 0;
# Line 751  int section_list_append_article(SECTION_ Line 757  int section_list_append_article(SECTION_
757    
758          if (p_section == NULL || p_article_src == NULL)          if (p_section == NULL || p_article_src == NULL)
759          {          {
760                  log_error("section_list_append_article() NULL pointer error\n");                  log_error("NULL pointer error\n");
761                  return -1;                  return -1;
762          }          }
763    
# Line 1047  int section_list_page_count_with_ontop(S Line 1053  int section_list_page_count_with_ontop(S
1053                  return -1;                  return -1;
1054          }          }
1055    
1056          page_count = p_section->page_count - 1 +          page_count = p_section->page_count - (p_section->last_page_visible_article_count > 0 ? 1 : 0) +
1057                                   (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 +
1058                                   ((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);
1059    
# Line 1086  ARTICLE *section_list_find_article_with_ Line 1092  ARTICLE *section_list_find_article_with_
1092    
1093          if (p_section == NULL)          if (p_section == NULL)
1094          {          {
1095                  log_error("section_list_find_article_with_offset() NULL pointer error\n");                  log_error("NULL pointer error\n");
1096                  return NULL;                  return NULL;
1097          }          }
1098    
# Line 1178  int section_list_calculate_page(SECTION_ Line 1184  int section_list_calculate_page(SECTION_
1184    
1185          if (p_section == NULL)          if (p_section == NULL)
1186          {          {
1187                  log_error("section_list_calculate_page() NULL pointer error\n");                  log_error("NULL pointer error\n");
1188                  return -1;                  return -1;
1189          }          }
1190    
# Line 1337  int section_list_move_topic(SECTION_LIST Line 1343  int section_list_move_topic(SECTION_LIST
1343    
1344          if (p_section_src == NULL || p_section_dest == NULL)          if (p_section_src == NULL || p_section_dest == NULL)
1345          {          {
1346                  log_error("section_list_move_topic() NULL pointer error\n");                  log_error("NULL pointer error\n");
1347                  return -1;                  return -1;
1348          }          }
1349    
# Line 1709  int section_list_rd_lock(SECTION_LIST *p Line 1715  int section_list_rd_lock(SECTION_LIST *p
1715                          timer++;                          timer++;
1716                          if (timer % SECTION_TRY_LOCK_TIMES == 0)                          if (timer % SECTION_TRY_LOCK_TIMES == 0)
1717                          {                          {
1718                                  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);
1719                          }                          }
1720                  }                  }
1721                  else // failed                  else // failed
1722                  {                  {
1723                          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);
1724                          break;                          break;
1725                  }                  }
1726          }          }
# Line 1740  int section_list_rw_lock(SECTION_LIST *p Line 1746  int section_list_rw_lock(SECTION_LIST *p
1746                          timer++;                          timer++;
1747                          if (timer % SECTION_TRY_LOCK_TIMES == 0)                          if (timer % SECTION_TRY_LOCK_TIMES == 0)
1748                          {                          {
1749                                  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);
1750                          }                          }
1751                  }                  }
1752                  else // failed                  else // failed
1753                  {                  {
1754                          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);
1755                          break;                          break;
1756                  }                  }
1757          }          }


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

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