summaryrefslogtreecommitdiffhomepage
path: root/eval.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-09-02 22:22:45 +0200
committerJo-Philipp Wich <jo@mein.io>2020-09-02 22:28:56 +0200
commit26f152e73eb02c6afdb98e6f7228d0a30ee973f3 (patch)
treee4737757d02f16d02355ab1b5b690bc737c2b17a /eval.c
parent2bce10151bace89d6ed38475da816f469b73418d (diff)
eval, lib: add loadable module infrastructure
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/eval.c b/eval.c
index 5a2beb4..1043c49 100644
--- a/eval.c
+++ b/eval.c
@@ -1333,6 +1333,29 @@ ut_execute_op_sequence(struct ut_state *state, struct ut_opcode *op)
return v;
}
+static void
+ut_globals_init(struct ut_state *state, struct json_object *scope)
+{
+ struct json_object *arr = json_object_new_array();
+ const char *p, *last;
+
+ if (!arr)
+ return;
+
+ for (p = last = LIB_SEARCH_PATH;; p++) {
+ if (*p == ':' || *p == '\0') {
+ json_object_array_add(arr, json_object_new_string_len(last, p - last));
+
+ if (!*p)
+ break;
+
+ last = p + 1;
+ }
+ }
+
+ json_object_object_add(scope, "REQUIRE_SEARCH_PATH", arr);
+}
+
enum ut_error_type
ut_run(struct ut_state *state)
{
@@ -1351,6 +1374,7 @@ ut_run(struct ut_state *state)
state->ctx = scope;
+ ut_globals_init(state, scope);
ut_lib_init(state, scope);
args = json_object_new_array();