author | Lars Hjemli <hjemli@gmail.com> | 2008-08-06 20:57:44 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2008-08-06 20:57:44 (UTC) |
commit | 885096c189574b1cf2e0897cc05aadd7b092a677 (patch) (side-by-side diff) | |
tree | e915e78aa09d61a3492926f2eb8a1a3e59c60f4d /html.c | |
parent | 65b7b876aaaf50fc15060533359d6561f4f1819a (diff) | |
download | cgit-885096c189574b1cf2e0897cc05aadd7b092a677.zip cgit-885096c189574b1cf2e0897cc05aadd7b092a677.tar.gz cgit-885096c189574b1cf2e0897cc05aadd7b092a677.tar.bz2 |
Supply status description to html_status()
Signed-off-by: Lars Hjemli <hjemli@gmail.com>
-rw-r--r-- | html.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -11,99 +11,99 @@ #include <stdlib.h> #include <stdarg.h> #include <string.h> #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) +void html_status(int code, const char *msg, int more_headers) { - htmlf("Status: %d\n", code); + htmlf("Status: %d %s\n", code, msg); if (!more_headers) html("\n"); } void html_txt(char *txt) { char *t = txt; while(t && *t){ int c = *t; if (c=='<' || c=='>' || c=='&') { write(htmlfd, txt, t - txt); if (c=='>') html(">"); else if (c=='<') html("<"); else if (c=='&') html("&"); txt = t+1; } t++; } if (t!=txt) html(txt); } void html_ntxt(int len, char *txt) { char *t = txt; while(t && *t && len--){ int c = *t; if (c=='<' || c=='>' || c=='&') { write(htmlfd, txt, t - txt); if (c=='>') html(">"); else if (c=='<') html("<"); else if (c=='&') html("&"); txt = t+1; } t++; } if (t!=txt) write(htmlfd, txt, t - txt); if (len<0) html("..."); } |