| 15 |
***************************************************************************/ |
***************************************************************************/ |
| 16 |
|
|
| 17 |
#include "article_cache.h" |
#include "article_cache.h" |
| 18 |
|
#include "article_op.h" |
| 19 |
#include "article_post.h" |
#include "article_post.h" |
| 20 |
#include "article_view_log.h" |
#include "article_view_log.h" |
| 21 |
#include "article_del.h" |
#include "article_del.h" |
| 23 |
#include "io.h" |
#include "io.h" |
| 24 |
#include "log.h" |
#include "log.h" |
| 25 |
#include "login.h" |
#include "login.h" |
| 26 |
|
#include "menu.h" |
| 27 |
#include "section_list_display.h" |
#include "section_list_display.h" |
| 28 |
#include "section_list_loader.h" |
#include "section_list_loader.h" |
| 29 |
#include "screen.h" |
#include "screen.h" |
| 39 |
enum select_cmd_t |
enum select_cmd_t |
| 40 |
{ |
{ |
| 41 |
EXIT_SECTION = 0, |
EXIT_SECTION = 0, |
| 42 |
VIEW_ARTICLE = 1, |
VIEW_ARTICLE, |
| 43 |
CHANGE_PAGE = 2, |
CHANGE_PAGE, |
| 44 |
SHOW_HELP = 3, |
SHOW_HELP, |
| 45 |
CHANGE_NAME_DISPLAY = 4, |
CHANGE_NAME_DISPLAY, |
| 46 |
POST_ARTICLE = 5, |
POST_ARTICLE, |
| 47 |
EDIT_ARTICLE = 6, |
EDIT_ARTICLE, |
| 48 |
DELETE_ARTICLE = 7, |
DELETE_ARTICLE, |
| 49 |
FIRST_TOPIC_ARTICLE = 8, |
QUERY_ARTICLE, |
| 50 |
LAST_TOPIC_ARTICLE = 9, |
FIRST_TOPIC_ARTICLE, |
| 51 |
|
LAST_TOPIC_ARTICLE, |
| 52 |
|
VIEW_EX_DIR, |
| 53 |
}; |
}; |
| 54 |
|
|
| 55 |
static int section_list_draw_items(int page_id, ARTICLE *p_articles[], int article_count, int display_nickname) |
static int section_list_draw_items(int page_id, ARTICLE *p_articles[], int article_count, int display_nickname, int ontop_start_offset) |
| 56 |
{ |
{ |
| 57 |
char str_time[LINE_BUFFER_LEN]; |
char str_time[LINE_BUFFER_LEN]; |
| 58 |
struct tm tm_sub; |
struct tm tm_sub; |
| 61 |
int eol; |
int eol; |
| 62 |
int len; |
int len; |
| 63 |
int i; |
int i; |
| 64 |
|
size_t j; |
| 65 |
char article_flag; |
char article_flag; |
| 66 |
int is_viewed; |
int is_viewed; |
| 67 |
time_t tm_now; |
time_t tm_now; |
| 109 |
strftime(str_time, sizeof(str_time), "%m/%Y", &tm_sub); |
strftime(str_time, sizeof(str_time), "%m/%Y", &tm_sub); |
| 110 |
} |
} |
| 111 |
|
|
| 112 |
strncpy(title_f, (p_articles[i]->tid == 0 ? " " : ""), sizeof(title_f) - 1); |
strncpy(title_f, (p_articles[i]->tid == 0 ? "● " : ""), sizeof(title_f) - 1); |
| 113 |
title_f[sizeof(title_f) - 1] = '\0'; |
title_f[sizeof(title_f) - 1] = '\0'; |
| 114 |
strncat(title_f, (p_articles[i]->transship ? "[ת]" : ""), sizeof(title_f) - 1 - strnlen(title_f, sizeof(title_f))); |
strncat(title_f, (p_articles[i]->transship ? "[转载]" : ""), sizeof(title_f) - 1 - strnlen(title_f, sizeof(title_f))); |
| 115 |
strncat(title_f, p_articles[i]->title, sizeof(title_f) - 1 - strnlen(title_f, sizeof(title_f))); |
|
| 116 |
|
// Rewrite title with "Re: Re: " prefix into "Re: ... " |
| 117 |
|
j = 0; |
| 118 |
|
if (p_articles[i]->tid != 0) |
| 119 |
|
{ |
| 120 |
|
while (strncmp(p_articles[i]->title + j, "Re: ", strlen("Re: ")) == 0) |
| 121 |
|
{ |
| 122 |
|
j += strlen("Re: "); |
| 123 |
|
} |
| 124 |
|
if (j >= strlen("Re: Re: ")) |
| 125 |
|
{ |
| 126 |
|
strncat(title_f, "Re: ... ", sizeof(title_f) - 1 - strnlen(title_f, sizeof(title_f))); |
| 127 |
|
} |
| 128 |
|
else |
| 129 |
|
{ |
| 130 |
|
j = 0; |
| 131 |
|
} |
| 132 |
|
} |
| 133 |
|
strncat(title_f, p_articles[i]->title + j, sizeof(title_f) - 1 - strnlen(title_f, sizeof(title_f))); |
| 134 |
|
|
| 135 |
len = split_line(title_f, 47 - (display_nickname ? 8 : 0), &eol, &title_f_len, 1); |
len = split_line(title_f, 47 - (display_nickname ? 8 : 0), &eol, &title_f_len, 1); |
| 136 |
if (title_f[len] != '\0') |
if (title_f[len] != '\0') |
| 137 |
{ |
{ |
| 139 |
} |
} |
| 140 |
|
|
| 141 |
moveto(4 + i, 1); |
moveto(4 + i, 1); |
| 142 |
prints(" %s%7d\033[m %c %s%*s %s %s%s\033[m", |
if (i >= ontop_start_offset) |
| 143 |
(p_articles[i]->ontop |
{ |
| 144 |
? "\033[47;30m" |
prints(" \033[1;33m[提示]\033[m %c %s%*s %s %s%s\033[m", |
| 145 |
: (p_articles[i]->aid == section_topic_view_tid |
article_flag, |
| 146 |
? "\033[1;33m" |
(display_nickname ? p_articles[i]->nickname : p_articles[i]->username), |
| 147 |
: (p_articles[i]->tid == section_topic_view_tid |
(display_nickname ? BBS_nickname_max_len - (int)strnlen(p_articles[i]->nickname, sizeof(p_articles[i]->nickname)) |
| 148 |
? "\033[1;36m" |
: BBS_username_max_len - (int)strnlen(p_articles[i]->username, sizeof(p_articles[i]->username))), |
| 149 |
: ""))), |
"", |
| 150 |
p_articles[i]->aid, |
str_time, |
| 151 |
article_flag, |
(p_articles[i]->aid == section_topic_view_tid |
| 152 |
(display_nickname ? p_articles[i]->nickname : p_articles[i]->username), |
? "\033[1;33m" |
| 153 |
(display_nickname ? BBS_nickname_max_len - (int)strnlen(p_articles[i]->nickname, sizeof(p_articles[i]->nickname)) |
: (p_articles[i]->tid == section_topic_view_tid |
| 154 |
: BBS_username_max_len - (int)strnlen(p_articles[i]->username, sizeof(p_articles[i]->username))), |
? "\033[1;36m" |
| 155 |
"", |
: "")), |
| 156 |
str_time, |
title_f); |
| 157 |
(p_articles[i]->aid == section_topic_view_tid |
} |
| 158 |
? "\033[1;33m" |
else |
| 159 |
: (p_articles[i]->tid == section_topic_view_tid |
{ |
| 160 |
? "\033[1;36m" |
prints(" %s%7d\033[m %c %s%*s %s %s%s\033[m", |
| 161 |
: "")), |
(p_articles[i]->aid == section_topic_view_tid |
| 162 |
title_f); |
? "\033[1;33m" |
| 163 |
|
: (p_articles[i]->tid == section_topic_view_tid |
| 164 |
|
? "\033[1;36m" |
| 165 |
|
: "")), |
| 166 |
|
p_articles[i]->aid, |
| 167 |
|
article_flag, |
| 168 |
|
(display_nickname ? p_articles[i]->nickname : p_articles[i]->username), |
| 169 |
|
(display_nickname ? BBS_nickname_max_len - (int)strnlen(p_articles[i]->nickname, sizeof(p_articles[i]->nickname)) |
| 170 |
|
: BBS_username_max_len - (int)strnlen(p_articles[i]->username, sizeof(p_articles[i]->username))), |
| 171 |
|
"", |
| 172 |
|
str_time, |
| 173 |
|
(p_articles[i]->aid == section_topic_view_tid |
| 174 |
|
? "\033[1;33m" |
| 175 |
|
: (p_articles[i]->tid == section_topic_view_tid |
| 176 |
|
? "\033[1;36m" |
| 177 |
|
: "")), |
| 178 |
|
title_f); |
| 179 |
|
} |
| 180 |
} |
} |
| 181 |
|
|
| 182 |
return 0; |
return 0; |
| 184 |
|
|
| 185 |
static int section_list_draw_screen(const char *sname, const char *stitle, const char *master_list, int display_nickname) |
static int section_list_draw_screen(const char *sname, const char *stitle, const char *master_list, int display_nickname) |
| 186 |
{ |
{ |
| 187 |
char str_section_master[LINE_BUFFER_LEN] = ""; |
char str_section_master[LINE_BUFFER_LEN] = "诚征版主中"; |
| 188 |
char str_section_name[LINE_BUFFER_LEN]; |
char str_section_name[LINE_BUFFER_LEN]; |
| 189 |
|
|
| 190 |
if (master_list[0] != '\0') |
if (master_list[0] != '\0') |
| 191 |
{ |
{ |
| 192 |
snprintf(str_section_master, sizeof(str_section_master), "%s", master_list); |
snprintf(str_section_master, sizeof(str_section_master), "版主:%s", master_list); |
| 193 |
} |
} |
| 194 |
snprintf(str_section_name, sizeof(str_section_name), " [%s]", sname); |
snprintf(str_section_name, sizeof(str_section_name), "讨论区 [%s]", sname); |
| 195 |
|
|
| 196 |
clearscr(); |
clearscr(); |
| 197 |
show_top(str_section_master, stitle, str_section_name); |
show_top(str_section_master, stitle, str_section_name); |
| 198 |
moveto(2, 0); |
moveto(2, 0); |
| 199 |
prints("[\033[1;32m\033[0;37m,\033[1;32mESC\033[0;37m] ѡ[\033[1;32m\033[0;37m,\033[1;32m\033[0;37m] " |
prints("返回[\033[1;32m←\033[0;37m,\033[1;32mESC\033[0;37m] 选择[\033[1;32m↑\033[0;37m,\033[1;32m↓\033[0;37m] " |
| 200 |
"Ķ[\033[1;32m\033[0;37m,\033[1;32mENTER\033[0;37m] [\033[1;32mCtrl-P\033[0;37m] " |
"阅读[\033[1;32m→\033[0;37m,\033[1;32mENTER\033[0;37m] 发表[\033[1;32mCtrl-P\033[0;37m] " |
| 201 |
"%s[\033[1;32mn\033[0;37m] [\033[1;32mh\033[0;37m]\033[m", |
"%s[\033[1;32mn\033[0;37m] 精华区[\033[1;32mx\033[0;37m] 帮助[\033[1;32mh\033[0;37m]\033[m", |
| 202 |
(display_nickname ? "ʾû" : "ʾdz")); |
(display_nickname ? "用户名" : "昵称")); |
| 203 |
moveto(3, 0); |
moveto(3, 0); |
| 204 |
if (display_nickname) |
if (display_nickname) |
| 205 |
{ |
{ |
| 206 |
prints("\033[44;37m \033[1;37m dz ± \033[m"); |
prints("\033[44;37m \033[1;37m 编 号 发布者昵称 日 期 文章标题 \033[m"); |
| 207 |
} |
} |
| 208 |
else |
else |
| 209 |
{ |
{ |
| 210 |
prints("\033[44;37m \033[1;37m ± \033[m"); |
prints("\033[44;37m \033[1;37m 编 号 发 布 者 日 期 文章标题 \033[m"); |
| 211 |
} |
} |
| 212 |
|
|
| 213 |
return 0; |
return 0; |
| 260 |
case Ctrl('P'): |
case Ctrl('P'): |
| 261 |
return POST_ARTICLE; |
return POST_ARTICLE; |
| 262 |
case 'E': |
case 'E': |
| 263 |
return EDIT_ARTICLE; |
if (item_count > 0) |
| 264 |
|
{ |
| 265 |
|
return EDIT_ARTICLE; |
| 266 |
|
} |
| 267 |
|
break; |
| 268 |
case 'd': |
case 'd': |
| 269 |
return DELETE_ARTICLE; |
if (item_count > 0) |
| 270 |
|
{ |
| 271 |
|
return DELETE_ARTICLE; |
| 272 |
|
} |
| 273 |
|
break; |
| 274 |
|
case Ctrl('Q'): |
| 275 |
|
if (item_count > 0) |
| 276 |
|
{ |
| 277 |
|
return QUERY_ARTICLE; |
| 278 |
|
} |
| 279 |
|
break; |
| 280 |
case KEY_HOME: |
case KEY_HOME: |
| 281 |
*p_page_id = 0; |
*p_page_id = 0; |
| 282 |
case 'P': |
case 'P': |
| 329 |
} |
} |
| 330 |
break; |
break; |
| 331 |
case '=': |
case '=': |
| 332 |
return FIRST_TOPIC_ARTICLE; |
if (item_count > 0) |
| 333 |
|
{ |
| 334 |
|
return FIRST_TOPIC_ARTICLE; |
| 335 |
|
} |
| 336 |
|
break; |
| 337 |
case '\\': |
case '\\': |
| 338 |
return LAST_TOPIC_ARTICLE; |
if (item_count > 0) |
| 339 |
|
{ |
| 340 |
|
return LAST_TOPIC_ARTICLE; |
| 341 |
|
} |
| 342 |
|
break; |
| 343 |
case 'h': |
case 'h': |
| 344 |
return SHOW_HELP; |
return SHOW_HELP; |
| 345 |
|
case 'x': |
| 346 |
|
return VIEW_EX_DIR; |
| 347 |
default: |
default: |
| 348 |
} |
} |
| 349 |
|
|
| 390 |
if (section_topic_view_mode) |
if (section_topic_view_mode) |
| 391 |
{ |
{ |
| 392 |
snprintf(p_ctx->msg, sizeof(p_ctx->msg), |
snprintf(p_ctx->msg, sizeof(p_ctx->msg), |
| 393 |
"| [\033[32m\033[33m,\033[32mESC\033[33m] " |
"| 返回[\033[32m←\033[33m,\033[32mESC\033[33m] " |
| 394 |
"ͬĶ[\033[32m\033[33m/\033[32m\033[33m] " |
"同主题阅读[\033[32m↑\033[33m/\033[32m↓\033[33m] " |
| 395 |
"л[\033[32mp\033[33m] ظ[\033[32mr\033[33m] [\033[32mh\033[33m] |"); |
"切换[\033[32mp\033[33m] 回复[\033[32mr\033[33m] 帮助[\033[32mh\033[33m] |"); |
| 396 |
} |
} |
| 397 |
else |
else |
| 398 |
{ |
{ |
| 399 |
snprintf(p_ctx->msg, sizeof(p_ctx->msg), |
snprintf(p_ctx->msg, sizeof(p_ctx->msg), |
| 400 |
"| [\033[32m\033[33m,\033[32mESC\033[33m] " |
"| 返回[\033[32m←\033[33m,\033[32mESC\033[33m] " |
| 401 |
"ƶ[\033[32m\033[33m/\033[32m\033[33m/\033[32mPgUp\033[33m/\033[32mPgDn\033[33m] " |
"移动[\033[32m↑\033[33m/\033[32m↓\033[33m/\033[32mPgUp\033[33m/\033[32mPgDn\033[33m] " |
| 402 |
"л[\033[32mp\033[33m] ظ[\033[32mr\033[33m] [\033[32mh\033[33m] |"); |
"切换[\033[32mp\033[33m] 回复[\033[32mr\033[33m] 帮助[\033[32mh\033[33m] |"); |
| 403 |
} |
} |
| 404 |
*p_key = 0; |
*p_key = 0; |
| 405 |
break; |
break; |
| 477 |
ARTICLE *p_articles[BBS_article_limit_per_page]; |
ARTICLE *p_articles[BBS_article_limit_per_page]; |
| 478 |
int article_count; |
int article_count; |
| 479 |
int page_count; |
int page_count; |
| 480 |
|
int ontop_start_offset; |
| 481 |
int page_id = 0; |
int page_id = 0; |
| 482 |
int selected_index = 0; |
int selected_index = 0; |
| 483 |
ARTICLE_CACHE cache; |
ARTICLE_CACHE cache; |
| 517 |
return -2; |
return -2; |
| 518 |
} |
} |
| 519 |
|
|
| 520 |
ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count); |
ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset); |
| 521 |
if (ret < 0) |
if (ret < 0) |
| 522 |
{ |
{ |
| 523 |
log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id); |
log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id); |
| 531 |
|
|
| 532 |
while (!SYS_server_exit) |
while (!SYS_server_exit) |
| 533 |
{ |
{ |
| 534 |
ret = section_list_draw_items(page_id, p_articles, article_count, display_nickname); |
ret = section_list_draw_items(page_id, p_articles, article_count, display_nickname, ontop_start_offset); |
| 535 |
if (ret < 0) |
if (ret < 0) |
| 536 |
{ |
{ |
| 537 |
log_error("section_list_draw_items(sid=%d, page_id=%d) error\n", p_section->sid, page_id); |
log_error("section_list_draw_items(sid=%d, page_id=%d) error\n", p_section->sid, page_id); |
| 539 |
} |
} |
| 540 |
|
|
| 541 |
snprintf(page_info_str, sizeof(page_info_str), |
snprintf(page_info_str, sizeof(page_info_str), |
| 542 |
"\033[33m[\033[36m%d\033[33m/\033[36m%d\033[33mҳ]", |
"\033[33m[第\033[36m%d\033[33m/\033[36m%d\033[33m页]", |
| 543 |
page_id + 1, MAX(page_count, 1)); |
page_id + 1, MAX(page_count, 1)); |
| 544 |
|
|
| 545 |
show_bottom(page_info_str); |
show_bottom(page_info_str); |
| 556 |
case EXIT_SECTION: |
case EXIT_SECTION: |
| 557 |
return 0; |
return 0; |
| 558 |
case CHANGE_PAGE: |
case CHANGE_PAGE: |
| 559 |
ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count); |
ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset); |
| 560 |
if (ret < 0) |
if (ret < 0) |
| 561 |
{ |
{ |
| 562 |
log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id); |
log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id); |
| 612 |
page_id--; |
page_id--; |
| 613 |
selected_index = BBS_article_limit_per_page - 1; |
selected_index = BBS_article_limit_per_page - 1; |
| 614 |
|
|
| 615 |
ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count); |
ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset); |
| 616 |
if (ret < 0) |
if (ret < 0) |
| 617 |
{ |
{ |
| 618 |
log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id); |
log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id); |
| 643 |
page_id++; |
page_id++; |
| 644 |
selected_index = 0; |
selected_index = 0; |
| 645 |
|
|
| 646 |
ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count); |
ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset); |
| 647 |
if (ret < 0) |
if (ret < 0) |
| 648 |
{ |
{ |
| 649 |
log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id); |
log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id); |
| 679 |
} |
} |
| 680 |
else if (ret > 0) // found |
else if (ret > 0) // found |
| 681 |
{ |
{ |
| 682 |
ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count); |
ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset); |
| 683 |
if (ret < 0) |
if (ret < 0) |
| 684 |
{ |
{ |
| 685 |
log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id); |
log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id); |
| 716 |
{ |
{ |
| 717 |
if (page_id != page_id_cur) // page changed |
if (page_id != page_id_cur) // page changed |
| 718 |
{ |
{ |
| 719 |
ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count); |
ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset); |
| 720 |
if (ret < 0) |
if (ret < 0) |
| 721 |
{ |
{ |
| 722 |
log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id); |
log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id); |
| 758 |
} |
} |
| 759 |
else if (ret > 0) // New article posted |
else if (ret > 0) // New article posted |
| 760 |
{ |
{ |
| 761 |
ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count); |
ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset); |
| 762 |
if (ret < 0) |
if (ret < 0) |
| 763 |
{ |
{ |
| 764 |
log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id); |
log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id); |
| 805 |
} |
} |
| 806 |
else if (ret > 0) // Article deleted |
else if (ret > 0) // Article deleted |
| 807 |
{ |
{ |
| 808 |
ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count); |
ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset); |
| 809 |
if (ret < 0) |
if (ret < 0) |
| 810 |
{ |
{ |
| 811 |
log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id); |
log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id); |
| 818 |
return -2; |
return -2; |
| 819 |
} |
} |
| 820 |
break; |
break; |
| 821 |
|
case QUERY_ARTICLE: |
| 822 |
|
if ((ret = display_article_meta(p_articles[selected_index]->aid)) < 0) |
| 823 |
|
{ |
| 824 |
|
log_error("display_article_meta(aid=%d) error\n", p_articles[selected_index]->aid); |
| 825 |
|
} |
| 826 |
|
if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0) |
| 827 |
|
{ |
| 828 |
|
log_error("section_list_draw_screen() error\n"); |
| 829 |
|
return -2; |
| 830 |
|
} |
| 831 |
|
break; |
| 832 |
case FIRST_TOPIC_ARTICLE: |
case FIRST_TOPIC_ARTICLE: |
| 833 |
case LAST_TOPIC_ARTICLE: |
case LAST_TOPIC_ARTICLE: |
| 834 |
page_id_cur = page_id; |
page_id_cur = page_id; |
| 843 |
} |
} |
| 844 |
else if (ret > 0 && page_id != page_id_cur) // found and page changed |
else if (ret > 0 && page_id != page_id_cur) // found and page changed |
| 845 |
{ |
{ |
| 846 |
ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count); |
ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset); |
| 847 |
if (ret < 0) |
if (ret < 0) |
| 848 |
{ |
{ |
| 849 |
log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id); |
log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id); |
| 860 |
return -2; |
return -2; |
| 861 |
} |
} |
| 862 |
break; |
break; |
| 863 |
|
case VIEW_EX_DIR: |
| 864 |
|
if (section_list_ex_dir_display(p_section) < 0) |
| 865 |
|
{ |
| 866 |
|
log_error("section_list_ex_dir_display(sid=%d) error\n", p_section->sid); |
| 867 |
|
} |
| 868 |
|
if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0) |
| 869 |
|
{ |
| 870 |
|
log_error("section_list_draw_screen() error\n"); |
| 871 |
|
return -2; |
| 872 |
|
} |
| 873 |
|
break; |
| 874 |
default: |
default: |
| 875 |
log_error("Unknown command %d\n", ret); |
log_error("Unknown command %d\n", ret); |
| 876 |
} |
} |
| 878 |
|
|
| 879 |
return 0; |
return 0; |
| 880 |
} |
} |
| 881 |
|
|
| 882 |
|
int section_list_ex_dir_display(SECTION_LIST *p_section) |
| 883 |
|
{ |
| 884 |
|
MENU_SET ex_menu_set; |
| 885 |
|
int ch = 0; |
| 886 |
|
|
| 887 |
|
if (p_section == NULL) |
| 888 |
|
{ |
| 889 |
|
log_error("NULL pointer error\n"); |
| 890 |
|
return -1; |
| 891 |
|
} |
| 892 |
|
|
| 893 |
|
if (p_section->ex_menu_tm == 0) // N/A |
| 894 |
|
{ |
| 895 |
|
moveto(2, 1); |
| 896 |
|
clrtoeol(); |
| 897 |
|
prints("该版块精华区未开放"); |
| 898 |
|
press_any_key(); |
| 899 |
|
return 0; |
| 900 |
|
} |
| 901 |
|
|
| 902 |
|
if (get_section_ex_menu_set(p_section, &ex_menu_set) < 0) |
| 903 |
|
{ |
| 904 |
|
log_error("get_section_ex_menu_set(sid=%d) error\n", p_section->sid); |
| 905 |
|
return -3; |
| 906 |
|
} |
| 907 |
|
if (get_menu_shm_readonly(&ex_menu_set) < 0) |
| 908 |
|
{ |
| 909 |
|
log_error("get_menu_shm_readonly(sid=%d) error\n", p_section->sid); |
| 910 |
|
return -3; |
| 911 |
|
} |
| 912 |
|
|
| 913 |
|
clearscr(); |
| 914 |
|
show_bottom(""); |
| 915 |
|
|
| 916 |
|
if (display_menu(&ex_menu_set) == 0) |
| 917 |
|
{ |
| 918 |
|
while (!SYS_server_exit) |
| 919 |
|
{ |
| 920 |
|
iflush(); |
| 921 |
|
ch = igetch(100); |
| 922 |
|
switch (ch) |
| 923 |
|
{ |
| 924 |
|
case KEY_NULL: // broken pipe |
| 925 |
|
return 0; |
| 926 |
|
case KEY_TIMEOUT: |
| 927 |
|
if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME) |
| 928 |
|
{ |
| 929 |
|
return 0; |
| 930 |
|
} |
| 931 |
|
continue; |
| 932 |
|
case CR: |
| 933 |
|
igetch_reset(); |
| 934 |
|
default: |
| 935 |
|
switch (menu_control(&ex_menu_set, ch)) |
| 936 |
|
{ |
| 937 |
|
case EXITMENU: |
| 938 |
|
ch = EXITMENU; |
| 939 |
|
break; |
| 940 |
|
case REDRAW: |
| 941 |
|
clearscr(); |
| 942 |
|
show_bottom(""); |
| 943 |
|
display_menu(&ex_menu_set); |
| 944 |
|
break; |
| 945 |
|
case NOREDRAW: |
| 946 |
|
case UNKNOWN_CMD: |
| 947 |
|
default: |
| 948 |
|
break; |
| 949 |
|
} |
| 950 |
|
} |
| 951 |
|
|
| 952 |
|
BBS_last_access_tm = time(NULL); |
| 953 |
|
|
| 954 |
|
if (ch == EXITMENU) |
| 955 |
|
{ |
| 956 |
|
break; |
| 957 |
|
} |
| 958 |
|
} |
| 959 |
|
} |
| 960 |
|
|
| 961 |
|
detach_menu_shm(&ex_menu_set); |
| 962 |
|
|
| 963 |
|
return 0; |
| 964 |
|
} |