From 3d2f83b5a3d42dd9b3430379a08a81f8004c7eb4 Mon Sep 17 00:00:00 2001 From: midipix Date: Sun, 25 Feb 2024 21:57:24 +0000 Subject: internals: added slbt_impl_get_txtfile_ctx() (caller-provided fd as input). --- src/driver/slbt_txtfile_ctx.c | 23 +++++++++++++++++++++-- src/internal/slibtool_driver_impl.h | 6 ++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/driver/slbt_txtfile_ctx.c b/src/driver/slbt_txtfile_ctx.c index 12b9cff..6159b1e 100644 --- a/src/driver/slbt_txtfile_ctx.c +++ b/src/driver/slbt_txtfile_ctx.c @@ -14,6 +14,7 @@ #include #include "slibtool_driver_impl.h" #include "slibtool_errinfo_impl.h" +#include "slibtool_visibility_impl.h" /********************************************************/ /* Read a text file, and create an in-memory vecotr of */ @@ -45,9 +46,10 @@ static int slbt_lib_free_txtfile_ctx_impl( return ret; } -int slbt_lib_get_txtfile_ctx( +static int slbt_lib_get_txtfile_ctx_impl( const struct slbt_driver_ctx * dctx, const char * path, + int fdsrc, struct slbt_txtfile_ctx ** pctx) { struct slbt_txtfile_ctx_impl * ctx; @@ -62,7 +64,7 @@ int slbt_lib_get_txtfile_ctx( int cint; /* map txtfile file temporarily */ - if (slbt_fs_map_input(dctx,-1,path,PROT_READ,&mapinfo) < 0) + if (slbt_fs_map_input(dctx,fdsrc,path,PROT_READ,&mapinfo) < 0) return SLBT_NESTED_ERROR(dctx); /* alloc context */ @@ -140,6 +142,23 @@ int slbt_lib_get_txtfile_ctx( return 0; } +slbt_hidden int slbt_impl_get_txtfile_ctx( + const struct slbt_driver_ctx * dctx, + const char * path, + int fdsrc, + struct slbt_txtfile_ctx ** pctx) +{ + return slbt_lib_get_txtfile_ctx_impl(dctx,path,fdsrc,pctx); +} + +int slbt_lib_get_txtfile_ctx( + const struct slbt_driver_ctx * dctx, + const char * path, + struct slbt_txtfile_ctx ** pctx) +{ + return slbt_lib_get_txtfile_ctx_impl(dctx,path,(-1),pctx); +} + void slbt_lib_free_txtfile_ctx(struct slbt_txtfile_ctx * ctx) { struct slbt_txtfile_ctx_impl * ictx; diff --git a/src/internal/slibtool_driver_impl.h b/src/internal/slibtool_driver_impl.h index fcb8324..b6ab601 100644 --- a/src/internal/slibtool_driver_impl.h +++ b/src/internal/slibtool_driver_impl.h @@ -308,6 +308,12 @@ void slbt_reset_placeholders (struct slbt_exec_ctx *); void slbt_disable_placeholders (struct slbt_exec_ctx *); +int slbt_impl_get_txtfile_ctx( + const struct slbt_driver_ctx * dctx, + const char * path, + int fdsrc, + struct slbt_txtfile_ctx ** pctx); + static inline struct slbt_archive_ctx_impl * slbt_get_archive_ictx(const struct slbt_archive_ctx * actx) { -- cgit v1.2.3