summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/main.c b/main.c
index 31dbf45..00a184a 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,35 @@
-int main(void)
+#include <stdio.h>
+#include <unistd.h>
+
+#include "mem.h"
+#include "dom.h"
+
+int main(int argc, char *argv[])
{
+ if (argc < 2)
+ errx(1, "usage: glacier <file>");
+
+ unveil(argv[1], "r");
+ unveil(NULL, NULL);
+ pledge("stdio rpath", NULL);
+
+ FILE *file;
+ char *html;
+ long len;
+
+ file = fopen("test.html", "rb");
+ fseek(file, 0, SEEK_END);
+ len = ftell(file);
+ fseek(file, 0, SEEK_SET);
+
+ html = MALLOC((size_t)len + 1);
+ fread(html, 1, len, file);
+ html[len] = '\0';
+ fclose(file);
+
+ init_dom(html);
+
+ free(html);
+
return 0;
}