/[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.1 by sysadm, Wed May 21 04:07:42 2025 UTC Revision 1.2 by sysadm, Wed May 21 05:36:04 2025 UTC
# Line 380  int section_data_append_article(SECTION_ Line 380  int section_data_append_article(SECTION_
380    
381          if (p_article->tid != 0)          if (p_article->tid != 0)
382          {          {
383                  p_topic_head = section_data_search_article(p_section, p_article->tid);                  p_topic_head = section_data_find_article_by_aid(p_section, p_article->tid);
384                  if (p_topic_head == NULL)                  if (p_topic_head == NULL)
385                  {                  {
386                          log_error("search head of topic (aid=%d) error\n", p_article->tid);                          log_error("search head of topic (aid=%d) error\n", p_article->tid);
387                          return -4;                          return -4;
388                  }                  }
389    
390                  p_topic_tail = section_data_search_article(p_section, p_topic_head->prior_aid);                  p_topic_tail = section_data_find_article_by_aid(p_section, p_topic_head->prior_aid);
391                  if (p_topic_tail == NULL)                  if (p_topic_tail == NULL)
392                  {                  {
393                          log_error("search tail of topic (aid=%d) error\n", p_topic_head->prior_aid);                          log_error("search tail of topic (aid=%d) error\n", p_topic_head->prior_aid);
# Line 415  int section_data_append_article(SECTION_ Line 415  int section_data_append_article(SECTION_
415          return 0;          return 0;
416  }  }
417    
418  ARTICLE *section_data_search_article(SECTION_DATA *p_section, int32_t aid)  ARTICLE *section_data_find_article_by_aid(SECTION_DATA *p_section, int32_t aid)
419  {  {
420          ARTICLE *p_article;          ARTICLE *p_article;
421          ARTICLE_BLOCK *p_block;          ARTICLE_BLOCK *p_block;
# Line 425  ARTICLE *section_data_search_article(SEC Line 425  ARTICLE *section_data_search_article(SEC
425    
426          if (p_section == NULL)          if (p_section == NULL)
427          {          {
428                  log_error("section_data_append_article() NULL pointer error\n");                  log_error("section_data_find_article_by_aid() NULL pointer error\n");
429                  return NULL;                  return NULL;
430          }          }
431    
# Line 484  ARTICLE *section_data_search_article(SEC Line 484  ARTICLE *section_data_search_article(SEC
484          return p_article;          return p_article;
485  }  }
486    
487    ARTICLE *section_data_find_article_by_index(SECTION_DATA *p_section, int index)
488    {
489            ARTICLE *p_article;
490            ARTICLE_BLOCK *p_block;
491    
492            if (p_section == NULL)
493            {
494                    log_error("section_data_find_article_by_index() NULL pointer error\n");
495                    return NULL;
496            }
497    
498            if (index < 0 || index >= p_section->article_count)
499            {
500                    log_error("section_data_find_article_by_index(%d) is out of boundary [0, %d)\n", index, p_section->article_count);
501                    return NULL;
502            }
503    
504            p_block = p_section->p_block[index / BBS_article_limit_per_block];
505            p_article = &(p_block->articles[index % BBS_article_limit_per_block]);
506    
507            return p_article;
508    }
509    
510  int section_data_mark_del_article(SECTION_DATA *p_section, int32_t aid)  int section_data_mark_del_article(SECTION_DATA *p_section, int32_t aid)
511  {  {
512          ARTICLE *p_article;          ARTICLE *p_article;
513    
514          p_article = section_data_search_article(p_section, aid);          if (p_section == NULL)
515            {
516                    log_error("section_data_mark_del_article() NULL pointer error\n");
517                    return -2;
518            }
519    
520            p_article = section_data_find_article_by_aid(p_section, aid);
521          if (p_article == NULL)          if (p_article == NULL)
522          {          {
523                  return -1; // Not found                  return -1; // Not found


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

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