From 9fff6c5452c5f5f071f0d334ec71f192b150f8ff Mon Sep 17 00:00:00 2001 From: KatolaZ Date: Fri, 29 Mar 2019 23:38:28 +0000 Subject: [PATCH] added code to manage header --- ui_70-shared.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ui_70-shared.c b/ui_70-shared.c index 9abf94c..629b283 100644 --- a/ui_70-shared.c +++ b/ui_70-shared.c @@ -98,6 +98,26 @@ void gopher_fileperm(unsigned short mode) } +void gopher_include(const char *fname){ + + FILE *f; + char buf[4096]; + size_t len; + + if (!(f = fopen(fname, "r"))) { + fprintf(stderr, "[cgit] Failed to include file %s: %s (%d).\n", + fname, strerror(errno), errno); + return -1; + } + while ((len = fread(buf, 1, 4096, f)) > 0) + html_raw(buf, len); + fclose(f); + return 0; +} + + + + void cgit_gopher_textf(const char *fmt, va_list ap){ va_list cp; @@ -1049,6 +1069,9 @@ void cgit_print_layout_start(void) { /*cgit_print_http_headers(); cgit_print_docstart();*/ + if (ctx.cfg.header) + gopher_include(ctx.cfg.header); + cgit_print_pageheader(); }