diff options
Diffstat (limited to 'ts3db.c')
-rw-r--r-- | ts3db.c | 135 |
1 files changed, 135 insertions, 0 deletions
@@ -0,0 +1,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; +} |