/[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.25 by sysadm, Tue Nov 11 00:28:05 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     */
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    
 #include "user_priv.h"  
13  #include "bbs.h"  #include "bbs.h"
14  #include "common.h"  #include "common.h"
15  #include "database.h"  #include "database.h"
16  #include "log.h"  #include "log.h"
17    #include "user_priv.h"
18  #include <stdio.h>  #include <stdio.h>
19  #include <stdlib.h>  #include <stdlib.h>
20  #include <mysql/mysql.h>  #include <mysql/mysql.h>
# Line 35  inline static int search_priv(BBS_user_p Line 31  inline static int search_priv(BBS_user_p
31          {          {
32                  mid = (left + right) / 2;                  mid = (left + right) / 2;
33    
34                  if (sid <= p_priv->s_priv_list[mid].sid)                  if (sid < p_priv->s_priv_list[mid].sid)
35                  {                  {
36                          right = mid;                          right = mid - 1;
37                  }                  }
38                  else                  else if (sid > p_priv->s_priv_list[mid].sid)
39                  {                  {
40                          left = mid + 1;                          left = mid + 1;
41                  }                  }
42                    else // if (sid == p_priv->s_priv_list[mid].sid)
43                    {
44                            left = mid;
45                            break;
46                    }
47          }          }
48    
49          *p_offset = left;          *p_offset = left;
50    
51          return (left == right && sid == p_priv->s_priv_list[left].sid);          return (sid == p_priv->s_priv_list[left].sid);
52  }  }
53    
54  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 62  int setpriv(BBS_user_priv *p_priv, int s
62                  return 0;                  return 0;
63          }          }
64    
65          if (search_priv(p_priv, sid, &offset)) //found          if (search_priv(p_priv, sid, &offset)) // found
66          {          {
67                  p_priv->s_priv_list[offset].s_priv = priv;                  p_priv->s_priv_list[offset].s_priv = priv;
68                  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 94  int getpriv(BBS_user_priv *p_priv, int s
94  {  {
95          int offset;          int offset;
96    
97          if (search_priv(p_priv, sid, &offset)) //found          if (search_priv(p_priv, sid, &offset)) // found
98          {          {
99                  *p_is_favor = p_priv->s_priv_list[offset].is_favor;                  *p_is_favor = p_priv->s_priv_list[offset].is_favor;
100                  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