From 336352a335d3090a61525b1b0210b75a9c6d240a Mon Sep 17 00:00:00 2001 From: - <-> Date: Wed, 16 Feb 2022 20:19:33 -0800 Subject: [PATCH] Added compilation flag for static generation (default: cgi) --- Makefile | 6 ++++++ src/dbquery.c | 6 +++++- src/main.c | 4 ++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c86f686..3f21dfe 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,12 @@ BIN=cts all: main +staticgen: colors.o src/dbquery.c + echo "\nCompiling executable as static page generator\n" + gcc -c src/dbquery.c $(CFLAGS) -DSTATICGEN + gcc -c src/main.c $(CFLAGS) -DSTATICGEN + gcc colors.o dbquery.o main.o -lsqlite3 -o $(BIN) + main: main.o gcc colors.o dbquery.o main.o -lsqlite3 -o $(BIN) diff --git a/src/dbquery.c b/src/dbquery.c index 7705e03..7b331ec 100644 --- a/src/dbquery.c +++ b/src/dbquery.c @@ -98,7 +98,11 @@ static void qresult(sqlite3_stmt * const sp, const char *c) { if (ISPLAYERNAME(c, i)) { print_plname(field); } else if (ISMAPNAME(c, i)) { - printf("%s", field, field); +#ifdef STATICGEN + printf("%s", field, field); +#else + printf("%s", field, field); +#endif } else if (i == 2 && (*c == QMLEADERBOARD || *c == QOVERVIEW)) { print_time(field); } else { diff --git a/src/main.c b/src/main.c index 0f64fd4..b2130ee 100644 --- a/src/main.c +++ b/src/main.c @@ -34,6 +34,10 @@ void templated(void) { } int main(void) { +#ifdef STATICGEN templated(); +#else + html(); +#endif return 0; }