From 563f2b7a806f3940720dea4c68a68faa40951f36 Mon Sep 17 00:00:00 2001 From: midipix Date: Sun, 18 May 2025 14:02:56 +0000 Subject: driver: tpax_lib_get_unit_ctx(): integrated pure path output support. --- src/driver/tpax_unit_ctx.c | 32 +++++++++++++++++++++++++++++++- src/internal/tpax_driver_impl.h | 2 ++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/driver/tpax_unit_ctx.c b/src/driver/tpax_unit_ctx.c index 5c4cf80..57964de 100644 --- a/src/driver/tpax_unit_ctx.c +++ b/src/driver/tpax_unit_ctx.c @@ -19,6 +19,9 @@ static int tpax_free_unit_ctx_impl(struct tpax_unit_ctx_impl * ctx, int ret) { if (ctx) { + if (ctx->pathbuf) + free(ctx->pathbuf); + free(ctx); } @@ -33,6 +36,7 @@ int tpax_lib_get_unit_ctx( { int ret; struct tpax_unit_ctx_impl * ctx; + size_t pathlen; if (!dctx) return TPAX_CUSTOM_ERROR( @@ -64,7 +68,33 @@ int tpax_lib_get_unit_ctx( } } - ctx->path = path; + if (dctx->cctx->drvflags & TPAX_DRIVER_PURE_PATH_OUTPUT) { + if (!(pathlen = strlen(path))) + return TPAX_CUSTOM_ERROR( + dctx, + TPAX_ERR_FORBIDDEN_PATH); + + if (!(ctx->pathbuf = calloc(1,++pathlen))) + return TPAX_BUFFER_ERROR(dctx); + + ret = tpax_util_path_copy( + ctx->pathbuf,path,pathlen, + dctx->cctx->drvflags, + &pathlen); + + if (ret < 0) + return TPAX_CUSTOM_ERROR( + dctx, + TPAX_ERR_FLOW_ERROR); + + ctx->path = ctx->pathbuf; + ctx->patharg = path; + } else { + ctx->path = path; + ctx->patharg = path; + ctx->pathbuf = 0; + } + ctx->link = ctx->linkbuf[0] ? ctx->linkbuf : 0; ctx->uctx.path = &ctx->path; diff --git a/src/internal/tpax_driver_impl.h b/src/internal/tpax_driver_impl.h index 02e0d84..9f87a72 100644 --- a/src/internal/tpax_driver_impl.h +++ b/src/internal/tpax_driver_impl.h @@ -129,6 +129,8 @@ struct tpax_driver_ctx_impl { struct tpax_unit_ctx_impl { const char * path; + const char * patharg; + char * pathbuf; struct tpax_unit_ctx uctx; struct stat st; off_t hpos; -- cgit v1.2.3