Move make_base_path to ind.c - geomyidae - A small C-based gopherd.
 (HTM) git clone git://bitreich.org/geomyidae/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/geomyidae/
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Tags
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 9b695d406cbc9c2d9ffddb7a086d44d22f0623ad
 (DIR) parent d8f16138b6d4930eed5abe43baa21193730507eb
 (HTM) Author: Christoph Lohmann <20h@r-36.net>
       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(-)
       ---
 (DIR) 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, char *args,
        
                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 *args,
                                                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,
 (DIR) 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;
       +        }
       +}
       +
 (DIR) diff --git a/ind.h b/ind.h
       @@ -52,6 +52,7 @@ void setcgienviron(char *file, char *path, char *port, char *base,
                        char *bhost, int istls);
        char *humansize(off_t n);
        char *humantime(const time_t *clock);
       +char *makebasepath(char *path, char *base);
        
        #endif