--- lbbs/include/user_priv.h 2025/04/30 09:19:42 1.1 +++ lbbs/include/user_priv.h 2025/05/19 02:16:24 1.3 @@ -1,16 +1,15 @@ /*************************************************************************** user_priv.h - description ------------------- - begin : Mon Oct 22 2004 - copyright : (C) 2004 by Leaflet - email : leaflet@leafok.com + Copyright : (C) 2004-2025 by Leaflet + Email : leaflet@leafok.com ***************************************************************************/ /*************************************************************************** * * * 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 2 of the License, or * + * the Free Software Foundation; either version 3 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ @@ -59,13 +58,31 @@ typedef struct user_priv BBS_user_priv; extern BBS_user_priv BBS_priv; -extern int checklevel(BBS_user_priv *p_priv, int level); +// Check whether user level matches any bit in the given param +inline int checklevel(BBS_user_priv *p_priv, int level) +{ + if (level == P_GUEST) + { + return 1; + } + + return ((p_priv->level & level) ? 1 : 0); +} + +// Check whether user level is equal or greater than the given param +inline int checklevel2(BBS_user_priv *p_priv, int level) +{ + return ((p_priv->level >= level) ? 1 : 0); +} extern int setpriv(BBS_user_priv *p_priv, int sid, int priv); extern int getpriv(BBS_user_priv *p_priv, int sid); -extern int checkpriv(BBS_user_priv *p_priv, int sid, int priv); +inline int checkpriv(BBS_user_priv *p_priv, int sid, int priv) +{ + return (((getpriv(p_priv, sid) & priv)) == priv ? 1 : 0); +} extern int load_priv(MYSQL *db, BBS_user_priv *p_priv, long int uid);