while(t && *t){
int c = *t;
if (c=='<' || c=='>' || c=='&') {
- write(htmlfd, txt, t - txt);
+ html_raw(txt, t - txt);
if (c=='>')
html(">");
else if (c=='<')
while(t && *t && len--){
int c = *t;
if (c=='<' || c=='>' || c=='&') {
- write(htmlfd, txt, t - txt);
+ html_raw(txt, t - txt);
if (c=='>')
html(">");
else if (c=='<')
t++;
}
if (t!=txt)
- write(htmlfd, txt, t - txt);
+ html_raw(txt, t - txt);
if (len<0)
html("...");
}
const char *t = txt;
while(t && *t){
int c = *t;
- if (c=='<' || c=='>' || c=='\'' || c=='\"') {
- write(htmlfd, txt, t - txt);
+ if (c=='<' || c=='>' || c=='\'' || c=='\"' || c=='&') {
+ html_raw(txt, t - txt);
if (c=='>')
html(">");
else if (c=='<')
html("'");
else if (c=='"')
html(""");
+ else if (c=='&')
+ html("&");
txt = t+1;
}
t++;
while(t && *t){
int c = *t;
const char *e = url_escape_table[c];
- if (e && c!='+' && c!='&' && c!='+') {
- write(htmlfd, txt, t - txt);
- write(htmlfd, e, 3);
+ if (e && c!='+' && c!='&') {
+ html_raw(txt, t - txt);
+ html(e);
txt = t+1;
}
t++;
while(t && *t){
int c = *t;
const char *e = url_escape_table[c];
+ if (c == ' ')
+ e = "+";
if (e) {
- write(htmlfd, txt, t - txt);
- write(htmlfd, e, 3);
+ html_raw(txt, t - txt);
+ html(e);
txt = t+1;
}
t++;
html("</option>\n");
}
+void html_intoption(int value, const char *text, int selected_value)
+{
+ htmlf("<option value='%d'%s>", value,
+ value == selected_value ? " selected='selected'" : "");
+ html_txt(text);
+ html("</option>");
+}
+
void html_link_open(const char *url, const char *title, const char *class)
{
html("<a href='");
return -1;
}
while((len = fread(buf, 1, 4096, f)) > 0)
- write(htmlfd, buf, len);
+ html_raw(buf, len);
fclose(f);
return 0;
}
d1 = hextoint(*(txt+1));
d2 = hextoint(*(txt+2));
if (d1<0 || d2<0) {
- memmove(txt, txt+3, n-3);
+ memmove(txt, txt+3, n-2);
return txt-1;
} else {
*txt = d1 * 16 + d2;
int http_parse_querystring(const char *txt_, void (*fn)(const char *name, const char *value))
{
- char *t, *txt, *value = NULL, c;
+ char *o, *t, *txt, *value = NULL, c;
if (!txt_)
return 0;
- t = txt = strdup(txt_);
+ o = t = txt = strdup(txt_);
if (t == NULL) {
printf("Out of memory\n");
exit(1);
}
if (t!=txt)
(*fn)(txt, value);
+ free(o);
return 0;
}