aboutsummaryrefslogtreecommitdiff
path: root/lib/data.h
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2024-02-17 11:41:23 +0100
committergabrielgio <gabrielgio@workstation.lan>2024-02-17 16:48:54 +0100
commitd102e028aee6571c0fd9dfd4074cfb3c15f4594e (patch)
treee0f3bdadc96019de0a7576ea591f8b304a962e67 /lib/data.h
parentc573d3b7954296d95a0f8a79b8ac2ca261d86a02 (diff)
downloaddict-d102e028aee6571c0fd9dfd4074cfb3c15f4594e.tar.gz
dict-d102e028aee6571c0fd9dfd4074cfb3c15f4594e.tar.bz2
dict-d102e028aee6571c0fd9dfd4074cfb3c15f4594e.zip
ref: Refactor newer folder structure
Create a lib dict and importer project. * dict: holds the main application * importer: code to read from source to a common database. * lib: shared code
Diffstat (limited to 'lib/data.h')
-rw-r--r--lib/data.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/lib/data.h b/lib/data.h
new file mode 100644
index 0000000..56edd34
--- /dev/null
+++ b/lib/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*, int);
+
+/*
+ * Select all words.
+ */
+LIST* data_select(Data*, char*, int);
+
+/*
+ * Print result code from sqlite.
+ */
+void print_result_code(int error);