From 333bf0f71734c6e8f3c0d6e419f282c968efc7ae Mon Sep 17 00:00:00 2001 From: midipix Date: Wed, 16 Dec 2015 05:13:07 -0500 Subject: driver: added sfrt_create_driver_ctx(). --- include/sofort/sofort.h | 1 + src/driver/sfrt_driver_ctx.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/sofort/sofort.h b/include/sofort/sofort.h index 0808bbe..a8373a1 100644 --- a/include/sofort/sofort.h +++ b/include/sofort/sofort.h @@ -73,6 +73,7 @@ struct sfrt_unit_ctx { /* driver api */ sfrt_api int sfrt_get_driver_ctx (const char ** argv, const char ** envp, uint32_t flags, struct sfrt_driver_ctx **); +sfrt_api int sfrt_create_driver_ctx (const struct sfrt_common_ctx *, struct sfrt_driver_ctx **); sfrt_api void sfrt_free_driver_ctx (struct sfrt_driver_ctx *); sfrt_api int sfrt_get_unit_ctx (const struct sfrt_driver_ctx *, const char * path, struct sfrt_unit_ctx **); diff --git a/src/driver/sfrt_driver_ctx.c b/src/driver/sfrt_driver_ctx.c index bec02f6..58ea3ce 100644 --- a/src/driver/sfrt_driver_ctx.c +++ b/src/driver/sfrt_driver_ctx.c @@ -142,6 +142,26 @@ int sfrt_get_driver_ctx( return SFRT_OK; } +int sfrt_create_driver_ctx( + const struct sfrt_common_ctx * cctx, + struct sfrt_driver_ctx ** pctx) +{ + struct argv_meta * meta; + struct sfrt_driver_ctx_impl * ctx; + const char * argv[] = {"sofort_driver",0}; + + if (!(meta = argv_get(argv,sfrt_default_options,0))) + return -1; + + if (!(ctx = sfrt_driver_ctx_alloc(meta,0))) + return sfrt_get_driver_ctx_fail(0); + + ctx->ctx.cctx = &ctx->cctx; + memcpy(&ctx->cctx,cctx,sizeof(*cctx)); + *pctx = &ctx->ctx; + return SFRT_OK; +} + static void sfrt_free_driver_ctx_impl(struct sfrt_driver_ctx_alloc * ictx) { argv_free(ictx->meta); -- cgit v1.2.3