1 /* html.c: helper functions for html output
3 * Copyright (C) 2006 Lars Hjemli
5 * Licensed under GNU General Public License v2
6 * (see COPYING for full license text)
11 char *fmt(const char *format, ...)
13 static char buf[8][1024];
21 va_start(args, format);
22 len = vsnprintf(buf[bufidx], sizeof(buf[bufidx]), format, args);
24 if (len>sizeof(buf[bufidx]))
25 die("[html.c] string truncated: %s", format);
29 void html(const char *txt)
31 write(htmlfd, txt, strlen(txt));
34 void htmlf(const char *format, ...)
36 static char buf[65536];
39 va_start(args, format);
40 vsnprintf(buf, sizeof(buf), format, args);
45 void html_txt(char *txt)
50 if (c=='<' || c=='>' || c=='&') {
69 void html_attr(char *txt)
74 if (c=='<' || c=='>' || c=='\'') {
92 void html_link_open(char *url, char *title, char *class)
107 void html_link_close(void)
112 void html_fileperm(unsigned short mode)
114 htmlf("%c%c%c", (mode & 4 ? 'r' : '-'),
115 (mode & 2 ? 'w' : '-'), (mode & 1 ? 'x' : '-'));
118 void html_filemode(unsigned short mode)
122 else if (S_ISLNK(mode))
126 html_fileperm(mode >> 6);
127 html_fileperm(mode >> 3);