summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2024-05-18 01:23:41 +0000
committermidipix <writeonce@midipix.org>2024-05-19 03:36:18 +0000
commitf5ae320ff28a77cb8bfe21a24369500f86c19df1 (patch)
treeafb8c2e049a5ee526931c653d2e5f9b02c679c42
parent9f55a17009446a7586a3694edb0b54988e201e7f (diff)
downloadtpax-f5ae320ff28a77cb8bfe21a24369500f86c19df1.tar.bz2
tpax-f5ae320ff28a77cb8bfe21a24369500f86c19df1.tar.xz
item queue: removed old implementation of tpax_archive_append().
-rw-r--r--include/tpax/tpax.h3
-rw-r--r--src/driver/tpax_amain.c2
-rw-r--r--src/logic/tpax_archive_append.c141
3 files changed, 8 insertions, 138 deletions
diff --git a/include/tpax/tpax.h b/include/tpax/tpax.h
index 85cb5cf..993352b 100644
--- a/include/tpax/tpax.h
+++ b/include/tpax/tpax.h
@@ -150,8 +150,7 @@ tpax_api int tpax_get_driver_fdctx (const struct tpax_driver_ctx *, struct
tpax_api int tpax_set_driver_fdctx (struct tpax_driver_ctx *, const struct tpax_fd_ctx *);
/* core api */
-tpax_api int tpax_archive_append (const struct tpax_driver_ctx *, const struct tpax_unit_ctx *,
- const char *);
+tpax_api int tpax_archive_append_item (const struct tpax_driver_ctx *, const struct tpax_unit_ctx *);
tpax_api int tpax_archive_seal (const struct tpax_driver_ctx *);
diff --git a/src/driver/tpax_amain.c b/src/driver/tpax_amain.c
index b11dd68..fabd5ab 100644
--- a/src/driver/tpax_amain.c
+++ b/src/driver/tpax_amain.c
@@ -54,7 +54,7 @@ static void tpax_perform_unit_actions(
struct tpax_unit_ctx * uctx)
{
if (dctx->cctx->drvflags & TPAX_DRIVER_EXEC_MODE_WRITE)
- tpax_archive_append(dctx,uctx,0);
+ tpax_archive_append_item(dctx,uctx);
}
static int tpax_exit(struct tpax_driver_ctx * dctx, int ret)
diff --git a/src/logic/tpax_archive_append.c b/src/logic/tpax_archive_append.c
index d8ac12f..1ff71bc 100644
--- a/src/logic/tpax_archive_append.c
+++ b/src/logic/tpax_archive_append.c
@@ -598,144 +598,15 @@ static int tpax_archive_append_dir(
unit);
}
-static int tpax_archive_append_impl(
+int tpax_archive_append_item(
const struct tpax_driver_ctx * dctx,
- const struct tpax_unit_ctx * uctx,
- int depth,
- const char * prefix,
- struct tpax_dirent * parent)
-{
- if (S_ISDIR(uctx->st->st_mode))
- if (dctx->cctx->drvflags & TPAX_DRIVER_DIR_MEMBER_RECURSE)
- return tpax_archive_append_dir(
- dctx,uctx,0,
- tpax_driver_fdcwd(dctx),
- depth,prefix,parent);
-
- return tpax_archive_append_one(
- dctx,uctx,0,
- tpax_driver_fdcwd(dctx),
- prefix,0,0);
-}
-
-int tpax_archive_append(
- const struct tpax_driver_ctx * dctx,
- const struct tpax_unit_ctx * uctx,
- const char * prefix)
+ const struct tpax_unit_ctx * uctx)
{
- struct tpax_dirent_buffer * dentbuf;
- struct tpax_dirent * cdent;
- struct tpax_dirent * cnext;
- const struct tpax_dirent * parent;
- uintptr_t addr;
- const char * rdir;
- const char * src;
- char * dst;
- char * cap;
- char * mark;
- int idx;
- const char * dirv[256];
- char pbuf[2048];
-
- /* normalized prefix */
- if (prefix && (prefix[0] == '.') && (!prefix[1]))
- prefix = 0;
-
- if (prefix && (prefix[0] == '.') && (prefix[1] == '/'))
- for (++prefix; *prefix=='/'; prefix++)
- (void)0;
-
- if (prefix)
- if (!(prefix = tpax_append_prefix_item(dctx,prefix)))
- return TPAX_BUFFER_ERROR(dctx);
-
- /* append explicit item */
- tpax_archive_append_impl(dctx,uctx,0,prefix,0);
-
- /* iterate through queued items */
- dentbuf = tpax_get_driver_dirents(dctx);
- cdent = dentbuf ? dentbuf->dbuf : 0;
+ (void)dctx;
+ (void)uctx;
- if (cdent) {
- dst = pbuf;
- cap = &pbuf[sizeof(pbuf)];
-
- if (prefix && prefix[0]) {
- for (; *src && dst<cap; )
- *dst++ = *src++;
-
- if (dst == cap)
- return TPAX_BUFFER_ERROR(dctx);
-
- if (dst[-1] != '/')
- *dst++ = '/';
- }
-
- src = *uctx->path;
-
- for (; *src && dst<cap; )
- *dst++ = *src++;
-
- if (dst == cap)
- return TPAX_BUFFER_ERROR(dctx);
-
- if (dst[-1] != '/')
- *dst++ = '/';
-
- *dst = 0;
- mark = dst;
- rdir = pbuf;
-
- (void)mark;
- }
-
- for (; cdent; ) {
- switch (cdent->dirent.d_type) {
- case DT_DIR:
- if (tpax_archive_append_dir(
- dctx,0,cdent,cdent->fdat,
- cdent->depth,rdir,cdent) < 0)
- return TPAX_NESTED_ERROR(dctx);
-
- break;
-
- default:
- if (tpax_archive_append_one(
- dctx,0,&cdent->dirent,
- cdent->fdat,rdir,cdent,0) < 0)
- return TPAX_NESTED_ERROR(dctx);
- }
-
- addr = (uintptr_t)cdent;
- addr += cdent->nsize;
- cnext = (struct tpax_dirent *)addr;
-
- if (cnext == dentbuf->cdent) {
- dentbuf = dentbuf->next;
- cnext = dentbuf ? dentbuf->dbuf : 0;
- }
-
- if (cnext && (cnext->parent != cdent->parent)) {
- if (cnext->depth > 256)
- return TPAX_BUFFER_ERROR(dctx);
-
- for (parent=cnext->parent; parent; parent=parent->parent)
- dirv[parent->depth - 1] = parent->dirent.d_name;
-
- for (idx=0,dst=mark; idx<cnext->parent->depth; idx++) {
- src = dirv[idx];
-
- for (; *src; )
- *dst++ = *src++;
-
- *dst++ = '/';
- }
-
- *--dst = 0;
- }
-
- cdent = cnext;
- }
+ (void)tpax_archive_append_dir;
+ (void)tpax_append_prefix_item;
return 0;
}