summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c41
1 files changed, 37 insertions, 4 deletions
diff --git a/util.c b/util.c
index 11c9d72..444a910 100644
--- a/util.c
+++ b/util.c
@@ -1,6 +1,10 @@
#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)
{
@@ -27,11 +31,40 @@ spin (int* target, int success, int fail)
}
}
-int
-initialize_db_con ()
+/*
+ * 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()
-{}
+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)
+{
+}