#include "util.h" #include 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) { }