Move make_base_path to ind.c - geomyidae - a small C-based gopherd (mirror) | |
git clone git://git.codemadness.org/geomyidae | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 9b695d406cbc9c2d9ffddb7a086d44d22f0623ad | |
parent d8f16138b6d4930eed5abe43baa21193730507eb | |
Author: Christoph Lohmann <[email protected]> | |
Date: Fri, 31 Mar 2023 20:35:06 +0200 | |
Move make_base_path to ind.c | |
Diffstat: | |
M handlr.c | 16 +++------------- | |
M ind.c | 11 +++++++++++ | |
M ind.h | 1 + | |
3 files changed, 15 insertions(+), 13 deletions(-) | |
--- | |
diff --git a/handlr.c b/handlr.c | |
@@ -21,16 +21,6 @@ | |
#include "ind.h" | |
#include "arg.h" | |
-char * | |
-make_base_path(char *path, char *base) | |
-{ | |
- if (!(base[0] == '/' && base[1] == '\0') && | |
- strlen(path) > strlen(base)) | |
- return path + strlen(base); | |
- else | |
- return path; | |
-} | |
- | |
void | |
handledir(int sock, char *path, char *port, char *base, char *args, | |
char *sear, char *ohost, char *chost, char *bhost, int istls) | |
@@ -52,11 +42,11 @@ handledir(int sock, char *path, char *port, char *base, cha… | |
par = xstrdup(pa); | |
- b = strrchr(make_base_path(par, base), '/'); | |
+ b = strrchr(makebasepath(par, base), '/'); | |
if (b != NULL) { | |
*b = '\0'; | |
dprintf(sock, "1..\t%s\t%s\t%s\r\n", | |
- make_base_path(par, base), ohost, port); | |
+ makebasepath(par, base), ohost, port); | |
} | |
free(par); | |
@@ -76,7 +66,7 @@ handledir(int sock, char *path, char *port, char *base, char … | |
dirent[i]->d_name); | |
if (stat(file, &st) >= 0 && S_ISDIR(st.st_mode)) | |
type = gettype("index.gph"); | |
- e = make_base_path(file, base); | |
+ e = makebasepath(file, base); | |
ret = dprintf(sock, | |
"%c%-50.50s %10s %16s\t%s\t%s\t%s\r\n", | |
*type->type, | |
diff --git a/ind.c b/ind.c | |
@@ -622,3 +622,14 @@ humantime(const time_t *clock) | |
return buf; | |
} | |
+char * | |
+makebasepath(char *path, char *base) | |
+{ | |
+ if (!(base[0] == '/' && base[1] == '\0') && | |
+ strlen(path) > strlen(base)) { | |
+ return path + strlen(base); | |
+ } else { | |
+ return path; | |
+ } | |
+} | |
+ | |
diff --git a/ind.h b/ind.h | |
@@ -52,6 +52,7 @@ void setcgienviron(char *file, char *path, char *port, char *… | |
char *bhost, int istls); | |
char *humansize(off_t n); | |
char *humantime(const time_t *clock); | |
+char *makebasepath(char *path, char *base); | |
#endif | |