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

Diff of /lbbs/src/user_list.c

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

Revision 1.3 by sysadm, Tue Oct 21 12:10:20 2025 UTC Revision 1.4 by sysadm, Tue Oct 21 12:35:03 2025 UTC
# Line 520  cleanup: Line 520  cleanup:
520    
521      return ret;      return ret;
522  }  }
523    
524    int query_user_info(int32_t uid, USER_INFO *p_user)
525    {
526        int left;
527        int right;
528        int mid;
529        int ret = 0;
530    
531        if (p_user == NULL)
532        {
533            log_error("NULL pointer error\n");
534            return -1;
535        }
536    
537        // acquire lock of user list
538        if (user_list_rd_lock() < 0)
539        {
540            log_error("user_list_rd_lock() error\n");
541            return -2;
542        }
543    
544        left = 0;
545        right = p_user_list_pool->p_current->user_count - 1;
546    
547        while (left < right)
548        {
549            mid = (left + right) / 2;
550            if (uid < p_user_list_pool->p_current->users[mid].uid)
551            {
552                right = mid;
553            }
554            else if (uid > p_user_list_pool->p_current->users[mid].uid)
555            {
556                left = mid + 1;
557            }
558            else // if (uid == p_user_list_pool->p_current->users[mid].uid)
559            {
560                left = mid;
561                break;
562            }
563        }
564    
565        if (uid == p_user_list_pool->p_current->users[left].uid) // Found
566        {
567            *p_user = p_user_list_pool->p_current->users[left];
568            ret = 1;
569        }
570    
571        // release lock of user list
572        if (user_list_rd_unlock() < 0)
573        {
574            log_error("user_list_rd_unlock() error\n");
575            ret = -1;
576        }
577    
578        return ret;
579    }


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

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