summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--Makefile17
-rw-r--r--scooper.14
-rw-r--r--server.c6
4 files changed, 26 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
index ac9b3a5..cc46bc9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
 *.o
+.test
 config.mk
 scooper
+tags
diff --git a/Makefile b/Makefile
index 47f6aa4..1f56ebf 100644
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,8 @@ MANDIR ?= ${PREFIX}/share/man
 CFLAGS += -std=c11 -Wall -Wextra -Wpedantic
 LDLIBS = -lkcgi -lkcgihtml -lsqlite3
 
+TEST_DB = ~/.local/share/litterbox/litterbox.sqlite
+
 -include config.mk
 
 OBJS += contexts.o
@@ -13,13 +15,26 @@ OBJS += networks.o
 OBJS += search.o
 OBJS += server.o
 
+dev: tags all test
+
+all: scooper
+
 scooper: ${OBJS}
 	${CC} ${LDFLAGS} ${OBJS} ${LDLIBS} -o $@
 
 ${OBJS}: server.h
 
+test: .test
+
+.test: scooper
+	./scooper -c ${TEST_DB}
+	touch .test
+
+tags: *.c *.h
+	ctags -w *.c *.h
+
 clean:
-	rm -f scooper ${OBJS}
+	rm -f scooper ${OBJS} .test tags
 
 install: scooper scooper.1
 	install -d ${PREFIX}/bin ${MANDIR}/man1
diff --git a/scooper.1 b/scooper.1
index 1e72631..9350ad1 100644
--- a/scooper.1
+++ b/scooper.1
@@ -8,7 +8,7 @@
 .
 .Sh SYNOPSIS
 .Nm
-.Op Fl fp
+.Op Fl cfp
 .Op Fl s Ar url
 .Ar database
 .
@@ -22,6 +22,8 @@ IRC log database.
 .Pp
 The arguments are as follows:
 .Bl -tag -width Ds
+.It Fl c
+Exit after preparing statements.
 .It Fl f
 Become a FastCGI worker,
 which can be managed by
diff --git a/server.c b/server.c
index 3dcdea3..751d414 100644
--- a/server.c
+++ b/server.c
@@ -63,9 +63,11 @@ static enum kcgi_err request(struct kreq *req) {
 
 int main(int argc, char *argv[]) {
 	bool fastCGI = false;
+	bool test = false;
 
-	for (int opt; 0 < (opt = getopt(argc, argv, "fps:"));) {
+	for (int opt; 0 < (opt = getopt(argc, argv, "cfps:"));) {
 		switch (opt) {
+			break; case 'c': test = true;
 			break; case 'f': fastCGI = true;
 			break; case 'p': pagePublic = true;
 			break; case 's': htmlStylesheet = optarg;
@@ -98,6 +100,8 @@ int main(int argc, char *argv[]) {
 	prepare(&stmt.eventsAfter, EventsAfterQuery);
 	prepare(&stmt.eventsBefore, EventsBeforeQuery);
 	
+	if (test) return EX_OK;
+	
 	if (fastCGI) {
 		struct kfcgi *fcgi;
 		enum kcgi_err error = khttp_fcgi_init(