all repos — cgit @ 5e75128a8bee885d83563d8c521172328d511d12

a hyperfast web frontend for git written in c

Add html_include()

This is a function used to include external htmlfiles in cgit-
generated pages.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Lars Hjemli hjemli@gmail.com
Fri, 18 May 2007 23:56:10 +0200
commit

5e75128a8bee885d83563d8c521172328d511d12

parent

08cc2e5f0e24773dad81d38bd6b689e36afe9dda

2 files changed, 15 insertions(+), 0 deletions(-)

jump to
M cgit.hcgit.h

@@ -144,6 +144,7 @@ extern void html_hidden(char *name, char *value);

extern void html_link_open(char *url, char *title, char *class); extern void html_link_close(void); extern void html_filemode(unsigned short mode); +extern int html_include(const char *filename); extern int cgit_read_config(const char *filename, configfn fn); extern int cgit_parse_query(char *txt, configfn fn);
M html.chtml.c

@@ -166,3 +166,17 @@ html_fileperm(mode >> 6);

html_fileperm(mode >> 3); html_fileperm(mode); } + +int html_include(const char *filename) +{ + FILE *f; + char buf[4096]; + size_t len; + + if (!(f = fopen(filename, "r"))) + return -1; + while((len = fread(buf, 1, 4096, f)) > 0) + write(htmlfd, buf, len); + fclose(f); + return 0; +}