geomyidae

A small C-based gopherd. (gopher://bitreich.org/1/scm/geomyidae)
git clone git://r-36.net/geomyidae
Log | Files | Refs | README | LICENSE

commit 31cab7f26e390b9e29a3f9fa185df6bd67abd826
parent e418a673b849daeac362148c6dfcb3dc9355f4dc
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sat, 22 Jul 2023 19:15:03 +0200

handlr.c: use basename() to get the base filename

Signed-off-by: Christoph Lohmann <20h@r-36.net>

Diffstat:
Mhandlr.c | 12++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/handlr.c b/handlr.c @@ -144,7 +144,7 @@ handlecgi(int sock, char *file, char *port, char *base, char *args, char *sear, char *ohost, char *chost, char *bhost, int istls, char *sel, char *traverse) { - char *script, *path, *filec; + char *script, *path, *filec, *scriptc; USED(base); USED(port); @@ -157,8 +157,9 @@ handlecgi(int sock, char *file, char *port, char *base, char *args, printf("sel = %s; traverse = %s;\n", sel, traverse); filec = xstrdup(file); + scriptc = xstrdup(file); path = dirname(filec); - script = path + strlen(path) + 1; + script = basename(scriptc); if (sear == NULL) sear = ""; @@ -189,6 +190,7 @@ handlecgi(int sock, char *file, char *port, char *base, char *args, default: wait(NULL); free(filec); + free(scriptc); break; } } @@ -199,7 +201,7 @@ handledcgi(int sock, char *file, char *port, char *base, char *args, char *sel, char *traverse) { FILE *fp; - char *script, *path, *filec, *ln = NULL; + char *script, *path, *filec, *scriptc, *ln = NULL; size_t linesiz = 0; ssize_t n; int outsocks[2], ret = 0; @@ -216,8 +218,9 @@ handledcgi(int sock, char *file, char *port, char *base, char *args, return; filec = xstrdup(file); + scriptc = xstrdup(file); path = dirname(filec); - script = path + strlen(path) + 1; + script = basename(scriptc); if (sear == NULL) sear = ""; @@ -276,6 +279,7 @@ handledcgi(int sock, char *file, char *port, char *base, char *args, fclose(fp); wait(NULL); free(filec); + free(scriptc); break; } }