diff --git a/.fossil-settings/ignore-glob b/.fossil-settings/ignore-glob
index bcc267c..be80a39 100644
--- a/.fossil-settings/ignore-glob
+++ b/.fossil-settings/ignore-glob
@@ -1,3 +1,4 @@
+template
filec
emojitoc
**/*.cgi
diff --git a/Makefile b/Makefile
index 5e37c5c..88d9f71 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@ GIT ?= git
MASTODONT_DIR = mastodont-c/
MASTODONT = $(MASTODONT_DIR)libmastodont.a
CFLAGS += -Wall -I $(MASTODONT_DIR)include/ -Wno-unused-variable -Wno-ignored-qualifiers -I/usr/include/ $(shell pkg-config --cflags libcurl libcjson libpcre)
-LDFLAGS = -lm -L$(MASTODONT_DIR) -lmastodont $(shell pkg-config --libs libcjson libcurl libpcre) -lfcgi
+LDFLAGS = -L$(MASTODONT_DIR) -lmastodont $(shell pkg-config --libs libcjson libcurl libpcre) -lfcgi
SRC = $(wildcard src/*.c)
OBJ = $(patsubst %.c,%.o,$(SRC))
HEADERS = $(wildcard src/*.h)
@@ -19,9 +19,12 @@ MASTODONT_URL = https://fossil.nekobit.net/mastodont-c
all: $(MASTODONT_DIR) dep_build $(TARGET)
apache: all apache_start
-$(TARGET): filec $(PAGES_CMP) $(OBJ) $(HEADERS)
+$(TARGET): filec template $(PAGES_CMP) $(OBJ) $(HEADERS)
$(CC) -o $(TARGET) $(OBJ) $(LDFLAGS)
+template: src/template/main.o
+ $(CC) -o template $<
+
filec: src/file-to-c/main.o
$(CC) -o filec $<
diff --git a/src/template/main.c b/src/template/main.c
new file mode 100644
index 0000000..6e317c0
--- /dev/null
+++ b/src/template/main.c
@@ -0,0 +1,100 @@
+/*
+ * Treebird - Lightweight frontend for Pleroma
+ * Copyright (C) 2022 Nekobit
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+
+#include
+#include
+#include
+
+enum args
+{
+ ARG_FILENAME = 1,
+ ARG_VARIABLE
+};
+
+enum tmpl_type
+{
+ TMPL_INT,
+ TMPL_UINT,
+ TMPL_STR,
+ TMPL_STRLEN
+}
+
+long filesize(FILE* file)
+{
+ long orig = ftell(file);
+ fseek(file, 0, SEEK_END);
+ long size = ftell(file);
+ fseek(file, orig, SEEK_SET);
+ return size;
+}
+
+void print_template(char* var, char* buf)
+{
+ char* buf_prev = buf;
+ char* buf_curr = buf;
+ char** tokens;
+
+ printf("#ifndef __%s\n", var);
+ printf("#define __%s\n", var);
+
+ printf("static const char data_%s[] = {", var);
+ while (1)
+ {
+ buf_curr = strstr(buf_curr, "{{");
+ }
+ /* for (size_t i = 0; i < size; ++i) */
+ /* { */
+ /* printf("0X%hhX,", buf[i]); */
+ /* } */
+ /* puts("0};\n#endif"); */
+
+ puts("#endif");
+}
+
+int main(int argc, char** argv)
+{
+ char* buf;
+ FILE* file = fopen(argv[ARG_FILENAME], "rb");
+
+ long size = filesize(file);
+
+ if (!(buf = malloc(size)))
+ {
+ perror("malloc");
+ return 1;
+ }
+
+ if (fread(buf, 1, size, file) != size)
+ {
+ fputs("Didn't read correctly!", stderr);
+ free(buf);
+ return 1;
+ }
+
+ fclose(file);
+
+ print_template(argv[ARG_VARIABLE], buf);
+
+
+
+
+ free(buf);
+ return 0;
+}
+