summaryrefslogtreecommitdiffhomepage
path: root/src/driver
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-04-19 12:08:51 -0400
committermidipix <writeonce@midipix.org>2016-04-19 14:17:33 -0400
commita313a4648ed153a53296f1e6b1bcda83b3c9f4da (patch)
tree642137a74515834005efec4095f634ce650cba05 /src/driver
parent52556c7d6514382cf92faec5ac33e08c781113fa (diff)
downloadslibtool-a313a4648ed153a53296f1e6b1bcda83b3c9f4da.tar.bz2
slibtool-a313a4648ed153a53296f1e6b1bcda83b3c9f4da.tar.xz
driver: added slbt_set_alternate_host(), slbt_reset_alternate_host().
Diffstat (limited to 'src/driver')
-rw-r--r--src/driver/slbt_driver_ctx.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/driver/slbt_driver_ctx.c b/src/driver/slbt_driver_ctx.c
index eac0ac6..68ddee8 100644
--- a/src/driver/slbt_driver_ctx.c
+++ b/src/driver/slbt_driver_ctx.c
@@ -441,6 +441,8 @@ static void slbt_free_host_params(struct slbt_host_strs * host)
if (host->dlltool)
free(host->dlltool);
+
+ memset(host,0,sizeof(*host));
}
static void slbt_init_flavor_settings(
@@ -909,3 +911,56 @@ void slbt_free_driver_ctx(struct slbt_driver_ctx * ctx)
slbt_free_driver_ctx_impl(ictx);
}
}
+
+void slbt_reset_alternate_host(const struct slbt_driver_ctx * ctx)
+{
+ struct slbt_driver_ctx_alloc * ictx;
+ uintptr_t addr;
+
+ addr = (uintptr_t)ctx - offsetof(struct slbt_driver_ctx_alloc,ctx);
+ addr = addr - offsetof(struct slbt_driver_ctx_impl,ctx);
+ ictx = (struct slbt_driver_ctx_alloc *)addr;
+
+ slbt_free_host_params(&ictx->ctx.ahost);
+}
+
+int slbt_set_alternate_host(
+ const struct slbt_driver_ctx * ctx,
+ const char * host,
+ const char * flavor)
+{
+ struct slbt_driver_ctx_alloc * ictx;
+ uintptr_t addr;
+
+ addr = (uintptr_t)ctx - offsetof(struct slbt_driver_ctx_alloc,ctx);
+ addr = addr - offsetof(struct slbt_driver_ctx_impl,ctx);
+ ictx = (struct slbt_driver_ctx_alloc *)addr;
+ slbt_free_host_params(&ictx->ctx.ahost);
+
+ if (!(ictx->ctx.ahost.host = strdup(host)))
+ return -1;
+
+ if (!(ictx->ctx.ahost.flavor = strdup(flavor))) {
+ slbt_free_host_params(&ictx->ctx.ahost);
+ return -1;
+ }
+
+ ictx->ctx.cctx.ahost.host = ictx->ctx.ahost.host;
+ ictx->ctx.cctx.ahost.flavor = ictx->ctx.ahost.flavor;
+
+ if (slbt_init_host_params(
+ ctx->cctx,
+ &ictx->ctx.ahost,
+ &ictx->ctx.cctx.ahost,
+ &ictx->ctx.cctx.acfgmeta)) {
+ slbt_free_host_params(&ictx->ctx.ahost);
+ return -1;
+ }
+
+ slbt_init_flavor_settings(
+ &ictx->ctx.cctx,
+ &ictx->ctx.cctx.ahost,
+ &ictx->ctx.cctx.asettings);
+
+ return 0;
+}