diff options
Diffstat (limited to 'src/driver')
-rw-r--r-- | src/driver/tpax_unit_ctx.c | 32 |
1 files changed, 31 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; |