diff options
| author | 2007-05-20 21:33:59 (JST) | |
|---|---|---|
| committer | 2007-05-20 21:33:59 (JST) | |
| commit | 977a0b173df6fe1a4d362fe4c70f9badff1fd46c (patch) | |
| tree | 8bd383fff396bb1790c03ab5b461d899af997568 /html.c | |
| parent | d4dbfdfbaea3aa93e824ea484787de10e73eae65 (diff) | |
| parent | de69ce020c4ccd7146d6ac72bbd8f417088e8c03 (diff) | |
| download | cgit-977a0b173df6fe1a4d362fe4c70f9badff1fd46c.zip cgit-977a0b173df6fe1a4d362fe4c70f9badff1fd46c.tar.gz | |
Merge branch 'index-header'
* index-header:
Teach cgit howto include an external file on index page.
Add html_include()
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 14 |
1 files changed, 14 insertions, 0 deletions
| @@ -166,3 +166,17 @@ void html_filemode(unsigned short mode) | |||
| 166 | html_fileperm(mode >> 3); | 166 | html_fileperm(mode >> 3); |
| 167 | html_fileperm(mode); | 167 | html_fileperm(mode); |
| 168 | } | 168 | } |
| 169 | |||
| 170 | int html_include(const char *filename) | ||
| 171 | { | ||
| 172 | FILE *f; | ||
| 173 | char buf[4096]; | ||
| 174 | size_t len; | ||
| 175 | |||
| 176 | if (!(f = fopen(filename, "r"))) | ||
| 177 | return -1; | ||
| 178 | while((len = fread(buf, 1, 4096, f)) > 0) | ||
| 179 | write(htmlfd, buf, len); | ||
| 180 | fclose(f); | ||
| 181 | return 0; | ||
| 182 | } | ||
