From 6c8a81097fd305d428891377433d7d88ba1119fd Mon Sep 17 00:00:00 2001 From: midipix Date: Sun, 26 May 2024 14:41:33 +0000 Subject: library api's: _util_ (utility helper interfaces) namespace overhaul. --- src/helper/tpax_path_copy.c | 86 ------------------------------------------ src/helper/tpax_stat_compare.c | 41 -------------------- 2 files changed, 127 deletions(-) delete mode 100644 src/helper/tpax_path_copy.c delete mode 100644 src/helper/tpax_stat_compare.c (limited to 'src/helper') diff --git a/src/helper/tpax_path_copy.c b/src/helper/tpax_path_copy.c deleted file mode 100644 index 084cc73..0000000 --- a/src/helper/tpax_path_copy.c +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************/ -/* tpax: a topological pax implementation */ -/* Copyright (C) 2020--2024 SysDeer Technologies, LLC */ -/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ -/**************************************************************/ - -#include -#include -#include -#include -#include - -#include -#include "tpax_driver_impl.h" - -int tpax_path_copy( - char * dstpath, - const char * srcpath, - size_t bufsize, - uint32_t flags, - size_t * nwritten) -{ - const char * src; - char * dst; - char * cap; - - if (!bufsize) { - errno = ENOBUFS; - return -1; - } - - src = srcpath; - dst = dstpath; - cap = &dst[bufsize]; - - if ((src[0] == '/') && (src[1] == '/') && (src[2] != '/')) { - *dst++ = *src++; - *dst++ = *src++; - } - - if (flags & TPAX_DRIVER_PURE_PATH_OUTPUT) - if ((src[0] == '.') && (src[1] == '/')) - for (++src; *src=='/'; src++) - (void)0; - - for (; *src; ) { - if ((src[0] == '.') && (src[1] == '.')) { - if ((src[2] == '/') || (src[2] == '\0')) { - if (flags & TPAX_DRIVER_STRICT_PATH_INPUT) { - errno = EINVAL; - return -1; - } - } - } - - if (flags & TPAX_DRIVER_PURE_PATH_OUTPUT) { - if ((src[0] == '.') && (src[1] == '/') && (src[-1] == '/')) { - for (++src; *src=='/'; src++) - (void)0; - - } else if ((src[0] == '/')) { - for (src++; *src=='/'; src++) - (void)0; - - *dst++ = '/'; - - } else { - *dst++ = *src++; - } - } else { - *dst++ = *src++; - } - - if (dst == cap) { - errno = ENOBUFS; - return -1; - } - } - - if (nwritten) - *nwritten = dst - dstpath; - - *dst = '\0'; - - return 0; -} diff --git a/src/helper/tpax_stat_compare.c b/src/helper/tpax_stat_compare.c deleted file mode 100644 index 398e45c..0000000 --- a/src/helper/tpax_stat_compare.c +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************/ -/* tpax: a topological pax implementation */ -/* Copyright (C) 2020--2024 SysDeer Technologies, LLC */ -/* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ -/**************************************************************/ - -#include -#include -#include -#include -#include - -#include -#include "tpax_driver_impl.h" - -#define TPAX_STAT_COMPARE(member) \ - if (src -> member - dst -> member) \ - return (src -> member > dst -> member) \ - ? (1) : (-1) - -int tpax_stat_compare( - const struct stat * src, - const struct stat * dst) -{ - TPAX_STAT_COMPARE(st_dev); - TPAX_STAT_COMPARE(st_ino); - - TPAX_STAT_COMPARE(st_mode); - TPAX_STAT_COMPARE(st_uid); - TPAX_STAT_COMPARE(st_gid); - - TPAX_STAT_COMPARE(st_rdev); - TPAX_STAT_COMPARE(st_size); - TPAX_STAT_COMPARE(st_blksize); - TPAX_STAT_COMPARE(st_blocks); - - TPAX_STAT_COMPARE(st_mtim.tv_sec); - TPAX_STAT_COMPARE(st_mtim.tv_nsec); - - return 0; -} -- cgit v1.2.3