phroxy

Gopher to HTTP proxy
git clone git://git.z3bra.org/phroxy.git
Log | Files | Refs | LICENSE

commit 813a41fdb0d7fe01d316f02ac1f3774fedc2cacc
parent dfc1f827663825fec6794c8849751ecdfe3553b5
Author: Willy Goiffon <dev@z3bra.org>
Date:   Tue, 15 Sep 2020 11:05:28 +0200

Change formatting to show link types

Diffstat:
Mphroxy.c | 32+++++++++++++++++++++++++++++---
1 file changed, 29 insertions(+), 3 deletions(-)

diff --git a/phroxy.c b/phroxy.c @@ -203,6 +203,30 @@ contenttype(char i) return NULL; } +char * +itemname(char i) +{ + switch(i) { + case '0': return "TXT"; + case '1': return "DIR"; + case '2': return "CSO"; + case '3': return "ERR"; + case '4': return "MAC"; + case '5': return "WIN"; + case '6': return "UUE"; + case '7': return "QRY"; + case '8': return "TNT"; + case '9': return "BIN"; + case 'I': return "IMG"; + case 'g': return "GIF"; + case 'h': return "URL"; + case 's': return "SND"; + } + + return NULL; +} + + void printheaders(char *ctype) { @@ -224,7 +248,8 @@ htmlize(char *data, size_t *bodysize) size_t alen, blen; char *body = NULL; char i, *p, a[LINE_MAX], *f[4]; - char *fmt = "<a href='http://%s/%s:%s/%c%s'>%s</a>\n"; + char *ifmt = "%s\n"; + char *afmt = "<a href='http://%s/%s:%s/%c%s'>%s (%s)</a>\n"; blen = 0; body = NULL; @@ -243,12 +268,13 @@ htmlize(char *data, size_t *bodysize) f[3] = strsep(&p, "\r"); if (!f[1]) continue; + switch(i) { case 'i': - snprintf(a, sizeof(a), "%s\n", f[0]); + snprintf(a, sizeof(a), ifmt, f[0]); break; default: - snprintf(a, sizeof(a), fmt, http_host, f[2], f[3], i, f[1], f[0]); + snprintf(a, sizeof(a), afmt, http_host, f[2], f[3], i, f[1], f[0], itemname(i)); } alen = strnlen(a, sizeof(a));