diff options
Diffstat (limited to 'src/host.c')
-rw-r--r-- | src/host.c | 38 |
1 files changed, 37 insertions, 1 deletions
@@ -1,5 +1,6 @@ /* - Copyright 2011-2015 David Robillard <http://drobilla.net> + Copyright 2011-2017 David Robillard <http://drobilla.net> + Copyright 2017 Stefan Westerfeld <stefan@space.twc.de> Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -16,6 +17,9 @@ #include "./suil_internal.h" +int suil_argc = 0; +char** suil_argv = NULL; + SUIL_API SuilHost* suil_host_new(SuilPortWriteFunc write_func, @@ -28,6 +32,8 @@ suil_host_new(SuilPortWriteFunc write_func, host->index_func = index_func; host->subscribe_func = subscribe_func; host->unsubscribe_func = unsubscribe_func; + host->argc = suil_argc; + host->argv = suil_argv; return host; } @@ -50,3 +56,33 @@ suil_host_free(SuilHost* host) free(host); } } + +static void +suil_load_init_module(const char* module_name) +{ + void* const lib = suil_open_module(module_name); + if (!lib) { + return; + } + + SuilVoidFunc init_func = (SuilVoidFunc)suil_dlfunc(lib, "suil_host_init"); + if (init_func) { + (*init_func)(); + } else { + SUIL_ERRORF("Corrupt init module %s\n", module_name); + } + + dlclose(lib); +} + +SUIL_API +void +suil_init(int* argc, char*** argv, SuilArg key, ...) +{ + suil_argc = argc ? *argc : 0; + suil_argv = argv ? *argv : NULL; + +#if SUIL_WITH_X11 + suil_load_init_module("suil_x11"); +#endif +} |