summaryrefslogtreecommitdiffstats
path: root/src/squark-filter.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2010-11-07 01:37:06 +0200
committerTimo Teräs <timo.teras@iki.fi>2010-11-07 01:37:06 +0200
commitcb2db2f1c759c60849b66dabf8ee03c9cdfb2dd5 (patch)
tree870455fc986e81816bd3631f4674b6dd49c30506 /src/squark-filter.c
parent660b77270e599fed9a8a6bc94a0e2d44b8f282dd (diff)
downloadsquark-cb2db2f1c759c60849b66dabf8ee03c9cdfb2dd5.tar.bz2
squark-cb2db2f1c759c60849b66dabf8ee03c9cdfb2dd5.tar.xz
all: check error for sqdb_open and adb_open
so we don't crash on startup if essential files are missing. fixes #454
Diffstat (limited to 'src/squark-filter.c')
-rw-r--r--src/squark-filter.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/squark-filter.c b/src/squark-filter.c
index 14515cf..567201a 100644
--- a/src/squark-filter.c
+++ b/src/squark-filter.c
@@ -18,6 +18,7 @@
#include <cmph.h>
+#include "config.h"
#include "blob.h"
#include "addr.h"
#include "filterdb.h"
@@ -422,12 +423,25 @@ static void read_input(struct sqdb *db)
int main(int argc, char **argv)
{
- sqdb_open(&db, "/var/lib/squark/squark.db");
- authdb_open(&adb, &adbc, &db);
+ int rc = 1;
+
+ if (sqdb_open(&db, squark_dbname) < 0) {
+ fprintf(stderr, "%s: failed to open squarkdb\n",
+ squark_dbname);
+ goto err_sqdb;
+ }
+ if (authdb_open(&adb, &adbc, &db) < 0) {
+ fprintf(stderr, "Failed to initialize authdb\n");
+ goto err_adb;
+ }
while (running)
read_input(&db);
+ rc = 0;
- sqdb_close(&db);
authdb_close(&adb);
+err_adb:
+ sqdb_close(&db);
+err_sqdb:
+ return rc;
}