phroxy

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.z3bra.org/phroxy.git
Log | Files | Refs | LICENSE

commit a44d2079ba256f02068daa7b153d9c87eb2e8160
parent d521a7e51213a29de0e339b7bd9fb1bb04f227df
Author: Willy Goiffon <dev@z3bra.org>
Date:   Mon, 14 Sep 2020 11:24:01 +0200

Various fixes about presentation

Diffstat:
Mphroxy.c | 16+++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/phroxy.c b/phroxy.c @@ -180,6 +180,8 @@ contenttype(char i) { switch(i) { case '0': + return "text/plain; charset=utf-8"; + break; /* NOTREACHED */ case '1': return "text/html; charset=utf-8"; break; /* NOTREACHED */ @@ -207,12 +209,12 @@ printheaders(char *ctype) } char * -htmlize(char *data, size_t len, size_t *newsize) +htmlize(char *data, size_t *htmlsize) { size_t alen, blen, hlen; char *html = NULL; char i, *p, *body, a[LINE_MAX], *f[4]; - char *fmt = "<a href='gopher://%s:%s/%c/%s'>%s</a><br/>\n"; + char *fmt = "<a href='http://%s/%s:%s/%c%s'>%s</a><br/>\n"; blen = 0; body = NULL; @@ -231,7 +233,7 @@ htmlize(char *data, size_t len, size_t *newsize) snprintf(a, sizeof(a), "%s<br/>\n", f[0]); break; default: - snprintf(a, sizeof(a), fmt, f[2], f[3], i, f[1], f[0]); + snprintf(a, sizeof(a), fmt, http_host, f[2], f[3], i, f[1], f[0]); } alen = strnlen(a, sizeof(a)); body = realloc(body, blen + alen); @@ -246,8 +248,8 @@ htmlize(char *data, size_t len, size_t *newsize) snprintf(html, hlen, htmlfmt, body); - if (newsize) - *newsize = hlen; + if (htmlsize) + *htmlsize = hlen; return html; } @@ -259,13 +261,13 @@ serveitem(char item, char *data, size_t len) int sent; switch(item) { - case '0': case '1': - html = htmlize(data, len, &len); + html = htmlize(data, &len); free(data); data = html; break; + case '0': case '6': case '9': case 'g':