/[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.14 by sysadm, Sun Nov 2 14:38:53 2025 UTC Revision 1.20 by sysadm, Tue Nov 4 13:49:51 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 by Leaflet <leaflet@leafok.com>
7     */
 /***************************************************************************  
  *                                                                         *  
  *   This program is free software; you can redistribute it and/or modify  *  
  *   it under the terms of the GNU General Public License as published by  *  
  *   the Free Software Foundation; either version 3 of the License, or     *  
  *   (at your option) any later version.                                   *  
  *                                                                         *  
  ***************************************************************************/  
8    
9  #include "common.h"  #include "common.h"
10  #include "io.h"  #include "io.h"
# Line 483  int user_list_search(void) Line 475  int user_list_search(void)
475          int ret;          int ret;
476          int i;          int i;
477          USER_INFO user_info;          USER_INFO user_info;
478          char user_intro[BBS_user_intro_max_len];          char user_intro[BBS_user_intro_max_len + 1];
479          int ok;          int ok;
480            int ch;
481    
482          username[0] = '\0';          username[0] = '\0';
483    
# Line 492  int user_list_search(void) Line 485  int user_list_search(void)
485    
486          while (!SYS_server_exit)          while (!SYS_server_exit)
487          {          {
488                    clrline(3, SCREEN_ROWS);
489                  get_data(2, 1, "查找谁: ", username, sizeof(username), BBS_username_max_len);                  get_data(2, 1, "查找谁: ", username, sizeof(username), BBS_username_max_len);
490    
491                  if (username[0] == '\0')                  if (username[0] == '\0')
# Line 502  int user_list_search(void) Line 496  int user_list_search(void)
496                  // Verify format                  // Verify format
497                  for (i = 0, ok = 1; ok && username[i] != '\0'; i++)                  for (i = 0, ok = 1; ok && username[i] != '\0'; i++)
498                  {                  {
499                          if (!(isalpha(username[i]) || (i > 0 && isdigit(username[i]))))                          if (!(isalpha(username[i]) || (i > 0 && (isdigit(username[i]) || username[i] == '_'))))
500                          {                          {
501                                  ok = 0;                                  ok = 0;
502                          }                          }
503                  }                  }
504                  if (ok && i > 12)                  if (ok && i > BBS_username_max_len)
505                  {                  {
506                          ok = 0;                          ok = 0;
507                  }                  }
# Line 530  int user_list_search(void) Line 524  int user_list_search(void)
524                  }                  }
525                  else if (ret > 1)                  else if (ret > 1)
526                  {                  {
527                            for (i = 0; i < MIN(ret, users_per_line * max_user_lines); i++)
528                            {
529                                    moveto(4 + i / users_per_line, 3 + i % users_per_line * (BBS_username_max_len + 3));
530                                    prints("%s", username_list[i]);
531                            }
532                            moveto(SCREEN_ROWS, 1);
533                            if (ret > users_per_line * max_user_lines)
534                            {
535                                    prints("还有更多...");
536                            }
537    
538                          moveto(3, 1);                          moveto(3, 1);
539                          prints("存在多个匹配的用户,[S]精确查找,[L]列出全部? [L]");                          prints("存在多个匹配的用户,按\033[1;33mEnter\033[m精确查找");
540                          iflush();                          iflush();
541    
542                          switch (igetch_t(MAX_DELAY_TIME))                          ch = igetch_t(MAX_DELAY_TIME);
543                            switch (ch)
544                          {                          {
545                          case KEY_NULL:                          case KEY_NULL:
546                          case KEY_TIMEOUT:                          case KEY_TIMEOUT:
547                                    return -1;
548                            case KEY_ESC:
549                                  return 0;                                  return 0;
550                          case 'S':                          case CR:
                         case 's':  
551                                  ret = (strcasecmp(username_list[0], username) == 0 ? 1 : 0);                                  ret = (strcasecmp(username_list[0], username) == 0 ? 1 : 0);
552                                  break;                                  break;
553                          default:                          default:
554                                  for (i = 0; i < MIN(ret, users_per_line * max_user_lines); i++)                                  i = (int)strnlen(username, sizeof(username) - 1);
555                                    if (i + 1 <= BBS_username_max_len && (isalnum((char)ch) || ch == '_'))
556                                  {                                  {
557                                          moveto(4 + i / users_per_line, 3 + i % users_per_line * (BBS_username_max_len + 3));                                          username[i] = (char)ch;
558                                          prints("%s", username_list[i]);                                          username[i + 1] = '\0';
                                 }  
                                 moveto(SCREEN_ROWS, 1);  
                                 if (ret > users_per_line * max_user_lines)  
                                 {  
                                         prints("还有更多...");  
559                                  }                                  }
560                                  continue;                                  continue;
561                          }                          }
562                  }                  }
563    
564                    clrline(3, SCREEN_ROWS);
565                  if (ret == 0)                  if (ret == 0)
566                  {                  {
567                          moveto(3, 1);                          moveto(3, 1);
                         clrtoeol();  
568                          prints("没有找到符合条件的用户");                          prints("没有找到符合条件的用户");
569                          continue;                          press_any_key();
570                            return 0;
571                  }                  }
572                  else // ret == 1                  else // ret == 1
573                  {                  {


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

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