X-Git-Url: https://gitweb.ps.run/ps-cgit/blobdiff_plain/9cae75d040d9102d4b628ba3c828d95d0251f5c0..bafab423f20bc1448b293842c235965e1681f07e:/html.c diff --git a/html.c b/html.c index 5b07aa0..b5c6903 100644 --- a/html.c +++ b/html.c @@ -39,7 +39,7 @@ static const char* url_escape_table[256] = { "%fe", "%ff" }; -int htmlfd = STDOUT_FILENO; +static int htmlfd = STDOUT_FILENO; char *fmt(const char *format, ...) { @@ -54,7 +54,7 @@ char *fmt(const char *format, ...) va_start(args, format); len = vsnprintf(buf[bufidx], sizeof(buf[bufidx]), format, args); va_end(args); - if (len>sizeof(buf[bufidx])) { + if (len > sizeof(buf[bufidx])) { fprintf(stderr, "[html.c] string truncated: %s\n", format); exit(1); } @@ -92,93 +92,93 @@ void html_status(int code, const char *msg, int more_headers) void html_txt(const char *txt) { const char *t = txt; - while(t && *t){ + while (t && *t) { int c = *t; - if (c=='<' || c=='>' || c=='&') { + if (c == '<' || c == '>' || c == '&') { html_raw(txt, t - txt); - if (c=='>') + if (c == '>') html(">"); - else if (c=='<') + else if (c == '<') html("<"); - else if (c=='&') + else if (c == '&') html("&"); - txt = t+1; + txt = t + 1; } t++; } - if (t!=txt) + if (t != txt) html(txt); } void html_ntxt(int len, const char *txt) { const char *t = txt; - while(t && *t && len--){ + while (t && *t && len--) { int c = *t; - if (c=='<' || c=='>' || c=='&') { + if (c == '<' || c == '>' || c == '&') { html_raw(txt, t - txt); - if (c=='>') + if (c == '>') html(">"); - else if (c=='<') + else if (c == '<') html("<"); - else if (c=='&') + else if (c == '&') html("&"); - txt = t+1; + txt = t + 1; } t++; } - if (t!=txt) + if (t != txt) html_raw(txt, t - txt); - if (len<0) + if (len < 0) html("..."); } void html_attr(const char *txt) { const char *t = txt; - while(t && *t){ + while (t && *t) { int c = *t; - if (c=='<' || c=='>' || c=='\'' || c=='\"' || c=='&') { + if (c == '<' || c == '>' || c == '\'' || c == '\"' || c == '&') { html_raw(txt, t - txt); - if (c=='>') + if (c == '>') html(">"); - else if (c=='<') + else if (c == '<') html("<"); - else if (c=='\'') + else if (c == '\'') html("'"); - else if (c=='"') + else if (c == '"') html("""); - else if (c=='&') + else if (c == '&') html("&"); - txt = t+1; + txt = t + 1; } t++; } - if (t!=txt) + if (t != txt) html(txt); } void html_url_path(const char *txt) { const char *t = txt; - while(t && *t){ + while (t && *t) { unsigned char c = *t; const char *e = url_escape_table[c]; - if (e && c!='+' && c!='&') { + if (e && c != '+' && c != '&') { html_raw(txt, t - txt); html(e); - txt = t+1; + txt = t + 1; } t++; } - if (t!=txt) + if (t != txt) html(txt); } void html_url_arg(const char *txt) { const char *t = txt; - while(t && *t){ + while (t && *t) { unsigned char c = *t; const char *e = url_escape_table[c]; if (c == ' ') @@ -186,11 +186,11 @@ void html_url_arg(const char *txt) if (e) { html_raw(txt, t - txt); html(e); - txt = t+1; + txt = t + 1; } t++; } - if (t!=txt) + if (t != txt) html(txt); } @@ -215,6 +215,14 @@ void html_option(const char *value, const char *text, const char *selected_value html("\n"); } +void html_intoption(int value, const char *text, int selected_value) +{ + htmlf(""); +} + void html_link_open(const char *url, const char *title, const char *class) { html("