From 7ffcb591bd686006e325722b45c1fe91d1ff3eff Mon Sep 17 00:00:00 2001 From: midipix Date: Sat, 17 Feb 2024 00:44:29 +0000 Subject: ar mode: posix pretty printer: multiple inputs: also print the archive name. --- src/arbits/output/slbt_ar_output_arname.c | 39 +++++++++++++++++++------------ 1 file changed, 24 insertions(+), 15 deletions(-) (limited to 'src/arbits') diff --git a/src/arbits/output/slbt_ar_output_arname.c b/src/arbits/output/slbt_ar_output_arname.c index 4ee722a..38917e7 100644 --- a/src/arbits/output/slbt_ar_output_arname.c +++ b/src/arbits/output/slbt_ar_output_arname.c @@ -15,17 +15,32 @@ | SLBT_PRETTY_POSIX \ | SLBT_PRETTY_HEXDATA) +static int slbt_ar_output_arname_impl( + const struct slbt_driver_ctx * dctx, + const struct slbt_archive_ctx * actx, + const struct slbt_fd_ctx * fdctx, + const char * fmt) +{ + const char * path; + const char mema[] = ""; + + path = actx->path && *actx->path ? *actx->path : mema; + + if (slbt_dprintf(fdctx->fdout,fmt,path) < 0) + return SLBT_SYSTEM_ERROR(dctx,0); + + return 0; +} static int slbt_ar_output_arname_posix( const struct slbt_driver_ctx * dctx, const struct slbt_archive_ctx * actx, const struct slbt_fd_ctx * fdctx) { - (void)dctx; - (void)actx; - (void)fdctx; - - /* posix ar(1) does not print the file-name */ + if (slbt_ar_output_arname_impl( + dctx,actx,fdctx, + "%s:\n") < 0) + return SLBT_NESTED_ERROR(dctx); return 0; } @@ -35,18 +50,12 @@ static int slbt_ar_output_arname_yaml( const struct slbt_archive_ctx * actx, const struct slbt_fd_ctx * fdctx) { - const char * path; - const char mema[] = ""; - - path = actx->path && *actx->path ? *actx->path : mema; - - if (slbt_dprintf( - fdctx->fdout, + if (slbt_ar_output_arname_impl( + dctx,actx,fdctx, "Archive:\n" " - Meta:\n" - " - [ name: %s ]\n\n", - path) < 0) - return SLBT_SYSTEM_ERROR(dctx,0); + " - [ name: %s ]\n\n") < 0) + return SLBT_NESTED_ERROR(dctx); return 0; } -- cgit v1.2.3