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

Diff of /lbbs/src/user_list_display.c

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

Revision 1.16 by sysadm, Sun Nov 2 15:31:23 2025 UTC Revision 1.26 by sysadm, Wed Dec 17 03:47:01 2025 UTC
# Line 1  Line 1 
1  /***************************************************************************  /* SPDX-License-Identifier: GPL-3.0-or-later */
2                                           user_list_display.c  -  description  /*
3                                                           -------------------   * user_list_display
4          Copyright            : (C) 2004-2025 by Leaflet   *   - user interactive list of (online) users
5          Email                : leaflet@leafok.com   *
6   ***************************************************************************/   * Copyright (C) 2004-2025  Leaflet <leaflet@leafok.com>
7     */
8  /***************************************************************************  
9   *                                                                         *  #ifdef HAVE_CONFIG_H
10   *   This program is free software; you can redistribute it and/or modify  *  #include "config.h"
11   *   it under the terms of the GNU General Public License as published by  *  #endif
  *   the Free Software Foundation; either version 3 of the License, or     *  
  *   (at your option) any later version.                                   *  
  *                                                                         *  
  ***************************************************************************/  
12    
13  #include "common.h"  #include "common.h"
14  #include "io.h"  #include "io.h"
# Line 222  static enum select_cmd_t user_list_selec Line 218  static enum select_cmd_t user_list_selec
218                  if (ch != KEY_NULL && ch != KEY_TIMEOUT)                  if (ch != KEY_NULL && ch != KEY_TIMEOUT)
219                  {                  {
220                          BBS_last_access_tm = time(NULL);                          BBS_last_access_tm = time(NULL);
221    
222                            // Refresh current action
223                            if (user_online_update(NULL) < 0)
224                            {
225                                    log_error("user_online_update(NULL) error\n");
226                            }
227                  }                  }
228    
229                  switch (ch)                  switch (ch)
230                  {                  {
231                  case KEY_NULL: // broken pipe                  case KEY_NULL: // broken pipe
232    #ifdef _DEBUG
233                          log_error("KEY_NULL\n");                          log_error("KEY_NULL\n");
234    #endif
235                  case KEY_ESC:                  case KEY_ESC:
236                  case KEY_LEFT:                  case KEY_LEFT:
237                          return EXIT_LIST; // exit list                          return EXIT_LIST; // exit list
238                  case KEY_TIMEOUT:                  case KEY_TIMEOUT:
239                          if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME)                          if (time(NULL) - BBS_last_access_tm >= BBS_max_user_idle_time)
240                          {                          {
241                                  log_error("User input timeout\n");                                  log_error("User input timeout\n");
242                                  return EXIT_LIST; // exit list                                  return EXIT_LIST; // exit list
# Line 483  int user_list_search(void) Line 487  int user_list_search(void)
487          int ret;          int ret;
488          int i;          int i;
489          USER_INFO user_info;          USER_INFO user_info;
490          char user_intro[BBS_user_intro_max_len];          char user_intro[BBS_user_intro_max_len + 1];
491          int ok;          int ok;
492            int ch;
493    
494          username[0] = '\0';          username[0] = '\0';
495    
# Line 492  int user_list_search(void) Line 497  int user_list_search(void)
497    
498          while (!SYS_server_exit)          while (!SYS_server_exit)
499          {          {
500                    clrline(3, SCREEN_ROWS);
501                  get_data(2, 1, "查找谁: ", username, sizeof(username), BBS_username_max_len);                  get_data(2, 1, "查找谁: ", username, sizeof(username), BBS_username_max_len);
502    
503                  if (username[0] == '\0')                  if (username[0] == '\0')
# Line 502  int user_list_search(void) Line 508  int user_list_search(void)
508                  // Verify format                  // Verify format
509                  for (i = 0, ok = 1; ok && username[i] != '\0'; i++)                  for (i = 0, ok = 1; ok && username[i] != '\0'; i++)
510                  {                  {
511                          if (!(isalpha(username[i]) || (i > 0 && isdigit(username[i]))))                          if (!(isalpha((int)username[i]) || (i > 0 && (isdigit((int)username[i]) || username[i] == '_'))))
512                          {                          {
513                                  ok = 0;                                  ok = 0;
514                          }                          }
515                  }                  }
516                  if (ok && i > 12)                  if (ok && i > BBS_username_max_len)
517                  {                  {
518                          ok = 0;                          ok = 0;
519                  }                  }
# Line 530  int user_list_search(void) Line 536  int user_list_search(void)
536                  }                  }
537                  else if (ret > 1)                  else if (ret > 1)
538                  {                  {
539                            for (i = 0; i < MIN(ret, users_per_line * max_user_lines); i++)
540                            {
541                                    moveto(4 + i / users_per_line, 3 + i % users_per_line * (BBS_username_max_len + 3));
542                                    prints("%s", username_list[i]);
543                            }
544                            moveto(SCREEN_ROWS, 1);
545                            if (ret > users_per_line * max_user_lines)
546                            {
547                                    prints("还有更多...");
548                            }
549    
550                          moveto(3, 1);                          moveto(3, 1);
551                          prints("存在多个匹配的用户,[S]精确查找,[L]列出全部? [L]");                          prints("存在多个匹配的用户,按\033[1;33mEnter\033[m精确查找");
552                          iflush();                          iflush();
                         igetch_reset();  
553    
554                          switch (igetch_t(MAX_DELAY_TIME))                          ch = igetch_t(BBS_max_user_idle_time);
555                            switch (ch)
556                          {                          {
557                          case KEY_NULL:                          case KEY_NULL:
558                          case KEY_TIMEOUT:                          case KEY_TIMEOUT:
559                                  return -1;                                  return -1;
560                          case KEY_ESC:                          case KEY_ESC:
561                                  return 0;                                  return 0;
562                          case 'S':                          case CR:
                         case 's':  
563                                  ret = (strcasecmp(username_list[0], username) == 0 ? 1 : 0);                                  ret = (strcasecmp(username_list[0], username) == 0 ? 1 : 0);
564                                  break;                                  break;
565                          case 'L':                          default:
566                          case 'l':                                  i = (int)strnlen(username, sizeof(username) - 1);
567                          case CR:                                  if (i + 1 <= BBS_username_max_len && (isalnum(ch) || ch == '_'))
                                 for (i = 0; i < MIN(ret, users_per_line * max_user_lines); i++)  
                                 {  
                                         moveto(4 + i / users_per_line, 3 + i % users_per_line * (BBS_username_max_len + 3));  
                                         prints("%s", username_list[i]);  
                                 }  
                                 moveto(SCREEN_ROWS, 1);  
                                 if (ret > users_per_line * max_user_lines)  
568                                  {                                  {
569                                          prints("还有更多...");                                          username[i] = (char)ch;
570                                            username[i + 1] = '\0';
571                                  }                                  }
572                                  continue;                                  continue;
                         default:  
                                 moveto(3, 1);  
                                 clrtoeol();  
                                 continue;  
573                          }                          }
574                  }                  }
575    
576                    clrline(3, SCREEN_ROWS);
577                  if (ret == 0)                  if (ret == 0)
578                  {                  {
579                          moveto(3, 1);                          moveto(3, 1);
                         clrtoeol();  
580                          prints("没有找到符合条件的用户");                          prints("没有找到符合条件的用户");
581                          press_any_key();                          press_any_key();
582                          return 0;                          return 0;


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

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