aboutsummaryrefslogtreecommitdiff
path: root/primitives.c
diff options
context:
space:
mode:
authorMistivia <i@mistivia.com>2025-07-24 17:12:42 +0800
committerMistivia <i@mistivia.com>2025-07-24 17:12:42 +0800
commit601ad7249add73d392b21c572921e0bbf6114e9f (patch)
tree8a545eafa0b37949efb51b0c91f8011d8ecca269 /primitives.c
parentdec35ab80b9cc3b83b3a806835198b0a58cdc0cb (diff)
load path
Diffstat (limited to 'primitives.c')
-rw-r--r--primitives.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/primitives.c b/primitives.c
index 1b49bfe..5efcc36 100644
--- a/primitives.c
+++ b/primitives.c
@@ -1,10 +1,12 @@
#include "primitives.h"
+
+#include <dlfcn.h>
+#include <algds/str.h>
+
#include "interp.h"
#include "sexp.h"
#include "parser.h"
-#include <dlfcn.h>
-
SExpRef primitive_assert_exception(Interp *interp, SExpRef args, bool istail) {
SExpRef eargs = lisp_eval_args(interp, args);
if (VALTYPE(eargs) == kExceptionSignal) return interp->t;
@@ -83,7 +85,12 @@ SExpRef primitive_loadext(Interp *interp, SExpRef args, bool istail) {
const char *filename = REF(CAR(args))->str;
void *handle = dlopen(filename, RTLD_LAZY);
if (!handle) {
- return new_error(interp, "Failed to load library: %s\n", dlerror());
+ str_builder_t sb;
+ init_str_builder(&sb);
+ str_builder_append(&sb, "/usr/local/share/bamboo-lisp/exts/%s", filename);
+ handle = dlopen(sb.buf, RTLD_LAZY);
+ free(sb.buf);
+ if (!handle) return new_error(interp, "Failed to load library: %s\n", filename);
}
dlerror();
BambooLispExtInitFn init_func = (BambooLispExtInitFn)dlsym(handle, "bamboo_lisp_ext_init");