summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/_infotojson/Makefile3
-rw-r--r--tools/_infotojson/infotojson.c1
-rw-r--r--tools/_infotojson/sqlite3_database.c25
-rw-r--r--tools/_infotojson/utils.c8
-rw-r--r--tools/_infotojson/utils.h2
5 files changed, 8 insertions, 31 deletions
diff --git a/tools/_infotojson/Makefile b/tools/_infotojson/Makefile
index a52fcab6..8812e9b9 100644
--- a/tools/_infotojson/Makefile
+++ b/tools/_infotojson/Makefile
@@ -1 +1,2 @@
-tools/_infotojson/infotojson: tools/_infotojson/infotojson.o tools/_infotojson/sqlite3_database.o tools/_infotojson/utils.o
+tools/_infotojson/infotojson: tools/_infotojson/infotojson.o tools/_infotojson/sqlite3_database.o tools/_infotojson/utils.o ccan/string/string.o ccan/talloc/talloc.o
+ $(CC) $(LDFLAGS) -o $@ $^ -lsqlite3
diff --git a/tools/_infotojson/infotojson.c b/tools/_infotojson/infotojson.c
index 611e0b39..e169fe17 100644
--- a/tools/_infotojson/infotojson.c
+++ b/tools/_infotojson/infotojson.c
@@ -112,7 +112,6 @@ int storejsontodb(struct json *jsonobj, char *db)
{
char *cmd, *query;
sqlite3 *handle;
- char *errstr;
struct db_query *q;
handle = db_open(db);
diff --git a/tools/_infotojson/sqlite3_database.c b/tools/_infotojson/sqlite3_database.c
index ed62aee0..6021eab6 100644
--- a/tools/_infotojson/sqlite3_database.c
+++ b/tools/_infotojson/sqlite3_database.c
@@ -70,31 +70,6 @@ void db_command(void *h, const char *command)
printf("Failed sqlite3 command '%s': %s", command, err);
}
-/* Starts transaction. Doesn't need to nest. */
-/*void db_transaction_start(void *h)
-{
- char *err;
- if (sqlite3_exec(h, "BEGIN EXCLUSIVE TRANSACTION", NULL, NULL, &err)!=SQLITE_OK)
- printf("Starting sqlite3 transaction: %s\n", err);
-}
-
-/* Finishes transaction, or rolls it back and caller needs to start again. */
-/*
-bool db_transaction_finish(void *h)
-{
- switch (sqlite3_exec(h, "COMMIT TRANSACTION;", NULL, NULL, NULL)) {
- case SQLITE_OK:
- return true;
- case SQLITE_BUSY:
- if (sqlite3_exec(h, "ROLLBACK TRANSACTION;", NULL, NULL, NULL)
- != SQLITE_OK)
- printf("Ending sqlite3 busy rollback failed");
- return false;
- default:
- printf("Strange sqlite3 error return from COMMIT");
- }
-}*/
-
/* Closes database (only called when everything OK). */
void db_close(void *h)
{
diff --git a/tools/_infotojson/utils.c b/tools/_infotojson/utils.c
index 9f99972d..4f2fc43a 100644
--- a/tools/_infotojson/utils.c
+++ b/tools/_infotojson/utils.c
@@ -1,11 +1,13 @@
-#include "utils.h"
+#define _GNU_SOURCE
#include <stdio.h>
+#include "utils.h"
#include <string.h>
#include <limits.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
+#include <err.h>
#include <assert.h>
#include "utils.h"
@@ -31,7 +33,7 @@ char *aprintf(const char *fmt, ...)
return ret;
}
-int strreplace(char * str, char src, char dest)
+void strreplace(char * str, char src, char dest)
{
int i;
for(i = 0; str[i]; i++)
@@ -51,5 +53,5 @@ void *realloc_nofail(void *ptr, size_t size)
ptr = realloc(ptr, size);
if (ptr)
return ptr;
- printf("realloc of %zu failed", size);
+ err(1, "realloc of %zu failed", size);
}
diff --git a/tools/_infotojson/utils.h b/tools/_infotojson/utils.h
index 4a94e573..24f3375e 100644
--- a/tools/_infotojson/utils.h
+++ b/tools/_infotojson/utils.h
@@ -14,4 +14,4 @@ void * palloc(int size);
char *aprintf(const char *fmt, ...);
-int strreplace(char * str, char src, char dest);
+void strreplace(char * str, char src, char dest);