/[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.11 by sysadm, Sat May 31 03:37:47 2025 UTC Revision 1.58 by sysadm, Wed Oct 29 01:48:46 2025 UTC
# Line 14  Line 14 
14   *                                                                         *   *                                                                         *
15   ***************************************************************************/   ***************************************************************************/
16    
 #include "section_list_display.h"  
 #include "section_list_loader.h"  
17  #include "article_cache.h"  #include "article_cache.h"
18    #include "article_favor.h"
19    #include "article_op.h"
20    #include "article_post.h"
21    #include "article_view_log.h"
22    #include "article_del.h"
23  #include "common.h"  #include "common.h"
24  #include "io.h"  #include "io.h"
 #include "screen.h"  
25  #include "log.h"  #include "log.h"
26    #include "login.h"
27    #include "menu.h"
28    #include "menu_proc.h"
29    #include "section_list_display.h"
30    #include "section_list_loader.h"
31    #include "screen.h"
32  #include "str_process.h"  #include "str_process.h"
33    #include "user_info_display.h"
34    #include "user_priv.h"
35    #include <string.h>
36  #include <time.h>  #include <time.h>
37  #include <sys/param.h>  #include <sys/param.h>
 #define _POSIX_C_SOURCE 200809L  
 #include <string.h>  
38    
39    static int section_aid_locations[BBS_max_section] = {0};
40  static int section_topic_view_mode = 0;  static int section_topic_view_mode = 0;
41    static int section_topic_view_tid = -1;
42    
43  enum select_cmd_t  enum select_cmd_t
44  {  {
45          EXIT_SECTION = 0,          EXIT_SECTION = 0,
46          VIEW_ARTICLE = 1,          VIEW_ARTICLE,
47          CHANGE_PAGE = 2,          CHANGE_PAGE,
48          REFRESH_SCREEN = 3,          SHOW_HELP,
49          CHANGE_NAME_DISPLAY = 4,          CHANGE_NAME_DISPLAY,
50            POST_ARTICLE,
51            EDIT_ARTICLE,
52            DELETE_ARTICLE,
53            QUERY_ARTICLE,
54            QUERY_USER,
55            SET_FAVOR_ARTICLE,
56            UNSET_FAVOR_ARTICLE,
57            FIRST_TOPIC_ARTICLE,
58            LAST_TOPIC_ARTICLE,
59            SCAN_NEW_ARTICLE,
60            VIEW_EX_DIR,
61            SHOW_TOP10,
62  };  };
63    
64  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)
65  {  {
66          char str_time[LINE_BUFFER_LEN];          char str_time[LINE_BUFFER_LEN];
67          struct tm tm_sub;          struct tm tm_sub;
# Line 47  static int section_list_draw_items(int p Line 70  static int section_list_draw_items(int p
70          int eol;          int eol;
71          int len;          int len;
72          int i;          int i;
73            size_t j;
74          char article_flag;          char article_flag;
75            int is_viewed;
76            int is_favor;
77          time_t tm_now;          time_t tm_now;
78    
79          time(&tm_now);          time(&tm_now);
# Line 56  static int section_list_draw_items(int p Line 82  static int section_list_draw_items(int p
82    
83          for (i = 0; i < article_count; i++)          for (i = 0; i < article_count; i++)
84          {          {
85                  article_flag = ' ';                  if (p_articles[i]->uid == BBS_priv.uid)
86                    {
87                            is_viewed = 1;
88                    }
89                    else
90                    {
91                            is_viewed = article_view_log_is_viewed(p_articles[i]->aid, &BBS_article_view_log);
92                            if (is_viewed < 0)
93                            {
94                                    log_error("article_view_log_is_viewed(aid=%d) error\n", p_articles[i]->aid);
95                                    is_viewed = 0;
96                            }
97                    }
98    
99                    if (p_articles[i]->tid == 0)
100                    {
101                            is_favor = article_favor_check(p_articles[i]->aid, &BBS_article_favor);
102                            if (is_favor < 0)
103                            {
104                                    log_error("article_favor_check(aid=%d) error\n", p_articles[i]->aid);
105                                    is_favor = 0;
106                            }
107                    }
108                    else
109                    {
110                            is_favor = 0;
111                    }
112    
113                  if (p_articles[i]->excerption)                  if (p_articles[i]->excerption)
114                  {                  {
115                          article_flag = 'm';                          article_flag = (is_viewed ? 'm' : 'M');
116                  }                  }
117                  else if (p_articles[i]->lock)                  else if (p_articles[i]->lock && is_viewed)
118                  {                  {
119                          article_flag = 'x';                          article_flag = 'x';
120                  }                  }
121                    else
122                    {
123                            article_flag = (is_viewed ? ' ' : 'N');
124                    }
125    
126                  localtime_r(&p_articles[i]->sub_dt, &tm_sub);                  localtime_r(&p_articles[i]->sub_dt, &tm_sub);
127                  if (tm_now - p_articles[i]->sub_dt < 3600 * 24 * 365)                  if (tm_now - p_articles[i]->sub_dt < 3600 * 24 * 365)
# Line 77  static int section_list_draw_items(int p Line 133  static int section_list_draw_items(int p
133                          strftime(str_time, sizeof(str_time), "%m/%Y", &tm_sub);                          strftime(str_time, sizeof(str_time), "%m/%Y", &tm_sub);
134                  }                  }
135    
136                  strncpy(title_f, (p_articles[i]->tid == 0 ? " " : ""), sizeof(title_f) - 1);                  strncpy(title_f, (p_articles[i]->tid == 0 ? "● " : ""), sizeof(title_f) - 1);
137                  title_f[sizeof(title_f) - 1] = '\0';                  title_f[sizeof(title_f) - 1] = '\0';
138                  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)));
139                  strncat(title_f, p_articles[i]->title, sizeof(title_f) - 1 - strnlen(title_f, sizeof(title_f)));  
140                  len = split_line(title_f, 47 - (display_nickname ? 8 : 0), &eol, &title_f_len);                  // Rewrite title with "Re: Re: " prefix into "Re: ... "
141                    j = 0;
142                    if (p_articles[i]->tid != 0)
143                    {
144                            while (strncmp(p_articles[i]->title + j, "Re: ", strlen("Re: ")) == 0)
145                            {
146                                    j += strlen("Re: ");
147                            }
148                            if (j >= strlen("Re: Re: "))
149                            {
150                                    strncat(title_f, "Re: ... ", sizeof(title_f) - 1 - strnlen(title_f, sizeof(title_f)));
151                            }
152                            else
153                            {
154                                    j = 0;
155                            }
156                    }
157                    strncat(title_f, p_articles[i]->title + j, sizeof(title_f) - 1 - strnlen(title_f, sizeof(title_f)));
158    
159                    len = split_line(title_f, 59 - (display_nickname ? BBS_nickname_max_len / 2 : BBS_username_max_len), &eol, &title_f_len, 1);
160                  if (title_f[len] != '\0')                  if (title_f[len] != '\0')
161                  {                  {
162                          title_f[len] = '\0';                          title_f[len] = '\0';
163                  }                  }
164    
165                  moveto(4 + i, 1);                  moveto(4 + i, 1);
166                  prints("  %7d %c %s%*s %s %s",                  if (i >= ontop_start_offset)
167                             p_articles[i]->aid,                  {
168                             article_flag,                          prints("   \033[1;33m[提示]\033[m%c%c %s%*s %s %s%s\033[m",
169                             (display_nickname ? p_articles[i]->nickname : p_articles[i]->username),                                     (is_favor ? '@' : ' '),
170                             (display_nickname ? BBS_nickname_max_len - (int)strnlen(p_articles[i]->nickname, sizeof(p_articles[i]->nickname))                                     article_flag,
171                                                                   : BBS_username_max_len - (int)strnlen(p_articles[i]->username, sizeof(p_articles[i]->username))),                                     (display_nickname ? p_articles[i]->nickname : p_articles[i]->username),
172                             "",                                     (display_nickname ? BBS_nickname_max_len / 2 - str_length(p_articles[i]->nickname, 1)
173                             str_time,                                                                           : BBS_username_max_len - str_length(p_articles[i]->username, 1)),
174                             title_f);                                     "",
175                                       str_time,
176                                       (p_articles[i]->aid == section_topic_view_tid
177                                                    ? "\033[1;33m"
178                                                    : (p_articles[i]->tid == section_topic_view_tid
179                                                               ? "\033[1;36m"
180                                                               : "")),
181                                       title_f);
182                    }
183                    else
184                    {
185                            prints("  %s%7d\033[m%c%c %s%*s %s %s%s\033[m",
186                                       (p_articles[i]->aid == section_topic_view_tid
187                                                    ? "\033[1;33m"
188                                                    : (p_articles[i]->tid == section_topic_view_tid
189                                                               ? "\033[1;36m"
190                                                               : "")),
191                                       p_articles[i]->aid,
192                                       (is_favor ? '@' : ' '),
193                                       article_flag,
194                                       (display_nickname ? p_articles[i]->nickname : p_articles[i]->username),
195                                       (display_nickname ? BBS_nickname_max_len / 2 - str_length(p_articles[i]->nickname, 1)
196                                                                             : BBS_username_max_len - str_length(p_articles[i]->username, 1)),
197                                       "",
198                                       str_time,
199                                       (p_articles[i]->aid == section_topic_view_tid
200                                                    ? "\033[1;33m"
201                                                    : (p_articles[i]->tid == section_topic_view_tid
202                                                               ? "\033[1;36m"
203                                                               : "")),
204                                       title_f);
205                    }
206          }          }
207    
208          return 0;          return 0;
# Line 104  static int section_list_draw_items(int p Line 210  static int section_list_draw_items(int p
210    
211  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)
212  {  {
213          char str_section_master[LINE_BUFFER_LEN] = "";          char str_section_master[LINE_BUFFER_LEN] = "诚征版主中";
214          char str_section_name[LINE_BUFFER_LEN];          char str_section_name[LINE_BUFFER_LEN];
215    
216          if (master_list[0] != '\0')          if (master_list[0] != '\0')
217          {          {
218                  snprintf(str_section_master, sizeof(str_section_master), "%s", master_list);                  snprintf(str_section_master, sizeof(str_section_master), "版主:%s", master_list);
219          }          }
220          snprintf(str_section_name, sizeof(str_section_name), " [%s]", sname);          snprintf(str_section_name, sizeof(str_section_name), "讨论区 [%s]", sname);
221    
222          clearscr();          clearscr();
223          show_top(str_section_master, stitle, str_section_name);          show_top(str_section_master, stitle, str_section_name);
224          moveto(2, 0);          moveto(2, 0);
225          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] "
226                     "Ķ[\033[1;32m\033[0;37m,\033[1;32mENTER\033[0;37m]\033[m %s[\033[1;32mn\033[0;37m]\033[m",                     "阅读[\033[1;32m→\033[0;37m,\033[1;32mENTER\033[0;37m] 发表[\033[1;32mCtrl-P\033[0;37m] "
227                     (display_nickname ? "ʾû" : "ʾdz"));                     "%s[\033[1;32mn\033[0;37m] 精华区[\033[1;32mx\033[0;37m] 帮助[\033[1;32mh\033[0;37m]\033[m",
228                       (display_nickname ? "用户名" : "昵称"));
229          moveto(3, 0);          moveto(3, 0);
230          if (display_nickname)          if (display_nickname)
231          {          {
232                  prints("\033[44;37m  \033[1;37m     dz              ±                               \033[m");                  prints("\033[44;37m  \033[1;37m 编  号   发布者昵称           日  期  文章标题                               \033[m");
233          }          }
234          else          else
235          {          {
236                  prints("\033[44;37m  \033[1;37m            ±                                       \033[m");                  prints("\033[44;37m  \033[1;37m 编  号   发 布 者     日  期  文章标题                                       \033[m");
237          }          }
238    
239          return 0;          return 0;
# Line 137  static enum select_cmd_t section_list_se Line 244  static enum select_cmd_t section_list_se
244          int old_page_id = *p_page_id;          int old_page_id = *p_page_id;
245          int old_selected_index = *p_selected_index;          int old_selected_index = *p_selected_index;
246          int ch;          int ch;
247            time_t last_refresh_tm = time(NULL);
         BBS_last_access_tm = time(0);  
248    
249          if (item_count > 0 && *p_selected_index >= 0)          if (item_count > 0 && *p_selected_index >= 0)
250          {          {
# Line 151  static enum select_cmd_t section_list_se Line 257  static enum select_cmd_t section_list_se
257          {          {
258                  ch = igetch(100);                  ch = igetch(100);
259    
260                    if (ch != KEY_NULL && ch != KEY_TIMEOUT)
261                    {
262                            BBS_last_access_tm = time(NULL);
263                    }
264    
265                  switch (ch)                  switch (ch)
266                  {                  {
267                  case KEY_NULL: // broken pipe                  case KEY_NULL: // broken pipe
268                  case KEY_ESC:                          log_error("KEY_NULL\n");
269                  case KEY_LEFT:                          return EXIT_SECTION;
                         return EXIT_SECTION; // exit section  
270                  case KEY_TIMEOUT:                  case KEY_TIMEOUT:
271                          if (time(0) - BBS_last_access_tm >= MAX_DELAY_TIME)                          if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME)
272                          {                          {
273                                  return EXIT_SECTION; // exit section                                  log_error("User input timeout\n");
274                                    return EXIT_SECTION;
275                          }                          }
276                          continue;                          continue;
277                    case KEY_ESC:
278                    case KEY_LEFT:
279                            return EXIT_SECTION;
280                  case 'n':                  case 'n':
281                          return CHANGE_NAME_DISPLAY;                          return CHANGE_NAME_DISPLAY;
282                  case CR:                  case CR:
283                          igetch_reset();                  case 'r':
284                  case KEY_RIGHT:                  case KEY_RIGHT:
285                          if (item_count > 0)                          if (item_count > 0)
286                          {                          {
287                                  return VIEW_ARTICLE;                                  return VIEW_ARTICLE;
288                          }                          }
289                          break;                          break;
290                    case Ctrl('P'):
291                            return POST_ARTICLE;
292                    case 'E':
293                            if (item_count > 0)
294                            {
295                                    return EDIT_ARTICLE;
296                            }
297                            break;
298                    case 'd':
299                            if (item_count > 0)
300                            {
301                                    return DELETE_ARTICLE;
302                            }
303                            break;
304                    case Ctrl('Q'):
305                            if (item_count > 0)
306                            {
307                                    return QUERY_ARTICLE;
308                            }
309                            break;
310                    case Ctrl('A'):
311                            if (item_count > 0)
312                            {
313                                    return QUERY_USER;
314                            }
315                            break;
316                    case 'F':
317                            if (item_count > 0)
318                            {
319                                    return SET_FAVOR_ARTICLE;
320                            }
321                            break;
322                    case '-':
323                            if (item_count > 0)
324                            {
325                                    return UNSET_FAVOR_ARTICLE;
326                            }
327                            break;
328                  case KEY_HOME:                  case KEY_HOME:
329                          *p_page_id = 0;                          *p_page_id = 0;
330                    case 'P':
331                  case KEY_PGUP:                  case KEY_PGUP:
332                          *p_selected_index = 0;                          *p_selected_index = 0;
333                    case 'k':
334                  case KEY_UP:                  case KEY_UP:
335                          if (*p_selected_index <= 0)                          if (*p_selected_index <= 0)
336                          {                          {
# Line 185  static enum select_cmd_t section_list_se Line 339  static enum select_cmd_t section_list_se
339                                          (*p_page_id)--;                                          (*p_page_id)--;
340                                          *p_selected_index = BBS_article_limit_per_page - 1;                                          *p_selected_index = BBS_article_limit_per_page - 1;
341                                  }                                  }
342                                    else if (ch == KEY_UP || ch == 'k') // Rotate to the tail of section list
343                                    {
344                                            if (total_page > 0)
345                                            {
346                                                    *p_page_id = total_page - 1;
347                                            }
348                                            if (item_count > 0)
349                                            {
350                                                    *p_selected_index = item_count - 1;
351                                            }
352                                    }
353                          }                          }
354                          else                          else
355                          {                          {
356                                  (*p_selected_index)--;                                  (*p_selected_index)--;
357                          }                          }
358                          break;                          break;
359                    case '$':
360                  case KEY_END:                  case KEY_END:
361                          if (total_page > 0)                          if (total_page > 0)
362                          {                          {
363                                  *p_page_id = total_page - 1;                                  *p_page_id = total_page - 1;
364                          }                          }
365                    case 'N':
366                  case KEY_PGDN:                  case KEY_PGDN:
367                          if (item_count > 0)                          if (item_count > 0)
368                          {                          {
369                                  *p_selected_index = item_count - 1;                                  *p_selected_index = item_count - 1;
370                          }                          }
371                    case 'j':
372                  case KEY_DOWN:                  case KEY_DOWN:
373                          if (*p_selected_index + 1 >= item_count) // next page                          if (*p_selected_index + 1 >= item_count) // next page
374                          {                          {
# Line 209  static enum select_cmd_t section_list_se Line 377  static enum select_cmd_t section_list_se
377                                          (*p_page_id)++;                                          (*p_page_id)++;
378                                          *p_selected_index = 0;                                          *p_selected_index = 0;
379                                  }                                  }
380                                    else if (ch == KEY_DOWN || ch == 'j') // Rotate to the head of section list
381                                    {
382                                            *p_page_id = 0;
383                                            *p_selected_index = 0;
384                                    }
385                          }                          }
386                          else                          else
387                          {                          {
388                                  (*p_selected_index)++;                                  (*p_selected_index)++;
389                          }                          }
390                          break;                          break;
391                    case '=':
392                            if (item_count > 0)
393                            {
394                                    return FIRST_TOPIC_ARTICLE;
395                            }
396                            break;
397                    case '\\':
398                            if (item_count > 0)
399                            {
400                                    return LAST_TOPIC_ARTICLE;
401                            }
402                            break;
403                    case 'S':
404                            if (item_count > 0)
405                            {
406                                    return SCAN_NEW_ARTICLE;
407                            }
408                            break;
409                    case 'h':
410                            return SHOW_HELP;
411                    case 'x':
412                            return VIEW_EX_DIR;
413                    case 'H':
414                            return SHOW_TOP10;
415                  default:                  default:
416                            break;
417                  }                  }
418    
419                  if (old_page_id != *p_page_id)                  if (old_page_id != *p_page_id)
# Line 240  static enum select_cmd_t section_list_se Line 438  static enum select_cmd_t section_list_se
438                          old_selected_index = *p_selected_index;                          old_selected_index = *p_selected_index;
439                  }                  }
440    
441                  BBS_last_access_tm = time(0);                  if (BBS_last_access_tm - last_refresh_tm >= BBS_section_list_load_interval)
442                    {
443                            return CHANGE_PAGE; // force section list refresh
444                    }
445          }          }
446    
447          return EXIT_SECTION;          return EXIT_SECTION;
# Line 251  static int display_article_key_handler(i Line 452  static int display_article_key_handler(i
452          switch (*p_key)          switch (*p_key)
453          {          {
454          case 'p':          case 'p':
455            case Ctrl('X'):
456                  section_topic_view_mode = !section_topic_view_mode;                  section_topic_view_mode = !section_topic_view_mode;
457          case 0: // Set msg          case 0: // Set msg
458                  if (section_topic_view_mode)                  if (section_topic_view_mode)
459                  {                  {
460                          snprintf(p_ctx->msg, sizeof(p_ctx->msg),                          snprintf(p_ctx->msg, sizeof(p_ctx->msg),
461                                           "| [\033[32m\033[33m,\033[32mESC\033[33m] "                                           "| 返回[\033[32m←\033[33m,\033[32mESC\033[33m] "
462                                           "ͬĶ[\033[32m\033[33m/\033[32m\033[33m] "                                           "同主题阅读[\033[32m↑\033[33m/\033[32m↓\033[33m] "
463                                           "[\033[32mh\033[33m] |");                                           "切换[\033[32mp\033[33m] 回复[\033[32mr\033[33m] 帮助[\033[32mh\033[33m] |");
464                  }                  }
465                  else                  else
466                  {                  {
467                          snprintf(p_ctx->msg, sizeof(p_ctx->msg),                          snprintf(p_ctx->msg, sizeof(p_ctx->msg),
468                                           "| [\033[32m\033[33m,\033[32mESC\033[33m] "                                           "| 返回[\033[32m←\033[33m,\033[32mESC\033[33m] "
469                                           "ƶ[\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] "
470                                           "[\033[32mh\033[33m] |");                                           "切换[\033[32mp\033[33m] 回复[\033[32mr\033[33m] 帮助[\033[32mh\033[33m] |");
471                  }                  }
472                  *p_key = 0;                  *p_key = 0;
473                  break;                  break;
474            case 'r': // Reply article
475                    return 1;
476            case '=': // First topic article
477                    return 1;
478            case '\\': // Last topic article
479                    return 1;
480            case KEY_UP:
481            case KEY_PGUP:
482            case KEY_HOME:
483                    if (p_ctx->reach_begin)
484                    {
485                            if (section_topic_view_mode)
486                            {
487                                    *p_key = KEY_PGUP;
488                            }
489                            else
490                            {
491                                    *p_key = KEY_UP;
492                            }
493                            return 1;
494                    }
495                    break;
496            case 'k':
497                    if (section_topic_view_mode)
498                    {
499                            *p_key = KEY_PGUP;
500                    }
501                    else
502                    {
503                            *p_key = KEY_UP;
504                    }
505                    return 1;
506            case KEY_DOWN:
507            case KEY_PGDN:
508            case KEY_END:
509                    if (p_ctx->reach_end)
510                    {
511                            if (section_topic_view_mode)
512                            {
513                                    *p_key = KEY_PGDN;
514                            }
515                            else
516                            {
517                                    *p_key = KEY_DOWN;
518                            }
519                            return 1;
520                    }
521                    break;
522            case 'j':
523                    if (section_topic_view_mode)
524                    {
525                            *p_key = KEY_PGDN;
526                    }
527                    else
528                    {
529                            *p_key = KEY_DOWN;
530                    }
531                    return 1;
532          }          }
533    
534          return 0;          return 0;
535  }  }
536    
537  int section_list_display(const char *sname)  int section_list_display(const char *sname, int32_t aid)
538  {  {
539          static int display_nickname = 0;          static int display_nickname = 0;
540    
541          SECTION_LIST *p_section;          SECTION_LIST *p_section;
542            int64_t section_index;
543            int32_t aid_location;
544          char stitle[BBS_section_title_max_len + 1];          char stitle[BBS_section_title_max_len + 1];
545          char master_list[(BBS_username_max_len + 1) * 3 + 1];          char master_list[(BBS_username_max_len + 1) * 3 + 1];
546          char page_info_str[LINE_BUFFER_LEN];          char page_info_str[LINE_BUFFER_LEN];
547          ARTICLE *p_articles[BBS_article_limit_per_page];          ARTICLE *p_articles[BBS_article_limit_per_page];
548          int article_count;          int article_count;
549          int page_count;          int page_count;
550            int ontop_start_offset;
551          int page_id = 0;          int page_id = 0;
552          int selected_index = 0;          int selected_index = 0;
553          ARTICLE_CACHE cache;          ARTICLE_CACHE cache;
554          int ret;          int ret;
555            int loop;
556            int direction;
557            ARTICLE article_new;
558            int page_id_cur;
559            const ARTICLE *p_article_locate;
560            USER_INFO user_info;
561    
562          p_section = section_list_find_by_name(sname);          p_section = section_list_find_by_name(sname);
563          if (p_section == NULL)          if (p_section == NULL)
# Line 297  int section_list_display(const char *sna Line 566  int section_list_display(const char *sna
566                  return -1;                  return -1;
567          }          }
568    
569          if ((ret = section_list_rd_lock(p_section)) < 0)          if (!checkpriv(&BBS_priv, p_section->sid, S_LIST))
570          {          {
571                  log_error("section_list_rd_lock(sid = 0) error\n");                  log_error("Forbid access to unauthorized section, sid=%d, uid=%d\n",
572                  return -2;                                    p_section->sid, BBS_priv.uid);
573                    return -1;
574          }          }
575    
576          strncpy(stitle, p_section->stitle, sizeof(stitle) - 1);          section_index = get_section_index(p_section);
         stitle[sizeof(stitle) - 1] = '\0';  
         strncpy(master_list, p_section->master_list, sizeof(master_list) - 1);  
         master_list[sizeof(master_list) - 1] = '\0';  
577    
578          if ((ret = section_list_rd_unlock(p_section)) < 0)          if (get_section_info(p_section, NULL, stitle, master_list) < 0)
579          {          {
580                  log_error("section_list_rd_unlock(sid = 0) error\n");                  log_error("get_section_info(sid=%d) error\n", p_section->sid);
581                  return -2;                  return -4;
582            }
583    
584            if (aid == 0)
585            {
586                    aid_location = section_aid_locations[section_index];
587            }
588            else
589            {
590                    aid_location = aid;
591            }
592    
593            // Locate at article with aid_locate
594            if (aid_location > 0)
595            {
596                    p_article_locate = article_block_find_by_aid(aid_location);
597                    if (p_article_locate == NULL)
598                    {
599                            log_error("article_block_find_by_aid(%d) error\n", aid_location);
600                            return -3;
601                    }
602    
603                    ret = locate_article_in_section(p_section, p_article_locate, 0, 0,
604                                                                                    &page_id, &selected_index, &article_count);
605                    if (ret < 0)
606                    {
607                            log_error("locate_article_in_section(sid=%d, aid=%d, direction=0, step=0) error\n",
608                                              p_section->sid, p_article_locate->aid);
609                            return -3;
610                    }
611          }          }
612    
613          if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)          if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
# Line 320  int section_list_display(const char *sna Line 616  int section_list_display(const char *sna
616                  return -2;                  return -2;
617          }          }
618    
619          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);
620          if (ret < 0)          if (ret < 0)
621          {          {
622                  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);
623                  return -3;                  return -3;
624          }          }
625    
626            section_topic_view_tid = -1;
627    
628          if (article_count == 0) // empty section          if (article_count == 0) // empty section
629          {          {
630                  selected_index = 0;                  selected_index = 0;
631          }          }
632            else if (aid > 0)
633            {
634                    // Update current topic
635                    section_topic_view_tid = (p_articles[selected_index]->tid == 0 ? p_articles[selected_index]->aid : p_articles[selected_index]->tid);
636    
637                    // Update current aid location
638                    section_aid_locations[section_index] = p_articles[selected_index]->aid;
639            }
640    
641          while (!SYS_server_exit)          while (!SYS_server_exit)
642          {          {
643                  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);
644                  if (ret < 0)                  if (ret < 0)
645                  {                  {
646                          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);
# Line 342  int section_list_display(const char *sna Line 648  int section_list_display(const char *sna
648                  }                  }
649    
650                  snprintf(page_info_str, sizeof(page_info_str),                  snprintf(page_info_str, sizeof(page_info_str),
651                                   "\033[33m[\033[36m%d\033[33m/\033[36m%d\033[33mҳ]",                                   "\033[33m[第\033[36m%d\033[33m/\033[36m%d\033[33m页]",
652                                   page_id + 1, MAX(page_count, 1));                                   page_id + 1, MAX(page_count, 1));
653    
654                  show_bottom(page_info_str);                  show_bottom(page_info_str);
655                  iflush();                  iflush();
656    
657                    if (user_online_update(sname) < 0)
658                    {
659                            log_error("user_online_update(%s) error\n", sname);
660                    }
661    
662                  ret = section_list_select(page_count, article_count, &page_id, &selected_index);                  ret = section_list_select(page_count, article_count, &page_id, &selected_index);
663                  switch (ret)                  switch (ret)
664                  {                  {
665                  case EXIT_SECTION:                  case EXIT_SECTION:
666                          return 0;                          return 0;
667                  case CHANGE_PAGE:                  case CHANGE_PAGE:
668                          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);
669                          if (ret < 0)                          if (ret < 0)
670                          {                          {
671                                  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);
# Line 370  int section_list_display(const char *sna Line 681  int section_list_display(const char *sna
681                          }                          }
682                          break;                          break;
683                  case VIEW_ARTICLE:                  case VIEW_ARTICLE:
684                          ret = article_cache_load(&cache, VAR_ARTICLE_CACHE_DIR, p_articles[selected_index]);                          do
                         if (ret < 0)  
685                          {                          {
686                                  log_error("article_cache_load(aid=%d, cid=%d) error\n", p_articles[selected_index]->aid, p_articles[selected_index]->cid);                                  loop = 0;
687                                  break;  
688                                    if (article_cache_load(&cache, VAR_ARTICLE_CACHE_DIR, p_articles[selected_index]) < 0)
689                                    {
690                                            log_error("article_cache_load(aid=%d, cid=%d) error\n", p_articles[selected_index]->aid, p_articles[selected_index]->cid);
691                                            break;
692                                    }
693    
694                                    if (user_online_update("VIEW_ARTICLE") < 0)
695                                    {
696                                            log_error("user_online_update(VIEW_ARTICLE) error\n");
697                                    }
698    
699                                    ret = display_data(cache.p_data, cache.line_total, cache.line_offsets, 0,
700                                                                       display_article_key_handler, DATA_READ_HELP);
701    
702                                    if (article_cache_unload(&cache) < 0)
703                                    {
704                                            log_error("article_cache_unload(aid=%d, cid=%d) error\n", p_articles[selected_index]->aid, p_articles[selected_index]->cid);
705                                            break;
706                                    }
707    
708                                    // Update article_view_log
709                                    if (article_view_log_set_viewed(p_articles[selected_index]->aid, &BBS_article_view_log) < 0)
710                                    {
711                                            log_error("article_view_log_set_viewed(aid=%d) error\n", p_articles[selected_index]->aid);
712                                    }
713    
714                                    switch (ret)
715                                    {
716                                    case KEY_UP:
717                                            if (selected_index <= 0)
718                                            {
719                                                    if (page_id > 0)
720                                                    {
721                                                            page_id--;
722                                                            selected_index = BBS_article_limit_per_page - 1;
723    
724                                                            ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset);
725                                                            if (ret < 0)
726                                                            {
727                                                                    log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id);
728                                                                    return -3;
729                                                            }
730    
731                                                            if (article_count != BBS_article_limit_per_page) // page is not full
732                                                            {
733                                                                    selected_index = MAX(0, article_count - 1);
734                                                            }
735                                                            else
736                                                            {
737                                                                    loop = 1;
738                                                            }
739                                                    }
740                                            }
741                                            else
742                                            {
743                                                    selected_index--;
744                                                    loop = 1;
745                                            }
746                                            break;
747                                    case KEY_DOWN:
748                                            if (selected_index + 1 >= article_count) // next page
749                                            {
750                                                    if (page_id + 1 < page_count)
751                                                    {
752                                                            page_id++;
753                                                            selected_index = 0;
754    
755                                                            ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset);
756                                                            if (ret < 0)
757                                                            {
758                                                                    log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id);
759                                                                    return -3;
760                                                            }
761    
762                                                            if (article_count == 0) // empty page
763                                                            {
764                                                                    selected_index = 0;
765                                                            }
766                                                            else
767                                                            {
768                                                                    loop = 1;
769                                                            }
770                                                    }
771                                            }
772                                            else
773                                            {
774                                                    selected_index++;
775                                                    loop = 1;
776                                            }
777                                            break;
778                                    case KEY_PGUP:
779                                    case KEY_PGDN:
780                                            direction = (ret == KEY_PGUP ? -1 : 1);
781                                            ret = locate_article_in_section(p_section, p_articles[selected_index], direction, 1,
782                                                                                                            &page_id, &selected_index, &article_count);
783                                            if (ret < 0)
784                                            {
785                                                    log_error("locate_article_in_section(sid=%d, aid=%d, direction=%d, step=1) error\n",
786                                                                      p_section->sid, p_articles[selected_index]->aid, direction);
787                                                    return -3;
788                                            }
789                                            else if (ret > 0) // found
790                                            {
791                                                    ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset);
792                                                    if (ret < 0)
793                                                    {
794                                                            log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id);
795                                                            return -3;
796                                                    }
797                                                    loop = 1;
798                                            }
799                                            break;
800                                    case 'r': // Reply article
801                                            if (user_online_update("REPLY_ARTICLE") < 0)
802                                            {
803                                                    log_error("user_online_update(REPLY_ARTICLE) error\n");
804                                            }
805    
806                                            if (article_reply(p_section, p_articles[selected_index], &article_new) < 0)
807                                            {
808                                                    log_error("article_reply(aid=%d) error\n", p_articles[selected_index]->aid);
809                                            }
810                                            loop = 1;
811                                            break;
812                                    case '=':  // First topic article
813                                    case '\\': // Last topic article
814                                            page_id_cur = page_id;
815                                            direction = (ret == '=' ? -1 : 1);
816                                            ret = locate_article_in_section(p_section, p_articles[selected_index], direction, BBS_article_limit_per_section,
817                                                                                                            &page_id, &selected_index, &article_count);
818                                            if (ret < 0)
819                                            {
820                                                    log_error("locate_article_in_section(sid=%d, aid=%d, direction=%d, step=%d) error\n",
821                                                                      p_section->sid, p_articles[selected_index]->aid, direction, BBS_article_limit_per_section);
822                                                    return -3;
823                                            }
824                                            else if (ret > 0) // found
825                                            {
826                                                    if (page_id != page_id_cur) // page changed
827                                                    {
828                                                            ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset);
829                                                            if (ret < 0)
830                                                            {
831                                                                    log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id);
832                                                                    return -3;
833                                                            }
834                                                    }
835                                                    loop = 1;
836                                            }
837                                            break;
838                                    }
839                            } while (loop);
840    
841                            // Update current topic
842                            section_topic_view_tid = (p_articles[selected_index]->tid == 0 ? p_articles[selected_index]->aid : p_articles[selected_index]->tid);
843    
844                            // Update current aid location
845                            section_aid_locations[section_index] = p_articles[selected_index]->aid;
846    
847                            if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
848                            {
849                                    log_error("section_list_draw_screen() error\n");
850                                    return -2;
851                            }
852                            break;
853                    case CHANGE_NAME_DISPLAY:
854                            display_nickname = !display_nickname;
855                            if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
856                            {
857                                    log_error("section_list_draw_screen() error\n");
858                                    return -2;
859                            }
860                            break;
861                    case POST_ARTICLE:
862                            if (user_online_update("POST_ARTICLE") < 0)
863                            {
864                                    log_error("user_online_update(POST_ARTICLE) error\n");
865                          }                          }
866    
867                          ret = display_data(cache.p_data, cache.line_total, cache.line_offsets, 1, 0,                          if ((ret = article_post(p_section, &article_new)) < 0)
                                                            display_article_key_handler, DATA_READ_HELP);  
                         if (ret < 0)  
868                          {                          {
869                                  log_error("display_data(aid=%d, cid=%d) error\n", p_articles[selected_index]->aid, p_articles[selected_index]->cid);                                  log_error("article_post(sid=%d) error\n", p_section->sid);
870                                  break;                          }
871                            else if (ret > 0) // New article posted
872                            {
873                                    ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset);
874                                    if (ret < 0)
875                                    {
876                                            log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id);
877                                            return -3;
878                                    }
879                            }
880                            if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
881                            {
882                                    log_error("section_list_draw_screen() error\n");
883                                    return -2;
884                            }
885                            break;
886                    case EDIT_ARTICLE:
887                            if (!checkpriv(&BBS_priv, p_section->sid, S_POST) ||
888                                    p_articles[selected_index]->uid != BBS_priv.uid)
889                            {
890                                    break; // No permission
891                            }
892    
893                            if (user_online_update("EDIT_ARTICLE") < 0)
894                            {
895                                    log_error("user_online_update() error\n");
896                            }
897    
898                            if (article_modify(p_section, p_articles[selected_index], &article_new) < 0)
899                            {
900                                    log_error("article_modify(aid=%d) error\n", p_articles[selected_index]->aid);
901                            }
902                            if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
903                            {
904                                    log_error("section_list_draw_screen() error\n");
905                                    return -2;
906                            }
907                            break;
908                    case DELETE_ARTICLE:
909                            if (!checkpriv(&BBS_priv, p_section->sid, S_POST) ||
910                                    (!checkpriv(&BBS_priv, p_section->sid, S_MAN_S) && p_articles[selected_index]->uid != BBS_priv.uid))
911                            {
912                                    break; // No permission
913                            }
914                            if ((ret = article_del(p_section, p_articles[selected_index])) < 0)
915                            {
916                                    log_error("article_del(aid=%d) error\n", p_articles[selected_index]->aid);
917                            }
918                            else if (ret > 0) // Article deleted
919                            {
920                                    ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset);
921                                    if (ret < 0)
922                                    {
923                                            log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id);
924                                            return -3;
925                                    }
926                            }
927                            if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
928                            {
929                                    log_error("section_list_draw_screen() error\n");
930                                    return -2;
931                            }
932                            break;
933                    case QUERY_ARTICLE:
934                            if ((ret = display_article_meta(p_articles[selected_index]->aid)) < 0)
935                            {
936                                    log_error("display_article_meta(aid=%d) error\n", p_articles[selected_index]->aid);
937                            }
938                            if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
939                            {
940                                    log_error("section_list_draw_screen() error\n");
941                                    return -2;
942                            }
943                            break;
944                    case QUERY_USER:
945                            if ((ret = query_user_info_by_uid(p_articles[selected_index]->uid, &user_info)) < 0)
946                            {
947                                    log_error("query_user_info_by_uid(uid=%d) error\n", p_articles[selected_index]->uid);
948                                    return -2;
949                            }
950                            else if (ret == 0)
951                            {
952                                    clearscr();
953                                    prints("该用户已升天");
954                                    press_any_key();
955                            }
956                            else if (user_info_display(&user_info) < 0) // && ret > 0
957                            {
958                                    log_error("user_info_display(uid=%d) error\n", p_articles[selected_index]->uid);
959                          }                          }
960    
961                          ret = article_cache_unload(&cache);                          if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
962                            {
963                                    log_error("section_list_draw_screen() error\n");
964                                    return -2;
965                            }
966                            break;
967                    case SET_FAVOR_ARTICLE:
968                            ret = article_favor_set(p_articles[selected_index]->tid == 0
969                                                                                    ? p_articles[selected_index]->aid
970                                                                                    : p_articles[selected_index]->tid,
971                                                                            &BBS_article_favor, 1);
972                          if (ret < 0)                          if (ret < 0)
973                          {                          {
974                                  log_error("article_cache_unload(aid=%d, cid=%d) error\n", p_articles[selected_index]->aid, p_articles[selected_index]->cid);                                  log_error("article_favor_set(aid=%d, 1) error\n",
975                                                      p_articles[selected_index]->tid == 0 ? p_articles[selected_index]->aid : p_articles[selected_index]->tid);
976                            }
977                            break;
978                    case UNSET_FAVOR_ARTICLE:
979                            ret = article_favor_set(p_articles[selected_index]->tid == 0
980                                                                                    ? p_articles[selected_index]->aid
981                                                                                    : p_articles[selected_index]->tid,
982                                                                            &BBS_article_favor, 0);
983                            if (ret < 0)
984                            {
985                                    log_error("article_favor_set(aid=%d, 0) error\n",
986                                                      p_articles[selected_index]->tid == 0 ? p_articles[selected_index]->aid : p_articles[selected_index]->tid);
987                            }
988                            break;
989                    case FIRST_TOPIC_ARTICLE:
990                    case LAST_TOPIC_ARTICLE:
991                            page_id_cur = page_id;
992                            direction = (ret == FIRST_TOPIC_ARTICLE ? -1 : 1);
993                            ret = locate_article_in_section(p_section, p_articles[selected_index], direction, BBS_article_limit_per_section,
994                                                                                            &page_id, &selected_index, &article_count);
995                            if (ret < 0)
996                            {
997                                    log_error("locate_article_in_section(sid=%d, aid=%d, direction=%d, step=%d) error\n",
998                                                      p_section->sid, p_articles[selected_index]->aid, direction, BBS_article_limit_per_section);
999                                    return -3;
1000                            }
1001                            else if (ret > 0 && page_id != page_id_cur) // found and page changed
1002                            {
1003                                    ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset);
1004                                    if (ret < 0)
1005                                    {
1006                                            log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id);
1007                                            return -3;
1008                                    }
1009                            }
1010                            break;
1011                    case SCAN_NEW_ARTICLE:
1012                            ret = scan_unread_article_in_section(p_section, p_articles[selected_index], &p_article_locate);
1013                            if (ret < 0)
1014                            {
1015                                    log_error("scan_unread_article_in_section(sid=%d, aid=%d) error\n",
1016                                                      p_section->sid, p_articles[selected_index]->aid);
1017                                    return -3;
1018                            }
1019                            else if (ret == 0) // not found
1020                            {
1021                                  break;                                  break;
1022                          }                          }
1023                            page_id_cur = page_id;
1024                          // TODO: locate last viewed article                          ret = locate_article_in_section(p_section, p_article_locate, 0, 0,
1025                  case REFRESH_SCREEN:                                                                                          &page_id, &selected_index, &article_count);
1026                            if (ret < 0)
1027                            {
1028                                    log_error("locate_article_in_section(sid=%d, aid=%d, direction=0, step=0) error\n",
1029                                                      p_section->sid, p_article_locate->aid);
1030                                    return -3;
1031                            }
1032                            else if (ret > 0 && page_id != page_id_cur) // found and page changed
1033                            {
1034                                    ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset);
1035                                    if (ret < 0)
1036                                    {
1037                                            log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id);
1038                                            return -3;
1039                                    }
1040                            }
1041                            break;
1042                    case SHOW_HELP:
1043                            // Display help information
1044                            display_file(DATA_READ_HELP, 1);
1045                          if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)                          if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
1046                          {                          {
1047                                  log_error("section_list_draw_screen() error\n");                                  log_error("section_list_draw_screen() error\n");
1048                                  return -2;                                  return -2;
1049                          }                          }
1050                          break;                          break;
1051                  case CHANGE_NAME_DISPLAY:                  case VIEW_EX_DIR:
1052                          display_nickname = !display_nickname;                          if (section_list_ex_dir_display(p_section) < 0)
1053                            {
1054                                    log_error("section_list_ex_dir_display(sid=%d) error\n", p_section->sid);
1055                            }
1056                            if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
1057                            {
1058                                    log_error("section_list_draw_screen() error\n");
1059                                    return -2;
1060                            }
1061                            break;
1062                    case SHOW_TOP10:
1063                            show_top10_menu(NULL);
1064                          if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)                          if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
1065                          {                          {
1066                                  log_error("section_list_draw_screen() error\n");                                  log_error("section_list_draw_screen() error\n");
# Line 415  int section_list_display(const char *sna Line 1074  int section_list_display(const char *sna
1074    
1075          return 0;          return 0;
1076  }  }
1077    
1078    int section_list_ex_dir_display(SECTION_LIST *p_section)
1079    {
1080            MENU_SET ex_menu_set;
1081            int ch = 0;
1082    
1083            if (p_section == NULL)
1084            {
1085                    log_error("NULL pointer error\n");
1086                    return -1;
1087            }
1088    
1089            if (p_section->ex_menu_tm == 0) // N/A
1090            {
1091                    moveto(2, 1);
1092                    clrtoeol();
1093                    prints("该版块精华区未开放");
1094                    press_any_key();
1095                    return 0;
1096            }
1097    
1098            if (get_section_ex_menu_set(p_section, &ex_menu_set) < 0)
1099            {
1100                    log_error("get_section_ex_menu_set(sid=%d) error\n", p_section->sid);
1101                    return -3;
1102            }
1103            if (get_menu_shm_readonly(&ex_menu_set) < 0)
1104            {
1105                    log_error("get_menu_shm_readonly(sid=%d) error\n", p_section->sid);
1106                    return -3;
1107            }
1108    
1109            clearscr();
1110            show_bottom("");
1111    
1112            if (display_menu(&ex_menu_set) == 0)
1113            {
1114                    while (!SYS_server_exit)
1115                    {
1116                            iflush();
1117                            ch = igetch(100);
1118    
1119                            if (ch != KEY_NULL && ch != KEY_TIMEOUT)
1120                            {
1121                                    BBS_last_access_tm = time(NULL);
1122                            }
1123    
1124                            switch (ch)
1125                            {
1126                            case KEY_NULL: // broken pipe
1127                                    log_error("KEY_NULL\n");
1128                                    return 0;
1129                            case KEY_TIMEOUT:
1130                                    if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME)
1131                                    {
1132                                            log_error("User input timeout\n");
1133                                            return 0;
1134                                    }
1135                                    continue;
1136                            case CR:
1137                            default:
1138                                    switch (menu_control(&ex_menu_set, ch))
1139                                    {
1140                                    case EXITMENU:
1141                                            ch = EXITMENU;
1142                                            break;
1143                                    case REDRAW:
1144                                            clearscr();
1145                                            show_bottom("");
1146                                            display_menu(&ex_menu_set);
1147                                            break;
1148                                    case NOREDRAW:
1149                                    case UNKNOWN_CMD:
1150                                    default:
1151                                            break;
1152                                    }
1153                            }
1154    
1155                            if (ch == EXITMENU)
1156                            {
1157                                    break;
1158                            }
1159                    }
1160            }
1161    
1162            detach_menu_shm(&ex_menu_set);
1163    
1164            return 0;
1165    }


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

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