]> git.cameronkatri.com Git - cgit.git/commitdiff
Add html_include()
authorLars Hjemli <hjemli@gmail.com>
Fri, 18 May 2007 21:56:10 +0000 (23:56 +0200)
committerLars Hjemli <hjemli@gmail.com>
Fri, 18 May 2007 21:56:10 +0000 (23:56 +0200)
This is a function used to include external htmlfiles in cgit-
generated pages.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
cgit.h
html.c

diff --git a/cgit.h b/cgit.h
index f3d783e553704ffbab9ee1f8bcde346b8259531f..fc44a714c81fec2ee8814b554921686bf2320013 100644 (file)
--- a/cgit.h
+++ b/cgit.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);
diff --git a/html.c b/html.c
index 175b4b687efb75d443b847738775a1de92e97cf6..33a956fd5db8140eed9c1a237d3db31337d76918 100644 (file)
--- a/html.c
+++ b/html.c
@@ -166,3 +166,17 @@ void html_filemode(unsigned short mode)
        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;
+}