summaryrefslogtreecommitdiffabout
path: root/html.c
Unidiff
Diffstat (limited to 'html.c') (more/less context) (ignore whitespace changes)
-rw-r--r--html.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/html.c b/html.c
index 36e9a2f..167127f 100644
--- a/html.c
+++ b/html.c
@@ -107,48 +107,64 @@ void html_ntxt(int len, char *txt)
107 html("..."); 107 html("...");
108} 108}
109 109
110void html_attr(char *txt) 110void html_attr(char *txt)
111{ 111{
112 char *t = txt; 112 char *t = txt;
113 while(t && *t){ 113 while(t && *t){
114 int c = *t; 114 int c = *t;
115 if (c=='<' || c=='>' || c=='\'') { 115 if (c=='<' || c=='>' || c=='\'') {
116 write(htmlfd, txt, t - txt); 116 write(htmlfd, txt, t - txt);
117 if (c=='>') 117 if (c=='>')
118 html("&gt;"); 118 html("&gt;");
119 else if (c=='<') 119 else if (c=='<')
120 html("&lt;"); 120 html("&lt;");
121 else if (c=='\'') 121 else if (c=='\'')
122 html("&quote;"); 122 html("&quote;");
123 txt = t+1; 123 txt = t+1;
124 } 124 }
125 t++; 125 t++;
126 } 126 }
127 if (t!=txt) 127 if (t!=txt)
128 html(txt); 128 html(txt);
129} 129}
130 130
131void html_url_arg(char *txt)
132{
133 char *t = txt;
134 while(t && *t){
135 int c = *t;
136 if (c=='"' || c=='#' || c=='%' || c=='&' || c=='\'' || c=='+' || c=='?') {
137 write(htmlfd, txt, t - txt);
138 write(htmlfd, fmt("%%%2x", c), 3);
139 txt = t+1;
140 }
141 t++;
142 }
143 if (t!=txt)
144 html(txt);
145}
146
131void html_hidden(char *name, char *value) 147void html_hidden(char *name, char *value)
132{ 148{
133 html("<input type='hidden' name='"); 149 html("<input type='hidden' name='");
134 html_attr(name); 150 html_attr(name);
135 html("' value='"); 151 html("' value='");
136 html_attr(value); 152 html_attr(value);
137 html("'/>"); 153 html("'/>");
138} 154}
139 155
140void html_option(char *value, char *text, char *selected_value) 156void html_option(char *value, char *text, char *selected_value)
141{ 157{
142 html("<option value='"); 158 html("<option value='");
143 html_attr(value); 159 html_attr(value);
144 html("'"); 160 html("'");
145 if (selected_value && !strcmp(selected_value, value)) 161 if (selected_value && !strcmp(selected_value, value))
146 html(" selected='selected'"); 162 html(" selected='selected'");
147 html(">"); 163 html(">");
148 html_txt(text); 164 html_txt(text);
149 html("</option>\n"); 165 html("</option>\n");
150} 166}
151 167
152void html_link_open(char *url, char *title, char *class) 168void html_link_open(char *url, char *title, char *class)
153{ 169{
154 html("<a href='"); 170 html("<a href='");