| 50 |
ARTICLE article; |
ARTICLE article; |
| 51 |
int block_count; |
int block_count; |
| 52 |
int i, j; |
int i, j; |
| 53 |
|
int sid; |
| 54 |
int last_aid; |
int last_aid; |
| 55 |
int current_tid; |
int current_tid; |
| 56 |
int section_first_aid; |
int section_first_aid; |
| 90 |
|
|
| 91 |
if (article_block_init(ARTICLE_BLOCK_SHM_FILE, block_count) < 0) |
if (article_block_init(ARTICLE_BLOCK_SHM_FILE, block_count) < 0) |
| 92 |
{ |
{ |
| 93 |
log_error("section_data_pool_init(%s, %d) error\n", ARTICLE_BLOCK_SHM_FILE, block_count); |
log_error("article_block_init(%s, %d) error\n", ARTICLE_BLOCK_SHM_FILE, block_count); |
| 94 |
return -2; |
return -2; |
| 95 |
} |
} |
| 96 |
|
|
| 106 |
|
|
| 107 |
for (i = 0; i < section_count; i++) |
for (i = 0; i < section_count; i++) |
| 108 |
{ |
{ |
| 109 |
p_section[i] = section_list_create(i + 1, |
sid = i * 3 + 1; |
| 110 |
|
p_section[i] = section_list_create(sid, |
| 111 |
sname[i % section_conf_count], |
sname[i % section_conf_count], |
| 112 |
stitle[i % section_conf_count], |
stitle[i % section_conf_count], |
| 113 |
master_name[i % section_conf_count]); |
master_name[i % section_conf_count]); |
| 114 |
if (p_section[i] == NULL) |
if (p_section[i] == NULL) |
| 115 |
{ |
{ |
| 116 |
log_error("section_data_create(i=%d) error\n", i); |
log_error("section_list_create(i = %d) error\n", i); |
| 117 |
return -3; |
return -3; |
| 118 |
} |
} |
| 119 |
} |
} |
| 122 |
{ |
{ |
| 123 |
if (section_list_find_by_name(sname[i]) == NULL) |
if (section_list_find_by_name(sname[i]) == NULL) |
| 124 |
{ |
{ |
| 125 |
printf("section_data_find_section_by_name(%s) error\n", sname[i]); |
printf("section_list_find_by_name(%s) error\n", sname[i]); |
| 126 |
|
return -3; |
| 127 |
|
} |
| 128 |
|
} |
| 129 |
|
|
| 130 |
|
for (i = 0; i < section_count; i++) |
| 131 |
|
{ |
| 132 |
|
sid = i * 3 + 1; |
| 133 |
|
if (section_list_find_by_sid(sid) == NULL) |
| 134 |
|
{ |
| 135 |
|
printf("section_list_find_by_sid(%d) error\n", sid); |
| 136 |
return -3; |
return -3; |
| 137 |
} |
} |
| 138 |
} |
} |
| 145 |
|
|
| 146 |
// Set article data |
// Set article data |
| 147 |
article.aid = last_aid; |
article.aid = last_aid; |
|
article.cid = article.aid; |
|
| 148 |
article.tid = 0; |
article.tid = 0; |
| 149 |
|
article.sid = i * 3 + 1; |
| 150 |
|
article.cid = article.aid; |
| 151 |
article.uid = 1; // TODO: randomize |
article.uid = 1; // TODO: randomize |
| 152 |
article.visible = 1; |
article.visible = 1; |
| 153 |
article.excerption = 0; |
article.excerption = 0; |
| 169 |
|
|
| 170 |
last_aid = 0; |
last_aid = 0; |
| 171 |
|
|
| 172 |
for (i = 0; i < section_count; i++) |
for (j = 0; j < BBS_article_limit_per_section; j++) |
| 173 |
{ |
{ |
| 174 |
if (p_section[i]->article_count == 0) |
for (i = 0; i < section_count; i++) |
|
{ |
|
|
continue; |
|
|
} |
|
|
|
|
|
for (j = 0; j < p_section[i]->article_count; j++) |
|
| 175 |
{ |
{ |
| 176 |
last_aid++; |
last_aid++; |
| 177 |
|
|
| 181 |
printf("article_block_find_by_aid() at section %d index %d, %d != %d\n", i, j, p_article->aid, last_aid); |
printf("article_block_find_by_aid() at section %d index %d, %d != %d\n", i, j, p_article->aid, last_aid); |
| 182 |
} |
} |
| 183 |
|
|
|
p_article = article_block_find_by_index(last_aid - 1); |
|
|
if (p_article == NULL || p_article->aid != last_aid) |
|
|
{ |
|
|
printf("article_block_find_by_index() at section %d index %d, %d != %d\n", i, j, p_article->aid, last_aid); |
|
|
} |
|
|
|
|
| 184 |
if (section_list_set_article_visible(p_section[i], p_article->aid, 0) != 1) |
if (section_list_set_article_visible(p_section[i], p_article->aid, 0) != 1) |
| 185 |
{ |
{ |
| 186 |
printf("section_list_set_article_visible(aid = %d) error\n", p_article->aid); |
printf("section_list_set_article_visible(aid = %d) error\n", p_article->aid); |
| 194 |
|
|
| 195 |
if (article_block_reset() != 0) |
if (article_block_reset() != 0) |
| 196 |
{ |
{ |
| 197 |
log_error("section_data_free_block(i=%d) error\n", i); |
log_error("article_block_reset() error\n"); |
| 198 |
return -4; |
return -4; |
| 199 |
} |
} |
| 200 |
|
|
| 215 |
|
|
| 216 |
// Set article data |
// Set article data |
| 217 |
article.aid = last_aid; |
article.aid = last_aid; |
|
article.cid = article.aid; |
|
| 218 |
// Group articles into group_count topics |
// Group articles into group_count topics |
| 219 |
article.tid = ((article.aid < section_first_aid + group_count) ? 0 : (section_first_aid + j % group_count)); |
article.tid = ((article.aid < section_first_aid + group_count) ? 0 : (section_first_aid + j % group_count)); |
| 220 |
|
article.sid = i * 3 + 1; |
| 221 |
|
article.cid = article.aid; |
| 222 |
article.uid = 1; // TODO: randomize |
article.uid = 1; // TODO: randomize |
| 223 |
article.visible = 1; |
article.visible = 1; |
| 224 |
article.excerption = 0; |
article.excerption = 0; |
| 569 |
|
|
| 570 |
if (article_block_reset() != 0) |
if (article_block_reset() != 0) |
| 571 |
{ |
{ |
| 572 |
log_error("section_data_free_block(i=%d) error\n", i); |
log_error("article_block_reset() error\n"); |
| 573 |
return -4; |
return -4; |
| 574 |
} |
} |
| 575 |
|
|
| 590 |
|
|
| 591 |
// Set article data |
// Set article data |
| 592 |
article.aid = last_aid; |
article.aid = last_aid; |
|
article.cid = article.aid; |
|
| 593 |
// Group articles into group_count topics |
// Group articles into group_count topics |
| 594 |
article.tid = ((article.aid < section_first_aid + group_count) ? 0 : (section_first_aid + j % group_count)); |
article.tid = ((article.aid < section_first_aid + group_count) ? 0 : (section_first_aid + j % group_count)); |
| 595 |
|
article.sid = i * 3 + 1; |
| 596 |
|
article.cid = article.aid; |
| 597 |
article.uid = 1; // TODO: randomize |
article.uid = 1; // TODO: randomize |
| 598 |
article.visible = 1; |
article.visible = 1; |
| 599 |
article.excerption = 0; |
article.excerption = 0; |