diff options
author | midipix <writeonce@midipix.org> | 2025-05-18 14:02:56 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2025-05-18 14:14:22 +0000 |
commit | 563f2b7a806f3940720dea4c68a68faa40951f36 (patch) | |
tree | dd4bc581526b5d8652687d3e3c456e6e493a4022 | |
parent | a11b545a85a90f5f13b5cfd116e55a8179d2b39d (diff) | |
download | tpax-563f2b7a806f3940720dea4c68a68faa40951f36.tar.bz2 tpax-563f2b7a806f3940720dea4c68a68faa40951f36.tar.xz |
driver: tpax_lib_get_unit_ctx(): integrated pure path output support.
-rw-r--r-- | src/driver/tpax_unit_ctx.c | 32 | ||||
-rw-r--r-- | src/internal/tpax_driver_impl.h | 2 |
2 files changed, 33 insertions, 1 deletions
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; |