summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Stensgård <mastensg@mastensg.net>2025-07-09 20:34:44 +0200
committerMartin Stensgård <mastensg@mastensg.net>2025-07-09 20:34:44 +0200
commitcc80525980d004f32aa3342012060b4d421c18f2 (patch)
tree5e6e70f26848397aa3542333be6360e809c598ae
parenta8571be97dd6630387c22c53209fa56bc87065b4 (diff)
generic select_booking -> select
-rw-r--r--.gitignore2
-rw-r--r--Makefile8
-rw-r--r--select.c (renamed from select_booking.c)9
3 files changed, 10 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
index ff3310f..c25e3e7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,7 +4,7 @@
/check_ical_out.txt
/events.ical
/opplysning
-/select_booking
+/select
/sqlite3
/update
core
diff --git a/Makefile b/Makefile
index 48ddd20..73f834a 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ LIBS = -lraylib -lm -lpthread -lGLESv2 -lEGL \
-lical -licalss -licalvcal \
$$([ `uname -m` = aarch64 ] && echo '-lvcos -lvchiq_arm -lgbm -ldrm')
-all: check_ical opplysning select_booking update
+all: check_ical opplysning select update
check: all
./check_ical < check_ical_in.ical > check_ical_out.txt
@@ -14,7 +14,7 @@ check: all
clean:
rm -f check_ical check_ical_out.txt
rm -f opplysning
- rm -f select_booking
+ rm -f select
rm -f sqlite.o
rm -f sqlite3
rm -f update
@@ -27,8 +27,8 @@ check_ical: check_ical.c
opplysning: opplysning.c sqlite.o
$(CC) $(CFLAGS) -o $@ opplysning.c sqlite.o $(LIBS)
-select_booking: select_booking.c sqlite.o
- $(CC) $(CFLAGS) -o $@ select_booking.c sqlite.o
+select: select.c sqlite.o
+ $(CC) $(CFLAGS) -o $@ select.c sqlite.o
sqlite.o: sqlite/sqlite3.c
$(CC) $(CFLAGS) -c -o $@ sqlite/sqlite3.c
diff --git a/select_booking.c b/select.c
index f8cf595..ff6af50 100644
--- a/select_booking.c
+++ b/select.c
@@ -4,13 +4,14 @@
#include "sqlite/sqlite3.h"
-static const char *DATABASE = "booking.db";
-
int
-main(void)
+main(int argc, const char *argv[static argc])
{
+ if (2 != argc)
+ errx(1, "usage: %s dbfile", argv[0]);
+
sqlite3 *db;
- if (sqlite3_open(DATABASE, &db))
+ if (sqlite3_open(argv[1], &db))
errx(1, "sqlite3_open: %s", sqlite3_errmsg(db));
const char *sql = "SELECT "