summaryrefslogtreecommitdiffabout
path: root/html.c
Side-by-side diff
Diffstat (limited to 'html.c') (more/less context) (show whitespace changes)
-rw-r--r--html.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/html.c b/html.c
index 1237076..83fc7a9 100644
--- a/html.c
+++ b/html.c
@@ -14,48 +14,53 @@
#include <errno.h>
int htmlfd = STDOUT_FILENO;
char *fmt(const char *format, ...)
{
static char buf[8][1024];
static int bufidx;
int len;
va_list args;
bufidx++;
bufidx &= 7;
va_start(args, format);
len = vsnprintf(buf[bufidx], sizeof(buf[bufidx]), format, args);
va_end(args);
if (len>sizeof(buf[bufidx])) {
fprintf(stderr, "[html.c] string truncated: %s\n", format);
exit(1);
}
return buf[bufidx];
}
+void html_raw(const char *data, size_t size)
+{
+ write(htmlfd, data, size);
+}
+
void html(const char *txt)
{
write(htmlfd, txt, strlen(txt));
}
void htmlf(const char *format, ...)
{
static char buf[65536];
va_list args;
va_start(args, format);
vsnprintf(buf, sizeof(buf), format, args);
va_end(args);
html(buf);
}
void html_status(int code, int more_headers)
{
htmlf("Status: %d\n", code);
if (!more_headers)
html("\n");
}
void html_txt(char *txt)