/[LeafOK_CVS]/lbbs/include/user_priv.h
ViewVC logotype

Annotation of /lbbs/include/user_priv.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.12 - (hide annotations)
Sat Jan 3 10:27:14 2026 UTC (2 months, 1 week ago) by sysadm
Branch: MAIN
CVS Tags: HEAD
Changes since 1.11: +1 -1 lines
Content type: text/x-chdr
Update copyright info

1 sysadm 1.8 /* SPDX-License-Identifier: GPL-3.0-or-later */
2     /*
3     * user_priv
4     * - basic operations of user privilege
5     *
6 sysadm 1.12 * Copyright (C) 2004-2026 Leaflet <leaflet@leafok.com>
7 sysadm 1.8 */
8 sysadm 1.1
9     #ifndef _USER_PRIV_H_
10     #define _USER_PRIV_H_
11    
12     #include "bbs.h"
13 sysadm 1.11 #include <mysql.h>
14 sysadm 1.1
15     // User privilege
16 sysadm 1.10 enum user_priv_t
17     {
18     S_NONE = 0x0,
19     S_LIST = 0x1,
20     S_GETEXP = 0x2,
21     S_POST = 0x4,
22     S_MSG = 0x8,
23     S_MAN_S = 0x20,
24     S_MAN_M = 0x60, //(0x40 | 0x20)
25     S_ADMIN = 0xe0, //(0x80 | 0x40 | 0x20)
26     S_ALL = 0xff,
27     S_DEFAULT = 0x3, // 0x1 | 0x2
28     };
29    
30     enum user_level_t
31     {
32     P_GUEST = 0x0, // 游客
33     P_USER = 0x1, // 普通用户
34     P_AUTH_USER = 0x2, // Reserved
35     P_MAN_S = 0x4, // 副版主
36     P_MAN_M = 0x8, // 正版主
37     P_MAN_C = 0x10, // Reserved
38     P_ADMIN_S = 0x20, // 副系统管理员
39     P_ADMIN_M = 0x40, // 主系统管理员
40     };
41 sysadm 1.1
42     struct user_priv
43     {
44 sysadm 1.6 int uid;
45 sysadm 1.1 int level;
46     int g_priv;
47     struct
48     {
49     int sid;
50     int s_priv;
51 sysadm 1.4 int is_favor;
52 sysadm 1.1 } s_priv_list[BBS_max_section];
53     int s_count;
54     };
55    
56     typedef struct user_priv BBS_user_priv;
57    
58     extern BBS_user_priv BBS_priv;
59    
60 sysadm 1.3 // Check whether user level matches any bit in the given param
61     inline int checklevel(BBS_user_priv *p_priv, int level)
62     {
63     if (level == P_GUEST)
64     {
65     return 1;
66     }
67    
68     return ((p_priv->level & level) ? 1 : 0);
69     }
70    
71     // Check whether user level is equal or greater than the given param
72     inline int checklevel2(BBS_user_priv *p_priv, int level)
73     {
74     return ((p_priv->level >= level) ? 1 : 0);
75     }
76 sysadm 1.1
77 sysadm 1.4 extern int setpriv(BBS_user_priv *p_priv, int sid, int priv, int is_favor);
78 sysadm 1.1
79 sysadm 1.4 extern int getpriv(BBS_user_priv *p_priv, int sid, int *p_is_favor);
80 sysadm 1.1
81 sysadm 1.3 inline int checkpriv(BBS_user_priv *p_priv, int sid, int priv)
82     {
83 sysadm 1.4 int is_favor = 0;
84     return (((getpriv(p_priv, sid, &is_favor) & priv)) == priv ? 1 : 0);
85     }
86    
87     inline int is_favor(BBS_user_priv *p_priv, int sid)
88     {
89     int is_favor = 0;
90     getpriv(p_priv, sid, &is_favor);
91     return is_favor;
92 sysadm 1.3 }
93 sysadm 1.1
94 sysadm 1.6 extern int load_priv(MYSQL *db, BBS_user_priv *p_priv, int uid);
95 sysadm 1.1
96     #endif //_USER_PRIV_H_

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