aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/sqlite
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2023-07-09 15:53:11 +0200
committerEgor Tensin <Egor.Tensin@gmail.com>2023-07-09 17:37:44 +0200
commit0600cacfadf00e916340f2394f1d3bfc173a3d0b (patch)
tree4b1900b096de3d2b3ad49094e86adc310ec79dac /src/sqlite
parenttest: attempt to fix random port selection again (diff)
downloadcimple-0600cacfadf00e916340f2394f1d3bfc173a3d0b.tar.gz
cimple-0600cacfadf00e916340f2394f1d3bfc173a3d0b.zip
store process output in SQLite
Diffstat (limited to '')
-rw-r--r--src/sqlite.c14
-rw-r--r--src/sqlite.h3
2 files changed, 17 insertions, 0 deletions
diff --git a/src/sqlite.c b/src/sqlite.c
index 7080928..f064280 100644
--- a/src/sqlite.c
+++ b/src/sqlite.c
@@ -11,6 +11,7 @@
#include <sqlite3.h>
+#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -231,6 +232,19 @@ int sqlite_bind_text(sqlite3_stmt *stmt, int index, const char *value)
return ret;
}
+int sqlite_bind_blob(sqlite3_stmt *stmt, int index, unsigned char *value, size_t nb)
+{
+ int ret = 0;
+
+ ret = sqlite3_bind_blob64(stmt, index, value, nb, SQLITE_STATIC);
+ if (ret) {
+ sqlite_errno(ret, "sqlite3_bind_blob64");
+ return ret;
+ }
+
+ return ret;
+}
+
int sqlite_exec_as_transaction(sqlite3 *db, const char *stmt)
{
static const char *const fmt = "BEGIN; %s COMMIT;";
diff --git a/src/sqlite.h b/src/sqlite.h
index 20386d4..556684f 100644
--- a/src/sqlite.h
+++ b/src/sqlite.h
@@ -10,6 +10,8 @@
#include <sqlite3.h>
+#include <stddef.h>
+
int sqlite_init(void);
void sqlite_destroy(void);
@@ -27,6 +29,7 @@ int sqlite_step(sqlite3_stmt *);
int sqlite_bind_int(sqlite3_stmt *, int column_index, int value);
int sqlite_bind_text(sqlite3_stmt *, int column_index, const char *value);
+int sqlite_bind_blob(sqlite3_stmt *, int column_index, unsigned char *value, size_t nb);
int sqlite_column_int(sqlite3_stmt *, int column_index);
int sqlite_column_text(sqlite3_stmt *, int column_index, char **result);