From d98ef734940a49d192d87024e60559b38eb190c9 Mon Sep 17 00:00:00 2001 From: Omar Polo Date: Tue, 8 Aug 2023 15:56:27 +0000 Subject: move strip_path to utils.c --- utils.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'utils.c') diff --git a/utils.c b/utils.c index 2a9d4a4..a968159 100644 --- a/utils.c +++ b/utils.c @@ -29,6 +29,23 @@ #include "log.h" +const char * +strip_path(const char *path, int strip) +{ + char *t; + + while (strip > 0) { + if ((t = strchr(path, '/')) == NULL) { + path = strchr(path, '\0'); + break; + } + path = t; + strip--; + } + + return path; +} + int starts_with(const char *str, const char *prefix) { -- cgit v1.2.3