/[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.7 - (hide annotations)
Wed Jul 2 04:17:33 2025 UTC (8 months, 2 weeks ago) by sysadm
Branch: MAIN
Changes since 1.6: +6 -6 lines
Content type: text/x-chdr
Support UTF8 instead of GBK

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

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