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
|
#include "util.h"
#include <stdint.h>
sqlite3* initialize_db_con (char* target);
char* format_sql_query (char* data);
int read_db_callback (void*, int, char**, char**);
int
die(const char* msg)
{
fprintf(stderr, "%s\n", msg);
exit(-1);
}
int
set_data(unsigned char* data)
{
if (memset(data, 0x00, 17))
{
return -1;
}
return 0;
}
int
spin (int* target, int success, int fail)
{
while (!(*target))
{
; // spin
}
}
/*
* Database structure:
* The plan is to have one master database, which contains a list of all the different
* streamdecks that are available. Each streamdeck has a unique serial number, so that
* is going to be a field, another field being the name of the database for that streamdeck.
* Then in another folder, there will be a bunch of databases, and we will just open and read
* the appropriate one.
*/
sqlite3*
initialize_db_con (char* target)
{
sqlite3* res;
return (sqlite3_open(target, &res)) ? NULL : res;
}
int
parsestreamdeckdata(char* serial_num)
{
int sql_exec_res = 0;
char* errmsg;
char* query_res;
sqlite3* master = initialize_db_con("master.db");
if (!master)
return 1;
char* query_for_serial = format_sql_query(serial_num);
sql_exec_res = sqlite3_exec(master, query_for_serial, read_db_callback, &query_res, &errmsg);
if (sql_exec_res)
fprintf (stderr, "%s\n", errmsg);
free (query_for_serial);
return 0;
}
int
read_db_callback (void* data, int argc, char** argv, char** azcolname)
{
}
|