| 66 |
log_err_redirect(STDERR_FILENO); |
log_err_redirect(STDERR_FILENO); |
| 67 |
|
|
| 68 |
// - 1 to make blocks allocated is less than required, to trigger error handling |
// - 1 to make blocks allocated is less than required, to trigger error handling |
| 69 |
block_count = BBS_article_limit_per_section * BBS_max_section / ARTICLE_PER_BLOCK - 1; |
block_count = BBS_article_limit_per_section * BBS_max_section / ARTICLE_PER_BLOCK; |
| 70 |
|
|
| 71 |
if (article_block_init("../conf/menu.conf", block_count) < 0) |
if (article_block_init("../conf/menu.conf", block_count) < 0) |
| 72 |
{ |
{ |
| 447 |
|
|
| 448 |
if (p_section[i]->visible_article_count > 0) |
if (p_section[i]->visible_article_count > 0) |
| 449 |
{ |
{ |
| 450 |
printf("Inconsistent invisible count in section %d, %d > 0\n", i, p_section[i]->visible_article_count); |
printf("Inconsistent invisible article count in section %d, %d > 0\n", i, p_section[i]->visible_article_count); |
| 451 |
|
break; |
| 452 |
|
} |
| 453 |
|
|
| 454 |
|
if (p_section[i]->visible_topic_count > 0) |
| 455 |
|
{ |
| 456 |
|
printf("Inconsistent invisible topic count in section %d, %d > 0\n", i, p_section[i]->visible_topic_count); |
| 457 |
|
break; |
| 458 |
|
} |
| 459 |
|
|
| 460 |
|
last_aid = p_section[i]->p_article_head->aid; |
| 461 |
|
if (section_list_calculate_page(p_section[i], last_aid) < 0) |
| 462 |
|
{ |
| 463 |
|
printf("section_list_calculate_page(aid = %d) error in section %d offset %d\n", last_aid, i, j); |
| 464 |
|
break; |
| 465 |
|
} |
| 466 |
|
|
| 467 |
|
if (p_section[i]->visible_article_count / BBS_article_limit_per_page + |
| 468 |
|
(p_section[i]->visible_article_count % BBS_article_limit_per_page ? 1 : 0) != |
| 469 |
|
p_section[i]->page_count) |
| 470 |
|
{ |
| 471 |
|
printf("Inconsistent page count in section %d offset %d, %d != %d, " |
| 472 |
|
"visible_article_count = %d, last_page_visible_count = %d\n", |
| 473 |
|
i, j, |
| 474 |
|
p_section[i]->visible_article_count / BBS_article_limit_per_page + |
| 475 |
|
(p_section[i]->visible_article_count % BBS_article_limit_per_page ? 1 : 0), |
| 476 |
|
p_section[i]->page_count, p_section[i]->visible_article_count, |
| 477 |
|
p_section[i]->last_page_visible_article_count); |
| 478 |
|
break; |
| 479 |
|
} |
| 480 |
|
} |
| 481 |
|
|
| 482 |
|
for (i = 0; i < BBS_max_section; i++) |
| 483 |
|
{ |
| 484 |
|
affected_count = 0; |
| 485 |
|
|
| 486 |
|
for (j = 0; j < BBS_article_limit_per_section; j += 1) |
| 487 |
|
{ |
| 488 |
|
last_aid = i * BBS_article_limit_per_section + j + 1; |
| 489 |
|
|
| 490 |
|
if (section_list_set_article_visible(p_section[i], last_aid, 1) <= 0) |
| 491 |
|
{ |
| 492 |
|
printf("Error set article %d visible in section %d offset %d\n", last_aid, i, j); |
| 493 |
|
break; |
| 494 |
|
} |
| 495 |
|
|
| 496 |
|
affected_count++; |
| 497 |
|
} |
| 498 |
|
|
| 499 |
|
if (affected_count != p_section[i]->article_count) |
| 500 |
|
{ |
| 501 |
|
printf("Inconsistent total set visible article count in section %d, %d != %d\n", i, affected_count, p_section[i]->article_count); |
| 502 |
|
break; |
| 503 |
|
} |
| 504 |
|
|
| 505 |
|
if (p_section[i]->visible_article_count != p_section[i]->article_count) |
| 506 |
|
{ |
| 507 |
|
printf("Inconsistent visible article count in section %d, %d != %d\n", i, p_section[i]->visible_article_count, p_section[i]->article_count); |
| 508 |
|
break; |
| 509 |
|
} |
| 510 |
|
|
| 511 |
|
if (p_section[i]->visible_topic_count != group_count) |
| 512 |
|
{ |
| 513 |
|
printf("Inconsistent visible topic count in section %d, %d != %d\n", i, p_section[i]->visible_topic_count, group_count); |
| 514 |
|
break; |
| 515 |
|
} |
| 516 |
|
|
| 517 |
|
last_aid = p_section[i]->p_article_head->aid; |
| 518 |
|
if (section_list_calculate_page(p_section[i], last_aid) < 0) |
| 519 |
|
{ |
| 520 |
|
printf("section_list_calculate_page(aid = %d) error in section %d offset %d\n", last_aid, i, j); |
| 521 |
|
break; |
| 522 |
|
} |
| 523 |
|
|
| 524 |
|
if (p_section[i]->visible_article_count / BBS_article_limit_per_page + |
| 525 |
|
(p_section[i]->visible_article_count % BBS_article_limit_per_page ? 1 : 0) != |
| 526 |
|
p_section[i]->page_count) |
| 527 |
|
{ |
| 528 |
|
printf("Inconsistent page count in section %d offset %d, %d != %d, " |
| 529 |
|
"visible_article_count = %d, last_page_visible_count = %d\n", |
| 530 |
|
i, j, |
| 531 |
|
p_section[i]->visible_article_count / BBS_article_limit_per_page + |
| 532 |
|
(p_section[i]->visible_article_count % BBS_article_limit_per_page ? 1 : 0), |
| 533 |
|
p_section[i]->page_count, p_section[i]->visible_article_count, |
| 534 |
|
p_section[i]->last_page_visible_article_count); |
| 535 |
break; |
break; |
| 536 |
} |
} |
| 537 |
} |
} |