| 434 |
return -1; |
return -1; |
| 435 |
} |
} |
| 436 |
|
|
| 437 |
|
if (p_section->article_count >= BBS_article_limit_per_section) |
| 438 |
|
{ |
| 439 |
|
log_error("section_list_append_article() error: article_count reach limit in section %d\n", p_section->sid); |
| 440 |
|
return -2; |
| 441 |
|
} |
| 442 |
|
|
| 443 |
if (p_article_block_pool->block_count == 0 || |
if (p_article_block_pool->block_count == 0 || |
| 444 |
p_article_block_pool->p_block[p_article_block_pool->block_count - 1]->article_count >= ARTICLE_PER_BLOCK) |
p_article_block_pool->p_block[p_article_block_pool->block_count - 1]->article_count >= ARTICLE_PER_BLOCK) |
| 445 |
{ |
{ |
| 536 |
p_section->page_count++; |
p_section->page_count++; |
| 537 |
p_section->last_page_visible_article_count = 0; |
p_section->last_page_visible_article_count = 0; |
| 538 |
} |
} |
| 539 |
p_section->last_page_visible_article_count++; |
|
| 540 |
|
if (p_article->visible) |
| 541 |
|
{ |
| 542 |
|
p_section->last_page_visible_article_count++; |
| 543 |
|
} |
| 544 |
|
|
| 545 |
return 0; |
return 0; |
| 546 |
} |
} |
| 699 |
|
|
| 700 |
int section_list_calculate_page(SECTION_LIST *p_section, int32_t start_aid) |
int section_list_calculate_page(SECTION_LIST *p_section, int32_t start_aid) |
| 701 |
{ |
{ |
| 702 |
// ARTICLE *p_article; |
ARTICLE *p_article; |
| 703 |
|
int32_t page; |
| 704 |
|
int32_t offset; |
| 705 |
|
int visible_article_count; |
| 706 |
|
int page_head_set; |
| 707 |
|
|
| 708 |
if (p_section == NULL) |
if (p_section == NULL) |
| 709 |
{ |
{ |
| 711 |
return -1; |
return -1; |
| 712 |
} |
} |
| 713 |
|
|
| 714 |
|
p_article = section_list_find_article_with_offset(p_section, start_aid, &page, &offset); |
| 715 |
|
if (p_article == NULL) |
| 716 |
|
{ |
| 717 |
|
if (page < 0) |
| 718 |
|
{ |
| 719 |
|
return 0; |
| 720 |
|
} |
| 721 |
|
|
| 722 |
|
log_error("section_list_calculate_page() aid = %d not found in section sid = %d\n", start_aid, p_section->sid); |
| 723 |
|
} |
| 724 |
|
|
| 725 |
|
if (offset > 0) |
| 726 |
|
{ |
| 727 |
|
p_article = p_section->p_page_first_article[page]; |
| 728 |
|
} |
| 729 |
|
|
| 730 |
|
visible_article_count = 0; |
| 731 |
|
page_head_set = 0; |
| 732 |
|
|
| 733 |
|
do |
| 734 |
|
{ |
| 735 |
|
if (!page_head_set && visible_article_count == 0) |
| 736 |
|
{ |
| 737 |
|
p_section->p_page_first_article[page] = p_article; |
| 738 |
|
page_head_set = 1; |
| 739 |
|
} |
| 740 |
|
|
| 741 |
|
if (p_article->visible) |
| 742 |
|
{ |
| 743 |
|
visible_article_count++; |
| 744 |
|
} |
| 745 |
|
|
| 746 |
|
p_article = p_article->p_next; |
| 747 |
|
|
| 748 |
|
// skip remaining invisible articles |
| 749 |
|
while (p_article->visible == 0 && p_article != p_section->p_article_head) |
| 750 |
|
{ |
| 751 |
|
p_article = p_article->p_next; |
| 752 |
|
} |
| 753 |
|
|
| 754 |
|
if (visible_article_count >= BBS_article_limit_per_page && p_article != p_section->p_article_head) |
| 755 |
|
{ |
| 756 |
|
page++; |
| 757 |
|
visible_article_count = 0; |
| 758 |
|
page_head_set = 0; |
| 759 |
|
|
| 760 |
|
if (page >= BBS_article_limit_per_section / BBS_article_limit_per_page && p_article != p_section->p_article_head) |
| 761 |
|
{ |
| 762 |
|
log_error("Count of page exceed limit in section %d\n", p_section->sid); |
| 763 |
|
break; |
| 764 |
|
} |
| 765 |
|
} |
| 766 |
|
} while (p_article != p_section->p_article_head); |
| 767 |
|
|
| 768 |
|
p_section->page_count = page + (visible_article_count > 0 ? 1 : 0); |
| 769 |
|
p_section->last_page_visible_article_count = visible_article_count; |
| 770 |
|
|
| 771 |
return 0; |
return 0; |
| 772 |
} |
} |