Unidiff1 files changed, 7 insertions, 0 deletions
|
diff --git a/html.c b/html.c index bddb04d..1237076 100644 --- a/ html.c+++ b/ html.c |
|
@@ -38,32 +38,39 @@ char *fmt(const char *format, ...) |
38 | void html(const char *txt) |
38 | void html(const char *txt) |
39 | { |
39 | { |
40 | write(htmlfd, txt, strlen(txt)); |
40 | write(htmlfd, txt, strlen(txt)); |
41 | } |
41 | } |
42 | |
42 | |
43 | void htmlf(const char *format, ...) |
43 | void htmlf(const char *format, ...) |
44 | { |
44 | { |
45 | static char buf[65536]; |
45 | static char buf[65536]; |
46 | va_list args; |
46 | va_list args; |
47 | |
47 | |
48 | va_start(args, format); |
48 | va_start(args, format); |
49 | vsnprintf(buf, sizeof(buf), format, args); |
49 | vsnprintf(buf, sizeof(buf), format, args); |
50 | va_end(args); |
50 | va_end(args); |
51 | html(buf); |
51 | html(buf); |
52 | } |
52 | } |
53 | |
53 | |
| |
54 | void html_status(int code, int more_headers) |
| |
55 | { |
| |
56 | htmlf("Status: %d\n", code); |
| |
57 | if (!more_headers) |
| |
58 | html("\n"); |
| |
59 | } |
| |
60 | |
54 | void html_txt(char *txt) |
61 | void html_txt(char *txt) |
55 | { |
62 | { |
56 | char *t = txt; |
63 | char *t = txt; |
57 | while(t && *t){ |
64 | while(t && *t){ |
58 | int c = *t; |
65 | int c = *t; |
59 | if (c=='<' || c=='>' || c=='&') { |
66 | if (c=='<' || c=='>' || c=='&') { |
60 | write(htmlfd, txt, t - txt); |
67 | write(htmlfd, txt, t - txt); |
61 | if (c=='>') |
68 | if (c=='>') |
62 | html(">"); |
69 | html(">"); |
63 | else if (c=='<') |
70 | else if (c=='<') |
64 | html("<"); |
71 | html("<"); |
65 | else if (c=='&') |
72 | else if (c=='&') |
66 | html("&"); |
73 | html("&"); |
67 | txt = t+1; |
74 | txt = t+1; |
68 | } |
75 | } |
69 | t++; |
76 | t++; |
|