summaryrefslogtreecommitdiff
path: root/src/rdb.c
blob: e235be10fad84e613a77c285928a1f62cd0f64dd (plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/* RDB functions.
 *
 * (C) 2003 Anope Team
 * Contact us at info@anope.org
 *
 * Please read COPYING and README for furhter details.
 *
 * Based on the original code of Epona by Lara.
 * Based on the original code of Services by Andy Church. 
 * 
 * $Id$ 
 *
 */
#include "services.h"

#ifdef USE_MYSQL
#define RDB_MYSQL(x) x
#else
#define RDB_MYSQL(x)
#endif

void rdb_init(void)
{
    RDB_MYSQL(db_mysql_init());
}

void rdb_end(void)
{
    RDB_MYSQL(db_mysql_end());
}

/* BotServ */
void rdb_bs_add_bot(BotInfo *bi)
{
    RDB_MYSQL(db_mysql_bs_add_bot(bi));
}

void rdb_bs_del_bot(BotInfo *bi)
{
    RDB_MYSQL(db_mysql_bs_del_bot(bi));
}

void rdb_bs_change_bot(BotInfo *bi, char *newnick, char *newuser, char *newhost, char *newreal)
{
    RDB_MYSQL(db_mysql_bs_chg_bot(bi, newnick, newuser, newhost, newreal));
}

void rdb_bs_change_bot_chancount(BotInfo *bi)
{
    RDB_MYSQL(db_mysql_bs_chg_bot_chancount(bi));
}

void rdb_bs_change_bot_flags(BotInfo *bi)
{
    RDB_MYSQL(db_mysql_bs_chg_bot_flags(bi));
}

void rdb_cs_add_access(ChannelInfo *ci, ChanAccess *access)
{
    RDB_MYSQL(db_mysql_cs_add_access(ci, access));
}

void rdb_cs_del_access(ChanAccess *access)
{
    ChannelInfo *ci, *found;
    ChanAccess *caccess;
    int i, y;
    /* Need to fetch channel manually since ChanAccess has no member for it */
    for (i = 0; i < 256; i++) {
        for (ci = chanlists[i]; ci; ci = ci->next) {
            for (caccess = ci->access, y = 0; y < ci->accesscount; caccess++, y++) {
                if (caccess == access) { found = ci; }
            }
        }
    }
    if (!found) return;
    RDB_MYSQL(db_mysql_cs_del_access(found, access));
}