diff options
author | midipix <writeonce@midipix.org> | 2016-04-19 12:08:51 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-04-19 14:17:33 -0400 |
commit | a313a4648ed153a53296f1e6b1bcda83b3c9f4da (patch) | |
tree | 642137a74515834005efec4095f634ce650cba05 /src | |
parent | 52556c7d6514382cf92faec5ac33e08c781113fa (diff) | |
download | slibtool-a313a4648ed153a53296f1e6b1bcda83b3c9f4da.tar.bz2 slibtool-a313a4648ed153a53296f1e6b1bcda83b3c9f4da.tar.xz |
driver: added slbt_set_alternate_host(), slbt_reset_alternate_host().
Diffstat (limited to 'src')
-rw-r--r-- | src/driver/slbt_driver_ctx.c | 55 | ||||
-rw-r--r-- | src/internal/slibtool_driver_impl.h | 1 |
2 files changed, 56 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; +} diff --git a/src/internal/slibtool_driver_impl.h b/src/internal/slibtool_driver_impl.h index 466a4b3..b7a089f 100644 --- a/src/internal/slibtool_driver_impl.h +++ b/src/internal/slibtool_driver_impl.h @@ -64,6 +64,7 @@ struct slbt_driver_ctx_impl { struct slbt_common_ctx cctx; struct slbt_driver_ctx ctx; struct slbt_host_strs host; + struct slbt_host_strs ahost; char * libname; char ** targv; char ** cargv; |