| 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); |
printf("section_list_create(i = %d) error\n", i); |
| 117 |
|
return -3; |
| 118 |
|
} |
| 119 |
|
} |
| 120 |
|
|
| 121 |
|
for (i = 0; i < section_count; i++) |
| 122 |
|
{ |
| 123 |
|
if (get_section_index(p_section[i]) != i) |
| 124 |
|
{ |
| 125 |
|
printf("get_section_index(i = %d) error\n", i); |
| 126 |
return -3; |
return -3; |
| 127 |
} |
} |
| 128 |
} |
} |
| 131 |
{ |
{ |
| 132 |
if (section_list_find_by_name(sname[i]) == NULL) |
if (section_list_find_by_name(sname[i]) == NULL) |
| 133 |
{ |
{ |
| 134 |
printf("section_data_find_section_by_name(%s) error\n", sname[i]); |
printf("section_list_find_by_name(%s) error\n", sname[i]); |
| 135 |
|
return -3; |
| 136 |
|
} |
| 137 |
|
} |
| 138 |
|
|
| 139 |
|
for (i = 0; i < section_count; i++) |
| 140 |
|
{ |
| 141 |
|
sid = i * 3 + 1; |
| 142 |
|
if (section_list_find_by_sid(sid) == NULL || section_list_find_by_sid(sid)->sid != sid) |
| 143 |
|
{ |
| 144 |
|
printf("section_list_find_by_sid(%d) error\n", sid); |
| 145 |
return -3; |
return -3; |
| 146 |
} |
} |
| 147 |
} |
} |
| 154 |
|
|
| 155 |
// Set article data |
// Set article data |
| 156 |
article.aid = last_aid; |
article.aid = last_aid; |
|
article.cid = article.aid; |
|
| 157 |
article.tid = 0; |
article.tid = 0; |
| 158 |
|
article.sid = i * 3 + 1; |
| 159 |
|
article.cid = article.aid; |
| 160 |
article.uid = 1; // TODO: randomize |
article.uid = 1; // TODO: randomize |
| 161 |
article.visible = 1; |
article.visible = 1; |
| 162 |
article.excerption = 0; |
article.excerption = 0; |
| 178 |
|
|
| 179 |
last_aid = 0; |
last_aid = 0; |
| 180 |
|
|
| 181 |
for (i = 0; i < section_count; i++) |
for (j = 0; j < BBS_article_limit_per_section; j++) |
| 182 |
{ |
{ |
| 183 |
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++) |
|
| 184 |
{ |
{ |
| 185 |
last_aid++; |
last_aid++; |
| 186 |
|
|
| 190 |
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); |
| 191 |
} |
} |
| 192 |
|
|
|
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); |
|
|
} |
|
|
|
|
| 193 |
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) |
| 194 |
{ |
{ |
| 195 |
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); |
| 203 |
|
|
| 204 |
if (article_block_reset() != 0) |
if (article_block_reset() != 0) |
| 205 |
{ |
{ |
| 206 |
log_error("section_data_free_block(i=%d) error\n", i); |
log_error("article_block_reset() error\n"); |
| 207 |
return -4; |
return -4; |
| 208 |
} |
} |
| 209 |
|
|
| 224 |
|
|
| 225 |
// Set article data |
// Set article data |
| 226 |
article.aid = last_aid; |
article.aid = last_aid; |
|
article.cid = article.aid; |
|
| 227 |
// Group articles into group_count topics |
// Group articles into group_count topics |
| 228 |
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)); |
| 229 |
|
article.sid = i * 3 + 1; |
| 230 |
|
article.cid = article.aid; |
| 231 |
article.uid = 1; // TODO: randomize |
article.uid = 1; // TODO: randomize |
| 232 |
article.visible = 1; |
article.visible = 1; |
| 233 |
article.excerption = 0; |
article.excerption = 0; |
| 578 |
|
|
| 579 |
if (article_block_reset() != 0) |
if (article_block_reset() != 0) |
| 580 |
{ |
{ |
| 581 |
log_error("section_data_free_block(i=%d) error\n", i); |
log_error("article_block_reset() error\n"); |
| 582 |
return -4; |
return -4; |
| 583 |
} |
} |
| 584 |
|
|
| 599 |
|
|
| 600 |
// Set article data |
// Set article data |
| 601 |
article.aid = last_aid; |
article.aid = last_aid; |
|
article.cid = article.aid; |
|
| 602 |
// Group articles into group_count topics |
// Group articles into group_count topics |
| 603 |
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)); |
| 604 |
|
article.sid = i * 3 + 1; |
| 605 |
|
article.cid = article.aid; |
| 606 |
article.uid = 1; // TODO: randomize |
article.uid = 1; // TODO: randomize |
| 607 |
article.visible = 1; |
article.visible = 1; |
| 608 |
article.excerption = 0; |
article.excerption = 0; |