-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathplayer_channel_privilege.c
47 lines (37 loc) · 1.36 KB
/
player_channel_privilege.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "player_channel_privilege.h"
#include "server.h"
#include "database.h"
#include "log.h"
#include <stdlib.h>
void destroy_player_channel_privilege(struct player_channel_privilege *priv)
{
free(priv);
}
struct player_channel_privilege *new_player_channel_privilege()
{
struct player_channel_privilege *p;
p = (struct player_channel_privilege *)calloc(1, sizeof(struct player_channel_privilege));
if (p == NULL)
logger(LOG_ERR, "new_player_channel_privilege: calloc failed!");
return p;
}
void player_clr_channel_privilege(struct player *pl, struct channel *ch, uint16_t bit)
{
struct player_channel_privilege *tmp_priv;
tmp_priv = get_player_channel_privilege(pl, ch);
tmp_priv->flags &= ~bit;
logger(LOG_INFO, "player_clr_channel_privilege: tmp_priv->reg = %i", tmp_priv->reg);
/* update in the database if required */
if (tmp_priv->reg == PL_CH_PRIV_REGISTERED)
db_update_pl_chan_priv(ch->in_server->conf, tmp_priv);
}
void player_set_channel_privilege(struct player *pl, struct channel *ch, uint16_t bit)
{
struct player_channel_privilege *tmp_priv;
tmp_priv = get_player_channel_privilege(pl, ch);
tmp_priv->flags |= bit;
logger(LOG_INFO, "player_set_channel_privilege: tmp_priv->reg = %i", tmp_priv->reg);
/* update in the database if required */
if (tmp_priv->reg == PL_CH_PRIV_REGISTERED)
db_update_pl_chan_priv(ch->in_server->conf, tmp_priv);
}