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

Diff of /lbbs/src/section_list_loader.c

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

Revision 1.14 by sysadm, Sat May 31 08:54:03 2025 UTC Revision 1.15 by sysadm, Sat May 31 10:23:23 2025 UTC
# Line 821  int query_section_articles(SECTION_LIST Line 821  int query_section_articles(SECTION_LIST
821  }  }
822    
823  int locate_article_in_section(SECTION_LIST *p_section, const ARTICLE *p_article_cur, int direction,  int locate_article_in_section(SECTION_LIST *p_section, const ARTICLE *p_article_cur, int direction,
824                                                            int *p_page_id, int *p_offset, int *p_article_count)                                                            int *p_page_id, int *p_visible_offset, int *p_article_count)
825  {  {
826          ARTICLE *p_article = NULL;          const ARTICLE *p_article = NULL;
827          ARTICLE *p_next;          ARTICLE *p_tmp;
828          int32_t aid = 0;          int32_t aid = 0;
829            int page_id;
830            int offset;
831          int ret = 0;          int ret = 0;
832            int i;
833    
834          if (p_section == NULL || p_article_cur == NULL || p_page_id == NULL || p_offset == NULL || p_article_count == NULL)          if (p_section == NULL || p_article_cur == NULL || p_page_id == NULL || p_visible_offset == NULL || p_article_count == NULL)
835          {          {
836                  log_error("locate_article_in_section() NULL pointer error\n");                  log_error("locate_article_in_section() NULL pointer error\n");
837                  return -1;                  return -1;
# Line 847  int locate_article_in_section(SECTION_LI Line 850  int locate_article_in_section(SECTION_LI
850          }          }
851          else if (direction == 1)          else if (direction == 1)
852          {          {
853                  aid = p_article_cur->p_topic_next->aid;                  p_article = p_article_cur;
854                  if (aid <= p_article_cur->aid)                  do
855                  {                  {
856                          aid = 0;                          p_article = p_article->p_topic_next;
857                  }                  } while (p_article != p_article_cur && p_article->visible == 0);
858    
859                    aid = (p_article->aid > p_article_cur->aid ? p_article->aid : 0);
860          }          }
861          else if (direction == -1)          else if (direction == -1)
862          {          {
863                  aid = p_article_cur->p_topic_prior->aid;                  p_article = p_article_cur;
864                  if (aid >= p_article_cur->aid)                  do
865                  {                  {
866                          aid = 0;                          p_article = p_article->p_topic_prior;
867                  }                  } while (p_article != p_article_cur && p_article->visible == 0);
868    
869                    aid = (p_article->aid < p_article_cur->aid ? p_article->aid : 0);
870          }          }
871    
872            p_article = NULL;
873    
874          if (aid > 0)          if (aid > 0)
875          {          {
876                  p_article = section_list_find_article_with_offset(p_section, aid, p_page_id, p_offset, &p_next);                  p_article = section_list_find_article_with_offset(p_section, aid, &page_id, &offset, &p_tmp);
877                  if (p_article != NULL)                  if (p_article != NULL)
878                  {                  {
879                          *p_article_count = (*p_page_id == p_section->page_count - 1 ? p_section->last_page_visible_article_count : BBS_article_limit_per_page);                          *p_article_count = (page_id == p_section->page_count - 1 ? p_section->last_page_visible_article_count : BBS_article_limit_per_page);
880    
881                            p_article = p_section->p_page_first_article[page_id];
882                            for (i = 0; i < *p_article_count;)
883                            {
884                                    if (p_article->visible)
885                                    {
886                                            if (p_article->aid == aid)
887                                            {
888                                                    *p_page_id = page_id;
889                                                    *p_visible_offset = i;
890                                                    break;
891                                            }
892                                            i++;
893                                            if (i >= *p_article_count)
894                                            {
895                                                    log_error("Visible article (aid=%d) not found in page %d\n", aid, page_id);
896                                                    p_article = NULL;
897                                            }
898                                    }
899                                    p_article = p_article->p_next;
900                            }
901                  }                  }
902          }          }
903    


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

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