summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/slibtool/slibtool.h6
-rw-r--r--src/driver/slbt_driver_ctx.c55
-rw-r--r--src/internal/slibtool_driver_impl.h1
3 files changed, 62 insertions, 0 deletions
diff --git a/include/slibtool/slibtool.h b/include/slibtool/slibtool.h
index 533be58..7cc387d 100644
--- a/include/slibtool/slibtool.h
+++ b/include/slibtool/slibtool.h
@@ -160,6 +160,9 @@ struct slbt_common_ctx {
struct slbt_host_params host;
struct slbt_host_params cfgmeta;
struct slbt_flavor_settings settings;
+ struct slbt_host_params ahost;
+ struct slbt_host_params acfgmeta;
+ struct slbt_flavor_settings asettings;
struct slbt_version_info verinfo;
enum slbt_mode mode;
enum slbt_tag tag;
@@ -212,6 +215,9 @@ slbt_api int slbt_exec_compile (const struct slbt_driver_ctx *, struct slbt_ex
slbt_api int slbt_exec_install (const struct slbt_driver_ctx *, struct slbt_exec_ctx *);
slbt_api int slbt_exec_link (const struct slbt_driver_ctx *, struct slbt_exec_ctx *);
+slbt_api int slbt_set_alternate_host (const struct slbt_driver_ctx *, const char * host, const char * flavor);
+slbt_api void slbt_reset_alternate_host (const struct slbt_driver_ctx *);
+
/* helper api */
slbt_api int slbt_map_input (int fd, const char * path, int prot, struct slbt_input *);
slbt_api int slbt_unmap_input (struct slbt_input *);
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;