aboutsummaryrefslogtreecommitdiff
path: root/data.h
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2024-02-12 13:34:56 +0100
committerGabriel A. Giovanini <g.giovanini@gridx.de>2024-02-14 12:29:25 +0100
commitfc26d6542276e17f3206a00b996162397d875e93 (patch)
tree755683100beb190eb8c5983d77fdbdc041f20647 /data.h
downloaddict-fc26d6542276e17f3206a00b996162397d875e93.tar.gz
dict-fc26d6542276e17f3206a00b996162397d875e93.tar.bz2
dict-fc26d6542276e17f3206a00b996162397d875e93.zip
feat: Initial commit
Add initial code form dealing with sqlite.
Diffstat (limited to 'data.h')
-rw-r--r--data.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/data.h b/data.h
new file mode 100644
index 0000000..db8aedc
--- /dev/null
+++ b/data.h
@@ -0,0 +1,47 @@
+#pragma once
+#include <sqlite3.h>
+#include "list.h"
+
+/*
+ * This word into the dictionary
+ */
+typedef struct word {
+ int Id;
+ const unsigned char *Line;
+} Word;
+
+/*
+ * This is database connection.
+ */
+typedef struct data {
+ sqlite3 *db;
+} Data;
+
+
+/*
+ * create a new data struct from sqlite filename.
+ */
+Data* new_data(const char*);
+
+
+void free_data(Data*);
+
+/*
+ * Create the tables.
+ */
+void bootstrap(Data*);
+
+/*
+ * insert line into database.
+ */
+void insert(Data*, char*);
+
+/*
+ * Select all words.
+ */
+LIST* select(Data*);
+
+/*
+ * Print result code from sqlite.
+ */
+void print_result_code(int error);