support a nixide C API extension
This commit is contained in:
parent
c96289e688
commit
b7e9a69dd8
12 changed files with 96 additions and 12 deletions
30
nixide-sys/libnixide-c/nixide_api_main.cc
Normal file
30
nixide-sys/libnixide-c/nixide_api_main.cc
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#include <dlfcn.h>
|
||||
|
||||
#include <nix_api_util.h>
|
||||
#include <nix_api_util_internal.h>
|
||||
|
||||
#include <nix/main/plugin.hh>
|
||||
|
||||
extern "C" {
|
||||
|
||||
nix_err nixide_register_plugin(nix_c_context * context, char * plugin)
|
||||
{
|
||||
if (context)
|
||||
context->last_err_code = NIX_OK;
|
||||
if (plugin == nullptr) {
|
||||
// TODO: should this be `NIX_ERR_RECOVERABLE` or `NIX_ERR_UNKNOWN`?
|
||||
return nix_set_err_msg(context, NIX_ERR_RECOVERABLE, "Plugin is null");
|
||||
}
|
||||
|
||||
void * handle = dlopen("libnixmainc.so", RTLD_LAZY | RTLD_GLOBAL);
|
||||
if (!handle) {
|
||||
return nix_set_err_msg(context, NIX_ERR_UNKNOWN, dlerror());
|
||||
}
|
||||
|
||||
void * sym_addr = dlsym(handle, "pluginSettings");
|
||||
|
||||
try {
|
||||
}
|
||||
NIXC_CATCH_ERRS
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue