diff options
Diffstat (limited to 'src/driver/tpax_amain.c')
-rw-r--r-- | src/driver/tpax_amain.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/src/driver/tpax_amain.c b/src/driver/tpax_amain.c index b11dd68..429633e 100644 --- a/src/driver/tpax_amain.c +++ b/src/driver/tpax_amain.c @@ -1,6 +1,6 @@ /**************************************************************/ /* tpax: a topological pax implementation */ -/* Copyright (C) 2020--2021 SysDeer Technologies, LLC */ +/* Copyright (C) 2020--2024 SysDeer Technologies, LLC */ /* Released under GPLv2 and GPLv3; see COPYING.TPAX. */ /**************************************************************/ @@ -38,7 +38,7 @@ static ssize_t tpax_version(struct tpax_driver_ctx * dctx, int fdout) const struct tpax_source_version * verinfo; const char * const * verclr; - verinfo = tpax_source_version(); + verinfo = tpax_api_source_version(); verclr = isatty(fdout) ? tpax_ver_color : tpax_ver_plain; return tpax_dprintf( @@ -54,13 +54,27 @@ 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_enqueue(dctx,uctx); +} + +static void tpax_archive_write_and_seal( + const struct tpax_driver_ctx * dctx) +{ + if (tpax_archive_write(dctx) == TPAX_OK) + tpax_archive_seal(dctx); +} + +static void tpax_perform_archive_actions( + const struct tpax_driver_ctx * dctx) +{ + if (dctx->cctx->drvflags & TPAX_DRIVER_EXEC_MODE_WRITE) + tpax_archive_write_and_seal(dctx); } static int tpax_exit(struct tpax_driver_ctx * dctx, int ret) { tpax_output_error_vector(dctx); - tpax_free_driver_ctx(dctx); + tpax_lib_free_driver_ctx(dctx); return ret; } @@ -78,7 +92,7 @@ int tpax_main(char ** argv, char ** envp, const struct tpax_fd_ctx * fdctx) fdout = fdctx ? fdctx->fdout : STDOUT_FILENO; fdcwd = fdctx ? fdctx->fdcwd : AT_FDCWD; - if ((ret = tpax_get_driver_ctx(argv,envp,flags,fdctx,&dctx))) + if ((ret = tpax_lib_get_driver_ctx(argv,envp,flags,fdctx,&dctx))) return (ret == TPAX_USAGE) ? !argv || !argv[0] || !argv[1] : TPAX_ERROR; @@ -88,14 +102,13 @@ int tpax_main(char ** argv, char ** envp, const struct tpax_fd_ctx * fdctx) return tpax_exit(dctx,TPAX_ERROR); for (unit=dctx->units; *unit; unit++) { - if (!(tpax_get_unit_ctx(dctx,fdcwd,*unit,&uctx))) { + if (!(tpax_lib_get_unit_ctx(dctx,fdcwd,*unit,&uctx))) { tpax_perform_unit_actions(dctx,uctx); - tpax_free_unit_ctx(uctx); + tpax_lib_free_unit_ctx(uctx); } } - if ((dctx->cctx->drvflags & TPAX_DRIVER_EXEC_MODE_WRITE) && dctx->units[0]) - tpax_archive_seal(dctx); + tpax_perform_archive_actions(dctx); return tpax_exit(dctx,dctx->errv[0] ? TPAX_ERROR : TPAX_OK); } |