From d3a944d70ef6b07753659aabe237168f91473fc8 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Fri, 5 Jul 2024 18:40:15 +0000 Subject: Prepare for 0.5.5.0; add s6rc_livedir_canon Signed-off-by: Laurent Bercot --- src/libs6rc/deps-lib/s6rc | 1 + src/libs6rc/s6rc_livedir_canon.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 src/libs6rc/s6rc_livedir_canon.c (limited to 'src/libs6rc') diff --git a/src/libs6rc/deps-lib/s6rc b/src/libs6rc/deps-lib/s6rc index 52c220f..5dbb4de 100644 --- a/src/libs6rc/deps-lib/s6rc +++ b/src/libs6rc/deps-lib/s6rc @@ -5,6 +5,7 @@ s6rc_db_read.o s6rc_db_read_sizes.o s6rc_db_read_uint32.o s6rc_graph_closure.o +s6rc_livedir_canon.o s6rc_livedir_create.o s6rc_livedir_prefix.o s6rc_livedir_prefixsize.o diff --git a/src/libs6rc/s6rc_livedir_canon.c b/src/libs6rc/s6rc_livedir_canon.c new file mode 100644 index 0000000..db5d3a1 --- /dev/null +++ b/src/libs6rc/s6rc_livedir_canon.c @@ -0,0 +1,25 @@ +/* ISC license. */ + +#include +#include + +#include + +#include + +int s6rc_livedir_canon (char const **live) +{ + size_t llen = strlen(*live) ; + size_t n = llen ; + while (n && (*live)[n - 1] == '/') --n ; + if (!n) return (errno = EINVAL, 0) ; + if (n < llen) + { + char *x = alloc(n + 1) ; + if (!x) return 0 ; + memcpy(x, *live, n) ; + x[n] = 0 ; + *live = x ; + } + return 1 ; +} -- cgit v1.2.3