| 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 |
|
|
| 13 |
#include "bbs.h" |
#include "bbs.h" |
| 14 |
#include "common.h" |
#include "common.h" |
| 17 |
#include "user_priv.h" |
#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.h> |
| 21 |
|
|
| 22 |
BBS_user_priv BBS_priv; |
BBS_user_priv BBS_priv; |
| 23 |
|
|
| 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) |
| 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; |
| 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; |