diff options
Diffstat (limited to '')
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile | 10 | ||||
-rw-r--r-- | css.sh | 9 | ||||
-rw-r--r-- | server.c | 11 |
4 files changed, 20 insertions, 12 deletions
diff --git a/.gitignore b/.gitignore index bc13172..791d6d0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ *.o .test config.mk -default.css.h +css.h scooper tags diff --git a/Makefile b/Makefile index cd9f014..1cb3bf4 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ PREFIX ?= ~/.local MANDIR ?= ${PREFIX}/share/man -CFLAGS += -std=c11 -Wall -Wextra -Wpedantic +CFLAGS += -std=c11 -Wall -Wextra -Wpedantic -Wno-overlength-strings LDLIBS = -lkcgi -lkcgihtml -lsqlite3 TEST_DB = ~/.local/share/litterbox/litterbox.sqlite @@ -24,10 +24,10 @@ scooper: ${OBJS} ${OBJS}: server.h -server.o: default.css.h +server.o: css.h -default.css.h: default.css color.css - cat default.css color.css | file2c > $@ +css.h: css.sh default.css color.css + sh css.sh default.css color.css > $@ test: .test @@ -39,7 +39,7 @@ tags: *.c *.h ctags -w *.c *.h clean: - rm -f scooper ${OBJS} .test tags + rm -f scooper ${OBJS} css.h .test tags install: scooper scooper.1 install -d ${PREFIX}/bin ${MANDIR}/man1 diff --git a/css.sh b/css.sh new file mode 100644 index 0000000..80f28d1 --- /dev/null +++ b/css.sh @@ -0,0 +1,9 @@ +#!/bin/sh +set -eu + +cat <<EOF +#define CSS(...) #__VA_ARGS__ +static const char CSS[] = CSS( +EOF +cat "$@" +echo ');' diff --git a/server.c b/server.c index bc05299..c384020 100644 --- a/server.c +++ b/server.c @@ -21,6 +21,7 @@ #include <sysexits.h> #include <unistd.h> +#include "css.h" #include "server.h" sqlite3 *db; @@ -51,15 +52,13 @@ const struct kvalid Keys[KeysLen] = { #undef X }; -static const char CSS[] = { -#include "default.css.h" -}; -static const char *Cache = "public, max-age=86400, immutable"; - static enum kcgi_err stylesheet(struct kreq *req) { if (req->mime != KMIME_TEXT_CSS) return httpFail(req, KHTTP_404); return httpHead(req, KHTTP_200, KMIME_TEXT_CSS) - || khttp_head(req, kresps[KRESP_CACHE_CONTROL], "%s", Cache) + || khttp_head( + req, kresps[KRESP_CACHE_CONTROL], + "public, max-age=86400, immutable" + ) || khttp_body(req) || khttp_write(req, CSS, sizeof(CSS)); } |