| 39 |
#include <time.h> |
#include <time.h> |
| 40 |
#include <sys/param.h> |
#include <sys/param.h> |
| 41 |
|
|
| 42 |
|
#define TITLE_SEARCH_MAX_LEN 60 |
| 43 |
|
|
| 44 |
static int32_t section_aid_locations[BBS_max_section] = {0}; |
static int32_t section_aid_locations[BBS_max_section] = {0}; |
| 45 |
static int section_topic_view_mode = 0; |
static int section_topic_view_mode = 0; |
| 46 |
static int section_topic_view_tid = -1; |
static int section_topic_view_tid = -1; |
| 64 |
SCAN_NEW_ARTICLE, |
SCAN_NEW_ARTICLE, |
| 65 |
SCAN_ARTICLE_BACKWARD_BY_USER, |
SCAN_ARTICLE_BACKWARD_BY_USER, |
| 66 |
SCAN_ARTICLE_FORWARD_BY_USER, |
SCAN_ARTICLE_FORWARD_BY_USER, |
| 67 |
|
SCAN_ARTICLE_BACKWARD_BY_TITLE, |
| 68 |
|
SCAN_ARTICLE_FORWARD_BY_TITLE, |
| 69 |
VIEW_EX_DIR, |
VIEW_EX_DIR, |
| 70 |
SHOW_TOP10, |
SHOW_TOP10, |
| 71 |
SEARCH_USER, |
SEARCH_USER, |
| 428 |
return SCAN_ARTICLE_FORWARD_BY_USER; |
return SCAN_ARTICLE_FORWARD_BY_USER; |
| 429 |
} |
} |
| 430 |
break; |
break; |
| 431 |
|
case '?': |
| 432 |
|
if (item_count > 0) |
| 433 |
|
{ |
| 434 |
|
return SCAN_ARTICLE_BACKWARD_BY_TITLE; |
| 435 |
|
} |
| 436 |
|
break; |
| 437 |
|
case '/': |
| 438 |
|
if (item_count > 0) |
| 439 |
|
{ |
| 440 |
|
return SCAN_ARTICLE_FORWARD_BY_TITLE; |
| 441 |
|
} |
| 442 |
|
break; |
| 443 |
case 'u': |
case 'u': |
| 444 |
return SEARCH_USER; |
return SEARCH_USER; |
| 445 |
case 'h': |
case 'h': |
| 594 |
int page_id_cur; |
int page_id_cur; |
| 595 |
const ARTICLE *p_article_locate; |
const ARTICLE *p_article_locate; |
| 596 |
USER_INFO user_info; |
USER_INFO user_info; |
| 597 |
char user_intro[BBS_user_intro_max_len]; |
char user_intro[BBS_user_intro_max_len + 1]; |
| 598 |
char username[BBS_username_max_len + 1]; |
char username[BBS_username_max_len + 1]; |
| 599 |
char username_list[1][BBS_username_max_len + 1]; |
char username_list[1][BBS_username_max_len + 1]; |
| 600 |
int32_t uid; |
int32_t uid; |
| 601 |
int i; |
int i; |
| 602 |
int ok; |
int ok; |
| 603 |
|
char title[BBS_article_title_max_len + 1] = "\0"; |
| 604 |
|
|
| 605 |
p_section = section_list_find_by_name(sname); |
p_section = section_list_find_by_name(sname); |
| 606 |
if (p_section == NULL) |
if (p_section == NULL) |
| 710 |
// Update current aid location |
// Update current aid location |
| 711 |
if (p_articles[selected_index] != NULL) |
if (p_articles[selected_index] != NULL) |
| 712 |
{ |
{ |
| 713 |
section_aid_locations[section_index] = p_articles[selected_index]->aid; |
section_aid_locations[section_index] = (p_articles[selected_index]->visible ? p_articles[selected_index]->aid : 0); |
|
} |
|
|
else |
|
|
{ |
|
|
log_error("p_articles[selected_index=%d] is NULL when exit section [%s]\n", selected_index, sname); |
|
| 714 |
} |
} |
| 715 |
return 0; |
return 0; |
| 716 |
case CHANGE_PAGE: |
case CHANGE_PAGE: |
| 856 |
{ |
{ |
| 857 |
log_error("article_reply(aid=%d) error\n", p_articles[selected_index]->aid); |
log_error("article_reply(aid=%d) error\n", p_articles[selected_index]->aid); |
| 858 |
} |
} |
| 859 |
|
else if (ret > 0) // Article replied |
| 860 |
|
{ |
| 861 |
|
ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset); |
| 862 |
|
if (ret < 0) |
| 863 |
|
{ |
| 864 |
|
log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id); |
| 865 |
|
return -3; |
| 866 |
|
} |
| 867 |
|
} |
| 868 |
loop = 1; |
loop = 1; |
| 869 |
break; |
break; |
| 870 |
case '=': // First topic article |
case '=': // First topic article |
| 928 |
ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset); |
ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset); |
| 929 |
if (ret < 0) |
if (ret < 0) |
| 930 |
{ |
{ |
| 931 |
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: %d\n", p_section->sid, page_id, ret); |
| 932 |
return -3; |
return -3; |
| 933 |
} |
} |
| 934 |
} |
} |
| 954 |
{ |
{ |
| 955 |
log_error("article_modify(aid=%d) error\n", p_articles[selected_index]->aid); |
log_error("article_modify(aid=%d) error\n", p_articles[selected_index]->aid); |
| 956 |
} |
} |
| 957 |
|
else if (ret > 0) // Article modified |
| 958 |
|
{ |
| 959 |
|
ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset); |
| 960 |
|
if (ret < 0) |
| 961 |
|
{ |
| 962 |
|
log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id); |
| 963 |
|
return -3; |
| 964 |
|
} |
| 965 |
|
} |
| 966 |
if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0) |
if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0) |
| 967 |
{ |
{ |
| 968 |
log_error("section_list_draw_screen() error\n"); |
log_error("section_list_draw_screen() error\n"); |
| 981 |
} |
} |
| 982 |
else if (ret > 0) // Article deleted |
else if (ret > 0) // Article deleted |
| 983 |
{ |
{ |
| 984 |
ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset); |
do |
|
if (ret < 0) |
|
| 985 |
{ |
{ |
| 986 |
log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id); |
ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset); |
| 987 |
return -3; |
if (ret >= 0 && selected_index > article_count - 1) |
| 988 |
} |
{ |
| 989 |
|
selected_index = article_count - 1; |
| 990 |
|
break; |
| 991 |
|
} |
| 992 |
|
else if (ret < 0 && page_id > 0) |
| 993 |
|
{ |
| 994 |
|
page_id--; |
| 995 |
|
selected_index = BBS_article_limit_per_page - 1; |
| 996 |
|
} |
| 997 |
|
else if (ret < 0 && page_id <= 0) |
| 998 |
|
{ |
| 999 |
|
selected_index = 0; |
| 1000 |
|
break; |
| 1001 |
|
} |
| 1002 |
|
} while (ret < 0); |
| 1003 |
} |
} |
| 1004 |
if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0) |
if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0) |
| 1005 |
{ |
{ |
| 1190 |
} |
} |
| 1191 |
|
|
| 1192 |
page_id_cur = page_id; |
page_id_cur = page_id; |
| 1193 |
|
ret = locate_article_in_section(p_section, p_article_locate, 0, 0, |
| 1194 |
|
&page_id, &selected_index, &article_count); |
| 1195 |
|
if (ret < 0) |
| 1196 |
|
{ |
| 1197 |
|
log_error("locate_article_in_section(sid=%d, aid=%d, direction=0, step=0) error\n", |
| 1198 |
|
p_section->sid, p_article_locate->aid); |
| 1199 |
|
return -3; |
| 1200 |
|
} |
| 1201 |
|
else if (ret > 0 && page_id != page_id_cur) // found and page changed |
| 1202 |
|
{ |
| 1203 |
|
ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset); |
| 1204 |
|
if (ret < 0) |
| 1205 |
|
{ |
| 1206 |
|
log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id); |
| 1207 |
|
return -3; |
| 1208 |
|
} |
| 1209 |
|
} |
| 1210 |
|
break; |
| 1211 |
|
case SCAN_ARTICLE_BACKWARD_BY_TITLE: |
| 1212 |
|
case SCAN_ARTICLE_FORWARD_BY_TITLE: |
| 1213 |
|
direction = (ret == SCAN_ARTICLE_FORWARD_BY_TITLE ? 1 : -1); |
| 1214 |
|
|
| 1215 |
|
moveto(SCREEN_ROWS, 1); |
| 1216 |
|
clrtoeol(); |
| 1217 |
|
get_data(SCREEN_ROWS, 1, |
| 1218 |
|
(direction == 1 ? "向下搜寻标题: " : "向上搜寻标题: "), |
| 1219 |
|
title, sizeof(title), TITLE_SEARCH_MAX_LEN); |
| 1220 |
|
|
| 1221 |
|
if (title[0] == '\0') |
| 1222 |
|
{ |
| 1223 |
|
break; |
| 1224 |
|
} |
| 1225 |
|
|
| 1226 |
|
ret = scan_article_in_section_by_title(p_section, p_articles[selected_index], |
| 1227 |
|
direction, title, &p_article_locate); |
| 1228 |
|
if (ret < 0) |
| 1229 |
|
{ |
| 1230 |
|
log_error("scan_article_in_section_by_title(sid=%d, aid=%d, direction=%d, title=%s) error\n", |
| 1231 |
|
p_section->sid, p_articles[selected_index]->aid, direction, title); |
| 1232 |
|
return -3; |
| 1233 |
|
} |
| 1234 |
|
else if (ret == 0) // not found |
| 1235 |
|
{ |
| 1236 |
|
break; |
| 1237 |
|
} |
| 1238 |
|
|
| 1239 |
|
page_id_cur = page_id; |
| 1240 |
ret = locate_article_in_section(p_section, p_article_locate, 0, 0, |
ret = locate_article_in_section(p_section, p_article_locate, 0, 0, |
| 1241 |
&page_id, &selected_index, &article_count); |
&page_id, &selected_index, &article_count); |
| 1242 |
if (ret < 0) |
if (ret < 0) |