Added compilation flag for static generation (default: cgi)

This commit is contained in:
- 2022-02-16 20:19:33 -08:00
parent f09c05fd1a
commit 336352a335
3 changed files with 15 additions and 1 deletions

View File

@ -3,6 +3,12 @@ BIN=cts
all: main 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 main: main.o
gcc colors.o dbquery.o main.o -lsqlite3 -o $(BIN) gcc colors.o dbquery.o main.o -lsqlite3 -o $(BIN)

View File

@ -98,7 +98,11 @@ static void qresult(sqlite3_stmt * const sp, const char *c) {
if (ISPLAYERNAME(c, i)) { if (ISPLAYERNAME(c, i)) {
print_plname(field); print_plname(field);
} else if (ISMAPNAME(c, i)) { } else if (ISMAPNAME(c, i)) {
printf("<TD><a href='./%s.html'>%s</a></TD>", field, field); #ifdef STATICGEN
printf("<TD><a href='./maps/%s.html'>%s</a></TD>", field, field);
#else
printf("<TD><a href='/cgi/cts?map=%s'>%s</a></TD>", field, field);
#endif
} else if (i == 2 && (*c == QMLEADERBOARD || *c == QOVERVIEW)) { } else if (i == 2 && (*c == QMLEADERBOARD || *c == QOVERVIEW)) {
print_time(field); print_time(field);
} else { } else {

View File

@ -34,6 +34,10 @@ void templated(void) {
} }
int main(void) { int main(void) {
#ifdef STATICGEN
templated(); templated();
#else
html();
#endif
return 0; return 0;
} }