/[LeafOK_CVS]/lbbs/src/section_list_display.c
ViewVC logotype

Diff of /lbbs/src/section_list_display.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.62 by sysadm, Sun Nov 2 15:11:47 2025 UTC Revision 1.64 by sysadm, Mon Nov 3 06:43:55 2025 UTC
# Line 31  Line 31 
31  #include "screen.h"  #include "screen.h"
32  #include "str_process.h"  #include "str_process.h"
33  #include "user_info_display.h"  #include "user_info_display.h"
34    #include "user_list_display.h"
35  #include "user_priv.h"  #include "user_priv.h"
36  #include <errno.h>  #include <errno.h>
37  #include <string.h>  #include <string.h>
# Line 58  enum select_cmd_t Line 59  enum select_cmd_t
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,
67  };  };
68    
69  static int section_list_draw_items(int page_id, ARTICLE *p_articles[], int article_count, int display_nickname, int ontop_start_offset)  static int section_list_draw_items(int page_id, ARTICLE *p_articles[], int article_count, int display_nickname, int ontop_start_offset)
# Line 407  static enum select_cmd_t section_list_se Line 411  static enum select_cmd_t section_list_se
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':
427                            return SEARCH_USER;
428                  case 'h':                  case 'h':
429                          return SHOW_HELP;                          return SHOW_HELP;
430                  case 'x':                  case 'x':
# Line 560  int section_list_display(const char *sna Line 578  int section_list_display(const char *sna
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)
# Line 1048  int section_list_display(const char *sna Line 1071  int section_list_display(const char *sna
1071                                  }                                  }
1072                          }                          }
1073                          break;                          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)
1151                            {
1152                                    log_error("locate_article_in_section(sid=%d, aid=%d, direction=0, step=0) error\n",
1153                                                      p_section->sid, p_article_locate->aid);
1154                                    return -3;
1155                            }
1156                            else if (ret > 0 && page_id != page_id_cur) // found and page changed
1157                            {
1158                                    ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset);
1159                                    if (ret < 0)
1160                                    {
1161                                            log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id);
1162                                            return -3;
1163                                    }
1164                            }
1165                            break;
1166                    case SEARCH_USER:
1167                            user_list_search();
1168                            if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
1169                            {
1170                                    log_error("section_list_draw_screen() error\n");
1171                                    return -2;
1172                            }
1173                            break;
1174                  case SHOW_HELP:                  case SHOW_HELP:
1175                          // Display help information                          // Display help information
1176                          display_file(DATA_READ_HELP, 1);                          display_file(DATA_READ_HELP, 1);


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1