summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2015-12-16 05:13:07 -0500
committermidipix <writeonce@midipix.org>2015-12-16 05:13:07 -0500
commit333bf0f71734c6e8f3c0d6e419f282c968efc7ae (patch)
tree123b377eb7b7f3b5a1e4e994c12ee9ef51bc8e43
parente17a99b6b1c16b2c5ab2c23d4c51ea335a707474 (diff)
downloadsofort-333bf0f71734c6e8f3c0d6e419f282c968efc7ae.tar.bz2
sofort-333bf0f71734c6e8f3c0d6e419f282c968efc7ae.tar.xz
driver: added sfrt_create_driver_ctx().
-rw-r--r--include/sofort/sofort.h1
-rw-r--r--src/driver/sfrt_driver_ctx.c20
2 files changed, 21 insertions, 0 deletions
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);