| 59 |
FIRST_TOPIC_ARTICLE, |
FIRST_TOPIC_ARTICLE, |
| 60 |
LAST_TOPIC_ARTICLE, |
LAST_TOPIC_ARTICLE, |
| 61 |
SCAN_NEW_ARTICLE, |
SCAN_NEW_ARTICLE, |
| 62 |
|
SCAN_ARTICLE_BACKWARD_BY_USER, |
| 63 |
|
SCAN_ARTICLE_FORWARD_BY_USER, |
| 64 |
VIEW_EX_DIR, |
VIEW_EX_DIR, |
| 65 |
SHOW_TOP10, |
SHOW_TOP10, |
| 66 |
SEARCH_USER, |
SEARCH_USER, |
| 411 |
return SCAN_NEW_ARTICLE; |
return SCAN_NEW_ARTICLE; |
| 412 |
} |
} |
| 413 |
break; |
break; |
| 414 |
|
case 'A': |
| 415 |
|
if (item_count > 0) |
| 416 |
|
{ |
| 417 |
|
return SCAN_ARTICLE_BACKWARD_BY_USER; |
| 418 |
|
} |
| 419 |
|
break; |
| 420 |
|
case 'a': |
| 421 |
|
if (item_count > 0) |
| 422 |
|
{ |
| 423 |
|
return SCAN_ARTICLE_FORWARD_BY_USER; |
| 424 |
|
} |
| 425 |
|
break; |
| 426 |
case 'u': |
case 'u': |
| 427 |
return SEARCH_USER; |
return SEARCH_USER; |
| 428 |
case 'h': |
case 'h': |
| 578 |
const ARTICLE *p_article_locate; |
const ARTICLE *p_article_locate; |
| 579 |
USER_INFO user_info; |
USER_INFO user_info; |
| 580 |
char user_intro[BBS_user_intro_max_len]; |
char user_intro[BBS_user_intro_max_len]; |
| 581 |
|
char username[BBS_username_max_len + 1]; |
| 582 |
|
char username_list[1][BBS_username_max_len + 1]; |
| 583 |
|
int32_t uid; |
| 584 |
|
int i; |
| 585 |
|
int ok; |
| 586 |
|
|
| 587 |
p_section = section_list_find_by_name(sname); |
p_section = section_list_find_by_name(sname); |
| 588 |
if (p_section == NULL) |
if (p_section == NULL) |
| 1055 |
page_id_cur = page_id; |
page_id_cur = page_id; |
| 1056 |
ret = locate_article_in_section(p_section, p_article_locate, 0, 0, |
ret = locate_article_in_section(p_section, p_article_locate, 0, 0, |
| 1057 |
&page_id, &selected_index, &article_count); |
&page_id, &selected_index, &article_count); |
| 1058 |
|
if (ret < 0) |
| 1059 |
|
{ |
| 1060 |
|
log_error("locate_article_in_section(sid=%d, aid=%d, direction=0, step=0) error\n", |
| 1061 |
|
p_section->sid, p_article_locate->aid); |
| 1062 |
|
return -3; |
| 1063 |
|
} |
| 1064 |
|
else if (ret > 0 && page_id != page_id_cur) // found and page changed |
| 1065 |
|
{ |
| 1066 |
|
ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset); |
| 1067 |
|
if (ret < 0) |
| 1068 |
|
{ |
| 1069 |
|
log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id); |
| 1070 |
|
return -3; |
| 1071 |
|
} |
| 1072 |
|
} |
| 1073 |
|
break; |
| 1074 |
|
case SCAN_ARTICLE_BACKWARD_BY_USER: |
| 1075 |
|
case SCAN_ARTICLE_FORWARD_BY_USER: |
| 1076 |
|
direction = (ret == SCAN_ARTICLE_FORWARD_BY_USER ? 1 : -1); |
| 1077 |
|
strncpy(username, p_articles[selected_index]->username, sizeof(username) - 1); |
| 1078 |
|
username[sizeof(username) - 1] = '\0'; |
| 1079 |
|
uid = 0; |
| 1080 |
|
|
| 1081 |
|
moveto(SCREEN_ROWS, 1); |
| 1082 |
|
clrtoeol(); |
| 1083 |
|
get_data(SCREEN_ROWS, 1, |
| 1084 |
|
(direction == 1 ? "向下搜寻作者: " : "向上搜寻作者: "), |
| 1085 |
|
username, sizeof(username), BBS_username_max_len); |
| 1086 |
|
|
| 1087 |
|
if (username[0] == '\0') |
| 1088 |
|
{ |
| 1089 |
|
break; |
| 1090 |
|
} |
| 1091 |
|
|
| 1092 |
|
// Verify format |
| 1093 |
|
for (i = 0, ok = 1; ok && username[i] != '\0'; i++) |
| 1094 |
|
{ |
| 1095 |
|
if (!(isalpha(username[i]) || (i > 0 && (isdigit(username[i]) || username[i] == '_')))) |
| 1096 |
|
{ |
| 1097 |
|
ok = 0; |
| 1098 |
|
} |
| 1099 |
|
} |
| 1100 |
|
if (ok && i > BBS_username_max_len) |
| 1101 |
|
{ |
| 1102 |
|
ok = 0; |
| 1103 |
|
} |
| 1104 |
|
if (!ok) |
| 1105 |
|
{ |
| 1106 |
|
break; |
| 1107 |
|
} |
| 1108 |
|
|
| 1109 |
|
ret = query_user_info_by_username(username, 1, &uid, username_list); |
| 1110 |
|
if (ret < 0) |
| 1111 |
|
{ |
| 1112 |
|
log_error("query_user_info_by_username(%s) error\n", username); |
| 1113 |
|
break; |
| 1114 |
|
} |
| 1115 |
|
|
| 1116 |
|
if (uid > 0) |
| 1117 |
|
{ |
| 1118 |
|
ret = scan_article_in_section_by_uid(p_section, p_articles[selected_index], |
| 1119 |
|
direction, uid, &p_article_locate); |
| 1120 |
|
if (ret < 0) |
| 1121 |
|
{ |
| 1122 |
|
log_error("scan_article_in_section_by_uid(sid=%d, aid=%d, direction=%d, uid=%d) error\n", |
| 1123 |
|
p_section->sid, p_articles[selected_index]->aid, direction, uid); |
| 1124 |
|
return -3; |
| 1125 |
|
} |
| 1126 |
|
else if (ret == 0) // not found |
| 1127 |
|
{ |
| 1128 |
|
break; |
| 1129 |
|
} |
| 1130 |
|
} |
| 1131 |
|
else // uid == 0 |
| 1132 |
|
{ |
| 1133 |
|
ret = scan_article_in_section_by_username(p_section, p_articles[selected_index], |
| 1134 |
|
direction, username, &p_article_locate); |
| 1135 |
|
if (ret < 0) |
| 1136 |
|
{ |
| 1137 |
|
log_error("scan_article_in_section_by_username(sid=%d, aid=%d, direction=%d, username=%s) error\n", |
| 1138 |
|
p_section->sid, p_articles[selected_index]->aid, direction, username); |
| 1139 |
|
return -3; |
| 1140 |
|
} |
| 1141 |
|
else if (ret == 0) // not found |
| 1142 |
|
{ |
| 1143 |
|
break; |
| 1144 |
|
} |
| 1145 |
|
} |
| 1146 |
|
|
| 1147 |
|
page_id_cur = page_id; |
| 1148 |
|
ret = locate_article_in_section(p_section, p_article_locate, 0, 0, |
| 1149 |
|
&page_id, &selected_index, &article_count); |
| 1150 |
if (ret < 0) |
if (ret < 0) |
| 1151 |
{ |
{ |
| 1152 |
log_error("locate_article_in_section(sid=%d, aid=%d, direction=0, step=0) error\n", |
log_error("locate_article_in_section(sid=%d, aid=%d, direction=0, step=0) error\n", |