commit 399a509ccc04b9f4d7d7039481e3c8e10f312a01
parent 9c36f0b897774a4288a814be9e801acef1beb9cc
Author: olikru <olikru@tkruger.se>
Date: Mon, 29 Jan 2024 17:01:42 +0100
added a little dbcreate tool for upcoming RSA stuff
Diffstat:
2 files changed, 48 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
@@ -22,7 +22,8 @@ hnp.o\
cyclefind.o
TOOLS=\
hnpsolve\
-lcgfloyd
+lcgfloyd\
+dbcreate
PRECOMPUTERS=\
primorial16bit
SHARED=angrepp.so
@@ -57,6 +58,9 @@ hnpsolve: build $(OBJS)
lcgfloyd: build $(OBJS)
$(CC) -I. $(CFLAGS) -o $(BUILD)/tools/lcgfloyd $(TOOLS_DIR)/lcgfloyd.c $(BUILD_OBJS) $(LDFLAGS)
+dbcreate: build $(OBJS)
+ $(CC) -I. $(CFLAGS) -o $(BUILD)/tools/dbcreate $(TOOLS_DIR)/dbcreate.c $(BUILD_OBJS) $(LDFLAGS) -lsqlite3
+
# -- precomputers
primorial16bit: build $(OBJS)
diff --git a/tools/dbcreate.c b/tools/dbcreate.c
@@ -0,0 +1,43 @@
+/**
+ * Create an SQLite database, which uses serialized mode
+ * to prevent horrible file corruption issues.
+ */
+
+#include <err.h>
+#include <sqlite3.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static void
+usage(char *c)
+{
+ printf("Usage: %s <db>\n"
+ " where\n"
+ "<db> path to database to create\n", );
+ exit(1);
+}
+
+int
+main(int argc, char *argv[])
+{
+ sqlite3 *db;
+ int rc;
+
+ if (argc != 2) {
+ usage(argv[0]);
+ }
+
+ rc = sqlite3_open(argv[1], &db);
+
+ if (rc) {
+ errx(EXIT_FAILURE, "database opening error: %s\n",
+ sqlite3_errmsg(db));
+ } else {
+ fprintf(stderr, "Opened database successfully\n");
+ }
+
+ while (sqlite3_close(db) != SQLITE_OK) {
+ }
+
+ return 0;
+}