aboutsummaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2023-08-08 15:56:27 +0000
committerOmar Polo <op@omarpolo.com>2023-08-08 15:56:27 +0000
commitd98ef734940a49d192d87024e60559b38eb190c9 (patch)
tree9fd986bdf4000c35d8c51d0d5ce557162222acf9 /utils.c
parent877b479bcc183e71a6d78cb938548c21ed4303fc (diff)
move strip_path to utils.c
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c17
1 files changed, 17 insertions, 0 deletions
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)
{