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

Diff of /lbbs/src/user_priv.c

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

Revision 1.20 by sysadm, Sat Jun 7 06:16:25 2025 UTC Revision 1.24 by sysadm, Tue Nov 4 14:58:56 2025 UTC
# Line 1  Line 1 
1  /***************************************************************************  /* SPDX-License-Identifier: GPL-3.0-or-later */
2                                                    user_priv.c  -  description  /*
3                                                           -------------------   * user_priv
4          Copyright            : (C) 2004-2025 by Leaflet   *   - basic operations of user privilege
5          Email                : leaflet@leafok.com   *
6   ***************************************************************************/   * Copyright (C) 2004-2025  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    
 #include "user_priv.h"  
9  #include "bbs.h"  #include "bbs.h"
10  #include "common.h"  #include "common.h"
11  #include "database.h"  #include "database.h"
12  #include "log.h"  #include "log.h"
13    #include "user_priv.h"
14  #include <stdio.h>  #include <stdio.h>
15  #include <stdlib.h>  #include <stdlib.h>
16  #include <mysql/mysql.h>  #include <mysql/mysql.h>
# Line 35  inline static int search_priv(BBS_user_p Line 27  inline static int search_priv(BBS_user_p
27          {          {
28                  mid = (left + right) / 2;                  mid = (left + right) / 2;
29    
30                  if (sid <= p_priv->s_priv_list[mid].sid)                  if (sid < p_priv->s_priv_list[mid].sid)
31                  {                  {
32                          right = mid;                          right = mid - 1;
33                  }                  }
34                  else                  else if (sid > p_priv->s_priv_list[mid].sid)
35                  {                  {
36                          left = mid + 1;                          left = mid + 1;
37                  }                  }
38                    else // if (sid == p_priv->s_priv_list[mid].sid)
39                    {
40                            left = mid;
41                            break;
42                    }
43          }          }
44    
45          *p_offset = left;          *p_offset = left;
46    
47          return (left == right && sid == p_priv->s_priv_list[left].sid);          return (sid == p_priv->s_priv_list[left].sid);
48  }  }
49    
50  int setpriv(BBS_user_priv *p_priv, int sid, int priv, int is_favor)  int setpriv(BBS_user_priv *p_priv, int sid, int priv, int is_favor)
# Line 61  int setpriv(BBS_user_priv *p_priv, int s Line 58  int setpriv(BBS_user_priv *p_priv, int s
58                  return 0;                  return 0;
59          }          }
60    
61          if (search_priv(p_priv, sid, &offset)) //found          if (search_priv(p_priv, sid, &offset)) // found
62          {          {
63                  p_priv->s_priv_list[offset].s_priv = priv;                  p_priv->s_priv_list[offset].s_priv = priv;
64                  p_priv->s_priv_list[offset].is_favor = is_favor;                  p_priv->s_priv_list[offset].is_favor = is_favor;
# Line 93  int getpriv(BBS_user_priv *p_priv, int s Line 90  int getpriv(BBS_user_priv *p_priv, int s
90  {  {
91          int offset;          int offset;
92    
93          if (search_priv(p_priv, sid, &offset)) //found          if (search_priv(p_priv, sid, &offset)) // found
94          {          {
95                  *p_is_favor = p_priv->s_priv_list[offset].is_favor;                  *p_is_favor = p_priv->s_priv_list[offset].is_favor;
96                  return p_priv->s_priv_list[offset].s_priv;                  return p_priv->s_priv_list[offset].s_priv;


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

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