phroxy

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

commit 6080677947fba31e72da83dd8a881de1e37daf15
parent b8839df0fea0cf644b2be9a9d9620e525ba39bd3
Author: Willy Goiffon <dev@z3bra.org>
Date:   Mon, 14 Sep 2020 16:17:08 +0200

Remove strsep() usage to get item type

Using strsep() will overwrite the '/' between item type and path if it
is present. However, we must request a file in gopher from the root
directory, so we must keep this leading '/'.

Diffstat:
Mphroxy.c | 11++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/phroxy.c b/phroxy.c @@ -343,7 +343,8 @@ phroxy(char *url) { int sock; size_t len; - char *hole, *item, *path, *host, *port; + char item; + char *hole, *path, *host, *port; char *data = NULL, *srch = NULL; url++; @@ -358,9 +359,9 @@ phroxy(char *url) if (!port) port = "70"; - item = strsep(&url, "/"); - if (!item || !item[0] ) - item = "1"; + item = *url++; + if (!item) + item = '1'; path = strsep(&url, "\0"); if (!path) @@ -378,7 +379,7 @@ phroxy(char *url) if (!data) return 1; - serveitem(*item, data, len); + serveitem(item, data, len); return 0; }