summaryrefslogtreecommitdiffstats
path: root/ts3db.c
blob: 9f45ac456f5e2feabd75374f4e84b52945ef87c3 (plain) (blame)
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#include "ts3db.h"

static log_callback log = 0;

char *ts3dbplugin_version()
{
    // returns pointer to "127.0.0.1" in constant table ... strange maybe im mistaken here
    return "0.1";
}

char *ts3dbplugin_name()
{
    // returns pointer to "MySQL plugin, (c)TeamSpeak Systems GmbH" in constant table
    return "My own DB Plugin";
}

int ts3dbplugin_disconnect()
{
    // load zero terminated array of db connections from global variable
    // iterate over array elements, call mysql_close on all elements and zero them
    return 0;
}

void ts3dbplugin_shutdown()
{
    // same as ts3dbplugin_disconnect() but no return 0
}

int ts3dbplugin_init(log_callback logging, char *parameter)
{
    char buf[100];

    log = logging;
    log("init called", 5);
    int bar = log(0, 4);
    sprintf(buf,"%d",bar);
    log(buf, 5);
    log(parameter, 5);

    // logcallback is saved to global variable
    // put pointer do some global structure with offset 12 is saved in variable
    // if 2nd parameter or its target is zero "tb3db_mysql.ini" is written to a variable
    // else the pointer is saved its length is determined and saved also saved (saved in variables)
    // ini file is parsed and values are saved to global variables
    return 0;
}

int ts3dbplugin_connect(unsigned int *connection_nr)
{
    log("connect called", 5);
    *connection_nr = 1337;

    // only does somthing usefull when there are less than 100 connections in the connection array
    // calls mysql_init
    // big function is big ... needs work
    // seems to returns 0 on succses seems to return 1280 on failure
    return 0;
}

char *ts3dbplugin_getlasterror(unsigned int connection_nr)
{
    log("getlasterror called", 5);
    char buf[100];
    sprintf(buf,"%d", connection_nr);
    log(buf, 5);

    // returns output of mysql_error for the connection of the given connection number
    return "nothing";
}

unsigned int ts3dbplugin_tableexists(unsigned int connection_nr, const char* regex)
{
    log("tableexists called", 5);
    char buf[100];
    sprintf(buf,"%d", connection_nr);
    log(buf, 5);
    log(regex, 5);

    // returns 0 when no table is found 1 if it is found
    return 1;
}

unsigned long long ts3dbplugin_getmodifiedrowcount(unsigned int connection_nr)
{
    log("get modified row count", 5);
    char buf[100];
    sprintf(buf,"%d", connection_nr);
    log(buf, 5);

    // returns output of mysql_affected_rows for given connection
    return 0LL;
}

unsigned long long ts3dbplugin_getlastinsertid(unsigned int connection_nr)
{
    log("get last inserted id", 5);
    char buf[100];
    sprintf(buf,"%d", connection_nr);
    log(buf, 5);

    // returns output of mysql_insert_id for given connection
    return 0LL;
}

unsigned int ts3dbplugin_open(unsigned int connection_nr, const char* query,
                              field_callback new_field, value_callback new_value,
                              row_callback new_row, void *context)
{
    log("open", 5);
    char buf[100];
    sprintf(buf,"%d", connection_nr);
    log(buf, 5);
    log(query, 5);

    // get query result
    // if row ends value is 0
    // returns 0 for success or 1280 for fail
    return 0;
}

unsigned int ts3dbplugin_exec(unsigned int connection_nr, const char* query)
{
    log("exec", 5);
    char buf[100];
    sprintf(buf,"%d", connection_nr);
    log(buf, 5);
    log(query, 5);

    // form sqlite plugin
    // executes querry -> retrys every 200ms if db is locked, busy or when the db shema has changed
    // return 1284 if db is full
    // when result is SQLITE_OK return 0
    // else do error handling and return 1280
    return 0;
}